Examples of ApplicationClient


Examples of org.apache.openejb.jee.ApplicationClient

//        if (mainClass == null) throw new IllegalStateException("No Main-Class defined in META-INF/MANIFEST.MF file");

        Map<String, URL> descriptors = getDescriptors(clientFinder, log);

        ApplicationClient applicationClient = null;
        URL clientXmlUrl = descriptors.get("application-client.xml");
        if (clientXmlUrl != null) {
            applicationClient = ReadDescriptors.readApplicationClient(clientXmlUrl);
        }
View Full Code Here

Examples of org.apache.openejb.jee.ApplicationClient

                    }
                }
            }

            for (ClientModule clientModule : appModule.getClientModules()) {
                ApplicationClient applicationClient = clientModule.getApplicationClient();
                if (applicationClient == null) {
                    continue;
                }

                // map ejb-refs
                Map<String,org.apache.openejb.jee.EjbRef> refMap = applicationClient.getEjbRefMap();

                // map ejb-ref jndi name declaration to deploymentId
                for (EjbRef ref : sunApplication.getEjbRef()) {
                    if (ref.getJndiName() != null) {
                        String refName = ref.getEjbRefName();
                        refName = normalize(refName);
                        org.apache.openejb.jee.EjbRef ejbRef = refMap.get(refName);

                        // try to match from lookup name
                        for (Map.Entry<String, org.apache.openejb.jee.EjbRef> aRef : refMap.entrySet()) {
                            if (refName.equals(aRef.getValue().getLookupName())) {
                                ejbRef = aRef.getValue();
                                break;
                            }
                        }

                        if (ejbRef == null) {
                            ejbRef = new org.apache.openejb.jee.EjbRef();
                            ejbRef.setEjbRefName(refName);
                            refMap.put(refName, ejbRef);
                            applicationClient.getEjbRef().add(ejbRef);
                        }
                        ejbRef.setMappedName(ref.getJndiName());
                    }
                }

                // map resource-env-refs and message-destination-refs
                Map<String,JndiReference> resEnvMap = new TreeMap<String,JndiReference>();
                resEnvMap.putAll(applicationClient.getResourceEnvRefMap());
                resEnvMap.putAll(applicationClient.getMessageDestinationRefMap());

                for (ResourceRef ref : sunApplication.getResourceRef()) {
                    if (ref.getJndiName() != null) {
                        String refName = ref.getResRefName();
                        refName = normalize(refName);
                        JndiReference resEnvRef = resEnvMap.get(refName);
                        if (resEnvRef != null) {
                            resEnvRef.setMappedName(ref.getJndiName());
                        }
                    }
                }
                for (ResourceEnvRef ref : sunApplication.getResourceEnvRef()) {
                    if (ref.getJndiName() != null) {
                        String refName = ref.getResourceEnvRefName();
                        refName = normalize(refName);
                        JndiReference resEnvRef = resEnvMap.get(refName);
                        if (resEnvRef != null) {
                            resEnvRef.setMappedName(ref.getJndiName());
                        }
                    }
                }
                for (MessageDestinationRef ref : sunApplication.getMessageDestinationRef()) {
                    if (ref.getJndiName() != null) {
                        String refName = ref.getMessageDestinationRefName();
                        refName = normalize(refName);
                        JndiReference resEnvRef = resEnvMap.get(refName);
                        if (resEnvRef != null) {
                            resEnvRef.setMappedName(ref.getJndiName());
                        }
                    }
                }
                for (MessageDestination destination : sunApplication.getMessageDestination()) {
                    if (destination.getJndiName() != null) {
                        String name = destination.getMessageDestinationName();
                        name = normalize(name);
                        JndiReference ref = resEnvMap.get(name);
                        if (ref != null) {
                            ref.setMappedName(destination.getJndiName());
                        }
                    }
                }

                Map<String, ServiceRef> serviceRefMap = applicationClient.getServiceRefMap();
                for (org.apache.openejb.jee.sun.ServiceRef ref : sunApplication.getServiceRef()) {
                    String refName = ref.getServiceRefName();
                    refName = normalize(refName);
                    ServiceRef serviceRef = serviceRefMap.get(refName);
                    if (serviceRef != null) {
View Full Code Here

Examples of org.apache.openejb.jee.ApplicationClient

    public void convertModule(ClientModule clientModule) {
        if (clientModule == null) {
            return;
        }

        ApplicationClient applicationClient = clientModule.getApplicationClient();
        if (applicationClient == null) {
            return;
        }
        SunApplicationClient sunApplicationClient = getSunApplicationClient(clientModule);
        if (sunApplicationClient == null) {
            return;
        }

        // map ejb-refs
        Map<String,org.apache.openejb.jee.EjbRef> refMap = applicationClient.getEjbRefMap();

        // map ejb-ref jndi name declaration to deploymentId
        for (EjbRef ref : sunApplicationClient.getEjbRef()) {
            if (ref.getJndiName() != null) {
                String refName = ref.getEjbRefName();
                refName = normalize(refName);
                org.apache.openejb.jee.EjbRef ejbRef = refMap.get(refName);
                if (ejbRef == null) {
                    ejbRef = new org.apache.openejb.jee.EjbRef();
                    ejbRef.setEjbRefName(refName);
                    refMap.put(refName, ejbRef);
                    applicationClient.getEjbRef().add(ejbRef);
                }
                ejbRef.setMappedName(ref.getJndiName());
            }
        }

        // map resource-env-refs and message-destination-refs
        Map<String,JndiReference> resEnvMap = new TreeMap<String,JndiReference>();
        resEnvMap.putAll(applicationClient.getResourceEnvRefMap());
        resEnvMap.putAll(applicationClient.getMessageDestinationRefMap());

        for (ResourceRef ref : sunApplicationClient.getResourceRef()) {
            if (ref.getJndiName() != null) {
                String refName = ref.getResRefName();
                refName = normalize(refName);
                JndiReference resEnvRef = resEnvMap.get(refName);
                if (resEnvRef != null) {
                    resEnvRef.setMappedName(ref.getJndiName());
                }
            }
        }
        for (ResourceEnvRef ref : sunApplicationClient.getResourceEnvRef()) {
            if (ref.getJndiName() != null) {
                String refName = ref.getResourceEnvRefName();
                refName = normalize(refName);
                JndiReference resEnvRef = resEnvMap.get(refName);
                if (resEnvRef != null) {
                    resEnvRef.setMappedName(ref.getJndiName());
                }
            }
        }
        for (MessageDestinationRef ref : sunApplicationClient.getMessageDestinationRef()) {
            if (ref.getJndiName() != null) {
                String refName = ref.getMessageDestinationRefName();
                refName = normalize(refName);
                JndiReference resEnvRef = resEnvMap.get(refName);
                if (resEnvRef != null) {
                    resEnvRef.setMappedName(ref.getJndiName());
                }
            }
        }

        Map<String, ServiceRef> serviceRefMap = applicationClient.getServiceRefMap();
        for (org.apache.openejb.jee.sun.ServiceRef ref : sunApplicationClient.getServiceRef()) {
            String refName = ref.getServiceRefName();
            refName = normalize(refName);
            ServiceRef serviceRef = serviceRefMap.get(refName);
            if (serviceRef != null) {
View Full Code Here

Examples of org.apache.openejb.jee.ApplicationClient

        }
    }

    private void buildClientModules(AppModule appModule, AppInfo appInfo, JndiEncInfoBuilder jndiEncInfoBuilder) throws OpenEJBException {
        for (ClientModule clientModule : appModule.getClientModules()) {
            ApplicationClient applicationClient = clientModule.getApplicationClient();
            ClientInfo clientInfo = new ClientInfo();
            clientInfo.description = applicationClient.getDescription();
            clientInfo.displayName = applicationClient.getDisplayName();
            clientInfo.path = clientModule.getJarLocation();
            clientInfo.mainClass = clientModule.getMainClass();
            clientInfo.localClients.addAll(clientModule.getLocalClients());
            clientInfo.remoteClients.addAll(clientModule.getRemoteClients());
            clientInfo.callbackHandler = applicationClient.getCallbackHandler();
            clientInfo.moduleId = getClientModuleId(clientModule);
            clientInfo.watchedResources.addAll(clientModule.getWatchedResources());
            clientInfo.validationInfo = ValidatorBuilder.getInfo(clientModule.getValidationConfig());
            clientInfo.uniqueId = clientModule.getUniqueId();
View Full Code Here

Examples of org.apache.openejb.jee.ApplicationClient

        }

        public ClientModule deploy(ClientModule clientModule) throws OpenEJBException {

            if (clientModule.getApplicationClient() == null){
                clientModule.setApplicationClient(new ApplicationClient());
            }

            // Lots of jars have main classes so this might not even be an app client.
            // We're not going to scrape it for @LocalClient or @RemoteClient annotations
            // unless they flag us specifically by adding a META-INF/application-client.xml
            //
            // ClientModules that already have a AnnotationFinder have been generated automatically
            // from an EjbModule, so we don't skip those ever.
            if (clientModule.getFinder() == null && clientModule.getAltDDs().containsKey("application-client.xml"))

            if (clientModule.getApplicationClient() != null && clientModule.getApplicationClient().isMetadataComplete()) return clientModule;


            IAnnotationFinder finder = clientModule.getFinder();

            if (finder == null) {
                try {
                    finder = FinderFactory.createFinder(clientModule);
                } catch (MalformedURLException e) {
                    startupLogger.warning("startup.scrapeFailedForClientModule.url", clientModule.getJarLocation());
                    return clientModule;
                } catch (Exception e) {
                    startupLogger.warning("startup.scrapeFailedForClientModule", e, clientModule.getJarLocation());
                    return clientModule;
                }
            }

            // This method is also called by the deploy(EjbModule) method to see if those
            // modules have any @LocalClient or @RemoteClient classes
            for (Annotated<Class<?>> clazz : finder.findMetaAnnotatedClasses(LocalClient.class)) {
                clientModule.getLocalClients().add(clazz.get().getName());
            }

            for (Annotated<Class<?>> clazz : finder.findMetaAnnotatedClasses(RemoteClient.class)) {
                clientModule.getRemoteClients().add(clazz.get().getName());
            }

            if (clientModule.getApplicationClient() == null){
                if (clientModule.getRemoteClients().size() > 0 || clientModule.getLocalClients().size() > 0) {
                    clientModule.setApplicationClient(new ApplicationClient());
                }
            }

            return clientModule;
        }
View Full Code Here

Examples of org.apache.openejb.jee.ApplicationClient

            if (clientModule.getApplicationClient() != null && clientModule.getApplicationClient().isMetadataComplete())
                return clientModule;

            ClassLoader classLoader = clientModule.getClassLoader();

            ApplicationClient client = clientModule.getApplicationClient();

            if (client == null) client = new ApplicationClient();

            Set<Class> remoteClients = new HashSet<Class>();

            if (clientModule.getMainClass() != null){
                String className = clientModule.getMainClass();
View Full Code Here

Examples of org.apache.openejb.jee.ApplicationClient

        } catch (IOException e) {
            throw new DeploymentException("Could not get manifest from app client module: " + moduleFile.getName(), e);
        }

        String specDD = null;
        ApplicationClient appClient = null;
        try {
            if (specDDUrl == null) {
                specDDUrl = JarUtils.createJarURL(moduleFile, "META-INF/application-client.xml");
            }

            // read in the entire specDD as a string, we need this for getDeploymentDescriptor
            // on the J2ee management object
            specDD = JarUtils.readAll(specDDUrl);
        } catch (Exception e) {
            //construct a default spec dd
            appClient = new ApplicationClient();
            try {
                specDD = JaxbJavaee.marshal(ApplicationClient.class, appClient);
            } catch (JAXBException e1) {
                //??
            }
        }

        if (appClient == null) {
            //we found application-client.xml, if it won't parse it's an error.
            try {
                // parse it
                InputStream in = specDDUrl.openStream();
                try {
                    appClient = (ApplicationClient) JaxbJavaee.unmarshalJavaee(ApplicationClient.class, in);
                } finally {
                    in.close();
                }
            } catch (Exception e) {
                throw new DeploymentException("Unable to parse application-client.xml", e);
            }
        }

        // parse vendor dd
        GerApplicationClientType gerAppClient = getGeronimoAppClient(plan, moduleFile, standAlone, targetPath, appClient, earEnvironment);


        EnvironmentType clientEnvironmentType = gerAppClient.getClientEnvironment();
        Environment clientEnvironment = EnvironmentBuilder.buildEnvironment(clientEnvironmentType, defaultClientEnvironment);
        if (standAlone) {
            String name = new File(moduleFile.getName()).getName();
            idBuilder.resolve(clientEnvironment, name + "_" + name, "car");
        } else {
            Artifact earConfigId = earEnvironment.getConfigId();
            idBuilder.resolve(clientEnvironment, earConfigId.getArtifactId() + "_" + targetPath, "car");
        }
        EnvironmentType serverEnvironmentType = gerAppClient.getServerEnvironment();
        Environment serverEnvironment = EnvironmentBuilder.buildEnvironment(serverEnvironmentType, defaultServerEnvironment);
        if (!standAlone) {
            EnvironmentBuilder.mergeEnvironments(earEnvironment, serverEnvironment);
            serverEnvironment = earEnvironment;
            if (!serverEnvironment.getConfigId().isResolved()) {
                throw new IllegalStateException("Server environment module ID should be fully resolved (not " + serverEnvironment.getConfigId() + ")");
            }
        } else {
            idBuilder.resolve(serverEnvironment, new File(moduleFile.getName()).getName(), "car");
        }

        AbstractName earName;
        if (parentModule == null) {
            earName = naming.createRootName(serverEnvironment.getConfigId(), NameFactory.NULL, NameFactory.J2EE_APPLICATION);
        } else {
            earName = parentModule.getModuleName();
        }

        //always use the artifactId of the app client as the name component of the module name (on the server).
        AbstractName moduleName = naming.createChildName(earName, clientEnvironment.getConfigId().toString(), NameFactory.APP_CLIENT_MODULE);
        AbstractName clientBaseName = naming.createRootName(clientEnvironment.getConfigId(), clientEnvironment.getConfigId().toString(), NameFactory.J2EE_APPLICATION);

        // Create the AnnotatedApp interface for the AppClientModule
//        AnnotatedApplicationClient annotatedApplicationClient = new AnnotatedApplicationClient(appClient, mainClass);

        String name = null;
        if (appClient.getModuleName() != null) {
            name = appClient.getModuleName().trim();
        } else if (standAlone) {
            name = FileUtils.removeExtension(new File(moduleFile.getName()).getName(), ".jar");
        } else {
            name = FileUtils.removeExtension(targetPath, ".jar");
        }
View Full Code Here

Examples of org.apache.openejb.jee.ApplicationClient

        }

        AppClientModule appClientModule = (AppClientModule) module;
        JarFile moduleFile = module.getModuleFile();

        ApplicationClient appClient = appClientModule.getSpecDD();
        GerApplicationClientType geronimoAppClient = (GerApplicationClientType) appClientModule.getVendorDD();
        //First, the silly gbean on the server that says there's an app client
        // generate the object name for the app client
        AbstractName appClientModuleName = appClientModule.getModuleName();

        // create a gbean for the app client module and add it to the ear
        GBeanData appClientModuleGBeanData = new GBeanData(appClientModuleName, J2EEAppClientModuleImpl.class);
        try {
            appClientModuleGBeanData.setReferencePattern("J2EEServer", earContext.getServerName());
            if (!module.isStandAlone()) {
                appClientModuleGBeanData.setReferencePattern("J2EEApplication", earContext.getModuleName());
            }

        } catch (Exception e) {
            throw new DeploymentException("Unable to initialize AppClientModule GBean", e);
        }
        try {
            earContext.addGBean(appClientModuleGBeanData);
        } catch (GBeanAlreadyExistsException e) {
            throw new DeploymentException("Could not add application client module gbean to configuration", e);
        }

        //Now, the gbeans for the actual remote app client
        EARContext appClientDeploymentContext = appClientModule.getEarContext();
        //Share the ejb info with the ear.
        //TODO this might be too much, but I don't want to impose a dependency on geronimo-openejb to get
        //EjbModuleBuilder.EarData.class
        Map<EARContext.Key, Object> generalData = earContext.getGeneralData();
        for (Map.Entry<EARContext.Key, Object> entry : generalData.entrySet()) {
            EARContext.Key key = entry.getKey();
            if (key.getClass().getName().startsWith("org.apache.geronimo.openejb.deployment.EjbModuleBuilder$EarData")) {
                appClientDeploymentContext.getGeneralData().put(key, entry.getValue());
                break;
            }
        }

        //Share the messageDestination info with the ear
        if (appClientDeploymentContext.getMessageDestinations() != null && earContext.getMessageDestinations() != null) {
            appClientDeploymentContext.getMessageDestinations().putAll(earContext.getMessageDestinations());
        }

        try {
            try {

                //register the message destinations in the app client ear context.
                namingBuilders.initContext(appClient, geronimoAppClient, appClientModule);

                // get the classloader
                Bundle appClientClassBundle = appClientDeploymentContext.getDeploymentBundle();

                // pop in all the gbeans declared in the geronimo app client file
                if (geronimoAppClient != null) {
                    serviceBuilder.build(geronimoAppClient, appClientDeploymentContext, appClientDeploymentContext);
                    //deploy the resource adapters specified in the geronimo-application.xml

                    for (Module connectorModule : appClientModule.getModules()) {
                        if (connectorModule instanceof ConnectorModule) {
                            getConnectorModuleBuilder().addGBeans(appClientDeploymentContext, connectorModule, appClientClassBundle, repositories);
                        }
                    }
                }

                //Holder may be loaded in the "client" module classloader here, whereas
                //NamingBuilder.INJECTION_KEY.get(buildingContext) returns a Holder loaded in the j2ee-server classloader.
                Object holder;
                // add the app client static jndi provider
                //TODO track resource ref shared and app managed security
                AbstractName jndiContextName = earContext.getNaming().createChildName(appClientDeploymentContext.getModuleName(), "StaticJndiContext", "StaticJndiContext");
                GBeanData jndiContextGBeanData = new GBeanData(jndiContextName, StaticJndiContextPlugin.class);
                jndiContextGBeanData.setAttribute("uri", uri);
                try {
                    Map<EARContext.Key, Object> buildingContext = new HashMap<EARContext.Key, Object>();
                    buildingContext.put(NamingBuilder.GBEAN_NAME_KEY, jndiContextName);
                    Configuration localConfiguration = appClientDeploymentContext.getConfiguration();
                    Configuration remoteConfiguration = earContext.getConfiguration();

                    if (!appClient.isMetadataComplete()) {
                        // Create a classfinder and populate it for the naming builder(s). The absence of a
                        // classFinder in the module will convey whether metadata-complete is set
                        // (or not)
                        appClientModule.setClassFinder(createAppClientClassFinder(appClient, appClientModule));
                    }

                    if (appClient.getMainClass() == null) {
                        //LifecycleMethodBuilder.buildNaming() need the main class info in appClient specDD.
                        appClient.setMainClass(appClientModule.getMainClassName());
                    }

                    String moduleName = module.getName();

                    if (earContext.getSubModuleNames().contains(moduleName)) {
                        log.warn("Duplicated moduleName: '" + moduleName + "' is found ! deployer will rename it to: '" + moduleName
                                + "_duplicated' , please check your modules in application to make sure they don't share the same name");
                        moduleName = moduleName + "_duplicated";
                        earContext.getSubModuleNames().add(moduleName);
                    }

                    earContext.getSubModuleNames().add(moduleName);
                    appClientModule.getJndiScope(JndiScope.module).put("module/ModuleName", moduleName);

                    namingBuilders.buildNaming(appClient, geronimoAppClient, appClientModule, buildingContext);
                    if (!appClient.isMetadataComplete()) {
                        appClient.setMetadataComplete(true);
                        module.setOriginalSpecDD(module.getSpecDD().toString());
                    }
                    //n the server
                    appClientModuleGBeanData.setAttribute("deploymentDescriptor", appClientModule.getOriginalSpecDD());
                    //in the app client
                    holder = NamingBuilder.INJECTION_KEY.get(buildingContext);
                    jndiContextGBeanData.setAttribute("context", appClientModule.getJndiContext());
                } catch (DeploymentException e) {
                    throw e;
                } catch (Exception e) {
                    throw new DeploymentException("Unable to construct jndi context for AppClientModule GBean " + appClientModule.getName(), e);
                }
                appClientDeploymentContext.addGBean(jndiContextGBeanData);

                // finally add the app client container
                AbstractName appClientContainerName = appClientDeploymentContext.getModuleName();
                GBeanData appClientContainerGBeanData = new GBeanData(appClientContainerName, AppClientContainer.class);
                try {
                    appClientContainerGBeanData.setAttribute("mainClassName", appClientModule.getMainClassName());
                    appClientContainerGBeanData.setAttribute("appClientModuleName", appClientModuleName);
                    String callbackHandlerClassName = null;
                    if (appClient.getCallbackHandler() != null) {
                        callbackHandlerClassName = appClient.getCallbackHandler().trim();
                    }
                    if (geronimoAppClient.isSetCallbackHandler()) {
                        callbackHandlerClassName = geronimoAppClient.getCallbackHandler().trim();
                    }
                    String realmName = null;
View Full Code Here

Examples of org.apache.openejb.jee.ApplicationClient

            if (clientModule.getApplicationClient() != null && clientModule.getApplicationClient().isMetadataComplete())
                return clientModule;

            ClassLoader classLoader = clientModule.getClassLoader();

            ApplicationClient client = clientModule.getApplicationClient();

            if (client == null) client = new ApplicationClient();

            Set<Class> remoteClients = new HashSet<Class>();

            if (clientModule.getMainClass() != null){
                String className = clientModule.getMainClass();
View Full Code Here

Examples of org.apache.openejb.jee.ApplicationClient

    }

    private void buildClientModules(AppModule appModule, AppInfo appInfo, JndiEncInfoBuilder jndiEncInfoBuilder) throws OpenEJBException {
        for (ClientModule clientModule : appModule.getClientModules()) {
            ApplicationClient applicationClient = clientModule.getApplicationClient();
            ClientInfo clientInfo = new ClientInfo();
            clientInfo.description = applicationClient.getDescription();
            clientInfo.displayName = applicationClient.getDisplayName();
            clientInfo.codebase = clientModule.getJarLocation();
            clientInfo.mainClass = clientModule.getMainClass();
            clientInfo.localClients.addAll(clientModule.getLocalClients());
            clientInfo.remoteClients.addAll(clientModule.getRemoteClients());
            clientInfo.callbackHandler = applicationClient.getCallbackHandler();
            clientInfo.moduleId = getClientModuleId(clientModule);
            clientInfo.watchedResources.addAll(clientModule.getWatchedResources());

            clientInfo.jndiEnc = jndiEncInfoBuilder.build(applicationClient, clientModule.getJarLocation(), clientInfo.moduleId);
            appInfo.clients.add(clientInfo);
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.