Search in sources :

Example 11 with ArchiveType

use of org.glassfish.api.deployment.archive.ArchiveType in project Payara by payara.

the class UndeployedLaunchable method newUndeployedLaunchable.

static UndeployedLaunchable newUndeployedLaunchable(final ServiceLocator habitat, final ReadableArchive ra, final String callerSuppliedMainClassName, final String callerSuppliedAppName, final ClassLoader classLoader) throws IOException, SAXParseException, UserError {
    ArchivistFactory af = Util.getArchivistFactory();
    /*
         * Try letting the factory decide what type of archive this is.  That
         * will often allow an app client or an EAR archive to be detected
         * automatically.
         */
    Archivist archivist = af.getArchivist(ModuleType.CAR.toString(), classLoader);
    if (archivist == null) {
        throw new UserError(localStrings.get("appclient.invalidArchive", ra.getURI().toASCIIString()));
    }
    final ArchiveType moduleType = archivist.getModuleType();
    if (moduleType != null && moduleType.equals(DOLUtils.carType())) {
        return new UndeployedLaunchable(habitat, ra, (AppClientArchivist) archivist, callerSuppliedMainClassName);
    } else if (moduleType != null && moduleType.equals(DOLUtils.earType())) {
        /*
             * Locate the app client submodule that matches the main class name
             * or the app client name.
             */
        Application app = (Application) archivist.open(ra);
        for (ModuleDescriptor<BundleDescriptor> md : app.getModules()) {
            if (!md.getModuleType().equals(DOLUtils.carType())) {
                continue;
            }
            ApplicationClientDescriptor acd = (ApplicationClientDescriptor) md.getDescriptor();
            final String displayName = acd.getDisplayName();
            final String appName = acd.getModuleID();
            ArchiveFactory archiveFactory = Util.getArchiveFactory();
            ReadableArchive clientRA = archiveFactory.openArchive(ra.getURI().resolve(md.getArchiveUri()));
            /*
                 * Choose this nested app client if the caller-supplied name
                 * matches, or if the caller-supplied main class matches, or
                 * if neither was provided.  
                 */
            final boolean useThisClient = (displayName != null && displayName.equals(callerSuppliedAppName)) || (appName != null && appName.equals(callerSuppliedAppName)) || (callerSuppliedMainClassName != null && clientRA.exists(classToResource(callerSuppliedMainClassName)) || (callerSuppliedAppName == null && callerSuppliedMainClassName == null));
            if (useThisClient) {
                return new UndeployedLaunchable(habitat, clientRA, acd, callerSuppliedMainClassName);
            }
            clientRA.close();
        }
        throw new UserError(localStrings.get("appclient.noMatchingClientInEAR", ra.getURI(), callerSuppliedMainClassName, callerSuppliedAppName));
    } else {
        /*
             * There is a possibility that the user is trying to launch an
             * archive that is more than one type of archive: such as an EJB
             * but also an app client (because the manifest identifies a main
             * class, for example).
             *
             * Earlier the archivist factory might have returned the other type
             * of archivist - such as the EJB archivist.  Now see if the app
             * client archivist will work when selected directly.
             */
        archivist = af.getArchivist(DOLUtils.carType());
        /*
             * Try to open the archive as an app client archive just to see
             * if it works.
             */
        RootDeploymentDescriptor tempACD = archivist.open(ra);
        if (tempACD != null && tempACD instanceof ApplicationClientDescriptor) {
            /*
                 * Start with a fresh archivist - unopened - so we can request
                 * anno processing, etc. before opening it for real.
                 */
            archivist = af.getArchivist(DOLUtils.carType());
            return new UndeployedLaunchable(habitat, ra, (AppClientArchivist) archivist, callerSuppliedMainClassName);
        }
        throw new UserError(localStrings.get("appclient.unexpectedArchive", ra.getURI()));
    }
}
Also used : ArchiveFactory(com.sun.enterprise.deploy.shared.ArchiveFactory) AppClientArchivist(com.sun.enterprise.deployment.archivist.AppClientArchivist) Archivist(com.sun.enterprise.deployment.archivist.Archivist) ArchiveType(org.glassfish.api.deployment.archive.ArchiveType) ApplicationClientDescriptor(com.sun.enterprise.deployment.ApplicationClientDescriptor) AppClientArchivist(com.sun.enterprise.deployment.archivist.AppClientArchivist) ArchivistFactory(com.sun.enterprise.deployment.archivist.ArchivistFactory) ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor) RootDeploymentDescriptor(org.glassfish.deployment.common.RootDeploymentDescriptor) ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive) Application(com.sun.enterprise.deployment.Application)

