Search in sources :

Example 21 with EjbBundleDescriptor

use of com.sun.enterprise.deployment.EjbBundleDescriptor in project Payara by payara.

the class WeldDeployer method load.

/**
 * Processing in this method is performed for each module that is in the process of being loaded by
 * the container.
 *
 * <p>
 * This method will collect information from each archive (module) and produce
 * <code>BeanDeploymentArchive</code> information for each module.
 * </p>
 *
 * <p>
 * The
 * <code>BeanDeploymentArchive</code>s are stored in the <code>Deployment</code> (that will
 * eventually be handed off to <code>Weld</code>. Once this method is called for all modules (and
 * <code>BeanDeploymentArchive</code> information has been collected for all <code>Weld</code>
 * modules), a relationship structure is produced defining the accessiblity rules for the
 * <code>BeanDeploymentArchive</code>s.
 * </p>
 *
 * @param container
 * @param context
 * @return
 */
@Override
public WeldApplicationContainer load(WeldContainer container, DeploymentContext context) {
    DeployCommandParameters deployParams = context.getCommandParameters(DeployCommandParameters.class);
    ApplicationInfo applicationInfo = applicationRegistry.get(deployParams.name);
    ReadableArchive archive = context.getSource();
    boolean[] setTransientAppMetaData = { false };
    // See if a WeldBootsrap has already been created - only want one per app.
    WeldBootstrap bootstrap = getWeldBootstrap(context, applicationInfo, setTransientAppMetaData);
    EjbBundleDescriptor ejbBundle = getEjbBundleFromContext(context);
    EjbServices ejbServices = null;
    Set<EjbDescriptor> ejbs = new HashSet<>();
    if (ejbBundle != null) {
        ejbs.addAll(ejbBundle.getEjbs());
        ejbServices = new EjbServicesImpl(services);
    }
    // Create a deployment collecting information from the ReadableArchive (archive)
    // If the archive is a composite, or has version numbers per maven conventions, strip them out
    String archiveName = getArchiveName(context, applicationInfo, archive);
    DeploymentImpl deploymentImpl = context.getTransientAppMetaData(WELD_DEPLOYMENT, DeploymentImpl.class);
    if (deploymentImpl == null) {
        deploymentImpl = new DeploymentImpl(archive, ejbs, context, archiveFactory, archiveName, services.getService(InjectionManager.class));
        // Add services
        TransactionServices transactionServices = new TransactionServicesImpl(services);
        deploymentImpl.getServices().add(TransactionServices.class, transactionServices);
        SecurityServices securityServices = new SecurityServicesImpl();
        deploymentImpl.getServices().add(SecurityServices.class, securityServices);
        ProxyServices proxyServices = new ProxyServicesImpl(services);
        deploymentImpl.getServices().add(ProxyServices.class, proxyServices);
        BootstrapConfigurationImpl bootstrapConfiguration = new BootstrapConfigurationImpl();
        deploymentImpl.getServices().add(BootstrapConfiguration.class, bootstrapConfiguration);
        addWeldListenerToAllWars(context);
    } else {
        deploymentImpl.scanArchive(archive, ejbs, context, archiveName);
    }
    deploymentImpl.addDeployedEjbs(ejbs);
    if (ejbBundle != null && (!deploymentImpl.getServices().contains(EjbServices.class))) {
        // EJB Services is registered as a top-level service
        deploymentImpl.getServices().add(EjbServices.class, ejbServices);
    }
    DeployCommandParameters dc = context.getCommandParameters(DeployCommandParameters.class);
    ExternalConfigurationImpl externalConfiguration = new ExternalConfigurationImpl();
    externalConfiguration.setRollingUpgradesDelimiter(System.getProperty("fish.payara.rollingUpgradesDelimiter", ":"));
    externalConfiguration.setBeanIndexOptimization(dc != null ? !dc.isAvailabilityEnabled() : true);
    deploymentImpl.getServices().add(ExternalConfiguration.class, externalConfiguration);
    BeanDeploymentArchive beanDeploymentArchive = deploymentImpl.getBeanDeploymentArchiveForArchive(archiveName);
    if (beanDeploymentArchive != null && !beanDeploymentArchive.getBeansXml().getBeanDiscoveryMode().equals(NONE)) {
        if (setTransientAppMetaData[0]) {
            // Do this only if we have a root BDA
            appToBootstrap.put(context.getModuleMetaData(Application.class), bootstrap);
            applicationInfo.addTransientAppMetaData(WELD_BOOTSTRAP, bootstrap);
        }
        WebBundleDescriptor webBundleDescriptor = context.getModuleMetaData(WebBundleDescriptor.class);
        boolean developmentMode = isDevelopmentMode(context);
        if (webBundleDescriptor != null) {
            webBundleDescriptor.setExtensionProperty(WELD_EXTENSION, "true");
            // Add the Weld Listener. We have to do it here too in case addWeldListenerToAllWars wasn't
            // able to do it.
            webBundleDescriptor.addAppListenerDescriptorToFirst(new AppListenerDescriptorImpl(WELD_LISTENER));
            // Add Weld Context Listener - this listener will ensure the WeldELContextListener is used
            // for JSP's..
            webBundleDescriptor.addAppListenerDescriptor(new AppListenerDescriptorImpl(WELD_CONTEXT_LISTENER));
            // Weld 2.2.1.Final. There is a tck test for this:
            // org.jboss.cdi.tck.tests.context.session.listener.SessionContextHttpSessionListenerTest
            // This WeldTerminationListener must come after all application-defined listeners
            webBundleDescriptor.addAppListenerDescriptor(new AppListenerDescriptorImpl(WeldTerminationListenerProxy.class.getName()));
            // Adding Weld ConverstationFilter if there is a filterMapping for it and it doesn't exist already.
            // However, it will be applied only if web.xml has a mapping for it.
            // Doing this here to make sure that its done only for CDI enabled web applications
            registerWeldConversationFilter(webBundleDescriptor);
            // every deployment
            if (developmentMode) {
                registerProbeFilter(webBundleDescriptor);
            }
        }
        if (developmentMode) {
            registerProbeExtension(externalConfiguration, deploymentImpl);
        }
        BundleDescriptor bundle = (webBundleDescriptor != null) ? webBundleDescriptor : ejbBundle;
        if (bundle != null) {
            if (!beanDeploymentArchive.getBeansXml().getBeanDiscoveryMode().equals(NONE)) {
                // Register EE injection manager at the bean deployment archive level.
                // We use the generic InjectionService service to handle all EE-style
                // injection instead of the per-dependency-type InjectionPoint approach.
                // Each InjectionServicesImpl instance knows its associated GlassFish bundle.
                InjectionServices injectionServices = new InjectionServicesImpl(deploymentImpl.injectionManager, bundle, deploymentImpl);
                if (logger.isLoggable(FINE)) {
                    logger.log(FINE, ADDING_INJECTION_SERVICES, new Object[] { injectionServices, beanDeploymentArchive.getId() });
                }
                beanDeploymentArchive.getServices().add(InjectionServices.class, injectionServices);
                EEModuleDescriptor eeModuleDescriptor = getEEModuleDescriptor(beanDeploymentArchive);
                if (eeModuleDescriptor != null) {
                    beanDeploymentArchive.getServices().add(EEModuleDescriptor.class, eeModuleDescriptor);
                }
                // Relevant in WAR BDA - WEB-INF/lib BDA scenarios
                for (BeanDeploymentArchive subBda : beanDeploymentArchive.getBeanDeploymentArchives()) {
                    if (logger.isLoggable(FINE)) {
                        logger.log(FINE, ADDING_INJECTION_SERVICES, new Object[] { injectionServices, subBda.getId() });
                    }
                    subBda.getServices().add(InjectionServices.class, injectionServices);
                    // Should not be subBda?
                    eeModuleDescriptor = getEEModuleDescriptor(beanDeploymentArchive);
                    if (eeModuleDescriptor != null) {
                        beanDeploymentArchive.getServices().add(EEModuleDescriptor.class, eeModuleDescriptor);
                    }
                }
            }
            bundleToBeanDeploymentArchive.put(bundle, beanDeploymentArchive);
        }
    }
    context.addTransientAppMetaData(WELD_DEPLOYMENT, deploymentImpl);
    applicationInfo.addTransientAppMetaData(WELD_DEPLOYMENT, deploymentImpl);
    return new WeldApplicationContainer();
}
Also used : ProxyServices(org.jboss.weld.serialization.spi.ProxyServices) ExternalConfigurationImpl(org.glassfish.weld.services.ExternalConfigurationImpl) SecurityServices(org.jboss.weld.security.spi.SecurityServices) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) WeldBootstrap(org.jboss.weld.bootstrap.WeldBootstrap) NonModuleInjectionServices(org.glassfish.weld.services.NonModuleInjectionServices) InjectionServices(org.jboss.weld.injection.spi.InjectionServices) EjbServicesImpl(org.glassfish.weld.services.EjbServicesImpl) ProxyServicesImpl(org.glassfish.weld.services.ProxyServicesImpl) TransactionServicesImpl(org.glassfish.weld.services.TransactionServicesImpl) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) HashSet(java.util.HashSet) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor) DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) EjbServices(org.jboss.weld.ejb.spi.EjbServices) TransactionServices(org.jboss.weld.transaction.spi.TransactionServices) BootstrapConfigurationImpl(org.glassfish.weld.services.BootstrapConfigurationImpl) AppListenerDescriptorImpl(org.glassfish.web.deployment.descriptor.AppListenerDescriptorImpl) SecurityServicesImpl(org.glassfish.weld.services.SecurityServicesImpl) BeanDeploymentArchive(org.jboss.weld.bootstrap.spi.BeanDeploymentArchive) ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive) InjectionServicesImpl(org.glassfish.weld.services.InjectionServicesImpl) Application(com.sun.enterprise.deployment.Application) EEModuleDescriptor(org.jboss.weld.bootstrap.spi.EEModuleDescriptor)

