Search in sources :

Example 26 with WebBundleDescriptor

use of com.sun.enterprise.deployment.WebBundleDescriptor 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) EjbReferenceDescriptor(com.sun.enterprise.deployment.EjbReferenceDescriptor) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor)

Example 27 with WebBundleDescriptor

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

the class WebBundleDescriptorImpl method combineServiceReferenceDescriptors.

@Override
protected void combineServiceReferenceDescriptors(JndiNameEnvironment env) {
    for (Object oserviceRef : env.getServiceReferenceDescriptors()) {
        ServiceReferenceDescriptor serviceRef = (ServiceReferenceDescriptor) oserviceRef;
        ServiceReferenceDescriptor sr = _getServiceReferenceByName(serviceRef.getName());
        if (sr != null) {
            combineInjectionTargets(sr, serviceRef);
        } else {
            if (env instanceof WebBundleDescriptor && ((WebBundleDescriptor) env).isConflictServiceReference()) {
                throw new IllegalArgumentException(localStrings.getLocalString("web.deployment.exceptionconflictserviceref", "There are more than one service references defined in web fragments with the same name, but not overrided in web.xml"));
            } else {
                addServiceReferenceDescriptor(serviceRef);
            }
        }
    }
}
Also used : WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) ServiceReferenceDescriptor(com.sun.enterprise.deployment.ServiceReferenceDescriptor)

Example 28 with WebBundleDescriptor

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

the class WebBundleDescriptorImpl method combineMessageDestinationReferenceDescriptors.

@Override
protected void combineMessageDestinationReferenceDescriptors(JndiNameEnvironment env) {
    for (Object omdRef : env.getMessageDestinationReferenceDescriptors()) {
        MessageDestinationReferenceDescriptor mdRef = (MessageDestinationReferenceDescriptor) omdRef;
        MessageDestinationReferenceDescriptor mdr = _getMessageDestinationReferenceByName(mdRef.getName());
        if (mdr != null) {
            combineInjectionTargets(mdr, mdRef);
        } else {
            if (env instanceof WebBundleDescriptor && ((WebBundleDescriptor) env).isConflictMessageDestinationReference()) {
                throw new IllegalArgumentException(localStrings.getLocalString("web.deployment.exceptionconflictmessagedestinationref", "There are more than one message destination references defined in web fragments with the same name, but not overrided in web.xml"));
            } else {
                addMessageDestinationReferenceDescriptor(mdRef);
            }
        }
    }
}
Also used : MessageDestinationReferenceDescriptor(com.sun.enterprise.deployment.MessageDestinationReferenceDescriptor) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor)

Example 29 with WebBundleDescriptor

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

the class ServletMappingNode method setElementValue.

/**
 * receives notiification of the value for a particular tag
 *
 * @param element the xml element
 * @param value it's associated value
 */
public void setElementValue(XMLElement element, String value) {
    if (WebTagNames.SERVLET_NAME.equals(element.getQName())) {
        servletName = value;
    }
    if (WebTagNames.URL_PATTERN.equals(element.getQName())) {
        if (!URLPattern.isValid(value)) {
            // try trimming url (in case DD uses extra
            // whitespace for aligning)
            String trimmedUrl = value.trim();
            if ("\"\"".equals(trimmedUrl)) {
                trimmedUrl = "";
            }
            // If URL Pattern does not start with "/" then
            // prepend it (for Servlet2.2 Web apps)
            Object parent = getParentNode().getDescriptor();
            if (parent instanceof WebBundleDescriptor && ((WebBundleDescriptor) parent).getSpecVersion().equals("2.2")) {
                if (!trimmedUrl.startsWith("/") && !trimmedUrl.startsWith("*.")) {
                    trimmedUrl = "/" + trimmedUrl;
                }
            }
            if (URLPattern.isValid(trimmedUrl)) {
                // warn user if url included \r or \n
                if (URLPattern.containsCRorLF(value)) {
                    DOLUtils.getDefaultLogger().log(Level.WARNING, "enterprise.deployment.backend.urlcontainscrlf", new Object[] { value });
                }
                value = trimmedUrl;
            } else {
                throw new IllegalArgumentException(MessageFormat.format(rb.getString(LogFacade.ENTERPRISE_DEPLOYMENT_INVALID_URL_PATTERN), value));
            }
        }
        urlPattern = value;
        XMLNode parentNode = getParentNode();
        if (parentNode instanceof WebCommonNode) {
            ((WebCommonNode) parentNode).addServletMapping(servletName, urlPattern);
        } else {
            DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.addDescriptorFailure", new Object[] { getXMLRootTag(), "servlet-mapping" });
        }
    }
}
Also used : XMLNode(com.sun.enterprise.deployment.node.XMLNode) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor)