Example 12 with ArchiveType

use of org.glassfish.api.deployment.archive.ArchiveType in project Payara by payara.

the class ComponentValidator method accept.

@Override
protected void accept(EjbReference ejbRef) {
    DOLUtils.getDefaultLogger().fine("Visiting Ref" + ejbRef);
    if (ejbRef.getEjbDescriptor() != null)
        return;
    // let's try to derive the ejb-ref-type first it is not defined
    if (ejbRef.getType() == null) {
        // if it's EJB30 (no home/local home), it must be session
        if (ejbRef.isEJB30ClientView()) {
            ejbRef.setType("Session");
        } else {
            // if home interface has findByPrimaryKey method,
            // it's entity, otherwise it's session
            String homeIntf = ejbRef.getEjbHomeInterface();
            BundleDescriptor referringJar = ejbRef.getReferringBundleDescriptor();
            if (referringJar == null) {
                referringJar = getBundleDescriptor();
            }
            ClassLoader classLoader = referringJar.getClassLoader();
            Class<?> clazz = null;
            try {
                clazz = classLoader.loadClass(homeIntf);
                for (Method method : clazz.getDeclaredMethods()) {
                    if (method.getName().equals("findByPrimaryKey")) {
                        ejbRef.setType("Entity");
                        break;
                    }
                }
                if (ejbRef.getType() == null) {
                    ejbRef.setType("Session");
                }
            } catch (Exception e) {
                LogRecord lr = new LogRecord(Level.FINE, LOAD_ERROR);
                Object[] args = { homeIntf };
                lr.setParameters(args);
                lr.setThrown(e);
                deplLogger.log(lr);
            }
        }
    }
    if (ejbRef.getJndiName() != null && ejbRef.getJndiName().length() != 0) {
        // if this is a local ref, proceed with resolution only if ejb-link is null
        if (!ejbRef.isLocal() || (ejbRef.isLocal() && ejbRef.getLinkName() == null)) {
            DOLUtils.getDefaultLogger().fine("Ref " + ejbRef.getName() + " is bound to Ejb with JNDI Name " + ejbRef.getJndiName());
            if (getEjbDescriptors() != null) {
                for (Iterator iter = getEjbDescriptors().iterator(); iter.hasNext(); ) {
                    EjbDescriptor ejb = (EjbDescriptor) iter.next();
                    if (ejbRef.getJndiName().equals(ejb.getJndiName())) {
                        ejbRef.setEjbDescriptor(ejb);
                        return;
                    }
                }
            }
        }
    }
    // and let the existing error-checking logic kick in.
    if (((ejbRef.getJndiName() == null) || (ejbRef.getJndiName().length() == 0)) && ((ejbRef.getLinkName() == null) || (ejbRef.getLinkName().length() == 0)) && !ejbRef.hasLookupName()) {
        Map<String, EjbIntfInfo> ejbIntfInfoMap = getEjbIntfMap();
        if (ejbIntfInfoMap.size() > 0) {
            String interfaceToMatch = ejbRef.isEJB30ClientView() ? ejbRef.getEjbInterface() : ejbRef.getEjbHomeInterface();
            if (interfaceToMatch == null) {
                String msg = localStrings.getLocalString("enterprise.deployment.util.no_remoteinterface", "Cannot resolve reference {0} because it does not declare a remote interface or " + "remote home interface of target bean", new Object[] { ejbRef });
                throw new IllegalArgumentException(msg);
            }
            EjbIntfInfo intfInfo = ejbIntfInfoMap.get(interfaceToMatch);
            // make sure exactly one match
            if (intfInfo != null) {
                int numMatches = intfInfo.ejbs.size();
                if (numMatches == 1) {
                    EjbDescriptor target = intfInfo.ejbs.iterator().next();
                    BundleDescriptor targetModule = target.getEjbBundleDescriptor();
                    BundleDescriptor sourceModule = ejbRef.getReferringBundleDescriptor();
                    Application app = targetModule.getApplication();
                    // 
                    // It's much cleaner to derive the ejb-link value
                    // and set that instead of the descriptor.  This way,
                    // if there are multiple ejb-jars within the .ear that
                    // each have an ejb with the target bean's ejb-name,
                    // there won't be any ambiguity about which one is
                    // the correct target.  It's not so much a problem
                    // during this phase of the processing, but if the
                    // fully-qualified ejb-link name is required and is not
                    // written out, there could be non-deterministic
                    // behavior when the application is re-loaded.
                    // Let the ejb-link processing logic handle the
                    // conversion to ejb descriptor.
                    // 
                    // If the ejb reference and the target ejb are defined
                    // within the same ejb-jar, the ejb-link will only
                    // be set to ejb-name.  This is done regardless of
                    // whether the ejb-jar is within an .ear or is
                    // stand-alone.  The ejb-link processing
                    // logic will always check the current ejb-jar
                    // first so there won't be any ambiguity.
                    String ejbLinkName = target.getName();
                    if (!sourceModule.isPackagedAsSingleModule(targetModule)) {
                        String relativeUri = null;
                        if (sourceModule == app) {
                            // Now that dependencies can be defined within application.xml
                            // it's possible for source module to be the Application object.
                            // In this case, just use the target module uri as the relative
                            // uri.
                            relativeUri = targetModule.getModuleDescriptor().getArchiveUri();
                        } else {
                            // Since there are at least two modules, we
                            // must be within an application.
                            relativeUri = getApplication().getRelativeUri(sourceModule, targetModule);
                        }
                        ejbLinkName = relativeUri + "#" + ejbLinkName;
                    }
                    ejbRef.setLinkName(ejbLinkName);
                } else {
                    String msg = localStrings.getLocalString("enterprise.deployment.util.multiple_ejbs_with_interface", "Cannot resolve reference {0} because there are {1} ejbs in the application with interface {2}.", new Object[] { ejbRef, numMatches, interfaceToMatch });
                    throw new IllegalArgumentException(msg);
                }
            }
        }
    }
    // now all cases fall back here, we need to resolve through the link-name
    if (ejbRef.getLinkName() == null) {
        // local refs within the app and we cannot resolve it
        if (ejbRef.isLocal()) {
            if (ejbRef.hasLookupName()) {
                return;
            }
            DOLUtils.getDefaultLogger().severe("Cannot resolve reference " + ejbRef);
            throw new RuntimeException("Cannot resolve reference " + ejbRef);
        } else {
            // ejb ref, apply default jndi name if there is none
            if (!ejbRef.hasJndiName() && !ejbRef.hasLookupName()) {
                String jndiName = getDefaultEjbJndiName(ejbRef.isEJB30ClientView() ? ejbRef.getEjbInterface() : ejbRef.getEjbHomeInterface());
                ejbRef.setJndiName(jndiName);
                DOLUtils.getDefaultLogger().fine("Applying default to ejb reference: " + ejbRef);
            }
            return;
        }
    }
    // Beginning of ejb-link resolution
    // save anticipated types for checking if interfaces are compatible
    String homeClassName = ejbRef.getEjbHomeInterface();
    String intfClassName = ejbRef.getEjbInterface();
    // save anticipated type for checking if bean type is compatible
    String type = ejbRef.getType();
    EjbDescriptor ejbReferee = null;
    String linkName = ejbRef.getLinkName();
    int ind = linkName.lastIndexOf('#');
    if (ind != -1) {
        // link has a relative path from referring EJB JAR,
        // of form "../products/product.jar#ProductEJB"
        String ejbName = linkName.substring(ind + 1);
        String jarPath = linkName.substring(0, ind);
        BundleDescriptor referringJar = ejbRef.getReferringBundleDescriptor();
        if (referringJar == null) {
            ejbRef.setReferringBundleDescriptor(getBundleDescriptor());
            referringJar = getBundleDescriptor();
        }
        if (getApplication() != null) {
            BundleDescriptor refereeJar = null;
            if (referringJar instanceof Application) {
                refereeJar = ((Application) referringJar).getModuleByUri(jarPath);
            } else {
                refereeJar = getApplication().getRelativeBundle(referringJar, jarPath);
            }
            if ((refereeJar != null) && refereeJar instanceof EjbBundleDescriptor) {
                // this will throw an exception if ejb is not found
                ejbReferee = ((EjbBundleDescriptor) refereeJar).getEjbByName(ejbName);
            }
        }
    } else {
        // Handle an unqualified ejb-link, which is just an ejb-name.
        // If we're in an application and currently processing an
        // ejb-reference defined within an ejb-jar, first check
        // the current ejb-jar for an ejb-name match.  From a spec
        // perspective, the deployer can't depend on this behavior,
        // but it's still better to have deterministic results.  In
        // addition, in the case of automatic-linking, the fully-qualified
        // "#" ejb-link syntax is not used when the ejb reference and
        // target ejb are within the same ejb-jar.  Checking the
        // ejb-jar first will ensure the correct linking behavior for
        // that case.
        Application app = getApplication();
        EjbBundleDescriptor ebd = getEjbBundleDescriptor();
        if (app != null && ebd != null && ebd.hasEjbByName(linkName)) {
            ejbReferee = ebd.getEjbByName(linkName);
        } else if (app != null && app.hasEjbByName(linkName)) {
            ejbReferee = app.getEjbByName(ejbRef.getLinkName());
        } else if (getEjbDescriptor() != null) {
            try {
                ejbReferee = getEjbDescriptor().getEjbBundleDescriptor().getEjbByName(ejbRef.getLinkName());
            } catch (IllegalArgumentException e) {
                // this may happen when we have no application and the ejb ref
                // cannot be resolved to a ejb in the bundle. The ref will
                // probably be resolved when the application is assembled.
                DOLUtils.getDefaultLogger().warning("Unresolved <ejb-link>: " + linkName);
                return;
            }
        }
    }
    if (ejbReferee == null) {
        // a warning should suffice
        if (ejbRef.isLocal()) {
            DOLUtils.getDefaultLogger().severe("Unresolved <ejb-link>: " + linkName);
            throw new RuntimeException("Error: Unresolved <ejb-link>: " + linkName);
        } else {
            final ArchiveType moduleType = ejbRef.getReferringBundleDescriptor().getModuleType();
            if (moduleType != null && moduleType.equals(DOLUtils.carType())) {
                // Because no annotation processing is done within ACC runtime, this case typically
                // arises for remote @EJB annotations, so don't log it as warning.
                DOLUtils.getDefaultLogger().fine("Unresolved <ejb-link>: " + linkName);
            } else {
                DOLUtils.getDefaultLogger().warning("Unresolved <ejb-link>: " + linkName);
            }
            return;
        }
    } else {
        if (ejbRef.isEJB30ClientView()) {
            BundleDescriptor referringBundle = ejbRef.getReferringBundleDescriptor();
            // it must be remote business.
            if (((referringBundle == null) && (getEjbBundleDescriptor() == null)) || ((referringBundle != null) && (referringBundle.getModuleType() == DOLUtils.carType())) || ((getApplication() == null) && (referringBundle.getModuleType() != null && referringBundle.getModuleType().equals(DOLUtils.warType())))) {
                ejbRef.setLocal(false);
                if (!ejbReferee.getRemoteBusinessClassNames().contains(intfClassName)) {
                    String msg = "Target ejb " + ejbReferee.getName() + " for " + " remote ejb 3.0 reference " + ejbRef.getName() + " does not expose a remote business interface of type " + intfClassName;
                    throw new RuntimeException(msg);
                }
            } else if (ejbReferee.getLocalBusinessClassNames().contains(intfClassName)) {
                ejbRef.setLocal(true);
            } else if (ejbReferee.getRemoteBusinessClassNames().contains(intfClassName)) {
                ejbRef.setLocal(false);
            } else {
                if (ejbReferee.isLocalBean()) {
                    ejbRef.setLocal(true);
                } else {
                    String msg = "Warning : Unable to determine local " + " business vs. remote business designation for " + " EJB 3.0 ref " + ejbRef;
                    throw new RuntimeException(msg);
                }
            }
        }
        ejbRef.setEjbDescriptor(ejbReferee);
    }
    // if we are here, we must have resolved the reference
    if (DOLUtils.getDefaultLogger().isLoggable(Level.FINE)) {
        if (getEjbDescriptor() != null) {
            DOLUtils.getDefaultLogger().fine("Done Visiting " + getEjbDescriptor().getName() + " reference " + ejbRef);
        }
    }
    // if there is a target ejb descriptor available
    if (ejbRef.isEJB30ClientView()) {
        Set<String> targetBusinessIntfs = ejbRef.isLocal() ? ejbReferee.getLocalBusinessClassNames() : ejbReferee.getRemoteBusinessClassNames();
        EjbDescriptor ejbDesc = ejbRef.getEjbDescriptor();
        // If it's neither a business interface nor a no-interface view
        if (!targetBusinessIntfs.contains(intfClassName) && (ejbDesc.isLocalBean() && !(intfClassName.equals(ejbReferee.getEjbClassName())))) {
            DOLUtils.getDefaultLogger().log(Level.WARNING, "enterprise.deployment.backend.ejbRefTypeMismatch", new Object[] { ejbRef.getName(), intfClassName, ejbReferee.getName(), (ejbRef.isLocal() ? "Local Business" : "Remote Business"), targetBusinessIntfs.toString() });
            // if there is only 1 target remote/local business intf.
            if (targetBusinessIntfs.size() == 1) {
                Iterator iter = targetBusinessIntfs.iterator();
                ejbRef.setEjbInterface((String) iter.next());
            }
        }
    } else {
        String targetHome = ejbRef.isLocal() ? ejbReferee.getLocalHomeClassName() : ejbReferee.getHomeClassName();
        if (!homeClassName.equals(targetHome)) {
            DOLUtils.getDefaultLogger().log(Level.WARNING, "enterprise.deployment.backend.ejbRefTypeMismatch", new Object[] { ejbRef.getName(), homeClassName, ejbReferee.getName(), (ejbRef.isLocal() ? "Local Home" : "Remote Home"), targetHome });
            if (targetHome != null) {
                ejbRef.setEjbHomeInterface(targetHome);
            }
        }
        String targetComponentIntf = ejbRef.isLocal() ? ejbReferee.getLocalClassName() : ejbReferee.getRemoteClassName();
        // check if the intf is known.
        if ((intfClassName != null) && !intfClassName.equals(targetComponentIntf)) {
            DOLUtils.getDefaultLogger().log(Level.WARNING, "enterprise.deployment.backend.ejbRefTypeMismatch", new Object[] { ejbRef.getName(), intfClassName, ejbReferee.getName(), (ejbRef.isLocal() ? "Local" : "Remote"), targetComponentIntf });
            if (targetComponentIntf != null) {
                ejbRef.setEjbInterface(targetComponentIntf);
            }
        }
    }
    // set jndi name in ejb ref
    ejbRef.setJndiName(ejbReferee.getJndiName());
    if (!type.equals(ejbRef.getType())) {
        // if they don't match
        // print a warning and reset the type in ejb ref
        DOLUtils.getDefaultLogger().log(Level.WARNING, DOLUtils.INVALID_DESC_MAPPING, new Object[] { ejbRef.getName(), type });
        ejbRef.setType(ejbRef.getType());
    }
}
Also used : ArchiveType(org.glassfish.api.deployment.archive.ArchiveType) Method(java.lang.reflect.Method) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor) WebServiceEndpoint(com.sun.enterprise.deployment.WebServiceEndpoint) BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) LogRecord(java.util.logging.LogRecord) EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) Iterator(java.util.Iterator) Application(com.sun.enterprise.deployment.Application)

