Examples of NestedJarFile


Examples of org.apache.geronimo.deployment.util.NestedJarFile

                        } catch (MalformedURLException e) {
                            throw new DeploymentException("Invalid alt sped dd url: " + moduleXml.getAltDd().getStringValue(), e);
                        }
                    }

                    NestedJarFile moduleFile;
                    try {
                        moduleFile = new NestedJarFile(earFile, modulePath);
                    } catch (IOException e) {
                        throw new DeploymentException("Invalid moduleFile: " + modulePath, e);
                    }

                    Module module = builder.createModule(altVendorDDs.get(modulePath),
                            moduleFile,
                            modulePath,
                            altSpecDD,
                            environment,
                            moduleContextInfo,
                            earName,
                            naming, idBuilder);

                    if (module == null) {
                        throw new DeploymentException("Module was not " + moduleTypeName + ": " + modulePath);
                    }

                    modules.add(module);
                }
            }

            //deploy the extension modules
            GerExtModuleType gerExtModuleTypes[] = gerApplication.getExtModuleArray();
            for (int i = 0; i < gerExtModuleTypes.length; i++) {
                GerExtModuleType gerExtModule = gerExtModuleTypes[i];
                String moduleName;
                ModuleBuilder builder;
                Object moduleContextInfo = null;
                String moduleTypeName;

                if (gerExtModule.isSetEjb()) {
                    moduleName = gerExtModule.getEjb().getStringValue();
                    builder = getEjbConfigBuilder();
                    if (builder == null) {
                        throw new DeploymentException("Cannot deploy ejb application; No ejb deployer defined: " + moduleName);
                    }
                    moduleTypeName = "an EJB";
                } else if (gerExtModule.isSetWeb()) {
                    moduleName = gerExtModule.getWeb().getStringValue();
                    if (getWebConfigBuilder() == null) {
                        throw new DeploymentException("Cannot deploy web application; No war deployer defined: " + moduleName);
                    }
                    builder = getWebConfigBuilder();
                    moduleTypeName = "a war";
                    //ext modules must use vendor plan to set context-root
//                    moduleContextInfo = gerExtModule.getWeb().getContextRoot().getStringValue().trim();
                } else if (gerExtModule.isSetConnector()) {
                    moduleName = gerExtModule.getConnector().getStringValue();
                    if (getConnectorConfigBuilder() == null) {
                        throw new DeploymentException("Cannot deploy resource adapter; No rar deployer defined: " + moduleName);
                    }
                    builder = getConnectorConfigBuilder();
                    moduleTypeName = "a connector";
                } else if (gerExtModule.isSetJava()) {
                    moduleName = gerExtModule.getJava().getStringValue();
                    if (getAppClientConfigBuilder() == null) {
                        throw new DeploymentException("Cannot deploy app client; No app client deployer defined: " + moduleName);
                    }
                    builder = getAppClientConfigBuilder();
                    moduleTypeName = "an application client";
                } else {
                    throw new DeploymentException("Could not find a module builder for module: " + gerExtModule);
                }
                //dd is included explicitly
                XmlObject[] anys = gerExtModule.selectChildren(GerExtModuleType.type.qnameSetForWildcardElements());
                if (anys.length != 1) {
                    throw new DeploymentException("Unexpected count of xs:any elements in embedded vendor plan " + anys.length + " qnameset: " + GerExtModuleType.type.qnameSetForWildcardElements());
                }
                Object vendorDD = anys[0];

                JarFile moduleFile;
                if (gerExtModule.isSetInternalPath()) {
                    String modulePath = gerExtModule.getInternalPath().trim();
                    moduleLocations.add(modulePath);
                    try {
                        moduleFile = new NestedJarFile(earFile, modulePath);
                    } catch (IOException e) {
                        throw new DeploymentException("Invalid moduleFile: " + modulePath, e);
                    }
                } else {
                    String path = gerExtModule.getExternalPath().trim();
View Full Code Here

Examples of org.apache.geronimo.deployment.util.NestedJarFile

        configuration.addToClassPath(targetPath.toString());
    }

    public void addInclude(URI targetPath, ZipFile zipFile, ZipEntry zipEntry) throws IOException {
        if (zipFile instanceof NestedJarFile) {
            NestedJarFile nestedJarFile = (NestedJarFile) zipFile;
            if (nestedJarFile.isPacked()) {
                zipFilesToExpand.add(zipFile);
            }
        }
       
        configuration.addToClassPath(targetPath.toString());
View Full Code Here

Examples of org.apache.geronimo.deployment.util.NestedJarFile

        configuration.addToClassPath(targetPath.toString());
    }

    public void addFile(URI targetPath, ZipFile zipFile, ZipEntry zipEntry) throws IOException {
        if (zipFile instanceof NestedJarFile) {
            NestedJarFile nestedJarFile = (NestedJarFile) zipFile;
            if (nestedJarFile.isPacked()) {
                zipFilesToExpand.add(zipFile);
            }
        }
    }
View Full Code Here

Examples of org.apache.geronimo.deployment.util.NestedJarFile

                                    throw new DeploymentException("Could not access rar contents", e);
                                }
                            } else {
                                path = resource.getInternalRar();
                                try {
                                    connectorFile = new NestedJarFile(appClientModule.getEarFile(), path);
                                } catch (IOException e) {
                                    throw new DeploymentException("Could not locate connector inside ear", e);
                                }
                            }
                            XmlObject connectorPlan = resource.getConnector();
