Search in sources :

Example 6 with EnvironmentProperty

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

the class CheckConfigPropertyName method check.

/**
 * <p>
 * Properties names defined in the resource adapter config-propery should
 * be unique per resource adapter
 * </p>
 *
 * @paramm descriptor deployment descriptor for the rar file
 * @return result object containing the result of the individual test
 * performed
 */
public Result check(ConnectorDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    Set properties = descriptor.getConfigProperties();
    Iterator iterator = properties.iterator();
    // let's add the propery name
    HashSet<String> hs = new HashSet<String>();
    while (iterator.hasNext()) {
        EnvironmentProperty ep = (EnvironmentProperty) iterator.next();
        if (hs.add(ep.getName()) == false) {
            // duplicate name...
            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: More than one propery has a duplicate name [ {0} ] in the deployment descriptors", new Object[] { ep.getName() }));
            return result;
        }
    }
    // success
    result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
    result.passed(smh.getLocalString(getClass().getName() + ".passed", "There are no config properties with a duplicate name"));
    return result;
}
Also used : EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty) Result(com.sun.enterprise.tools.verifier.Result)

Example 7 with EnvironmentProperty

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

the class CheckAdminObjectJavaBean method check.

/**
 * <p>
 * Test for each adminobject, that "adminobject-class" is a Java Bean.
 * </p>
 *
 * @param descriptor deployment descriptor for the rar file
 * @return result object containing the result of the individual test
 * performed
 */
