Examples of ApplicationInfo


Examples of org.apache.geronimo.j2ee.ApplicationInfo

            throws PortletException, IOException {
        FileItem fileItem = (FileItem) getUploadFiles().get(MODULE_URI_PARAMETER);
        String fileName = fileItem.getName();
        if (fileName != null && fileName.length() > 0) {
            File uploadedFile = uploadFile(fileItem);
            ApplicationInfo applicationInfo = JSR88_Util.createApplicationInfo(request, uploadedFile);
            ConfigurationModuleType applicationType = applicationInfo.getType();
            if (ConfigurationModuleType.WAR == applicationType) {
                WARConfigData data = setNewWARSessionData(request);
                data.setUploadedWarUri(uploadedFile.toURI().toString());
                data.parseWeb((WebModule) (applicationInfo.getModules().toArray()[0]));
                return ENVIRONMENT_MODE + "-before";
            }
            if (ConfigurationModuleType.EAR == applicationType) {
                EARConfigData earConfigData = setNewEARSessionData(request);
                earConfigData.parseEAR(applicationInfo);
                return EAR_MODE + "-before";
            }
            if (ConfigurationModuleType.EJB == applicationType) {
                EjbConfigData ejbJarConfigData = setNewEjbJarSessionData(request);
                ejbJarConfigData.parseEjbJar((EjbModule) (applicationInfo.getModules().toArray()[0]));
                return EJB_MODE + "-before";
            }
        }
        portlet.addErrorMessage(request, portlet.getLocalizedString(request, "errorMsg01"));
        return getMode();
View Full Code Here

Examples of org.apache.geronimo.j2ee.ApplicationInfo

        }
        return classLoaders;
    }*/

    public static ApplicationInfo createApplicationInfo(PortletRequest actionRequest, File moduleFile) {
        ApplicationInfo applicationInfo = null;
        EARConfigBuilder.createPlanMode.set(Boolean.TRUE);
        try {
            DeploymentFactoryManager dfm = DeploymentFactoryManager.getInstance();
            DeploymentManager mgr = dfm.getDeploymentManager("deployer:geronimo:inVM", null, null);
            if (mgr instanceof JMXDeploymentManager) {
View Full Code Here

Examples of org.apache.geronimo.j2ee.ApplicationInfo

    public Object getDeploymentPlan(File planFile, JarFile jarFile) throws DeploymentException {
        if (planFile == null && jarFile == null) {
            return null;
        }
        ApplicationInfo plan = getEarPlan(planFile, jarFile);
        if (plan != null) {
            return plan;
        }
        //Only "synthetic" ears with only external modules can have no jar file.
        if (jarFile == null) {
            return null;
        }

        // get the modules either the application plan or for a stand alone module from the specific deployer
        Module module = null;
        if (webConfigBuilder != null) {
            module = webConfigBuilder.createModule(planFile, jarFile);
        }
        if (module == null && ejbConfigBuilder != null) {
            module = ejbConfigBuilder.createModule(planFile, jarFile);
        }
        if (module == null && connectorConfigBuilder != null) {
            module = connectorConfigBuilder.createModule(planFile, jarFile);
        }
        if (module == null && appClientConfigBuilder != null) {
            module = appClientConfigBuilder.createModule(planFile, jarFile);
        }
        if (module == null) {
            return null;
        }

        return new ApplicationInfo(module.getType(),
                module.getConfigId(),
                module.getParentId(),
                NameFactory.NULL,
                null,
                null,
View Full Code Here

Examples of org.apache.geronimo.j2ee.ApplicationInfo

            throw new DeploymentException(e);
        }

        String applicationName = gerApplication.isSetApplicationName() ? gerApplication.getApplicationName() : configId.toString();

        return new ApplicationInfo(ConfigurationModuleType.EAR,
                configId,
                parentId,
                applicationName,
                application,
                gerApplication,
View Full Code Here

Examples of org.apache.geronimo.j2ee.ApplicationInfo

        gerApplication.setConfigId(id);
        return gerApplication;
    }

    public URI getConfigurationID(Object plan, JarFile module) throws IOException, DeploymentException {
        ApplicationInfo applicationInfo = (ApplicationInfo) plan;
        return applicationInfo.getConfigId();
    }
View Full Code Here

Examples of org.apache.geronimo.j2ee.ApplicationInfo

        return applicationInfo.getConfigId();
    }

    public ConfigurationData buildConfiguration(Object plan, JarFile earFile, File outfile) throws IOException, DeploymentException {
        assert plan != null;
        ApplicationInfo applicationInfo = (ApplicationInfo) plan;
        try {
            // Create the output ear context
            EARContext earContext = null;
            ConfigurationModuleType applicationType = applicationInfo.getType();
            try {
                earContext = new EARContext(outfile,
                        applicationInfo.getConfigId(),
                        applicationType,
                        applicationInfo.getParentId(),
                        kernel,
                        applicationInfo.getApplicationName(),
                        transactionContextManagerObjectName,
                        connectionTrackerObjectName,
                        transactionalTimerObjectName,
                        nonTransactionalTimerObjectName,
                        corbaGBeanObjectName,
                        new RefContext(ejbReferenceBuilder, resourceReferenceBuilder, serviceReferenceBuilder, kernel));
            } catch (MalformedObjectNameException e) {
                throw new DeploymentException(e);
            }

            // Copy over all files that are _NOT_ modules
            Set moduleLocations = applicationInfo.getModuleLocations();
            if (ConfigurationModuleType.EAR == applicationType && earFile != null) {
                for (Enumeration e = earFile.entries(); e.hasMoreElements();) {
                    ZipEntry entry = (ZipEntry) e.nextElement();
                    if (!moduleLocations.contains(entry.getName())) {
                        earContext.addFile(URI.create(entry.getName()), earFile, entry);
                    }
                }
            }

            // add dependencies declared in the geronimo-application.xml
            GerApplicationType geronimoApplication = (GerApplicationType) applicationInfo.getVendorDD();
            if (geronimoApplication != null) {
                DependencyType[] dependencies = geronimoApplication.getDependencyArray();
                ServiceConfigBuilder.addDependencies(earContext, dependencies, repository);
            }

            // each module installs it's files into the output context.. this is different for each module type
            Set modules = applicationInfo.getModules();
            for (Iterator iterator = modules.iterator(); iterator.hasNext();) {
                Module module = (Module) iterator.next();
                getBuilder(module).installModule(earFile, earContext, module);
            }

            // give each module a chance to populate the earContext now that a classloader is available
            ClassLoader cl = earContext.getClassLoader(repository);
            for (Iterator iterator = modules.iterator(); iterator.hasNext();) {
                Module module = (Module) iterator.next();
                getBuilder(module).initContext(earContext, module, cl);
            }

            // add gbeans declared in the geronimo-application.xml
            if (geronimoApplication != null) {
                GbeanType[] gbeans = geronimoApplication.getGbeanArray();
                ServiceConfigBuilder.addGBeans(gbeans, cl, earContext.getJ2eeContext(), earContext);
            }

            // Create the J2EEApplication managed object
            if (ConfigurationModuleType.EAR == applicationType) {
                GBeanData gbeanData = new GBeanData(earContext.getApplicationObjectName(), J2EEApplicationImpl.GBEAN_INFO);
                try {
                    gbeanData.setAttribute("deploymentDescriptor", applicationInfo.getOriginalSpecDD());
                } catch (Exception e) {
                    throw new DeploymentException("Error initializing J2EEApplication managed object");
                }
                try {
                    gbeanData.setReferencePattern("j2eeServer", NameFactory.getServerName(earContext.getDomain(), earContext.getServer(), earContext.getJ2eeContext()));
                } catch (MalformedObjectNameException e) {
                    throw new DeploymentException("Error constructing J2EEServer name for application", e);
                }
                earContext.addGBean(gbeanData);
            }


            //TODO this might need to be constructed only if there is security...
            ObjectName jaccBeanName = null;
            String moduleName;
            if (ConfigurationModuleType.EAR == applicationType) {
                moduleName = NameFactory.NULL;
            } else {
                Module module = (Module) modules.iterator().next();
                moduleName = module.getName();
            }
            try {
                jaccBeanName = NameFactory.getComponentName(null, null, null, moduleName, NameFactory.JACC_MANAGER, NameFactory.JACC_MANAGER, earContext.getJ2eeContext());
            } catch (MalformedObjectNameException e) {
                throw new DeploymentException("Could not construct name for JACCBean", e);
            }
            earContext.setJaccManagerName(jaccBeanName);

            //look for application plan security config
            if (geronimoApplication != null && geronimoApplication.isSetSecurity()) {
                SecurityConfiguration securityConfiguration = SecurityBuilder.buildSecurityConfiguration(geronimoApplication.getSecurity());
                earContext.setSecurityConfiguration(securityConfiguration);
            }

            // each module can now add it's GBeans
            for (Iterator iterator = modules.iterator(); iterator.hasNext();) {
                Module module = (Module) iterator.next();
                getBuilder(module).addGBeans(earContext, module, cl);
            }

            //add the JACC gbean if there is a principal-role mapping
            if (earContext.getSecurityConfiguration() != null) {
                GBeanData jaccBeanData = SecurityBuilder.configureApplicationPolicyManager(jaccBeanName, earContext.getContextIDToPermissionsMap(), earContext.getSecurityConfiguration());
                earContext.addGBean(jaccBeanData);
            }
            earContext.close();
            return earContext.getConfigurationData();
        } finally {
            Set modules = applicationInfo.getModules();
            for (Iterator iterator = modules.iterator(); iterator.hasNext();) {
                Module module = (Module) iterator.next();
                module.close();
            }
        }
View Full Code Here

Examples of org.apache.geronimo.j2ee.ApplicationInfo

    public Object getDeploymentPlan(File planFile, JarFile jarFile, ModuleIDBuilder idBuilder) throws DeploymentException {
        if (planFile == null && jarFile == null) {
            return null;
        }
        ApplicationInfo plan = getEarPlan(planFile, jarFile, idBuilder);
        if (plan != null) {
            return plan;
        }
        //Only "synthetic" ears with only external modules can have no jar file.
        if (jarFile == null) {
            return null;
        }

        // get the modules either the application plan or for a stand alone module from the specific deployer
        Module module = null;
        if (getWebConfigBuilder() != null) {
            module = getWebConfigBuilder().createModule(planFile, jarFile, naming, idBuilder);
        }
        if (module == null && getEjbConfigBuilder() != null) {
            module = getEjbConfigBuilder().createModule(planFile, jarFile, naming, idBuilder);
        }
        if (module == null && getConnectorConfigBuilder() != null) {
            module = getConnectorConfigBuilder().createModule(planFile, jarFile, naming, idBuilder);
        }
        if (module == null && getAppClientConfigBuilder() != null) {
            module = getAppClientConfigBuilder().createModule(planFile, jarFile, naming, idBuilder);
        }
        if (module == null) {
            return null;
        }

        return new ApplicationInfo(module.getType(),
                module.getEnvironment(),
                module.getModuleName(),
                null,
                null,
                new LinkedHashSet<Module>(Collections.singleton(module)),
View Full Code Here

Examples of org.apache.geronimo.j2ee.ApplicationInfo

                throw (Error) e;
            }
            throw new DeploymentException(e);
        }

        return new ApplicationInfo(ConfigurationModuleType.EAR,
                environment,
                earName,
                application,
                gerApplication,
                modules,
View Full Code Here

Examples of org.apache.geronimo.j2ee.ApplicationInfo

        XmlBeansUtil.validateDD(xmlObject);
        return (ApplicationDocument) xmlObject;
    }

    public Artifact getConfigurationID(Object plan, JarFile module, ModuleIDBuilder idBuilder) throws IOException, DeploymentException {
        ApplicationInfo applicationInfo = (ApplicationInfo) plan;
        Artifact test = applicationInfo.getEnvironment().getConfigId();
        if(!test.isResolved()) {
            throw new IllegalStateException("Module ID should be fully resolved by now (not "+test+")");
        }
        return test;
    }
View Full Code Here

Examples of org.apache.geronimo.j2ee.ApplicationInfo

        return test;
    }

    public DeploymentContext buildConfiguration(boolean inPlaceDeployment, Artifact configId, Object plan, JarFile earFile, Collection configurationStores, ArtifactResolver artifactResolver, ConfigurationStore targetConfigurationStore) throws IOException, DeploymentException {
        assert plan != null;
        ApplicationInfo applicationInfo = (ApplicationInfo) plan;

        EARContext earContext = null;
        ConfigurationModuleType applicationType = applicationInfo.getType();
        applicationInfo.getEnvironment().setConfigId(configId);
        File configurationDir;
        try {
            configurationDir = targetConfigurationStore.createNewConfigurationDir(configId);
        } catch (ConfigurationAlreadyExistsException e) {
            throw new DeploymentException(e);
        }

        ConfigurationManager configurationManager = this.configurationManager;
        if (configurationManager == null) {
            configurationManager = new SimpleConfigurationManager(configurationStores, artifactResolver, repositories);
        }
        try {
            // Create the output ear context
            earContext = new EARContext(configurationDir,
                    inPlaceDeployment ? DeploymentUtil.toFile(earFile) : null,
                    applicationInfo.getEnvironment(),
                    applicationType,
                    naming,
                    configurationManager,
                    repositories,
                    serverName,
                    applicationInfo.getBaseName(),
                    transactionManagerObjectName,
                    connectionTrackerObjectName,
                    transactionalTimerObjectName,
                    nonTransactionalTimerObjectName,
                    corbaGBeanObjectName
            );

            // Copy over all files that are _NOT_ modules (e.g. META-INF and APP-INF files)
            Set moduleLocations = applicationInfo.getModuleLocations();
            if (ConfigurationModuleType.EAR == applicationType && earFile != null) {
              //get the value of the library-directory element in spec DD
              ApplicationType specDD = (ApplicationType) applicationInfo.getSpecDD();
              String libDir = null;
              //value 'lib' is used if element not set or ear does not contain a dd
              if(specDD == null || !specDD.isSetLibraryDirectory()) {
                libDir = "lib";
              } else {
                String value = specDD.getLibraryDirectory().getStringValue().trim();
                //only set if not empty value, empty value implies no library directory
                if(value.length() > 0) {
                  libDir = value;
                }
              }
                for (Enumeration<JarEntry> e = earFile.entries(); e.hasMoreElements();) {
                    ZipEntry entry = e.nextElement();
                    String entryName = entry.getName();
                    boolean addEntry = true;
                    for (Object moduleLocation : moduleLocations) {
                        String location = (String) moduleLocation;
                        if (entryName.startsWith(location)) {
                            addEntry = false;
                            break;
                        }
                    }
                    if(libDir != null && entry.getName().startsWith(libDir) && entry.getName().endsWith(".jar")) {
                  NestedJarFile library = new NestedJarFile(earFile, entry.getName());
                        earContext.addIncludeAsPackedJar(URI.create(entry.getName()), library);
                    } else if(addEntry) {
                      earContext.addFile(URI.create(entry.getName()), earFile, entry);
                    }
                }
            }

            GerApplicationType geronimoApplication = (GerApplicationType) applicationInfo.getVendorDD();

            // each module installs it's files into the output context.. this is different for each module type
            LinkedHashSet modules = applicationInfo.getModules();
            for (Object module2 : modules) {
                Module module = (Module) module2;
                getBuilder(module).installModule(earFile, earContext, module, configurationStores, targetConfigurationStore, repositories);
            }

            earContext.flush();

            // give each module a chance to populate the earContext now that a classloader is available
            ClassLoader cl = earContext.getClassLoader();
            for (Object module3 : modules) {
                Module module = (Module) module3;
                getBuilder(module).initContext(earContext, module, cl);
            }

            // add gbeans declared in the geronimo-application.xml
            if (geronimoApplication != null) {
                securityBuilders.build(geronimoApplication, earContext, earContext);
                serviceBuilders.build(geronimoApplication, earContext, earContext);
            }

            // Create the J2EEApplication managed object
            if (ConfigurationModuleType.EAR == applicationType) {
                GBeanData gbeanData = new GBeanData(earContext.getModuleName(), J2EEApplicationImpl.GBEAN_INFO);
                try {
                    String originalSpecDD = applicationInfo.getOriginalSpecDD();
                    if (originalSpecDD == null) {
                        originalSpecDD = "Synthetic EAR";
                    }
                    gbeanData.setAttribute("deploymentDescriptor", originalSpecDD);
                } catch (Exception e) {
                    throw new DeploymentException("Error initializing J2EEApplication managed object");
                }
                gbeanData.setReferencePatterns("Server", new ReferencePatterns(new AbstractNameQuery(J2EEServer.class.getName())));

                Map<String, String> thisApp = Collections.singletonMap(NameFactory.J2EE_APPLICATION, earContext.getModuleName().getNameProperty(NameFactory.J2EE_NAME));
                LinkedHashSet<AbstractNameQuery> resourcePatterns = new LinkedHashSet<AbstractNameQuery>();
                resourcePatterns.add(new AbstractNameQuery(null, filter(thisApp, NameFactory.J2EE_TYPE, NameFactory.JAVA_MAIL_RESOURCE), J2EEResource.class.getName()));
                resourcePatterns.add(new AbstractNameQuery(null, filter(thisApp, NameFactory.J2EE_TYPE, NameFactory.JCA_CONNECTION_FACTORY), J2EEResource.class.getName()));
                resourcePatterns.add(new AbstractNameQuery(null, filter(thisApp, NameFactory.J2EE_TYPE, NameFactory.JDBC_RESOURCE), J2EEResource.class.getName()));
                resourcePatterns.add(new AbstractNameQuery(null, filter(thisApp, NameFactory.J2EE_TYPE, NameFactory.JDBC_DRIVER), J2EEResource.class.getName()));
                resourcePatterns.add(new AbstractNameQuery(null, filter(thisApp, NameFactory.J2EE_TYPE, NameFactory.JMS_RESOURCE), J2EEResource.class.getName()));
                resourcePatterns.add(new AbstractNameQuery(null, filter(thisApp, NameFactory.J2EE_TYPE, NameFactory.JNDI_RESOURCE), J2EEResource.class.getName()));
                resourcePatterns.add(new AbstractNameQuery(null, filter(thisApp, NameFactory.J2EE_TYPE, NameFactory.JTA_RESOURCE), J2EEResource.class.getName()));
                resourcePatterns.add(new AbstractNameQuery(null, filter(thisApp, NameFactory.J2EE_TYPE, NameFactory.RMI_IIOP_RESOURCE), J2EEResource.class.getName()));
                resourcePatterns.add(new AbstractNameQuery(null, filter(thisApp, NameFactory.J2EE_TYPE, NameFactory.URL_RESOURCE), J2EEResource.class.getName()));
                gbeanData.setReferencePatterns("Resources", resourcePatterns);

                gbeanData.setReferencePatterns("AppClientModules", new ReferencePatterns(new AbstractNameQuery(null, thisApp, org.apache.geronimo.management.AppClientModule.class.getName())));
                gbeanData.setReferencePatterns("EJBModules", new ReferencePatterns(new AbstractNameQuery(null, thisApp, org.apache.geronimo.management.EJBModule.class.getName())));
                gbeanData.setReferencePatterns("ResourceAdapterModules", new ReferencePatterns(new AbstractNameQuery(null, thisApp, org.apache.geronimo.management.geronimo.ResourceAdapterModule.class.getName())));
                gbeanData.setReferencePatterns("WebModules", new ReferencePatterns(new AbstractNameQuery(null, thisApp, org.apache.geronimo.management.geronimo.WebModule.class.getName())));
                earContext.addGBean(gbeanData);
            }

            // each module can now add it's GBeans
            for (Object module1 : modules) {
                Module module = (Module) module1;
                getBuilder(module).addGBeans(earContext, module, cl, repositories);
            }

            // it's the caller's responsibility to close the context...
            return earContext;
        } catch (GBeanAlreadyExistsException e) {
            cleanupContext(earContext, configurationDir);
            throw new DeploymentException(e);
        } catch (IOException e) {
            cleanupContext(earContext, configurationDir);
            throw e;
        } catch (DeploymentException e) {
            cleanupContext(earContext, configurationDir);
            throw e;
        } catch(RuntimeException e) {
            cleanupContext(earContext, configurationDir);
            throw e;
        } catch(Error e) {
            cleanupContext(earContext, configurationDir);
            throw e;
        } finally {
            for (Object module1 : applicationInfo.getModules()) {
                Module module = (Module) module1;
                module.close();
            }
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.