Example 22 with EjbBundleDescriptor

use of com.sun.enterprise.deployment.EjbBundleDescriptor in project Payara by payara.

the class WebArchivist method postStandardDDsRead.

/**
 * After reading all the standard deployment descriptors, merge any
 * resource descriptors from EJB descriptors into the WebBundleDescriptor.
 *
 * @param descriptor the deployment descriptor for the module
 * @param archive the module archive
 * @param extensions map of extension archivists
 */
@Override
protected void postStandardDDsRead(WebBundleDescriptorImpl descriptor, ReadableArchive archive, Map<ExtensionsArchivist, RootDeploymentDescriptor> extensions) throws IOException {
    for (RootDeploymentDescriptor rd : extensions.values()) {
        if (rd instanceof EjbBundleDescriptor) {
            EjbBundleDescriptor eb = (EjbBundleDescriptor) rd;
            descriptor.addJndiNameEnvironment(eb);
            for (EjbDescriptor ejb : eb.getEjbs()) {
                ejb.notifyNewModule(descriptor);
            }
        }
    }
}
Also used : EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) RootDeploymentDescriptor(org.glassfish.deployment.common.RootDeploymentDescriptor) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor)

Example 23 with EjbBundleDescriptor

use of com.sun.enterprise.deployment.EjbBundleDescriptor 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 24 with EjbBundleDescriptor

