Search in sources :

Example 1 with EjbReference

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

the class ASWebEjbRef method check.

public Result check(WebBundleDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    boolean oneFailed = false;
    String refName;
    Set<EjbReference> ejbRefs = descriptor.getEjbReferenceDescriptors();
    if (ejbRefs != null && ejbRefs.size() > 0) {
        for (EjbReference ejbRef : ejbRefs) {
            refName = ejbRef.getName();
            if (validEjbRefName(refName, descriptor)) {
                addGoodDetails(result, compName);
                result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-WEB ejb-ref] ejb-ref-name [ {0} ] properly defined in the war file.", new Object[] { refName }));
            } else {
                oneFailed = true;
                addErrorDetails(result, compName);
                result.failed(smh.getLocalString(getClass().getName() + ".failed", "FAILED [AS-WEB ejb-ref] ejb-ref-name [ {0} ] is not valid, either empty or not defined in web.xml.", new Object[] { refName }));
            }
        }
    } else {
        addNaDetails(result, compName);
        result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-WEB sun-web-app] ejb-ref element(s) not defined in the web archive [ {0} ].", new Object[] { descriptor.getName() }));
        return result;
    }
    if (oneFailed) {
        result.setStatus(Result.FAILED);
    } else {
        addGoodDetails(result, compName);
        result.passed(smh.getLocalString(getClass().getName() + ".passed2", "PASSED [AS-WEB sun-web-app] ejb-ref element(s) defined are valid within the web archive [ {0} ].", new Object[] { descriptor.getName() }));
    }
    return result;
}
Also used : EjbReference(com.sun.enterprise.deployment.types.EjbReference) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Example 2 with EjbReference

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

the class StatefulSessionBeanInjection method check.

public Result check(WebBundleDescriptor descriptor) {
    // initialize the result object
    Result result = getInitializedResult();
    addWarningDetails(result, getVerifierContext().getComponentNameConstructor());
    // default status is PASSED
    result.setStatus(Result.PASSED);
    Set<EjbReference> s = descriptor.getEjbReferenceDescriptors();
    if (s == null)
        return result;
    for (EjbReference ejbRefDesc : s) {
        EjbDescriptor ejbDescriptor = ejbRefDesc.getEjbDescriptor();
        if (ejbDescriptor instanceof EjbSessionDescriptor) {
            // instaceof returns false if ejbDescriptor=null.
            String stateType = ((EjbSessionDescriptor) ejbDescriptor).getSessionType();
            if (EjbSessionDescriptor.STATEFUL.equals(stateType)) {
                Set<InjectionTarget> injectionTargets = ejbRefDesc.getInjectionTargets();
                if (injectionTargets != null) {
                    for (InjectionTarget it : injectionTargets) {
                        String itClassName = it.getClassName();
                        result.warning(smh.getLocalString(className + ".warning", "Found a stateful session bean [ {0} ] injected into [ {1} ].", new Object[] { ejbDescriptor.getEjbClassName(), itClassName }));
                    }
                }
            }
        }
    }
    return result;
}
Also used : EjbReference(com.sun.enterprise.deployment.types.EjbReference) InjectionTarget(com.sun.enterprise.deployment.InjectionTarget) EjbSessionDescriptor(com.sun.enterprise.deployment.EjbSessionDescriptor) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor) Result(com.sun.enterprise.tools.verifier.Result)

Example 3 with EjbReference

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

the class WebBundleRuntimeNode method writeDescriptor.

/**
 * write the descriptor class to a DOM tree and return it
 *
 * @param parent node for the DOM tree
 * @param bundleDescriptor the descriptor to write
 * @return the DOM tree top node
 */