public Result check(ConnectorDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    if (!descriptor.hasAdminObjects()) {
        result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.notApplicable(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.connector.admin.notApp", "Resource Adapter does not define any administered objects"));
        return result;
    }
    Set adminObjects = descriptor.getAdminObjects();
    boolean oneFailed = false;
    Iterator iter = adminObjects.iterator();
    while (iter.hasNext()) {
        AdminObject adminObj = (AdminObject) iter.next();
        String impl = adminObj.getAdminObjectClass();
        Class implClass = null;
        try {
            implClass = Class.forName(impl, false, getVerifierContext().getClassLoader());
        } catch (ClassNotFoundException e) {
            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.failed(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.connector.admin.nonexist", "Error: The class [ {0} ] as defined under adminobject-class in the deployment descriptor does not exist", new Object[] { impl }));
            return result;
        }
        Set configProps = adminObj.getConfigProperties();
        Iterator propIter = configProps.iterator();
        BeanInfo bi = null;
        try {
            bi = Introspector.getBeanInfo(implClass, Object.class);
        } catch (IntrospectionException ie) {
            oneFailed = true;
            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: The adminobject-class [ {0} ] is not JavaBeans compliant", new Object[] { impl }));
            return result;
        }
        PropertyDescriptor[] properties = bi.getPropertyDescriptors();
        Hashtable<String, PropertyDescriptor> props = new Hashtable<String, PropertyDescriptor>();
        for (int i = 0; i < properties.length; i++) {
            props.put(properties[i].getName(), properties[i]);
        }
        while (propIter.hasNext()) {
            EnvironmentProperty envProp = (EnvironmentProperty) propIter.next();
            String name = Introspector.decapitalize(envProp.getName());
            String type = envProp.getType();
            PropertyDescriptor propDesc = props.get(name);
            if (propDesc != null) {
                if (propDesc.getReadMethod() == null || propDesc.getWriteMethod() == null) {
                    oneFailed = true;
                    result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.failed(smh.getLocalString(getClass().getName() + ".failed1", "Error: The adminobject-class [ {0} ] does not provide accessor methods for [ {1} ].", new Object[] { impl, name }));
                    return result;
                }
            } else {
                oneFailed = true;
                result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.failed(smh.getLocalString(getClass().getName() + ".failed1", "Error: The adminobject-class [ {0} ] does not provide accessor methods for [ {1} ].", new Object[] { impl, name }));
                return result;
            }
        }
    }
    if (!oneFailed) {
        result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.passed(smh.getLocalString(getClass().getName() + ".passed", "Success: Each adminobject-class is a Java Bean"));
    }
    return result;
}
Also used : Result(com.sun.enterprise.tools.verifier.Result) EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty) AdminObject(com.sun.enterprise.deployment.AdminObject) AdminObject(com.sun.enterprise.deployment.AdminObject)

Example 8 with EnvironmentProperty

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

the class CheckActivationSpecJavaBean method check.

/**
 * <p>
 * Test for each message-listener, that "activationspec-class" is a Java Bean.
 * </p>
 *
 * @param descriptor deployment descriptor for the rar file
 * @return result object containing the result of the individual test
 * performed
 */
public Result check(ConnectorDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    if (!descriptor.getInBoundDefined()) {
        result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.notApplicable(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.connector.messageinflow.notApp", "Resource Adapter does not provide inbound communication"));
        return result;
    }
    InboundResourceAdapter ra = descriptor.getInboundResourceAdapter();
    Set msgListeners = ra.getMessageListeners();
    boolean oneFailed = false;
    Iterator iter = msgListeners.iterator();
    while (iter.hasNext()) {
        MessageListener msgListener = (MessageListener) iter.next();
        String impl = msgListener.getActivationSpecClass();
        Class implClass = null;
        try {
            implClass = Class.forName(impl, false, getVerifierContext().getClassLoader());
        } catch (ClassNotFoundException e) {
            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.failed(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.connector.messageinflow.nonexist", "Error: The class [ {0} ] as defined under activationspec-class in the deployment descriptor does not exist", new Object[] { impl }));
            return result;
        }
        Set configProps = msgListener.getConfigProperties();
        Iterator propIter = configProps.iterator();
        BeanInfo bi = null;
        try {
            bi = Introspector.getBeanInfo(implClass, Object.class);
        } catch (IntrospectionException ie) {
            oneFailed = true;
            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: The activationspec-class [ {0} ] is not JavaBeans compliant", new Object[] { impl }));
            return result;
        }
        PropertyDescriptor[] properties = bi.getPropertyDescriptors();
        Hashtable<String, PropertyDescriptor> props = new Hashtable<String, PropertyDescriptor>();
        for (int i = 0; i < properties.length; i++) {
            props.put(properties[i].getName(), properties[i]);
        }
        while (propIter.hasNext()) {
            EnvironmentProperty envProp = (EnvironmentProperty) propIter.next();
            String name = envProp.getName();
            String type = envProp.getType();
            PropertyDescriptor propDesc = (PropertyDescriptor) props.get(name.substring(0, 1).toLowerCase() + name.substring(1));
            if (propDesc != null) {
                if (propDesc.getReadMethod() == null || propDesc.getWriteMethod() == null) {
                    oneFailed = true;
                    result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.failed(smh.getLocalString(getClass().getName() + ".failed1", "Error: The activationspec-class [ {0} ] does not provide accessor methods for [ {1} ].", new Object[] { impl, name }));
                    return result;
                }
            } else {
                oneFailed = true;
                result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.failed(smh.getLocalString(getClass().getName() + ".failed1", "Error: The activationspec-class [ {0} ] does not provide accessor methods for [ {1} ].", new Object[] { impl, name }));
                return result;
            }
        }
    }
    if (!oneFailed) {
        result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.passed(smh.getLocalString(getClass().getName() + ".passed", "Success: Each activationspec-class is a Java Bean"));
    }
    return result;
}
Also used : InboundResourceAdapter(com.sun.enterprise.deployment.InboundResourceAdapter) MessageListener(com.sun.enterprise.deployment.MessageListener) Result(com.sun.enterprise.tools.verifier.Result) EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty)

Example 9 with EnvironmentProperty

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

the class EjbMessageBeanDescriptor method setHasDurableSubscription.

public void setHasDurableSubscription(boolean durable) {
    if (durable) {
        EnvironmentProperty durableProp = new EnvironmentProperty(DURABLE_SUBSCRIPTION_PROPERTY, DURABLE, "");
        putActivationConfigProperty(durableProp);
    } else {
        removeActivationConfigPropertyByName(DURABLE_SUBSCRIPTION_PROPERTY);
    }
}
Also used : EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty)

Example 10 with EnvironmentProperty

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

the class EnvEntriesValidator method validateSimpleEnvEntries.

private void validateSimpleEnvEntries(JndiNameEnvironment env, Set<EnvironmentProperty> envEntries) {
    for (EnvironmentProperty environmentProperty : envEntries) {
        SimpleEnvEntry simpleEnvEntry = new SimpleEnvEntry(environmentProperty);
        validateEnvEntry(env, simpleEnvEntry, simpleEnvEntry.getName());
    }
}
Also used : EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty)

Aggregations

EnvironmentProperty (com.sun.enterprise.deployment.EnvironmentProperty)29 Result (com.sun.enterprise.tools.verifier.Result)10 Iterator (java.util.Iterator)6 Node (org.w3c.dom.Node)4 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)3 DeploymentDescriptorNode (com.sun.enterprise.deployment.node.DeploymentDescriptorNode)3 ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)3 Set (java.util.Set)3 ServletFilterDescriptor (org.glassfish.web.deployment.descriptor.ServletFilterDescriptor)3 ConnectionDefDescriptor (com.sun.enterprise.deployment.ConnectionDefDescriptor)2 MessageListener (com.sun.enterprise.deployment.MessageListener)2 Method (java.lang.reflect.Method)2 URISyntaxException (java.net.URISyntaxException)2 PrivilegedActionException (java.security.PrivilegedActionException)2 ExecutionException (java.util.concurrent.ExecutionException)2 ResourceAdapterInternalException (javax.resource.spi.ResourceAdapterInternalException)2 WebInitParam (javax.servlet.annotation.WebInitParam)2 MultiException (org.glassfish.hk2.api.MultiException)2 AdminObject (com.sun.enterprise.deployment.AdminObject)1 ConnectorConfigProperty (com.sun.enterprise.deployment.ConnectorConfigProperty)1