Example 13 with ArchiveType

use of org.glassfish.api.deployment.archive.ArchiveType in project Payara by payara.

the class DeploymentPlanArchive method entries.

/**
 * @return an Enumeration of entries for this archive
 */
public Enumeration entries() {
    if (elements == null) {
        synchronized (this) {
            elements = new Vector();
            for (Enumeration e = jarFile.entries(); e.hasMoreElements(); ) {
                ZipEntry ze = (ZipEntry) e.nextElement();
                if (!ze.isDirectory() && !ze.getName().startsWith("META-INF/")) {
                    elements.add(ze.getName());
                }
            }
        }
    }
    Vector entries = new Vector();
    for (Enumeration e = elements.elements(); e.hasMoreElements(); ) {
        String entryName = (String) e.nextElement();
        String mangledName = entryName;
        String prefix = "META-INF/";
        ArchiveType warType = locator.getService(ArchiveType.class, "war");
        boolean isWar = DeploymentUtils.isArchiveOfType(getParentArchive(), warType, locator);
        if (entryName.indexOf("sun-web.xml") != -1 || entryName.indexOf("glassfish-web.xml") != -1) {
            prefix = "WEB-INF/";
        } else if (entryName.indexOf("glassfish-resources.xml") != -1 && isWar) {
            prefix = "WEB-INF/";
        } else if (entryName.indexOf("glassfish-services.xml") != -1 && isWar) {
            prefix = "WEB-INF/";
        }
        if (subArchiveUri != null && entryName.startsWith(subArchiveUri)) {
            mangledName = mangledName.substring(subArchiveUri.length() + 1);
        }
        if (entryName.endsWith(".dbschema")) {
            mangledName = mangledName.replaceAll("#", "/");
        } else {
            mangledName = prefix + mangledName;
        }
        if (subArchiveUri == null) {
            // top level archive
            if ((entryName.indexOf(".jar.") != -1) || (entryName.indexOf(".war.") != -1) || (entryName.indexOf(".rar.")) != -1) {
                // this element is in a sub archive
                continue;
            }
            entries.add(mangledName);
        } else {
            // this is a sub archive
            if (entryName.startsWith(subArchiveUri)) {
                entries.add(mangledName);
            }
        }
    }
    return entries.elements();
}
Also used : ArchiveType(org.glassfish.api.deployment.archive.ArchiveType) ZipEntry(java.util.zip.ZipEntry)

