Package org.apache.geronimo.j2ee.deployment

Examples of org.apache.geronimo.j2ee.deployment.EARContext


    @Override
    public void buildNaming(JndiConsumer specDD, XmlObject xmlObject1, Module module, Map<EARContext.Key, Object> sharedContext) throws DeploymentException {
        try {
            // perform a lookup on the bound GBean and add this as a resource reference.  If
            // we can't find one, then bind in a default validator.
            EARContext moduleContext = module.getEarContext();
            AbstractName abstractName = moduleContext.getNaming().createChildName(module.getModuleName(), "ValidatorFactory", NameFactory.VALIDATOR_FACTORY);
            // this verifies that the bean exists...if not, bind to a default factory reference.
            moduleContext.getGBeanInstance(abstractName);
            String osgiJndiName = module.getEarContext().getNaming().toOsgiJndiName(abstractName);
            String filter = "(osgi.jndi.service.name=" + osgiJndiName + ')';
            put("java:comp/ValidatorFactory", new ValidatorFactoryResourceReference(filter, ValidatorFactory.class.getName()), ReferenceType.RESOURCE_ENV, module.getJndiContext(), Collections.<InjectionTarget>emptySet(), sharedContext);
        } catch (GBeanNotFoundException e) {
            // if we can't find one on the module, then bind to a default validator factory
View Full Code Here


                } finally {
                    IOUtils.close(inp);
                }
            }
        }
        EARContext moduleContext = module.getEarContext();
        AbstractName abstractName = moduleContext.getNaming().createChildName(module.getModuleName(), "ValidatorFactory", NameFactory.VALIDATOR_FACTORY);
        GBeanData gbeanData = new GBeanData(abstractName, ValidatorFactoryGBean.class);
        gbeanData.setPriority(GBeanInfo.PRIORITY_CLASSLOADER);
        gbeanData.setAttribute("moduleName", moduleName);
        gbeanData.setAttribute("validationConfig", validationConfig);
        try {
            moduleContext.addGBean(gbeanData);
        } catch (GBeanAlreadyExistsException e) {
            throw new DeploymentException("Duplicate ValidatorFactory GBean", e);
        }
    }
View Full Code Here

//        if (!hasBeansXml(bundle)) {
//            return;
//        }

        EARContext moduleContext = module.getEarContext();
        Map sharedContext = module.getSharedContext();
        //add the ServletContextListener to the web app context
        GBeanData webAppData = (GBeanData) sharedContext.get(WebModule.WEB_APP_DATA);
        // add myfaces listener
        WebAppInfo webAppInfo = (WebAppInfo) webAppData.getAttribute("webAppInfo");
        if (webAppInfo != null && !webAppInfo.listeners.contains(CONTEXT_LISTENER_NAME)) {
            webAppInfo.listeners.add(0, CONTEXT_LISTENER_NAME);
        }
        AbstractName moduleName = moduleContext.getModuleName();
        Map<EARContext.Key, Object> buildingContext = new HashMap<EARContext.Key, Object>();
        buildingContext.put(NamingBuilder.GBEAN_NAME_KEY, moduleName);

        //use the same holder object as the web app.
        Holder holder = NamingBuilder.INJECTION_KEY.get(sharedContext);
View Full Code Here

        return new Axis2ServiceReference(serviceInterfaceClass.getName(), serviceReferenceName, wsdlURI, serviceQName, module.getModuleName(), handlerChainsInfo, seiInfoMap);
    }

    private void registerConfigGBean(Module module) throws DeploymentException {
        EARContext context = module.getEarContext();
        AbstractName containerFactoryName = context.getNaming().createChildName(module.getModuleName(), "Axis2ConfigGBean", GBeanInfoBuilder.DEFAULT_J2EE_TYPE);

        try {
            context.getGBeanInstance(containerFactoryName);
        } catch (GBeanNotFoundException e1) {
            GBeanData configGBeanData = new GBeanData(containerFactoryName, Axis2ConfigGBean.class);
            configGBeanData.setAttribute("moduleName", module.getModuleName());
            configGBeanData.setReferencePattern("Axis2ModuleRegistry", new AbstractNameQuery(Artifact.create("org.apache.geronimo.configs/axis2//car"), Collections.emptyMap(),
                    Axis2ModuleRegistry.class.getName()));
            try {
                context.addGBean(configGBeanData);
            } catch (GBeanAlreadyExistsException e) {
                throw new DeploymentException("Could not add config gbean", e);
            }
        }
    }
