Search in sources :

Example 6 with SetMethodAction

use of com.sun.enterprise.connectors.util.SetMethodAction in project Payara by payara.

the class ActiveOutboundResourceAdapter method loadRAConfiguration.

/**
 * Loads RA javabean. This method is protected, so that any system
 * resource adapter can have specific configuration done during the
 * loading.
 *
 * @throws ConnectorRuntimeException if there is a failure.
 */
protected void loadRAConfiguration() throws ConnectorRuntimeException {
    try {
        Set mergedProps;
        ConnectorRegistry registry = ConnectorRegistry.getInstance();
        ResourceAdapterConfig raConfig = registry.getResourceAdapterConfig(moduleName_);
        List<Property> raConfigProps = new ArrayList<Property>();
        mergedProps = mergeRAConfiguration(raConfig, raConfigProps);
        logMergedProperties(mergedProps);
        SetMethodAction setMethodAction = new SetMethodAction(this.resourceadapter_, mergedProps);
        setMethodAction.run();
    } catch (Exception e) {
        String i18nMsg = localStrings.getString("ccp_adm.wrong_params_for_create", e.getMessage());
        ConnectorRuntimeException cre = new ConnectorRuntimeException(i18nMsg);
        cre.initCause(e);
        throw cre;
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ResourceAdapterConfig(org.glassfish.connectors.config.ResourceAdapterConfig) ConnectorConfigProperty(com.sun.enterprise.deployment.ConnectorConfigProperty) Property(org.jvnet.hk2.config.types.Property) ResourceException(javax.resource.ResourceException) NamingException(javax.naming.NamingException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) SetMethodAction(com.sun.enterprise.connectors.util.SetMethodAction)

Example 7 with SetMethodAction

use of com.sun.enterprise.connectors.util.SetMethodAction 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

SetMethodAction (com.sun.enterprise.connectors.util.SetMethodAction)7 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)5 Set (java.util.Set)4 ConnectorConfigProperty (com.sun.enterprise.deployment.ConnectorConfigProperty)3 PrivilegedActionException (java.security.PrivilegedActionException)3 ManagedConnectionFactory (javax.resource.spi.ManagedConnectionFactory)3 Method (java.lang.reflect.Method)2 URISyntaxException (java.net.URISyntaxException)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 ExecutionException (java.util.concurrent.ExecutionException)2 ResourceException (javax.resource.ResourceException)2 ActivationSpec (javax.resource.spi.ActivationSpec)2 ResourceAdapterInternalException (javax.resource.spi.ResourceAdapterInternalException)2 MultiException (org.glassfish.hk2.api.MultiException)2 ConnectorRuntime (com.sun.appserv.connectors.internal.api.ConnectorRuntime)1 PoolingException (com.sun.appserv.connectors.internal.api.PoolingException)1 ConfigurableTransactionSupport (com.sun.appserv.connectors.spi.ConfigurableTransactionSupport)1 TransactionSupport (com.sun.appserv.connectors.spi.TransactionSupport)1