Example 14 with ArchiveType

use of org.glassfish.api.deployment.archive.ArchiveType in project Payara by payara.

the class SnifferManagerImpl method getApplicableSniffers.

private <T extends Sniffer> List<T> getApplicableSniffers(DeploymentContext context, List<URI> uris, Types types, Collection<T> sniffers, boolean checkPath) {
    ArchiveType archiveType = habitat.getService(ArchiveType.class, context.getArchiveHandler().getArchiveType());
    if (sniffers == null || sniffers.isEmpty()) {
        return Collections.emptyList();
    }
    List<T> result = new ArrayList<T>();
    for (T sniffer : sniffers) {
        if (archiveType != null && !sniffer.supportsArchiveType(archiveType)) {
            continue;
        }
        String[] annotationNames = sniffer.getAnnotationNames(context);
        if (annotationNames == null)
            continue;
        for (String annotationName : annotationNames) {
            if (types != null) {
                Type type = types.getBy(annotationName);
                if (type instanceof AnnotationType) {
                    Collection<AnnotatedElement> elements = ((AnnotationType) type).allAnnotatedTypes();
                    for (AnnotatedElement element : elements) {
                        if (checkPath) {
                            Type t = (element instanceof Member ? ((Member) element).getDeclaringType() : (Type) element);
                            if (t.wasDefinedIn(uris)) {
                                result.add(sniffer);
                                break;
                            }
                        } else {
                            result.add(sniffer);
                            break;
                        }
                    }
                }
            }
        }
    }
    return result;
}
Also used : ArchiveType(org.glassfish.api.deployment.archive.ArchiveType) ArchiveType(org.glassfish.api.deployment.archive.ArchiveType) ArrayList(java.util.ArrayList)

