Search in sources :

Example 6 with ModellerException

use of org.apache.aries.application.modelling.ModellerException in project aries by apache.

the class ModelledResourceManagerImpl method getBlueprintServiceElements.

private ParsedServiceElements getBlueprintServiceElements(BundleManifest bundleMf, Iterable<InputStream> blueprints) throws ModellerException {
    _logger.debug(LOG_ENTRY, "getServiceElements", new Object[] { bundleMf, blueprints });
    Set<ExportedService> services = new HashSet<ExportedService>();
    Set<ImportedService> references = new HashSet<ImportedService>();
    try {
        for (InputStream is : blueprints) {
            try {
                ParsedServiceElements pse = getParserProxy().parseAllServiceElements(is);
                services.addAll(pse.getServices());
                references.addAll(pse.getReferences());
            } finally {
                IOUtils.close(is);
            }
        }
    } catch (Exception e) {
        ModellerException m = new ModellerException(e);
        _logger.debug(LOG_EXIT, "getServiceElements", m);
        throw m;
    }
    ParsedServiceElements result = _modellingManager.getParsedServiceElements(services, references);
    _logger.debug(LOG_EXIT, "getServiceElements", result);
    return result;
}
Also used : ExportedService(org.apache.aries.application.modelling.ExportedService) ZipInputStream(java.util.zip.ZipInputStream) InputStream(java.io.InputStream) ModellerException(org.apache.aries.application.modelling.ModellerException) ImportedService(org.apache.aries.application.modelling.ImportedService) URISyntaxException(java.net.URISyntaxException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) InvalidAttributeException(org.apache.aries.application.InvalidAttributeException) ModellerException(org.apache.aries.application.modelling.ModellerException) HashSet(java.util.HashSet) ParsedServiceElements(org.apache.aries.application.modelling.ParsedServiceElements)

Example 7 with ModellerException

use of org.apache.aries.application.modelling.ModellerException in project aries by apache.

the class OpenEJBLocator method findEJBs.

public void findEJBs(BundleManifest manifest, IDirectory bundle, EJBRegistry registry) throws ModellerException {
    logger.debug("Scanning " + manifest.getSymbolicName() + "_" + manifest.getManifestVersion() + " for EJBs");
    String ejbJarLocation = (manifest.getRawAttributes().getValue("Web-ContextPath") == null) ? "META-INF/ejb-jar.xml" : "WEB-INF/ejb-jar.xml";
    try {
        //If we have an ejb-jar.xml then parse it 
        IFile file = bundle.getFile(ejbJarLocation);
        EjbJar ejbJar = (file == null) ? new EjbJar() : ReadDescriptors.readEjbJar(file.toURL());
        EjbModule module = new EjbModule(ejbJar);
        //We build our own because we can't trust anyone to get the classpath right otherwise!
        module.setFinder(new IDirectoryFinder(AnnotationDeployer.class.getClassLoader(), getClassPathLocations(manifest, bundle)));
        //Scan our app for annotated EJBs
        AppModule app = new AppModule(module);
        new AnnotationDeployer().deploy(app);
        //Register our session beans
        for (EnterpriseBean eb : ejbJar.getEnterpriseBeans()) {
            if (!!!(eb instanceof SessionBean))
                continue;
            else
                registerSessionBean(registry, (SessionBean) eb);
        }
    } catch (Exception e) {
        throw new ModellerException(e);
    }
}
Also used : AnnotationDeployer(org.apache.openejb.config.AnnotationDeployer) IFile(org.apache.aries.util.filesystem.IFile) AppModule(org.apache.openejb.config.AppModule) EnterpriseBean(org.apache.openejb.jee.EnterpriseBean) EjbModule(org.apache.openejb.config.EjbModule) ModellerException(org.apache.aries.application.modelling.ModellerException) SessionBean(org.apache.openejb.jee.SessionBean) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) ModellerException(org.apache.aries.application.modelling.ModellerException) EjbJar(org.apache.openejb.jee.EjbJar)

Aggregations

ModellerException (org.apache.aries.application.modelling.ModellerException)7 IOException (java.io.IOException)4 ParsedServiceElements (org.apache.aries.application.modelling.ParsedServiceElements)4 MalformedURLException (java.net.MalformedURLException)3 InvalidAttributeException (org.apache.aries.application.InvalidAttributeException)3 ExportedService (org.apache.aries.application.modelling.ExportedService)3 ImportedService (org.apache.aries.application.modelling.ImportedService)3 URISyntaxException (java.net.URISyntaxException)2 HashSet (java.util.HashSet)2 BundleManifest (org.apache.aries.util.manifest.BundleManifest)2 InputStream (java.io.InputStream)1 Attributes (java.util.jar.Attributes)1 ZipInputStream (java.util.zip.ZipInputStream)1 ModelledResource (org.apache.aries.application.modelling.ModelledResource)1 ServiceModeller (org.apache.aries.application.modelling.ServiceModeller)1 ICloseableDirectory (org.apache.aries.util.filesystem.ICloseableDirectory)1 IFile (org.apache.aries.util.filesystem.IFile)1 AnnotationDeployer (org.apache.openejb.config.AnnotationDeployer)1 AppModule (org.apache.openejb.config.AppModule)1 EjbModule (org.apache.openejb.config.EjbModule)1