Search in sources :

Example 1 with ResourceAdapterAssociation

use of javax.resource.spi.ResourceAdapterAssociation in project Payara by payara.

the class ConnectorConfigParserUtils method introspectJavaBean.

public Properties introspectJavaBean(String className, Set ddPropsSet, boolean associateResourceAdapter, String resourceAdapterName) throws ConnectorRuntimeException {
    Class loadedClass = loadClass(className, resourceAdapterName);
    Object loadedInstance = instantiate(loadedClass);
    try {
        if (associateResourceAdapter) {
            ActiveResourceAdapter activeRA = ConnectorRegistry.getInstance().getActiveResourceAdapter(resourceAdapterName);
            if (activeRA == null) {
                // Check and Load RAR
                ConnectorRuntime.getRuntime().loadDeferredResourceAdapter(resourceAdapterName);
                activeRA = ConnectorRegistry.getInstance().getActiveResourceAdapter(resourceAdapterName);
            }
            // Associate RAR
            if (activeRA instanceof ActiveOutboundResourceAdapter) {
                ResourceAdapter raInstance = activeRA.getResourceAdapter();
                if (loadedInstance instanceof ResourceAdapterAssociation) {
                    ((ResourceAdapterAssociation) loadedInstance).setResourceAdapter(raInstance);
                }
            }
        }
    } catch (Exception e) {
        _logger.log(Level.WARNING, "rardeployment.error_associating_ra", e);
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, "Exception while associating the resource adapter" + "to the JavaBean", e);
        }
    }
    return introspectJavaBean(loadedInstance, ddPropsSet);
}
Also used : ResourceAdapterAssociation(javax.resource.spi.ResourceAdapterAssociation) ResourceAdapter(javax.resource.spi.ResourceAdapter)

Example 2 with ResourceAdapterAssociation

use of javax.resource.spi.ResourceAdapterAssociation in project Payara by payara.

the class WorkCoordinator method preInvoke.

/**
 * Pre-invoke operation. This does the following
 * <pre>
 * 1. Notifies the <code> WorkManager.startWork </code> method.
 * 2. Checks whether the wok has already been timed out.
 * 3. Recreates the transaction with JTS.
 * </pre>
 */
public void preInvoke() {
    // If the work is just scheduled, check whether it has timed out or not.
    if (waitMode == NO_WAIT && timeout > -1) {
        long elapsedTime = System.currentTimeMillis() - startTime;
        if (probeProvider != null) {
            probeProvider.workWaitedFor(raName, elapsedTime);
        }
        if (elapsedTime > timeout) {
            workTimedOut();
        }
    }
    // If the work is timed out then return.
    if (!proceed()) {
        if (probeProvider != null) {
            probeProvider.workDequeued(raName);
        }
        return;
    } else {
        if (probeProvider != null) {
            probeProvider.workProcessingStarted(raName);
            probeProvider.workDequeued(raName);
        }
    }
    // associate ResourceAdapter if the Work is RAA
    if (work instanceof ResourceAdapterAssociation) {
        try {
            runtime.associateResourceAdapter(raName, (ResourceAdapterAssociation) work);
        } catch (ResourceException re) {
            logger.log(Level.SEVERE, RAR_RA_ASSOCIATE_ERROR, re);
        }
    }
    // Change the status to started.
    setState(STARTED);
    if (waitMode == WAIT_UNTIL_START) {
        unLock();
    }
    // All set to do start the work. So send the event.
    if (listener != null) {
        listener.workStarted(new WorkEvent(this, WorkEvent.WORK_STARTED, work, null));
    }
    // set the unauthenticated securityContext before executing the work
    com.sun.enterprise.security.SecurityContext.setUnauthenticatedContext();
}
Also used : ResourceAdapterAssociation(javax.resource.spi.ResourceAdapterAssociation) ResourceException(javax.resource.ResourceException) WorkEvent(javax.resource.spi.work.WorkEvent)

Example 3 with ResourceAdapterAssociation

use of javax.resource.spi.ResourceAdapterAssociation in project Payara by payara.

the class AdministeredObjectResource method createAdministeredObject.

// called by com.sun.enterprise.naming.factory.AdministeredObjectFactory
// FIXME.  embedded??
public Object createAdministeredObject(ClassLoader jcl) throws PoolingException {
    try {
        if (jcl == null) {
            // use context class loader
            jcl = (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {

                public Object run() {
                    return Thread.currentThread().getContextClassLoader();
                }
            });
        }
        Object adminObject = jcl.loadClass(adminObjectClass_).newInstance();
        AccessController.doPrivileged(new SetMethodAction(adminObject, configProperties_));
        // associate ResourceAdapter if the admin-object is RAA
        if (adminObject instanceof ResourceAdapterAssociation) {
            try {
                ResourceAdapter ra = ConnectorRegistry.getInstance().getActiveResourceAdapter(resadapter_).getResourceAdapter();
                ((ResourceAdapterAssociation) adminObject).setResourceAdapter(ra);
            } catch (ResourceException ex) {
                _logger.log(Level.SEVERE, "rardeployment.assoc_failed", ex);
            }
        }
        // At this stage, administered object is instantiated, config properties applied
        // validate administered object
        // ConnectorRuntime should be available in CLIENT mode now as admin-object-factory would have bootstapped
        // connector-runtime.
        ConnectorRuntime.getRuntime().getConnectorBeanValidator().validateJavaBean(adminObject, resadapter_);
        return adminObject;
    } catch (PrivilegedActionException ex) {
        throw (PoolingException) (new PoolingException().initCause(ex));
    } catch (Exception ex) {
        throw (PoolingException) (new PoolingException().initCause(ex));
    }
}
Also used : PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) ResourceAdapterAssociation(javax.resource.spi.ResourceAdapterAssociation) PrivilegedAction(java.security.PrivilegedAction) PrivilegedActionException(java.security.PrivilegedActionException) ResourceAdapter(javax.resource.spi.ResourceAdapter) AdminObject(com.sun.enterprise.deployment.AdminObject) ResourceException(javax.resource.ResourceException) PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) PrivilegedActionException(java.security.PrivilegedActionException) ResourceException(javax.resource.ResourceException) SetMethodAction(com.sun.enterprise.connectors.util.SetMethodAction)

Aggregations

ResourceAdapterAssociation (javax.resource.spi.ResourceAdapterAssociation)3 ResourceException (javax.resource.ResourceException)2 ResourceAdapter (javax.resource.spi.ResourceAdapter)2 PoolingException (com.sun.appserv.connectors.internal.api.PoolingException)1 SetMethodAction (com.sun.enterprise.connectors.util.SetMethodAction)1 AdminObject (com.sun.enterprise.deployment.AdminObject)1 PrivilegedAction (java.security.PrivilegedAction)1 PrivilegedActionException (java.security.PrivilegedActionException)1 WorkEvent (javax.resource.spi.work.WorkEvent)1