@Override
public Node writeDescriptor(Node parent, WebBundleDescriptorImpl bundleDescriptor) {
    Element web = (Element) super.writeDescriptor(parent, bundleDescriptor);
    SunWebAppImpl sunWebApp = (SunWebAppImpl) bundleDescriptor.getSunDescriptor();
    // context-root?
    appendTextChild(web, RuntimeTagNames.CONTEXT_ROOT, bundleDescriptor.getContextRoot());
    // security-role-mapping
    SecurityRoleMapping[] roleMappings = sunWebApp.getSecurityRoleMapping();
    if (roleMappings != null && roleMappings.length > 0) {
        SecurityRoleMappingNode srmn = new SecurityRoleMappingNode();
        for (SecurityRoleMapping roleMapping : roleMappings) {
            srmn.writeDescriptor(web, RuntimeTagNames.SECURITY_ROLE_MAPPING, roleMapping);
        }
    }
    // servlet
    Set servlets = bundleDescriptor.getServletDescriptors();
    org.glassfish.web.deployment.node.runtime.gf.ServletNode servletNode = new org.glassfish.web.deployment.node.runtime.gf.ServletNode();
    for (Iterator itr = servlets.iterator(); itr.hasNext(); ) {
        WebComponentDescriptor servlet = (WebComponentDescriptor) itr.next();
        servletNode.writeDescriptor(web, RuntimeTagNames.SERVLET, servlet);
    }
    // idempotent-url-pattern
    IdempotentUrlPattern[] patterns = sunWebApp.getIdempotentUrlPatterns();
    if (patterns != null && patterns.length > 0) {
        IdempotentUrlPatternNode node = new IdempotentUrlPatternNode();
        for (IdempotentUrlPattern pattern : patterns) {
            node.writeDescriptor(web, RuntimeTagNames.IDEMPOTENT_URL_PATTERN, pattern);
        }
    }
    // session-config?
    if (sunWebApp.getSessionConfig() != null) {
        SessionConfigNode scn = new SessionConfigNode();
        scn.writeDescriptor(web, RuntimeTagNames.SESSION_CONFIG, sunWebApp.getSessionConfig());
    }
    // ejb-ref*
    Set<EjbReference> ejbRefs = bundleDescriptor.getEjbReferenceDescriptors();
    if (ejbRefs.size() > 0) {
        EjbRefNode node = new EjbRefNode();
        for (EjbReference ejbRef : ejbRefs) {
            node.writeDescriptor(web, RuntimeTagNames.EJB_REF, ejbRef);
        }
    }
    // resource-ref*
    Set<ResourceReferenceDescriptor> resourceRefs = bundleDescriptor.getResourceReferenceDescriptors();
    if (resourceRefs.size() > 0) {
        ResourceRefNode node = new ResourceRefNode();
        for (ResourceReferenceDescriptor resourceRef : resourceRefs) {
            node.writeDescriptor(web, RuntimeTagNames.RESOURCE_REF, resourceRef);
        }
    }
    // resource-env-ref*
    Set<ResourceEnvReferenceDescriptor> resourceEnvRefs = bundleDescriptor.getResourceEnvReferenceDescriptors();
    if (resourceEnvRefs.size() > 0) {
        ResourceEnvRefNode node = new ResourceEnvRefNode();
        for (ResourceEnvReferenceDescriptor resourceEnvRef : resourceEnvRefs) {
            node.writeDescriptor(web, RuntimeTagNames.RESOURCE_ENV_REF, resourceEnvRef);
        }
    }
    // service-ref*
    if (bundleDescriptor.hasServiceReferenceDescriptors()) {
        ServiceRefNode serviceNode = new ServiceRefNode();
        for (ServiceReferenceDescriptor next : bundleDescriptor.getServiceReferenceDescriptors()) {
            serviceNode.writeDescriptor(web, WebServicesTagNames.SERVICE_REF, next);
        }
    }
    // message-destination-ref*
    MessageDestinationRefNode.writeMessageDestinationReferences(web, bundleDescriptor);
    // cache?
    Cache cache = sunWebApp.getCache();
    if (cache != null) {
        CacheNode cn = new CacheNode();
        cn.writeDescriptor(web, RuntimeTagNames.CACHE, cache);
    }
    // class-loader?
    ClassLoader classLoader = sunWebApp.getClassLoader();
    if (classLoader != null) {
        ClassLoaderNode cln = new ClassLoaderNode();
        cln.writeDescriptor(web, RuntimeTagNames.CLASS_LOADER, classLoader);
    }
    // jsp-config?
    if (sunWebApp.getJspConfig() != null) {
        WebPropertyNode propertyNode = new WebPropertyNode();
        Node jspConfig = appendChild(web, RuntimeTagNames.JSP_CONFIG);
        propertyNode.writeDescriptor(jspConfig, RuntimeTagNames.PROPERTY, sunWebApp.getJspConfig().getWebProperty());
    }
    // locale-charset-info?
    if (sunWebApp.getLocaleCharsetInfo() != null) {
        LocaleCharsetInfoNode localeNode = new LocaleCharsetInfoNode();
        localeNode.writeDescriptor(web, RuntimeTagNames.LOCALE_CHARSET_INFO, sunWebApp.getLocaleCharsetInfo());
    }
    // parameter-encoding?
    if (sunWebApp.isParameterEncoding()) {
        Element parameter = appendChild(web, RuntimeTagNames.PARAMETER_ENCODING);
        if (sunWebApp.getAttributeValue(SunWebApp.PARAMETER_ENCODING, SunWebApp.FORM_HINT_FIELD) != null) {
            setAttribute(parameter, RuntimeTagNames.FORM_HINT_FIELD, sunWebApp.getAttributeValue(SunWebApp.PARAMETER_ENCODING, SunWebApp.FORM_HINT_FIELD));
        }
        if (sunWebApp.getAttributeValue(SunWebApp.PARAMETER_ENCODING, SunWebApp.DEFAULT_CHARSET) != null) {
            setAttribute(parameter, RuntimeTagNames.DEFAULT_CHARSET, sunWebApp.getAttributeValue(SunWebApp.PARAMETER_ENCODING, SunWebApp.DEFAULT_CHARSET));
        }
    }
    // property*
    WebPropertyNode props = new WebPropertyNode();
    props.writeDescriptor(web, RuntimeTagNames.PROPERTY, sunWebApp.getWebProperty());
    // valve*
    if (sunWebApp.getValve() != null) {
        ValveNode valve = new ValveNode();
        valve.writeDescriptor(web, RuntimeTagNames.VALVE, sunWebApp.getValve());
    }
    // message-destination*
    RuntimeDescriptorNode.writeMessageDestinationInfo(web, bundleDescriptor);
    // webservice-description*
    WebServiceRuntimeNode webServiceNode = new WebServiceRuntimeNode();
    webServiceNode.writeWebServiceRuntimeInfo(web, bundleDescriptor);
    // error-url
    if (sunWebApp.getAttributeValue(SunWebApp.ERROR_URL) != null) {
        setAttribute(web, RuntimeTagNames.ERROR_URL, sunWebApp.getAttributeValue(SunWebApp.ERROR_URL));
    }
    // httpservlet-security-provider
    if (sunWebApp.getAttributeValue(SunWebApp.HTTPSERVLET_SECURITY_PROVIDER) != null) {
        setAttribute(web, RuntimeTagNames.HTTPSERVLET_SECURITY_PROVIDER, sunWebApp.getAttributeValue(SunWebApp.HTTPSERVLET_SECURITY_PROVIDER));
    }
    // keep-state
    appendTextChild(web, RuntimeTagNames.KEEP_STATE, String.valueOf(bundleDescriptor.getKeepState()));
    return web;
}
Also used : SunWebAppImpl(org.glassfish.web.deployment.runtime.SunWebAppImpl) Set(java.util.Set) XMLElement(com.sun.enterprise.deployment.node.XMLElement) Element(org.w3c.dom.Element) IdempotentUrlPattern(com.sun.enterprise.deployment.runtime.web.IdempotentUrlPattern) ServiceRefNode(com.sun.enterprise.deployment.node.runtime.ServiceRefNode) ResourceEnvRefNode(com.sun.enterprise.deployment.node.runtime.ResourceEnvRefNode) EjbRefNode(com.sun.enterprise.deployment.node.runtime.EjbRefNode) ServiceRefNode(com.sun.enterprise.deployment.node.runtime.ServiceRefNode) ResourceRefNode(com.sun.enterprise.deployment.node.runtime.ResourceRefNode) SecurityRoleMappingNode(com.sun.enterprise.deployment.node.runtime.common.SecurityRoleMappingNode) Node(org.w3c.dom.Node) RuntimeBundleNode(com.sun.enterprise.deployment.node.runtime.RuntimeBundleNode) RuntimeDescriptorNode(com.sun.enterprise.deployment.node.runtime.RuntimeDescriptorNode) MessageDestinationRefNode(com.sun.enterprise.deployment.node.runtime.MessageDestinationRefNode) MessageDestinationRuntimeNode(com.sun.enterprise.deployment.node.runtime.MessageDestinationRuntimeNode) WebServiceRuntimeNode(com.sun.enterprise.deployment.node.runtime.WebServiceRuntimeNode) WebBundleNode(org.glassfish.web.deployment.node.WebBundleNode) WebServiceRuntimeNode(com.sun.enterprise.deployment.node.runtime.WebServiceRuntimeNode) EjbRefNode(com.sun.enterprise.deployment.node.runtime.EjbRefNode) Iterator(java.util.Iterator) ClassLoader(org.glassfish.web.deployment.runtime.ClassLoader) ResourceReferenceDescriptor(com.sun.enterprise.deployment.ResourceReferenceDescriptor) SecurityRoleMapping(com.sun.enterprise.deployment.runtime.common.SecurityRoleMapping) ResourceRefNode(com.sun.enterprise.deployment.node.runtime.ResourceRefNode) ServiceReferenceDescriptor(com.sun.enterprise.deployment.ServiceReferenceDescriptor) SecurityRoleMappingNode(com.sun.enterprise.deployment.node.runtime.common.SecurityRoleMappingNode) EjbReference(com.sun.enterprise.deployment.types.EjbReference) WebComponentDescriptor(com.sun.enterprise.deployment.WebComponentDescriptor) ResourceEnvRefNode(com.sun.enterprise.deployment.node.runtime.ResourceEnvRefNode) ResourceEnvReferenceDescriptor(com.sun.enterprise.deployment.ResourceEnvReferenceDescriptor) Cache(org.glassfish.web.deployment.runtime.Cache)