View Full Code Here

Examples of org.apache.geronimo.deployment.util.NestedJarFile

                        } catch (MalformedURLException e) {
                            throw new DeploymentException("Invalid alt sped dd url: " + moduleXml.getAltDd().getStringValue(), e);
                        }
                    }

                    NestedJarFile moduleFile;
                    try {
                        moduleFile = new NestedJarFile(earFile, modulePath);
                    } catch (IOException e) {
                        throw new DeploymentException("Invalid moduleFile: " + modulePath, e);
                    }

                    Module module = builder.createModule(altVendorDDs.get(modulePath),
                            moduleFile,
                            modulePath,
                            altSpecDD,
                            environment,
                            moduleContextInfo,
                            earName,
                            naming, idBuilder);

                    if (module == null) {
                        throw new DeploymentException("Module was not " + moduleTypeName + ": " + modulePath);
                    }

                    modules.add(module);
                }
            }

            //deploy the extension modules
            GerExtModuleType gerExtModuleTypes[] = gerApplication.getExtModuleArray();
            for (int i = 0; i < gerExtModuleTypes.length; i++) {
                GerExtModuleType gerExtModule = gerExtModuleTypes[i];
                String moduleName;
                ModuleBuilder builder;
                Object moduleContextInfo = null;
                String moduleTypeName;

                if (gerExtModule.isSetEjb()) {
                    moduleName = gerExtModule.getEjb().getStringValue();
                    builder = getEjbConfigBuilder();
                    if (builder == null) {
                        throw new DeploymentException("Cannot deploy ejb application; No ejb deployer defined: " + moduleName);
                    }
                    moduleTypeName = "an EJB";
                } else if (gerExtModule.isSetWeb()) {
                    moduleName = gerExtModule.getWeb().getStringValue();
                    if (getWebConfigBuilder() == null) {
                        throw new DeploymentException("Cannot deploy web application; No war deployer defined: " + moduleName);
                    }
                    builder = getWebConfigBuilder();
                    moduleTypeName = "a war";
                    //ext modules must use vendor plan to set context-root
//                    moduleContextInfo = gerExtModule.getWeb().getContextRoot().getStringValue().trim();
                } else if (gerExtModule.isSetConnector()) {
                    moduleName = gerExtModule.getConnector().getStringValue();
                    if (getConnectorConfigBuilder() == null) {
                        throw new DeploymentException("Cannot deploy resource adapter; No rar deployer defined: " + moduleName);
                    }
                    builder = getConnectorConfigBuilder();
                    moduleTypeName = "a connector";
                } else if (gerExtModule.isSetJava()) {
                    moduleName = gerExtModule.getJava().getStringValue();
                    if (getAppClientConfigBuilder() == null) {
                        throw new DeploymentException("Cannot deploy app client; No app client deployer defined: " + moduleName);
                    }
                    builder = getAppClientConfigBuilder();
                    moduleTypeName = "an application client";
                } else {
                    throw new DeploymentException("Could not find a module builder for module: " + gerExtModule);
                }
                //dd is included explicitly
                XmlObject[] anys = gerExtModule.selectChildren(GerExtModuleType.type.qnameSetForWildcardElements());
                if (anys.length != 1) {
                    throw new DeploymentException("Unexpected count of xs:any elements in embedded vendor plan " + anys.length + " qnameset: " + GerExtModuleType.type.qnameSetForWildcardElements());
                }
                Object vendorDD = anys[0];

                JarFile moduleFile;
                if (gerExtModule.isSetInternalPath()) {
                    String modulePath = gerExtModule.getInternalPath().trim();
                    moduleLocations.add(modulePath);
                    try {
                        moduleFile = new NestedJarFile(earFile, modulePath);
                    } catch (IOException e) {
                        throw new DeploymentException("Invalid moduleFile: " + modulePath, e);
                    }
                } else {
                    String path = gerExtModule.getExternalPath().trim();
View Full Code Here

Examples of org.apache.geronimo.kernel.util.NestedJarFile

                }
                path = artifact.toString();
            } else {
                path = resource.getInternalRar();
                try {
                    connectorFile = new NestedJarFile(moduleFile, path);
                } catch (IOException e) {
                    throw new DeploymentException("Could not locate connector inside ear", e);
                }
            }
            XmlObject connectorPlan = resource.getConnector();
