Package org.apache.geronimo.xbeans.geronimo.client

Examples of org.apache.geronimo.xbeans.geronimo.client.GerApplicationClientType


    }

    public void testConnectorInclude() throws Exception {
        File resourcePlan = new File(BASEDIR, "src/test/resources/plans/plan2.xml");
        assertTrue(resourcePlan.exists());
        GerApplicationClientType appClient = builder.getGeronimoAppClient(resourcePlan, null, true, null, null, null);
        assertEquals(1, appClient.getResourceRefArray().length);
        assertEquals(1, appClient.getResourceArray().length);
    }
View Full Code Here


    File basedir = new File(System.getProperty("basedir", "."));

    public void testResourceRef() throws Exception {
        File resourcePlan = new File(basedir, "src/test-resources/plans/plan1.xml");
        assertTrue(resourcePlan.exists());
        GerApplicationClientType appClient = builder.getGeronimoAppClient(resourcePlan, null, true, null, null, null);
        assertEquals(1, appClient.getResourceRefArray().length);
    }
View Full Code Here

        assertEquals(1, appClient.getResourceRefArray().length);
    }

    public void testConstructPlan() throws Exception {
        GerApplicationClientDocument appClientDoc = GerApplicationClientDocument.Factory.newInstance();
        GerApplicationClientType appClient = appClientDoc.addNewApplicationClient();
        appClient.setClientConfigId("clientConfigId");
        appClient.setConfigId("configId");
        appClient.setParentId("parentId");
        GerResourceRefType ref = appClient.addNewResourceRef();
        ref.setRefName("ref");
        ref.setTargetName("target");

        SchemaConversionUtils.validateDD(appClient);
//        System.out.println(appClient.toString());
View Full Code Here

    }

    public void testConnectorInclude() throws Exception {
        File resourcePlan = new File(basedir, "src/test-resources/plans/plan2.xml");
        assertTrue(resourcePlan.exists());
        GerApplicationClientType appClient = builder.getGeronimoAppClient(resourcePlan, null, true, null, null, null);
        assertEquals(1, appClient.getResourceRefArray().length);
        assertEquals(1, appClient.getResourceArray().length);
    }
View Full Code Here

        } catch (Exception e) {
            return null;
        }

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

        // get the ids from either the application plan or for a stand alone module from the specific deployer
        URI configId = null;
        try {
            configId = new URI(gerAppClient.getConfigId());
        } catch (URISyntaxException e) {
            throw new DeploymentException("Invalid configId " + gerAppClient.getConfigId(), e);
        }

        URI parentId = null;
        if (gerAppClient.isSetParentId()) {
            try {
                parentId = new URI(gerAppClient.getParentId());
            } catch (URISyntaxException e) {
                throw new DeploymentException("Invalid parentId " + gerAppClient.getParentId(), e);
            }
        } else {
            parentId = defaultServerParentId;
        }