Example 4 with EjbReference

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

the class WebFragmentDescriptor method combineEjbReferenceDescriptors.

@Override
protected void combineEjbReferenceDescriptors(JndiNameEnvironment env) {
    for (Object oejbRef : env.getEjbReferenceDescriptors()) {
        EjbReference ejbRef = (EjbReference) oejbRef;
        EjbReferenceDescriptor ejbRefDesc = (EjbReferenceDescriptor) _getEjbReference(ejbRef.getName());
        if (ejbRefDesc != null) {
            if (ejbRefDesc.isConflict((EjbReferenceDescriptor) ejbRef)) {
                conflictEjbReference = true;
            }
            combineInjectionTargets(ejbRefDesc, (EnvironmentProperty) ejbRef);
        } else {
            addEjbReferenceDescriptor(ejbRef);
        }
    }
}
Also used : EjbReference(com.sun.enterprise.deployment.types.EjbReference)

Example 5 with EjbReference

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

the class WebBundleDescriptorImpl method combineEjbReferenceDescriptors.

@Override
protected void combineEjbReferenceDescriptors(JndiNameEnvironment env) {
    for (Object oejbRef : env.getEjbReferenceDescriptors()) {
        EjbReference ejbRef = (EjbReference) oejbRef;
        EjbReferenceDescriptor ejbRefDesc = (EjbReferenceDescriptor) _getEjbReference(ejbRef.getName());
        if (ejbRefDesc != null) {
            combineInjectionTargets(ejbRefDesc, (EnvironmentProperty) ejbRef);
        } else {
            if (env instanceof WebBundleDescriptor && ((WebBundleDescriptor) env).isConflictEjbReference()) {
                throw new IllegalArgumentException(localStrings.getLocalString("web.deployment.exceptionconflictejbref", "There are more than one ejb references defined in web fragments with the same name, but not overrided in web.xml"));
            } else {
                addEjbReferenceDescriptor(ejbRef);
            }
        }
    }
}
Also used : EjbReference(com.sun.enterprise.deployment.types.EjbReference)

