Search in sources :

Example 1 with ClassLoader

use of java.lang.ClassLoader in project Payara by payara.

the class WSTest method loadImplBeanClass.

/**
 * <p>
 * load the declared Service Impl Bean class from the archive
 * </p>
 *
 * @param descriptor the deployment descriptors for the WebService
 * @param result result to use if the load fails
 * @return the class object for the Service Endpoint Interface
 */
protected Class loadImplBeanClass(WebServiceEndpoint descriptor, Result result) {
    // here we could be an EJB Endpoint or a Servlet Endpoint take care of that
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    String beanClassName = null;
    if (descriptor.implementedByEjbComponent()) {
        beanClassName = descriptor.getEjbComponentImpl().getEjbClassName();
    } else if (descriptor.implementedByWebComponent()) {
        WebComponentDescriptor wcd = descriptor.getWebComponentImpl();
        if (wcd != null)
            beanClassName = wcd.getWebComponentImplementation();
    } else {
        // result.fail, neither implemented by web nor EJB
        result.addErrorDetails(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.webservices.Error", "Error: Unexpected error occurred [ {0} ]", new Object[] { "The WebService is neither implemented by an EJB nor a Servlet" }));
    }
    if (beanClassName != null) {
        try {
            VerifierTestContext context = getVerifierContext();
            ClassLoader jcl = context.getClassLoader();
            return Class.forName(beanClassName, false, getVerifierContext().getClassLoader());
        } catch (ClassNotFoundException e) {
            Verifier.debug(e);
            result.failed(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.webservices.WSTest.BeanClassExists", "Error: Service Endpoint Implementation Bean class [ {0} ]  not found.", new Object[] { beanClassName }));
            return null;
        }
    }
    // result.fail , beanclass name is NULL
    result.addErrorDetails(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.webservices.Error", "Error: Unexpected error occurred [ {0} ]", new Object[] { "The Servlet Impl Bean class name could not be resolved" }));
    return null;
}
Also used : ClassLoader(java.lang.ClassLoader)

Example 2 with ClassLoader

use of java.lang.ClassLoader in project Payara by payara.

the class WSTest method loadSEIClass.

/**
 * <p>
 * load the declared SEI class from the archive
 * </p>
 *
 * @param descriptor the deployment descriptors for the WebService
 * @param result result to use if the load fails
 * @return the class object for the Service Endpoint Interface
 */
protected Class loadSEIClass(WebServiceEndpoint descriptor, Result result) {
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    try {
        VerifierTestContext context = getVerifierContext();
        ClassLoader jcl = context.getClassLoader();
        Class cl = Class.forName(descriptor.getServiceEndpointInterface(), false, getVerifierContext().getClassLoader());
        result.passed(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.webservices.clpassed", "The [{0}] Class [{1}] exists and was loaded successfully.", new Object[] { "SEI", descriptor.getServiceEndpointInterface() }));
        return cl;
    } catch (ClassNotFoundException e) {
        Verifier.debug(e);
        result.failed(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.webservices.WSTest.SEIClassExists", "Error: Service Endpoint Interface class [ {0} ]  not found.", new Object[] { descriptor.getServiceEndpointInterface() }));
        return null;
    }
}
Also used : ClassLoader(java.lang.ClassLoader)

Example 3 with ClassLoader

use of java.lang.ClassLoader in project Payara by payara.

the class CCITest method getConnectionInterface.

/**
 * <p>
 * Returns the connection-interface that implements
 * "javax.resource.cci.Connection"
 * </p>
 * @param descriptor the deployment descriptor
 * @param result to put the result
 * @return interface name
 */
protected String getConnectionInterface(ConnectorDescriptor descriptor, Result result) {
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    OutboundResourceAdapter outboundRA = descriptor.getOutboundResourceAdapter();
    if (outboundRA == null) {
        return null;
    }
    Set connDefs = outboundRA.getConnectionDefs();
    Iterator iter = connDefs.iterator();
    while (iter.hasNext()) {
        ConnectionDefDescriptor connDefDesc = (ConnectionDefDescriptor) iter.next();
        String intf = connDefDesc.getConnectionIntf();
        VerifierTestContext context = getVerifierContext();
        ClassLoader jcl = context.getRarClassLoader();
        Class intfClass = null;
        try {
            intfClass = Class.forName(intf, 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.ConnectorTest.isClassLoadable.failed", "The class [ {0} ] is not contained in the archive file", new Object[] { intf }));
            continue;
        }
        if (isImplementorOf(intfClass, "javax.resource.cci.Connection")) {
            return intf;
        }
    }
    return null;
}
Also used : Set(java.util.Set) ConnectionDefDescriptor(com.sun.enterprise.deployment.ConnectionDefDescriptor) Iterator(java.util.Iterator) ClassLoader(java.lang.ClassLoader) OutboundResourceAdapter(com.sun.enterprise.deployment.OutboundResourceAdapter)

Aggregations

ClassLoader (java.lang.ClassLoader)3 ConnectionDefDescriptor (com.sun.enterprise.deployment.ConnectionDefDescriptor)1 OutboundResourceAdapter (com.sun.enterprise.deployment.OutboundResourceAdapter)1 Iterator (java.util.Iterator)1 Set (java.util.Set)1