use of com.sun.enterprise.deployment.EjbBundleDescriptor in project Payara by payara.

the class DOLUtils method getTreatComponentAsModule.

/**
 * Returns true if the environment or its parent is a {@link WebBundleDescriptor}, false otherwise
 * @param env
 * @return
 */
public static boolean getTreatComponentAsModule(JndiNameEnvironment env) {
    boolean treatComponentAsModule = false;
    if (env instanceof WebBundleDescriptor) {
        treatComponentAsModule = true;
    } else {
        if (env instanceof EjbDescriptor) {
            EjbDescriptor ejbDesc = (EjbDescriptor) env;
            EjbBundleDescriptor ejbBundle = ejbDesc.getEjbBundleDescriptor();
            if (ejbBundle.getModuleDescriptor().getDescriptor() instanceof WebBundleDescriptor) {
                treatComponentAsModule = true;
            }
        }
    }
    return treatComponentAsModule;
}
Also used : EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor)

Example 25 with EjbBundleDescriptor

use of com.sun.enterprise.deployment.EjbBundleDescriptor in project Payara by payara.

the class ModuleContentLinker method accept.

public void accept(BundleDescriptor bundle) {
    for (Iterator<WebService> itr = bundle.getWebServices().getWebServices().iterator(); itr.hasNext(); ) {
        WebService aWebService = itr.next();
        accept(aWebService);
    }
    if (bundle instanceof JndiNameEnvironment) {
        for (Iterator<ServiceReferenceDescriptor> itr = ((JndiNameEnvironment) bundle).getServiceReferenceDescriptors().iterator(); itr.hasNext(); ) {
            accept(itr.next());
        }
    }
    if (bundle instanceof EjbBundleDescriptor) {
        EjbBundleDescriptor ejbBundle = (EjbBundleDescriptor) bundle;
        for (EjbDescriptor anEjb : ejbBundle.getEjbs()) {
            for (Iterator<ServiceReferenceDescriptor> itr = anEjb.getServiceReferenceDescriptors().iterator(); itr.hasNext(); ) {
                accept(itr.next());
            }
        }
    }
}
Also used : JndiNameEnvironment(com.sun.enterprise.deployment.JndiNameEnvironment) WebService(com.sun.enterprise.deployment.WebService) EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) ServiceReferenceDescriptor(com.sun.enterprise.deployment.ServiceReferenceDescriptor) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor)

Aggregations

EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)28 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)15 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)14 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)7 Application (com.sun.enterprise.deployment.Application)5 ApplicationClientDescriptor (com.sun.enterprise.deployment.ApplicationClientDescriptor)5 ManagedBeanDescriptor (com.sun.enterprise.deployment.ManagedBeanDescriptor)4 WebServiceEndpoint (com.sun.enterprise.deployment.WebServiceEndpoint)4 WebComponentDescriptor (com.sun.enterprise.deployment.WebComponentDescriptor)3 WebService (com.sun.enterprise.deployment.WebService)3 Iterator (java.util.Iterator)3 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)2 JMSDestinationDefinitionDescriptor (com.sun.enterprise.deployment.JMSDestinationDefinitionDescriptor)2 JndiNameEnvironment (com.sun.enterprise.deployment.JndiNameEnvironment)2 ServiceReferenceDescriptor (com.sun.enterprise.deployment.ServiceReferenceDescriptor)2 EjbsContext (com.sun.enterprise.deployment.annotation.context.EjbsContext)2 IASSecurityException (com.sun.enterprise.security.util.IASSecurityException)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)2