View Full Code Here

        EnvironmentBuilder.mergeEnvironments(module.getEnvironment(), defaultEnvironment);

        WebModule webModule = (WebModule) module;
        WebApp webApp = webModule.getSpecDD();

        EARContext moduleContext = module.getEarContext();
        Map sharedContext = module.getSharedContext();

        GBeanData webAppData = (GBeanData) sharedContext.get(WebModule.WEB_APP_DATA);

        AbstractName moduleName = module.getModuleName();
        Map<EARContext.Key, Object> buildingContext = new HashMap<EARContext.Key, Object>();
        buildingContext.put(NamingBuilder.GBEAN_NAME_KEY, moduleName);


        //use the same holder object as the web app.
        Holder holder = NamingBuilder.INJECTION_KEY.get(sharedContext);
        buildingContext.put(NamingBuilder.INJECTION_KEY, holder);

        XmlObject jettyWebApp = webModule.getVendorDD();

        Set<String> listenerNames = new HashSet<String>();

        Map<String, Bundle> tldLocationBundleMap = getTldFiles(webApp, webModule);
        LinkedHashSet<Class<?>> classes = getListenerClasses(webApp, webModule, tldLocationBundleMap, listenerNames);
       
        AbstractFinder originalClassFinder = webModule.getClassFinder();
        ClassFinder classFinder = new ClassFinder(new ArrayList<Class<?>>(classes));
        webModule.setClassFinder(classFinder);
        namingBuilders.buildNaming(webApp, jettyWebApp, webModule, buildingContext);
        webModule.setClassFinder(originalClassFinder);

        //only try to install it if reference will work.
        //Some users (tomcat?) may have back doors into jasper that make adding this gbean unnecessary.
        GBeanInfo webAppGBeanInfo = webAppData.getGBeanInfo();
        if (webAppGBeanInfo.getReference("ContextCustomizer") != null) {
            AbstractName jspLifecycleName = moduleContext.getNaming().createChildName(moduleName, "jspLifecycleProvider", GBeanInfoBuilder.DEFAULT_J2EE_TYPE);
            GBeanData gbeanData = new GBeanData(jspLifecycleName, JasperServletContextCustomizer.class);
            gbeanData.setAttribute("holder", holder);

            try {
                moduleContext.addGBean(gbeanData);
            } catch (GBeanAlreadyExistsException e) {
                throw new DeploymentException("Duplicate jspLifecycleProvider", e);
            }

            webAppData.setReferencePattern("ContextCustomizer", jspLifecycleName);
        }

        WebAppInfoBuilder webAppInfoBuilder = (WebAppInfoBuilder)sharedContext.get(WebModule.WEB_APP_INFO);
        if (webAppInfoBuilder != null) {
            WebAppInfo webAppInfo = webAppInfoBuilder.getWebAppInfo();
            webAppInfo.listeners.addAll(listenerNames);
            //install default jsp servlet....
            ServletInfo jspServlet = webAppInfoBuilder.copy(defaultJspServletInfo);
            List<JspConfig> jspConfigs = webApp.getJspConfig();
            List<String> jspMappings = new ArrayList<String>();
            for (JspConfig jspConfig : jspConfigs) {
                for (JspPropertyGroup propertyGroup : jspConfig.getJspPropertyGroup()) {
                    WebAppInfoBuilder.normalizeUrlPatterns(propertyGroup.getUrlPattern(), jspMappings);
                }
            }

            jspServlet.servletMappings.addAll(jspMappings);
            for (ServletInfo servletInfo: webAppInfo.servlets) {
                servletInfo.servletMappings.removeAll(jspMappings);
            }
            webAppInfo.servlets.add(jspServlet);
        } else {
            GBeanData jspServletData = AbstractWebModuleBuilder.DEFAULT_JSP_SERVLET_KEY.get(sharedContext);
            if (jspServletData != null) {
                try {
                    moduleContext.addGBean(jspServletData);
                } catch (GBeanAlreadyExistsException e) {
                    throw new DeploymentException("jsp servlet already present", e);
                }
            }
            // add listeners
View Full Code Here

                              Collection configurationStores,
                              ConfigurationStore targetConfigurationStore,
                              Collection repository) throws DeploymentException {
        if (module instanceof EjbModule) {
            installModule(module, earContext);
            EARContext moduleContext;
            if (module.isStandAlone()) {
                moduleContext = earContext;
            } else {
                moduleContext = new FragmentContext(earContext, ConfigurationModuleType.EJB);
                //            Environment environment = earContext.getConfiguration().getEnvironment();
View Full Code Here

            respectExcludeUnlistedClasses(data);
        }
    }

    private GBeanData installPersistenceUnitGBean(Persistence.PersistenceUnit persistenceUnit, Module module, String persistenceModulePath) throws DeploymentException {
        EARContext moduleContext = module.getEarContext();
        String persistenceUnitName = persistenceUnit.getName().trim();
        if (persistenceUnitName.length() == 0) {
            persistenceUnitName = ANON_PU_NAME;
        }
        AbstractName abstractName;
        if (persistenceModulePath == null || persistenceModulePath.length() == 0) {
            abstractName = moduleContext.getNaming().createChildName(module.getModuleName(), persistenceUnitName, NameFactory.PERSISTENCE_UNIT);
        } else {
            abstractName = moduleContext.getNaming().createChildName(module.getModuleName(), persistenceModulePath, NameFactory.PERSISTENCE_UNIT_MODULE);
            abstractName = moduleContext.getNaming().createChildName(abstractName, moduleContext.getConfigID(), persistenceUnitName, NameFactory.PERSISTENCE_UNIT);
        }
        GBeanData gbeanData = new GBeanData(abstractName, PersistenceUnitGBean.class);
        try {
            moduleContext.addGBean(gbeanData);
        } catch (GBeanAlreadyExistsException e) {
            throw new DeploymentException("Duplicate persistenceUnit name " + persistenceUnitName, e);
        }
        gbeanData.setAttribute("persistenceUnitName", persistenceUnitName);
        gbeanData.setAttribute("persistenceUnitRoot", persistenceModulePath);
       
        //try to start PU GBean firstly to init the transformer before the entity classes get loaded.
        gbeanData.setPriority(GBeanInfo.PRIORITY_CLASSLOADER);

        //set defaults:
        gbeanData.setAttribute("persistenceProviderClassName", defaultPersistenceProviderClassName);
        //spec 6.2.1.2 the default is JTA
        gbeanData.setAttribute("persistenceUnitTransactionType", "JTA");
        if (defaultJtaDataSourceName != null) {
            gbeanData.setReferencePattern("JtaDataSourceWrapper", defaultJtaDataSourceName);
        }
        if (defaultNonJtaDataSourceName != null) {
            gbeanData.setReferencePattern("NonJtaDataSourceWrapper", defaultNonJtaDataSourceName);
        }

        gbeanData.setAttribute("mappingFileNames", new ArrayList<String>());
        gbeanData.setAttribute("excludeUnlistedClasses", false);
        gbeanData.setAttribute("managedClassNames", new ArrayList<String>());
        gbeanData.setAttribute("jarFileUrls", new ArrayList<String>());
        Properties properties = new Properties();
        gbeanData.setAttribute("properties", properties);
        properties.putAll(defaultPersistenceUnitProperties);
        AbstractNameQuery transactionManagerName = moduleContext.getTransactionManagerName();
        gbeanData.setReferencePattern("TransactionManager", transactionManagerName);
        gbeanData.setReferencePattern("EntityManagerRegistry", extendedEntityManagerRegistryName);
        AbstractName validatorName = moduleContext.getNaming().createChildName(module.getModuleName(), "ValidatorFactory", NameFactory.VALIDATOR_FACTORY);
        gbeanData.setReferencePattern("ValidatorFactory", validatorName);

        setOverrideableProperties(persistenceUnit, gbeanData);
        return gbeanData;
    }
View Full Code Here

        jarURLWebFragmentMap.put("WEB-INF/lib/testA.jar", loadXmlObject("webfragments/absolute/webfragmentA.xml", WebFragment.class));
        jarURLWebFragmentMap.put("WEB-INF/lib/testB.jar", loadXmlObject("webfragments/absolute/webfragmentB.xml", WebFragment.class));
        jarURLWebFragmentMap.put("WEB-INF/lib/testC.jar", loadXmlObject("webfragments/absolute/webfragmentC.xml", WebFragment.class));
        jarURLWebFragmentMap.put("WEB-INF/lib/testD.jar", loadXmlObject("webfragments/absolute/webfragmentD.xml", WebFragment.class));
        WebApp webApp = loadXmlObject("webfragments/absolute/web-withothers.xml", WebApp.class);
        EARContext rootContext = new DummyEARContext();
        WebFragmentEntry[] webFragmentEntries = MergeHelper.sortWebFragments(rootContext, createDummyWebModule(rootContext), null, webApp, jarURLWebFragmentMap);
        Assert.assertEquals(4, webFragmentEntries.length);
        Assert.assertEquals("webfragmentD", webFragmentEntries[0].getName());
        Assert.assertEquals("webfragmentB", webFragmentEntries[1].getName());
        Assert.assertEquals("webfragmentC", webFragmentEntries[2].getName());
View Full Code Here

        jarURLWebFragmentMap.put("WEB-INF/lib/testA.jar", loadXmlObject("webfragments/absolute/webfragmentA.xml", WebFragment.class));
        jarURLWebFragmentMap.put("WEB-INF/lib/testB.jar", loadXmlObject("webfragments/absolute/webfragmentB.xml", WebFragment.class));
        jarURLWebFragmentMap.put("WEB-INF/lib/testC.jar", loadXmlObject("webfragments/absolute/webfragmentC.xml", WebFragment.class));
        jarURLWebFragmentMap.put("WEB-INF/lib/testD.jar", loadXmlObject("webfragments/absolute/webfragmentD.xml", WebFragment.class));
        WebApp webApp = loadXmlObject("webfragments/absolute/web-withoutothers.xml", WebApp.class);
        EARContext rootContext = new DummyEARContext();
        WebFragmentEntry[] webFragmentEntries = MergeHelper.sortWebFragments(rootContext, createDummyWebModule(rootContext), null, webApp, jarURLWebFragmentMap);
        Assert.assertEquals(2, webFragmentEntries.length);
        Assert.assertEquals("webfragmentD", webFragmentEntries[0].getName());
        Assert.assertEquals("webfragmentA", webFragmentEntries[1].getName());
    }
View Full Code Here

        //C -(before) -> others
        jarURLWebFragmentMap.put("WEB-INF/lib/testC.jar", loadXmlObject("webfragments/relative/webfragmentC.xml", WebFragment.class));
        //D -(after) -> others
        jarURLWebFragmentMap.put("WEB-INF/lib/testD.jar", loadXmlObject("webfragments/relative/webfragmentD.xml", WebFragment.class));
        WebApp webApp = loadXmlObject("webfragments/relative/web.xml", WebApp.class);
        EARContext rootContext = new DummyEARContext();
        WebFragmentEntry[] webFragmentEntries = MergeHelper.sortWebFragments(rootContext, createDummyWebModule(rootContext), null, webApp, jarURLWebFragmentMap);
        Assert.assertEquals("webfragmentC", webFragmentEntries[0].getName());
        Assert.assertEquals("webfragmentB", webFragmentEntries[1].getName());
        Assert.assertEquals("webfragmentA", webFragmentEntries[2].getName());
        Assert.assertEquals("webfragmentD", webFragmentEntries[3].getName());
View Full Code Here

TOP

Related Classes of org.apache.geronimo.j2ee.deployment.EARContext

Copyright © 2018 www.massapicom. 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.