Aggregations

EjbReference (com.sun.enterprise.deployment.types.EjbReference)14 ResourceEnvReferenceDescriptor (com.sun.enterprise.deployment.ResourceEnvReferenceDescriptor)4 ResourceReferenceDescriptor (com.sun.enterprise.deployment.ResourceReferenceDescriptor)4 MessageDestinationReferencer (com.sun.enterprise.deployment.types.MessageDestinationReferencer)3 Iterator (java.util.Iterator)3 Set (java.util.Set)3 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)2 ServiceReferenceDescriptor (com.sun.enterprise.deployment.ServiceReferenceDescriptor)2 Result (com.sun.enterprise.tools.verifier.Result)2 EjbCMPEntityDescriptor (org.glassfish.ejb.deployment.descriptor.EjbCMPEntityDescriptor)2 PersistenceDescriptor (org.glassfish.ejb.deployment.descriptor.PersistenceDescriptor)2 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)1 EjbSessionDescriptor (com.sun.enterprise.deployment.EjbSessionDescriptor)1 EnvironmentProperty (com.sun.enterprise.deployment.EnvironmentProperty)1 InjectionCapable (com.sun.enterprise.deployment.InjectionCapable)1 InjectionTarget (com.sun.enterprise.deployment.InjectionTarget)1 MessageDestinationReferenceDescriptor (com.sun.enterprise.deployment.MessageDestinationReferenceDescriptor)1 MethodPermission (com.sun.enterprise.deployment.MethodPermission)1 RoleReference (com.sun.enterprise.deployment.RoleReference)1 RunAsIdentityDescriptor (com.sun.enterprise.deployment.RunAsIdentityDescriptor)1