Search in sources :

Example 6 with BundleManifest

use of org.apache.aries.util.manifest.BundleManifest in project aries by apache.

the class ModelledResourceManagerImpl method getServiceElements.

public ParsedServiceElements getServiceElements(InputStreamProvider archive) throws ModellerException {
    ICloseableDirectory dir = null;
    try {
        dir = FileSystem.getFSRoot(archive.open());
        BundleManifest bm = BundleManifest.fromBundle(dir);
        return getServiceElements(bm, dir);
    } catch (IOException e) {
        throw new ModellerException(e);
    } finally {
        IOUtils.close(dir);
    }
}
Also used : ICloseableDirectory(org.apache.aries.util.filesystem.ICloseableDirectory) BundleManifest(org.apache.aries.util.manifest.BundleManifest) ModellerException(org.apache.aries.application.modelling.ModellerException) IOException(java.io.IOException)

Example 7 with BundleManifest

use of org.apache.aries.util.manifest.BundleManifest in project aries by apache.

the class ModelledResourceManagerImpl method getModelledResource.

public ModelledResource getModelledResource(String uri, IDirectory bundle) throws ModellerException {
    _logger.debug(LOG_ENTRY, "getModelledResource", new Object[] { uri, bundle });
    if (bundle != null) {
        BundleManifest bm = BundleManifest.fromBundle(bundle);
        ParsedServiceElements pse = getServiceElements(bm, bundle);
        return model(uri, bm, pse);
    } else {
        // The bundle does not exist
        ModellerException me = new ModellerException(MessageUtil.getMessage("INVALID_BUNDLE_LOCATION", bundle));
        _logger.debug(LOG_EXIT, "getModelledResource", me);
        throw me;
    }
}
Also used : BundleManifest(org.apache.aries.util.manifest.BundleManifest) ModellerException(org.apache.aries.application.modelling.ModellerException) ParsedServiceElements(org.apache.aries.application.modelling.ParsedServiceElements)

Example 8 with BundleManifest

use of org.apache.aries.util.manifest.BundleManifest in project aries by apache.

the class SemanticVersioningChecker method getBundles.

private Map<String, BundleInfo> getBundles(IDirectory ds) {
    Map<String, BundleInfo> bundles = new HashMap<String, BundleInfo>();
    List<IFile> includedFiles = ds.listAllFiles();
    for (IFile ifile : includedFiles) {
        if (ifile.getName().endsWith(SemanticVersioningUtils.jarExt)) {
            // scan its manifest
            try {
                BundleManifest manifest = BundleManifest.fromBundle(ifile.open());
                // find the bundle symbolic name, store them in a map with bundle symbolic name as key, bundleInfo as value
                if (manifest.getSymbolicName() != null) {
                    bundles.put(manifest.getSymbolicName(), new BundleInfo(manifest, new File(ifile.toURL().getPath())));
                }
            } catch (MalformedURLException mue) {
                _logger.debug("Exception thrown when processing" + ifile.getName(), mue);
            } catch (IOException ioe) {
                _logger.debug("Exception thrown when processing" + ifile.getName(), ioe);
            }
        }
    }
    return bundles;
}
Also used : MalformedURLException(java.net.MalformedURLException) IFile(org.apache.aries.util.filesystem.IFile) HashMap(java.util.HashMap) BundleManifest(org.apache.aries.util.manifest.BundleManifest) String(java.lang.String) IOException(java.io.IOException) IFile(org.apache.aries.util.filesystem.IFile) File(java.io.File)

Example 9 with BundleManifest

use of org.apache.aries.util.manifest.BundleManifest in project aries by apache.

the class EJBModellerTest method testModelServicesNoneExportEJB.

@Test
public void testModelServicesNoneExportEJB() throws ModellerException {
    Manifest man = new Manifest();
    setBasicHeaders(man);
    man.getMainAttributes().putValue("Export-EJB", "NONE,anEJB , another");
    modeller.modelServices(new BundleManifest(man), bundleLocation);
    ejbLocator.assertSkeletonNotCalled();
}
Also used : BundleManifest(org.apache.aries.util.manifest.BundleManifest) Manifest(java.util.jar.Manifest) BundleManifest(org.apache.aries.util.manifest.BundleManifest) Test(org.junit.Test)

Example 10 with BundleManifest

use of org.apache.aries.util.manifest.BundleManifest in project aries by apache.

the class EJBModellerTest method testModelServicesEmptyExportEJB.

@Test
public void testModelServicesEmptyExportEJB() throws ModellerException {
    Manifest man = new Manifest();
    setBasicHeaders(man);
    man.getMainAttributes().putValue("Export-EJB", "");
    modeller.modelServices(new BundleManifest(man), bundleLocation);
    ejbLocator.assertCalled(new MethodCall(EJBLocator.class, "findEJBs", BundleManifest.class, bundleLocation, ParsedEJBServices.class));
}
Also used : BundleManifest(org.apache.aries.util.manifest.BundleManifest) Manifest(java.util.jar.Manifest) BundleManifest(org.apache.aries.util.manifest.BundleManifest) EJBLocator(org.apache.aries.ejb.modelling.EJBLocator) MethodCall(org.apache.aries.unittest.mocks.MethodCall) Test(org.junit.Test)

Aggregations

BundleManifest (org.apache.aries.util.manifest.BundleManifest)12 Manifest (java.util.jar.Manifest)5 Test (org.junit.Test)4 IOException (java.io.IOException)3 IFile (org.apache.aries.util.filesystem.IFile)3 File (java.io.File)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 BundleInfo (org.apache.aries.application.management.BundleInfo)2 ModellerException (org.apache.aries.application.modelling.ModellerException)2 SimpleBundleInfo (org.apache.aries.application.utils.management.SimpleBundleInfo)2 EJBLocator (org.apache.aries.ejb.modelling.EJBLocator)2 MethodCall (org.apache.aries.unittest.mocks.MethodCall)2 ICloseableDirectory (org.apache.aries.util.filesystem.ICloseableDirectory)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 String (java.lang.String)1 Field (java.lang.reflect.Field)1 MalformedURLException (java.net.MalformedURLException)1 Iterator (java.util.Iterator)1