View Full Code Here

Examples of org.apache.geronimo.kernel.util.NestedJarFile

            if (module.getParentModule() != null) {
                Collection<String> libClasspath = module.getParentModule().getClassPath();
                for (String libEntryPath : libClasspath) {
                    if (libEntryPath.endsWith(".jar")) {
                        try {
                            NestedJarFile library = new NestedJarFile(earFile, libEntryPath);
                            appClientDeploymentContext.addIncludeAsPackedJar(URI.create(libEntryPath), library);
                        } catch (IOException e) {
                            throw new DeploymentException("Could not add to app client library classpath: " + libEntryPath, e);
                        }
                    }
                }
                module.getClassPath().addAll(libClasspath);
                Enumeration<JarEntry> ear_entries = earFile.entries();
                //Copy non archive files from ear file to appclient configuration. These
                // files are needed when caculating dir classpath in manifest.
                while (ear_entries.hasMoreElements()) {
                    ZipEntry ear_entry = ear_entries.nextElement();
                    URI targetPath = module.getParentModule().resolve(ear_entry.getName());
                    if (!ear_entry.getName().endsWith(".jar") && !ear_entry.getName().endsWith(".war") && !ear_entry.getName().endsWith(".rar") && !ear_entry.getName().startsWith("META-INF")) {
                        appClientDeploymentContext.addFile(targetPath, earFile, ear_entry);
                    }
                }
            }
            Collection<String> appClientModuleClasspaths = module.getClassPath();
            try {
                // extract the client Jar file into a standalone packed jar file and add the contents to the output
                URI moduleBase = new URI(module.getTargetPath());
                appClientDeploymentContext.addIncludeAsPackedJar(moduleBase, moduleFile);
                // add manifest class path entries to the app client context
                addManifestClassPath(appClientDeploymentContext, appClientModule.getEarFile(), moduleFile, moduleBase);
            } catch (IOException e) {
                throw new DeploymentException("Unable to copy app client module jar into configuration: " + moduleFile.getName(), e);
            } catch (URISyntaxException e) {
                throw new DeploymentException("Unable to get app client module base URI " + module.getTargetPath(), e);
            }

            if (module.getParentModule() != null) {
                appClientModuleClasspaths.add(module.getTargetPath());
                EARContext moduleContext = module.getEarContext();
                Collection<String> moduleLocations = module.getParentModule().getModuleLocations();
                URI baseUri = URI.create(module.getTargetPath());
                moduleContext.getCompleteManifestClassPath(module.getDeployable(), baseUri, URI.create("."), appClientModuleClasspaths, moduleLocations);

                for (String classpath : appClientModuleClasspaths) {
                    appClientDeploymentContext.addToClassPath(classpath);

                    //Copy needed jar from ear to appclient configuration.
                    if (classpath.endsWith(".jar")) {
                        NestedJarFile library = new NestedJarFile(earFile, classpath);
                        appClientDeploymentContext.addIncludeAsPackedJar(URI.create(classpath), library);
                    }
                }
            }
            for (Module connectorModule : appClientModule.getModules()) {
View Full Code Here

Examples of org.apache.geronimo.kernel.util.NestedJarFile

                for (Enumeration<JarEntry> e = earFile.entries(); e.hasMoreElements();) {
                    ZipEntry entry = e.nextElement();
                    String entryName = entry.getName();
                    //   EAR/lib/sub-dir/*.jar should not be added into lib classpath.
                    if (libDir != null && entry.getName().startsWith(libDir) && entry.getName().endsWith(".jar") && entry.getName().substring(libDir.length()+1).indexOf("/") == -1) {
                        NestedJarFile library = new NestedJarFile(earFile, entry.getName());
                        earContext.addIncludeAsPackedJar(URI.create(entry.getName()), library);
                        libClasspath.add(entry.getName());
                        earContext.addManifestClassPath(library, URI.create(libDir+"/"), libClasspath);
                    }
                }
View Full Code Here

Examples of org.apache.geronimo.kernel.util.NestedJarFile

                            throw new DeploymentException("Could not find a module builder for module: " + moduleXml);
                        }

                        applicationInfo.getModuleLocations().add(modulePath);

                        NestedJarFile moduleFile;
                        try {
                            moduleFile = new NestedJarFile(earFile, modulePath);
                        } catch (IOException e) {
                            throw new DeploymentException("Invalid moduleFile: " + modulePath, e);
                        }

                        Module module = builder.createModule(altVendorDDs.get(modulePath),
                                moduleFile,
                                modulePath,
                                getAltSpecDDURL(earFile, moduleXml),
                                environment,
                                moduleContextInfo,
                                applicationInfo,
                                naming, idBuilder);

                        if (module == null) {
                            throw new DeploymentException("Module was not " + moduleTypeName + ": " + modulePath);
                        }

                        applicationInfo.getModules().add(module);
                    }
                } else {
                    //no application.xml available, must inspect ear to locate and process modules
                    Enumeration<JarEntry> entries = earFile.entries();
                    while (entries.hasMoreElements()) {
                        ModuleBuilder builder;
                        Object moduleContextInfo = null;
                        String moduleTypeName;
                        ZipEntry entry = entries.nextElement();
                        if (entry.getName().endsWith(".war")) {
                            if (getWebConfigBuilder() == null) {
                                throw new DeploymentException("Cannot deploy web application; No war deployer defined: " + entry.getName());
                            }
                            builder = getWebConfigBuilder();
                            moduleTypeName = "a war";
                            moduleContextInfo = entry.getName().split(".war")[0];
                        } else if (entry.getName().endsWith(".rar")) {
                            if (getConnectorConfigBuilder() == null) {
                                throw new DeploymentException("Cannot deploy resource adapter; No rar deployer defined: " + entry.getName());
                            }
                            builder = getConnectorConfigBuilder();
                            moduleTypeName = "a connector";
                        } else if (entry.getName().endsWith(".jar") && !isLibraryEntry(application, entry)) {
                            try {
                                NestedJarFile moduleFile = new NestedJarFile(earFile, entry.getName());
                                Manifest mf = moduleFile.getManifest();

                                if (mf.getMainAttributes().getValue(Attributes.Name.MAIN_CLASS) != null) {
                                    if (getAppClientConfigBuilder() == null) {
                                        throw new DeploymentException("Cannot deploy app client; No app client deployer defined: " + entry.getName());
                                    }
                                    builder = getAppClientConfigBuilder();
                                    moduleTypeName = "an application client";
                                } else {
                                    //ask the ejb builder if its an ejb module
                                    builder = getEjbConfigBuilder();
                                    if (builder == null) {
//                                        throw new DeploymentException("Cannot deploy ejb application; No ejb deployer defined: " + entry.getName());
                                        continue;
                                    }

                                    Module module = builder.createModule(altVendorDDs.get(entry.getName()),
                                            moduleFile,
                                            entry.getName(),
                                            null,
                                            environment,
                                            moduleContextInfo,
                                            applicationInfo,
                                            naming, idBuilder);

                                    if (module != null) {
                                        applicationInfo.getModuleLocations().add(entry.getName());
                                        applicationInfo.getModules().add(module);
                                    }
                                    continue;
                                }
                                //TODO if no ejb-jar.xml inspect classes for EJB component annotations to identify as EJBJar module
                            } catch (IOException e) {
                                throw new DeploymentException("Invalid moduleFile: " + entry.getName(), e);
                            }
                        } else {
                            continue;
                        }

                        applicationInfo.getModuleLocations().add(entry.getName());

                        NestedJarFile moduleFile;
                        try {
                            moduleFile = new NestedJarFile(earFile, entry.getName());
                        } catch (IOException e) {
                            throw new DeploymentException("Invalid moduleFile: " + entry.getName(), e);
                        }

                        Module module = builder.createModule(altVendorDDs.get(entry.getName()),
                                moduleFile,
                                entry.getName(),
                                null,
                                environment,
                                moduleContextInfo,
                                applicationInfo,
                                naming, idBuilder);

                        if (module == null) {
                            throw new DeploymentException("Module was not " + moduleTypeName + ": " + entry.getName());
                        }

                        applicationInfo.getModules().add(module);
                    }
                }

                discoverWebBeans(earFile, application,environment, applicationInfo, idBuilder, altVendorDDs);
            }

            //all the modules in the geronimo plan should have been found by now.
            if (!applicationInfo.getModuleLocations().containsAll(altVendorDDs.keySet())) {
                HashSet<String> missingModules = new HashSet<String>(altVendorDDs.keySet());
                missingModules.removeAll(applicationInfo.getModuleLocations());
                throw new DeploymentException("Geronimo ear plan contains modules that are not in the ear: " + missingModules);
            }
            //deploy the extension modules
            for (GerExtModuleType gerExtModule : gerApplication.getExtModuleArray()) {
                String moduleName;
                ModuleBuilder builder;
                Object moduleContextInfo = null;
                String moduleTypeName;

                if (gerExtModule.isSetEjb()) {
                    moduleName = gerExtModule.getEjb().getStringValue();
                    builder = getEjbConfigBuilder();
                    if (builder == null) {
                        throw new DeploymentException("Cannot deploy ejb application; No ejb deployer defined: " + moduleName);
                    }
                    moduleTypeName = "an EJB";
                } else if (gerExtModule.isSetWeb()) {
                    moduleName = gerExtModule.getWeb().getStringValue();
                    if (getWebConfigBuilder() == null) {
                        throw new DeploymentException("Cannot deploy web application; No war deployer defined: " + moduleName);
                    }
                    builder = getWebConfigBuilder();
                    moduleTypeName = "a war";
                    //ext modules must use vendor plan to set context-root
                } else if (gerExtModule.isSetConnector()) {
                    moduleName = gerExtModule.getConnector().getStringValue();
                    if (getConnectorConfigBuilder() == null) {
                        throw new DeploymentException("Cannot deploy resource adapter; No rar deployer defined: " + moduleName);
                    }
                    builder = getConnectorConfigBuilder();
                    moduleTypeName = "a connector";
                } else if (gerExtModule.isSetJava()) {
                    moduleName = gerExtModule.getJava().getStringValue();
                    if (getAppClientConfigBuilder() == null) {
                        throw new DeploymentException("Cannot deploy app client; No app client deployer defined: " + moduleName);
                    }
                    builder = getAppClientConfigBuilder();
                    moduleTypeName = "an application client";
                } else {
                    throw new DeploymentException("Could not find a module builder for module: " + gerExtModule);
                }
                //dd is included explicitly
                XmlObject[] anys = gerExtModule.selectChildren(GerExtModuleType.type.qnameSetForWildcardElements());
                if (anys.length != 1) {
                    throw new DeploymentException("Unexpected count of xs:any elements in embedded vendor plan " + anys.length + " qnameset: " + GerExtModuleType.type.qnameSetForWildcardElements());
                }
                Object vendorDD = anys[0];

                JarFile moduleFile;
                if (gerExtModule.isSetInternalPath()) {
                    String modulePath = gerExtModule.getInternalPath().trim();
                    applicationInfo.getModuleLocations().add(modulePath);
                    try {
                        moduleFile = new NestedJarFile(earFile, modulePath);
                    } catch (IOException e) {
                        throw new DeploymentException("Invalid moduleFile: " + modulePath, e);
                    }
                } else {
                    PatternType patternType = gerExtModule.getExternalPath();
View Full Code Here

Examples of org.apache.geronimo.kernel.util.NestedJarFile

        Enumeration<JarEntry> entries = earFile.entries();
        while (entries.hasMoreElements()) {
            ZipEntry entry = entries.nextElement();
            if (entry.getName().endsWith(".jar") && isLibraryEntry(application, entry)) {
                try {
                    NestedJarFile moduleFile = new NestedJarFile(earFile, entry.getName());

                    if (moduleFile.getEntry("META-INF/beans.xml") == null) continue;

                    //ask the ejb builder if its an ejb module
                    ModuleBuilder builder = getEjbConfigBuilder();
                    if (builder == null) {
                        continue;
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.