Search in sources :

Example 1 with XMLNode

use of com.sun.enterprise.deployment.node.XMLNode 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 2 with XMLNode

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

the class JavaWebStartAccessNode method getDescriptor.

// public JavaWebStartAccessNode(XMLElement element) {
// register();
// setXMLRootTag(element);
// }
/**
 * @return the descriptor instance to associate with this XMLNode
 */
@Override
public JavaWebStartAccessDescriptor getDescriptor() {
    if (descriptor == null) {
        descriptor = new JavaWebStartAccessDescriptor();
        XMLNode parentNode = getParentNode();
        if (parentNode != null && (parentNode instanceof AppClientRuntimeNode)) {
            Object parentDescriptor = parentNode.getDescriptor();
            if (parentDescriptor != null && (parentDescriptor instanceof ApplicationClientDescriptor)) {
                ApplicationClientDescriptor acDescriptor = (ApplicationClientDescriptor) parentDescriptor;
                acDescriptor.setJavaWebStartAccessDescriptor(descriptor);
            }
        }
    }
    return descriptor;
}
Also used : XMLNode(com.sun.enterprise.deployment.node.XMLNode) ApplicationClientDescriptor(com.sun.enterprise.deployment.ApplicationClientDescriptor) JavaWebStartAccessDescriptor(com.sun.enterprise.deployment.runtime.JavaWebStartAccessDescriptor)

Example 3 with XMLNode

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

the class MessageDestinationRefNode method setElementValue.

@Override
public void setElementValue(XMLElement element, String value) {
    if (TagNames.MESSAGE_DESTINATION_REFERENCE_NAME.equals(element.getQName())) {
        XMLNode parentNode = getParentNode();
        Object parentDesc = null;
        // in case of web
        if (parentNode.getDescriptor() instanceof WebBundleDescriptor) {
            parentDesc = parentNode.getDescriptor();
        // in case of appclient and ejb
        } else {
            parentDesc = getParentNode().getDescriptor();
        }
        if (parentDesc instanceof MessageDestinationReferenceContainer) {
            try {
                descriptor = ((MessageDestinationReferenceContainer) parentDesc).getMessageDestinationReferenceByName(value);
            } catch (IllegalArgumentException iae) {
                DOLUtils.getDefaultLogger().warning(iae.getMessage());
            }
        }
    } else
        super.setElementValue(element, value);
}
Also used : MessageDestinationReferenceContainer(com.sun.enterprise.deployment.types.MessageDestinationReferenceContainer) XMLNode(com.sun.enterprise.deployment.node.XMLNode) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor)

Example 4 with XMLNode

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

the class EjbRelationshipRoleNode method getEjbBundleDescriptor.

private EjbBundleDescriptor getEjbBundleDescriptor() {
    XMLNode parent = getParentNode();
    Object parentDesc = parent.getDescriptor();
    while (parent != null && !(parentDesc instanceof EjbBundleDescriptor)) {
        parent = parent.getParentNode();
        if (parent != null)
            parentDesc = parent.getDescriptor();
    }
    if (parent != null) {
        return (EjbBundleDescriptor) parentDesc;
    } else {
        throw new IllegalArgumentException("Cannot find bundle descriptor");
    }
}
Also used : XMLNode(com.sun.enterprise.deployment.node.XMLNode) EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor)

Aggregations

XMLNode (com.sun.enterprise.deployment.node.XMLNode)4 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)2 ApplicationClientDescriptor (com.sun.enterprise.deployment.ApplicationClientDescriptor)1 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)1 JavaWebStartAccessDescriptor (com.sun.enterprise.deployment.runtime.JavaWebStartAccessDescriptor)1 MessageDestinationReferenceContainer (com.sun.enterprise.deployment.types.MessageDestinationReferenceContainer)1