Search in sources :

Example 51 with ConnectorRuntimeException

use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.

the class ConnectorService method loadDeferredResourceAdapter.

public void loadDeferredResourceAdapter(String rarModuleName) throws ConnectorRuntimeException {
    // load the RA if its not already loaded
    if (_registry.getActiveResourceAdapter(rarModuleName) == null) {
        try {
            // Do this only for System RA
            if (ConnectorsUtil.belongsToSystemRA(rarModuleName)) {
                String systemModuleLocation = ConnectorsUtil.getSystemModuleLocation(rarModuleName);
                if (_runtime.isServer()) {
                    _runtime.getMonitoringBootstrap().registerProbes(rarModuleName, new File(systemModuleLocation), _runtime.getSystemRARClassLoader(rarModuleName));
                }
                _runtime.createActiveResourceAdapter(systemModuleLocation, rarModuleName, null);
            }
        /* not needed as long as standalone + embedded rars are loaded before recovery
                else if (rarModuleName.indexOf(ConnectorConstants.EMBEDDEDRAR_NAME_DELIMITER) != -1) {
                    createActiveResourceAdapterForEmbeddedRar(rarModuleName);
                } else{
                    _runtime.createActiveResourceAdapter(ConnectorsUtil.getLocation(rarModuleName), rarModuleName, null);
                }*/
        } catch (Exception e) {
            ConnectorRuntimeException ce = new ConnectorRuntimeException(e.getMessage());
            ce.initCause(e);
            throw ce;
        }
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) File(java.io.File) URISyntaxException(java.net.URISyntaxException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Example 52 with ConnectorRuntimeException

use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.

the class ConnectorService method checkAndLoadPool.

public boolean checkAndLoadPool(PoolInfo poolInfo) {
    boolean status = false;
    try {
        ResourcePool pool = _runtime.getConnectionPoolConfig(poolInfo);
        // DeferredResourceConfig defResConfig = resutil.getDeferredPoolConfig(poolName);
        DeferredResourceConfig defResConfig = getResourcesUtil().getDeferredResourceConfig(null, pool, null, null);
        status = loadResourcesAndItsRar(defResConfig);
    } catch (ConnectorRuntimeException cre) {
        Object[] params = new Object[] { poolInfo, cre };
        _logger.log(Level.WARNING, "unable.to.load.connection.pool", params);
    }
    return status;
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) DeferredResourceConfig(com.sun.enterprise.connectors.DeferredResourceConfig) ResourcePool(com.sun.enterprise.config.serverbeans.ResourcePool)

Example 53 with ConnectorRuntimeException

use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.

the class ConnectorService method switchOnMatching.

/**
 * Matching will be switched off in the pool, by default. This will be
 * switched on if the connections with different resource principals reach the pool.
 *
 * @param poolInfo Name of the pool to switchOn matching.
 * @param rarName  Name of the resource adater.
 */
public void switchOnMatching(String rarName, PoolInfo poolInfo) {
    // Later other resource adapters also become applicable.
    if (rarName.equals(ConnectorConstants.JDBCDATASOURCE_RA_NAME) || rarName.equals(ConnectorConstants.JDBCCONNECTIONPOOLDATASOURCE_RA_NAME) || rarName.equals(ConnectorConstants.JDBCXA_RA_NAME)) {
        PoolManager poolMgr = _runtime.getPoolManager();
        boolean result = poolMgr.switchOnMatching(poolInfo);
        if (!result) {
            try {
                _runtime.switchOnMatchingInJndi(poolInfo);
            } catch (ConnectorRuntimeException cre) {
            // This will never happen.
            }
        }
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) PoolManager(com.sun.enterprise.resource.pool.PoolManager)

Example 54 with ConnectorRuntimeException

use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.

the class ConnectorService method loadResourcesAndItsRar.

/*    public boolean checkAndLoadResource(Object resource, Object pool, String resourceType, String resourceName,
                                        String raName)
            throws ConnectorRuntimeException {
        String resname = ConnectorAdminServiceUtils.getOriginalResourceName(resourceName);
        if(_logger.isLoggable(Level.FINE)) {
            _logger.fine("ConnectorService :: checkAndLoadResource resolved to load " + resname);
        }

        DeferredResourceConfig defResConfig = getResourcesUtil().getDeferredResourceConfig(resource, pool, resourceType, raName);
        //DeferredResourceConfig defResConfig = resUtil.getDeferredResourceConfig(resname);
        return loadResourcesAndItsRar(defResConfig);
    }
*/
public boolean loadResourcesAndItsRar(DeferredResourceConfig defResConfig) {
    if (defResConfig != null) {
        try {
            loadDeferredResources(defResConfig.getResourceAdapterConfig());
            final String rarName = defResConfig.getRarName();
            loadDeferredResourceAdapter(rarName);
            final Resource[] resToLoad = defResConfig.getResourcesToLoad();
            AccessController.doPrivileged(new PrivilegedAction() {

                public Object run() {
                    try {
                        loadDeferredResources(resToLoad);
                    } catch (Exception ex) {
                        Object[] params = new Object[] { rarName, ex };
                        _logger.log(Level.SEVERE, "failed.to.load.deferred.resources", params);
                    }
                    return null;
                }
            });
        } catch (Exception ex) {
            Object[] params = new Object[] { defResConfig.getRarName(), ex };
            _logger.log(Level.SEVERE, "failed.to.load.deferred.ra", params);
            return false;
        }
        return true;
    }
    return false;
}
Also used : PrivilegedAction(java.security.PrivilegedAction) Resource(com.sun.enterprise.config.serverbeans.Resource) URISyntaxException(java.net.URISyntaxException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Example 55 with ConnectorRuntimeException

use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.

the class ConnectorService method getConnectorDescriptor.

/**
 * Obtains the connector Descriptor pertaining to rar.
 * If ConnectorDescriptor is present in registry, it is obtained from
 * registry and returned. Else it is explicitly read from directory
 * where rar is exploded.
 *
 * @param rarName Name of the rar
 * @return ConnectorDescriptor pertaining to rar.
 * @throws ConnectorRuntimeException when unable to get descriptor
 */
public ConnectorDescriptor getConnectorDescriptor(String rarName) throws ConnectorRuntimeException {
    if (rarName == null) {
        return null;
    }
    ConnectorDescriptor desc = null;
    desc = _registry.getDescriptor(rarName);
    if (desc != null) {
        return desc;
    }
    String moduleDir;
    // using the applicationarchivist
    if (rarName.indexOf(ConnectorConstants.EMBEDDEDRAR_NAME_DELIMITER) != -1) {
        try {
            desc = loadConnectorDescriptorForEmbeddedRAR(rarName);
            if (desc != null)
                return desc;
        } catch (ConnectorRuntimeException e) {
            throw e;
        }
    }
    if (ConnectorsUtil.belongsToSystemRA(rarName)) {
        moduleDir = ConnectorsUtil.getSystemModuleLocation(rarName);
    } else {
        moduleDir = ConnectorsUtil.getLocation(rarName);
    }
    if (moduleDir != null) {
        desc = ConnectorDDTransformUtils.getConnectorDescriptor(moduleDir, rarName);
    } else {
        _logger.log(Level.SEVERE, "rardeployment.no_module_deployed", rarName);
    }
    return desc;
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor)

Aggregations

ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)69 NamingException (javax.naming.NamingException)16 URISyntaxException (java.net.URISyntaxException)13 PoolInfo (org.glassfish.resourcebase.resources.api.PoolInfo)12 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)10 PrivilegedActionException (java.security.PrivilegedActionException)9 ExecutionException (java.util.concurrent.ExecutionException)8 ResourceAdapterInternalException (javax.resource.spi.ResourceAdapterInternalException)8 MultiException (org.glassfish.hk2.api.MultiException)8 JmsService (com.sun.enterprise.connectors.jms.config.JmsService)7 ConnectorConfigProperty (com.sun.enterprise.deployment.ConnectorConfigProperty)7 ManagedConnectionFactory (javax.resource.spi.ManagedConnectionFactory)7 ActiveResourceAdapter (com.sun.enterprise.connectors.ActiveResourceAdapter)5 ConnectorRuntime (com.sun.enterprise.connectors.ConnectorRuntime)5 ConnectorConnectionPool (com.sun.enterprise.connectors.ConnectorConnectionPool)4 IOException (java.io.IOException)4 ResourceInfo (org.glassfish.resourcebase.resources.api.ResourceInfo)4 Resource (com.sun.enterprise.config.serverbeans.Resource)3 ResourcePool (com.sun.enterprise.config.serverbeans.ResourcePool)3 File (java.io.File)3