Example 15 with ArchiveType

use of org.glassfish.api.deployment.archive.ArchiveType in project Payara by payara.

the class WebServicesDeployer method populateWsdlFilesForPublish.

/**
 * Populate the wsdl files entries to download (if any) (Only for webservices which
 * use file publishing).
 *
 * TODO File publishing currently works only for wsdls packaged in the application for jax-ws.
 * Need to publish the dynamically generated wsdls as well. Lazy creation of WSEndpoint objects prohibits it now.
 */
private Set<String> populateWsdlFilesForPublish(DeploymentContext dc, Set<WebService> webservices) throws IOException {
    Set<String> publishedFiles = new HashSet<String>();
    for (WebService webService : webservices) {
        if (!webService.hasFilePublishing()) {
            continue;
        }
        copyExtraFilesToGeneratedFolder(dc);
        BundleDescriptor bundle = webService.getBundleDescriptor();
        ArchiveType moduleType = bundle.getModuleType();
        // only EAR, WAR and EJB archives could contain wsdl files for publish
        if (moduleType == null || !(moduleType.equals(DOLUtils.earType()) || moduleType.equals(DOLUtils.warType()) || moduleType.equals(DOLUtils.ejbType()))) {
            return publishedFiles;
        }
        File sourceDir = dc.getScratchDir("xml");
        File parent;
        try {
            URI clientPublishURI = webService.getClientPublishUrl().toURI();
            if (!clientPublishURI.isOpaque()) {
                parent = new File(clientPublishURI);
            } else {
                parent = new File(webService.getClientPublishUrl().getPath());
            }
        } catch (URISyntaxException e) {
            logger.log(Level.WARNING, LogUtils.EXCEPTION_THROWN, e);
            parent = new File(webService.getClientPublishUrl().getPath());
        }
        // Collect the names of all entries in or below the
        // dedicated wsdl directory.
        FileArchive archive = new FileArchive();
        archive.open(sourceDir.toURI());
        Enumeration entries = archive.entries(bundle.getWsdlDir());
        while (entries.hasMoreElements()) {
            String name = (String) entries.nextElement();
            String wsdlName = stripWsdlDir(name, bundle);
            File clientwsdl = new File(parent, wsdlName);
            File fulluriFile = new File(sourceDir, name);
            if (!fulluriFile.isDirectory()) {
                publishFile(fulluriFile, clientwsdl);
                publishedFiles.add(clientwsdl.getAbsolutePath());
            }
        }
    }
    return publishedFiles;
}
Also used : ArchiveType(org.glassfish.api.deployment.archive.ArchiveType) FileArchive(com.sun.enterprise.deploy.shared.FileArchive)

