Search in sources :

Example 1 with ModelledResourceImpl

use of org.apache.aries.application.modelling.impl.ModelledResourceImpl in project aries by apache.

the class DeployedBundlesTest method createModelledResource.

public static ModelledResource createModelledResource(String bundleName, String bundleVersion, Collection<String> importedPackages, Collection<String> exportedPackages) throws InvalidAttributeException {
    Attributes att = new Attributes();
    att.put(new Attributes.Name(Constants.BUNDLE_SYMBOLICNAME), bundleName);
    att.put(new Attributes.Name(Constants.BUNDLE_VERSION), bundleVersion);
    att.put(new Attributes.Name(Constants.BUNDLE_MANIFESTVERSION), "2");
    StringBuilder builder = new StringBuilder();
    for (String iPackage : importedPackages) {
        builder.append(iPackage).append(",");
    }
    if (builder.length() > 0) {
        builder.deleteCharAt(builder.length() - 1);
        att.put(new Attributes.Name(Constants.IMPORT_PACKAGE), builder.toString());
    }
    builder = new StringBuilder();
    for (String ePackage : exportedPackages) {
        builder.append(ePackage).append(",");
    }
    if (builder.length() > 0) {
        builder.deleteCharAt(builder.length() - 1);
        att.put(new Attributes.Name(Constants.EXPORT_PACKAGE), builder.toString());
    }
    return new ModelledResourceImpl(null, att, null, null);
}
Also used : ModelledResourceImpl(org.apache.aries.application.modelling.impl.ModelledResourceImpl) Attributes(java.util.jar.Attributes)

Example 2 with ModelledResourceImpl

use of org.apache.aries.application.modelling.impl.ModelledResourceImpl in project aries by apache.

the class BundleResourceTest method instantiateBundleResource.

/**
   * @return
   * @throws IOException
   * @throws FileNotFoundException
   * @throws ResolverException
   * @throws InvalidAttributeException 
   */
protected ModelledResource instantiateBundleResource() throws Exception {
    File file = new File(TEST_APP_MANIFEST_PATH, MANIFEST_MF);
    Manifest man = new Manifest(new FileInputStream(file));
    ModelledResource br = new ModelledResourceImpl(null, man.getMainAttributes(), null, null);
    return br;
}
Also used : ModelledResourceImpl(org.apache.aries.application.modelling.impl.ModelledResourceImpl) Manifest(java.util.jar.Manifest) File(java.io.File) FileInputStream(java.io.FileInputStream) ModelledResource(org.apache.aries.application.modelling.ModelledResource)

Example 3 with ModelledResourceImpl

use of org.apache.aries.application.modelling.impl.ModelledResourceImpl in project aries by apache.

the class DeployedBundlesTest method createModelledServiceBundle.

public static ModelledResource createModelledServiceBundle(String bundleName, String bundleVersion, Collection<String> importService, Collection<String> exportService) throws InvalidAttributeException {
    Attributes att = new Attributes();
    att.put(new Attributes.Name(Constants.BUNDLE_SYMBOLICNAME), bundleName);
    att.put(new Attributes.Name(Constants.BUNDLE_VERSION), bundleVersion);
    att.put(new Attributes.Name(Constants.BUNDLE_MANIFESTVERSION), "2");
    List<ImportedService> importedServices = new ArrayList<ImportedService>();
    for (String s : importService) {
        importedServices.add(new ImportedServiceImpl(false, s, null, null, null, false));
    }
    List<ExportedService> exportedServices = new ArrayList<ExportedService>();
    for (String s : exportService) {
        exportedServices.add(new ExportedServiceImpl(null, 0, Collections.singleton(s), Collections.<String, Object>emptyMap()));
    }
    return new ModelledResourceImpl(null, att, importedServices, exportedServices);
}
Also used : ImportedServiceImpl(org.apache.aries.application.modelling.impl.ImportedServiceImpl) ModelledResourceImpl(org.apache.aries.application.modelling.impl.ModelledResourceImpl) ExportedService(org.apache.aries.application.modelling.ExportedService) Attributes(java.util.jar.Attributes) ArrayList(java.util.ArrayList) ImportedService(org.apache.aries.application.modelling.ImportedService) ExportedServiceImpl(org.apache.aries.application.modelling.impl.ExportedServiceImpl)

Aggregations

ModelledResourceImpl (org.apache.aries.application.modelling.impl.ModelledResourceImpl)3 Attributes (java.util.jar.Attributes)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 ArrayList (java.util.ArrayList)1 Manifest (java.util.jar.Manifest)1 ExportedService (org.apache.aries.application.modelling.ExportedService)1 ImportedService (org.apache.aries.application.modelling.ImportedService)1 ModelledResource (org.apache.aries.application.modelling.ModelledResource)1 ExportedServiceImpl (org.apache.aries.application.modelling.impl.ExportedServiceImpl)1 ImportedServiceImpl (org.apache.aries.application.modelling.impl.ImportedServiceImpl)1