Example 30 with WebBundleDescriptor

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

the class ResourceInjectorImpl method inject.

public void inject(WSWebServiceContext context, Object instance) throws WebServiceException {
    try {
        // Set proper component context
        invMgr.preInvoke(inv);
        // Injection first
        InjectionManager injManager = WebServiceContractImpl.getInstance().getInjectionManager();
        injManager.injectInstance(instance);
        // Set webservice context here
        // If the endpoint has a WebServiceContext with @Resource then
        // that has to be used
        WebServiceContextImpl wsc = null;
        WebBundleDescriptor bundle = (WebBundleDescriptor) endpoint.getBundleDescriptor();
        Iterator<ResourceReferenceDescriptor> it = bundle.getResourceReferenceDescriptors().iterator();
        while (it.hasNext()) {
            ResourceReferenceDescriptor r = it.next();
            if (r.isWebServiceContext()) {
                Iterator<InjectionTarget> iter = r.getInjectionTargets().iterator();
                boolean matchingClassFound = false;
                while (iter.hasNext()) {
                    InjectionTarget target = iter.next();
                    if (endpoint.getServletImplClass().equals(target.getClassName())) {
                        matchingClassFound = true;
                        break;
                    }
                }
                if (!matchingClassFound) {
                    continue;
                }
                try {
                    javax.naming.InitialContext ic = new javax.naming.InitialContext();
                    wsc = (WebServiceContextImpl) ic.lookup("java:comp/env/" + r.getName());
                } catch (Throwable t) {
                    // Do something here
                    if (logger.isLoggable(Level.FINE)) {
                        logger.log(Level.FINE, LogUtils.EXCEPTION_THROWN, t);
                    }
                }
                if (wsc != null) {
                    wsc.setContextDelegate(context);
                    // needed to support isUserInRole() on WSC;
                    wsc.setServletName(bundle.getWebComponentDescriptors());
                }
            }
        }
    } catch (InjectionException ie) {
        throw new WebServiceException(ie);
    } finally {
        invMgr.postInvoke(inv);
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) InjectionException(com.sun.enterprise.container.common.spi.util.InjectionException) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) InjectionTarget(com.sun.enterprise.deployment.InjectionTarget) ResourceReferenceDescriptor(com.sun.enterprise.deployment.ResourceReferenceDescriptor) InjectionManager(com.sun.enterprise.container.common.spi.util.InjectionManager)

Aggregations

WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)47 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)14 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)10 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)9 WebComponentDescriptor (com.sun.enterprise.deployment.WebComponentDescriptor)7 Application (com.sun.enterprise.deployment.Application)6 ApplicationClientDescriptor (com.sun.enterprise.deployment.ApplicationClientDescriptor)5 ArrayList (java.util.ArrayList)4 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)4 JndiNameEnvironment (com.sun.enterprise.deployment.JndiNameEnvironment)3 ManagedBeanDescriptor (com.sun.enterprise.deployment.ManagedBeanDescriptor)3 SecurityConstraint (com.sun.enterprise.deployment.web.SecurityConstraint)3 WebResourceCollection (com.sun.enterprise.deployment.web.WebResourceCollection)3 IASSecurityException (com.sun.enterprise.security.util.IASSecurityException)3 Iterator (java.util.Iterator)3 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)2 JMSDestinationDefinitionDescriptor (com.sun.enterprise.deployment.JMSDestinationDefinitionDescriptor)2 XMLNode (com.sun.enterprise.deployment.node.XMLNode)2 LoginConfiguration (com.sun.enterprise.deployment.web.LoginConfiguration)2 File (java.io.File)2