View Full Code Here

        return new AppClientModule(standAlone, configId, parentId, moduleFile, targetPath, appClient, gerAppClient, specDD);
    }

    GerApplicationClientType getGeronimoAppClient(Object plan, JarFile moduleFile, boolean standAlone, String targetPath, ApplicationClientType appClient, URI earConfigId) throws DeploymentException {
        GerApplicationClientType gerAppClient = null;
        try {
            // load the geronimo-application-client.xml from either the supplied plan or from the earFile
            try {
                if (plan instanceof XmlObject) {
                    gerAppClient = (GerApplicationClientType) SchemaConversionUtils.getNestedObjectAsType((XmlObject) plan,
View Full Code Here

            if (id.endsWith("/")) {
                id = id.substring(0, id.length() - 1);
            }
        }

        GerApplicationClientType geronimoAppClient = GerApplicationClientType.Factory.newInstance();

        // set the parentId and configId
        if (standAlone) {
            geronimoAppClient.setClientConfigId(id);
            geronimoAppClient.setConfigId(id + "/server");
        } else {
            geronimoAppClient.setClientConfigId(earConfigId.getPath() + "/" + id);
            // not used but we need to have a value
            geronimoAppClient.setConfigId(id);
        }
        return geronimoAppClient;
    }
View Full Code Here

        J2eeContext earJ2eeContext = earContext.getJ2eeContext();

        AppClientModule appClientModule = (AppClientModule) module;

        ApplicationClientType appClient = (ApplicationClientType) appClientModule.getSpecDD();
        GerApplicationClientType geronimoAppClient = (GerApplicationClientType) appClientModule.getVendorDD();

        // get the app client main class
        JarFile moduleFile = module.getModuleFile();
        String mainClasss = null;
        String classPath = null;
        try {
            Manifest manifest = moduleFile.getManifest();
            if (manifest == null) {
                throw new DeploymentException("App client module jar does not contain a manifest: " + moduleFile.getName());
            }
            mainClasss = manifest.getMainAttributes().getValue(Attributes.Name.MAIN_CLASS);
            if (mainClasss == null) {
                throw new DeploymentException("App client module jar does not have Main-Class defined in the manifest: " + moduleFile.getName());
            }
            classPath = manifest.getMainAttributes().getValue(Attributes.Name.CLASS_PATH);
            if (module.isStandAlone() && classPath != null) {
                throw new DeploymentException("Manifest class path entry is not allowed in a standalone jar (J2EE 1.4 Section 8.2)");
            }
        } catch (IOException e) {
            throw new DeploymentException("Could not get manifest from app client module: " + moduleFile.getName());
        }

        // generate the object name for the app client
        ObjectName appClientModuleName = null;
        try {
            appClientModuleName = NameFactory.getModuleName(null, null, null, appClientModule.getName(), NameFactory.APP_CLIENT_MODULE, earJ2eeContext);
        } catch (MalformedObjectNameException e) {
            throw new DeploymentException("Could not construct module name", e);
        }

        // create a gbean for the app client module and add it to the ear
        ReadOnlyContext componentContext;
        GBeanMBean appClientModuleGBean = new GBeanMBean(J2EEAppClientModuleImpl.GBEAN_INFO, earClassLoader);
        try {
            appClientModuleGBean.setReferencePatterns("J2EEServer", Collections.singleton(earContext.getServerObjectName()));
            if (!earContext.getJ2EEApplicationName().equals("null")) {
                appClientModuleGBean.setReferencePatterns("J2EEApplication", Collections.singleton(earContext.getApplicationObjectName()));
            }
            appClientModuleGBean.setAttribute("deploymentDescriptor", null);

            componentContext = buildComponentContext(earContext, appClientModule, appClient, geronimoAppClient, earClassLoader);
            appClientModuleGBean.setAttribute("componentContext", componentContext);
        } catch (Exception e) {
            throw new DeploymentException("Unable to initialize AppClientModule GBean", e);
        }
        earContext.addGBean(appClientModuleName, appClientModuleGBean);

        // create another child configuration within the config store for the client application
        EARContext appClientDeploymentContext = null;
        File appClientConfiguration = null;
        try {
            try {
                appClientConfiguration = store.createNewConfigurationDir();

                // construct the app client deployment context... this is the same class used by the ear context
                try {

                    URI clientConfigId = URI.create(geronimoAppClient.getClientConfigId());
                    URI clientParentId;
                    if (geronimoAppClient.isSetClientParentId()) {
                        clientParentId = URI.create(geronimoAppClient.getClientParentId());
                    } else {
                        clientParentId = defaultClientParentId;
                    }
                    appClientDeploymentContext = new EARContext(appClientConfiguration,
                            clientConfigId,
                            ConfigurationModuleType.APP_CLIENT,
                            clientParentId,
                            kernel,
                            clientDomainName,
                            clientServerName,
                            clientApplicationName,
                            transactionContextManagerObjectName,
                            connectionTrackerObjectName,
                            null,
                            null,
                            RefContext.derivedClientRefContext(earContext.getRefContext(), ejbReferenceBuilder, resourceReferenceBuilder));
                } catch (Exception e) {
                    throw new DeploymentException("Could not create a deployment context for the app client", e);
                }

                // extract the client Jar file into a standalone packed jar file and add the contents to the output
                URI moduleBase = new URI(appClientModule.getTargetPath());
                try {
                    appClientDeploymentContext.addIncludeAsPackedJar(moduleBase, moduleFile);
                } catch (IOException e) {
                    throw new DeploymentException("Unable to copy app client module jar into configuration: " + moduleFile.getName());
                }

                // add the includes
                GerDependencyType[] includes = geronimoAppClient.getIncludeArray();
                for (int i = 0; i < includes.length; i++) {
                    GerDependencyType include = includes[i];
                    URI uri = getDependencyURI(include);
                    String name = uri.toString();
                    int idx = name.lastIndexOf('/');
                    if (idx != -1) {
                        name = name.substring(idx + 1);
                    }
                    URI path;
                    try {
                        path = new URI(name);
                    } catch (URISyntaxException e) {
                        throw new DeploymentException("Unable to generate path for include: " + uri, e);
                    }
                    try {
                        URL url = repository.getURL(uri);
                        appClientDeploymentContext.addInclude(path, url);
                    } catch (IOException e) {
                        throw new DeploymentException("Unable to add include: " + uri, e);
                    }
                }

                // add the dependencies
                GerDependencyType[] dependencies = geronimoAppClient.getDependencyArray();
                for (int i = 0; i < dependencies.length; i++) {
                    appClientDeploymentContext.addDependency(getDependencyURI(dependencies[i]));
                }

                // add manifest class path entries to the app client context
                addManifestClassPath(appClientDeploymentContext, appClientModule.getEarFile(), moduleFile, moduleBase);

                // get the classloader
                ClassLoader appClientClassLoader = appClientDeploymentContext.getClassLoader(repository);

                // pop in all the gbeans declared in the geronimo app client file
                if (geronimoAppClient != null) {
                    GerGbeanType[] gbeans = geronimoAppClient.getGbeanArray();
                    for (int i = 0; i < gbeans.length; i++) {
                        GBeanHelper.addGbean(new AppClientGBeanAdapter(gbeans[i]), appClientClassLoader, appClientDeploymentContext);
                    }
                    //deploy the resource adapters specified in the geronimo-application.xml
                    Collection resourceModules = new ArrayList();
                    try {
                        GerResourceType[] resources = geronimoAppClient.getResourceArray();
                        for (int i = 0; i < resources.length; i++) {
                            GerResourceType resource = resources[i];
                            String path;
                            JarFile connectorFile;
                            if (resource.isSetExternalRar()) {
View Full Code Here

            throw new DeploymentException("Unable to parse application-client.xml", e);
        }

        // parse vendor dd
        boolean standAlone = earEnvironment == null;
        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, "jar");
        } else {
            Artifact earConfigId = earEnvironment.getConfigId();
            idBuilder.resolve(clientEnvironment, earConfigId.getArtifactId() + "_" + targetPath, "jar");
        }
        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(), "jar");
        }

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

        //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);

        //start installing the resource adapters in the client.
        Collection resourceModules = new ArrayList();
        GerResourceType[] resources = gerAppClient.getResourceArray();
        for (int i = 0; i < resources.length; i++) {
            GerResourceType resource = resources[i];
            String path;
            JarFile connectorFile;
            if (resource.isSetExternalRar()) {
View Full Code Here

        return new AppClientModule(standAlone, moduleName, clientBaseName, serverEnvironment, clientEnvironment, moduleFile, targetPath, appClient, gerAppClient, specDD, resourceModules);
    }

    GerApplicationClientType getGeronimoAppClient(Object plan, JarFile moduleFile, boolean standAlone, String targetPath, ApplicationClientType appClient, Environment environment) throws DeploymentException {
        GerApplicationClientType gerAppClient;
        XmlObject rawPlan = null;
        try {
            // load the geronimo-application-client.xml from either the supplied plan or from the earFile
            try {
                if (plan instanceof XmlObject) {
View Full Code Here

TOP

Related Classes of org.apache.geronimo.xbeans.geronimo.client.GerApplicationClientType

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.