Aggregations

ArchiveType (org.glassfish.api.deployment.archive.ArchiveType)15 ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)4 Application (com.sun.enterprise.deployment.Application)2 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)2 Iterator (java.util.Iterator)2 ModuleDescriptor (org.glassfish.deployment.common.ModuleDescriptor)2 RootDeploymentDescriptor (org.glassfish.deployment.common.RootDeploymentDescriptor)2 ApplicationHolder (org.glassfish.javaee.core.deployment.ApplicationHolder)2 ArchiveFactory (com.sun.enterprise.deploy.shared.ArchiveFactory)1 FileArchive (com.sun.enterprise.deploy.shared.FileArchive)1 ApplicationClientDescriptor (com.sun.enterprise.deployment.ApplicationClientDescriptor)1 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)1 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)1 PersistenceUnitDescriptor (com.sun.enterprise.deployment.PersistenceUnitDescriptor)1 ServiceReferenceDescriptor (com.sun.enterprise.deployment.ServiceReferenceDescriptor)1 WebServiceEndpoint (com.sun.enterprise.deployment.WebServiceEndpoint)1 AppClientArchivist (com.sun.enterprise.deployment.archivist.AppClientArchivist)1 Archivist (com.sun.enterprise.deployment.archivist.Archivist)1 ArchivistFactory (com.sun.enterprise.deployment.archivist.ArchivistFactory)1 Method (java.lang.reflect.Method)1