Search in sources :

Example 31 with ConnectorRuntimeException

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

the class FlushConnectionPool method execute.

public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    Resources resources = domain.getResources();
    String scope = "";
    if (moduleName != null) {
        if (!poolUtil.isValidModule(applicationName, moduleName, poolName, report)) {
            return;
        }
        Application application = applications.getApplication(applicationName);
        Module module = application.getModule(moduleName);
        resources = module.getResources();
        scope = ConnectorConstants.JAVA_MODULE_SCOPE_PREFIX;
    } else if (applicationName != null) {
        if (!poolUtil.isValidApplication(applicationName, poolName, report)) {
            return;
        }
        Application application = applications.getApplication(applicationName);
        resources = application.getResources();
        scope = ConnectorConstants.JAVA_APP_SCOPE_PREFIX;
    }
    if (!poolUtil.isValidPool(resources, poolName, scope, report)) {
        return;
    }
    boolean poolingEnabled = false;
    ResourcePool pool = (ResourcePool) ConnectorsUtil.getResourceByName(resources, ResourcePool.class, poolName);
    if (pool instanceof ConnectorConnectionPool) {
        ConnectorConnectionPool ccp = (ConnectorConnectionPool) pool;
        poolingEnabled = Boolean.valueOf(ccp.getPooling());
    } else {
        JdbcConnectionPool ccp = (JdbcConnectionPool) pool;
        poolingEnabled = Boolean.valueOf(ccp.getPooling());
    }
    if (!poolingEnabled) {
        String i18nMsg = localStrings.getLocalString("flush.connection.pool.pooling.disabled", "Attempt to Flush Connection Pool failed because Pooling is disabled for pool : {0}", poolName);
        report.setMessage(i18nMsg);
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    try {
        PoolInfo poolInfo = new PoolInfo(poolName, applicationName, moduleName);
        _runtime.flushConnectionPool(poolInfo);
        report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    } catch (ConnectorRuntimeException e) {
        report.setMessage(localStrings.getLocalString("flush.connection.pool.fail", "Flush connection pool for {0} failed", poolName));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(e);
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ConnectorConnectionPool(org.glassfish.connectors.config.ConnectorConnectionPool) JdbcConnectionPool(org.glassfish.jdbc.config.JdbcConnectionPool) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo) ActionReport(org.glassfish.api.ActionReport)

Example 32 with ConnectorRuntimeException

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

the class FlushConnectionPoolLocal method execute.

@Override
public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    Resources resources = domain.getResources();
    String scope = "";
    if (moduleName != null) {
        if (!poolUtil.isValidModule(applicationName, moduleName, poolName, report)) {
            return;
        }
        Application application = applications.getApplication(applicationName);
        Module module = application.getModule(moduleName);
        resources = module.getResources();
        scope = ConnectorConstants.JAVA_MODULE_SCOPE_PREFIX;
    } else if (applicationName != null) {
        if (!poolUtil.isValidApplication(applicationName, poolName, report)) {
            return;
        }
        Application application = applications.getApplication(applicationName);
        resources = application.getResources();
        scope = ConnectorConstants.JAVA_APP_SCOPE_PREFIX;
    }
    if (!poolUtil.isValidPool(resources, poolName, scope, report)) {
        return;
    }
    boolean poolingEnabled = false;
    ResourcePool pool = (ResourcePool) ConnectorsUtil.getResourceByName(resources, ResourcePool.class, poolName);
    if (pool instanceof ConnectorConnectionPool) {
        ConnectorConnectionPool ccp = (ConnectorConnectionPool) pool;
        poolingEnabled = Boolean.valueOf(ccp.getPooling());
    } else {
        JdbcConnectionPool ccp = (JdbcConnectionPool) pool;
        poolingEnabled = Boolean.valueOf(ccp.getPooling());
    }
    if (!poolingEnabled) {
        String i18nMsg = localStrings.getLocalString("flush.connection.pool.pooling.disabled", "Attempt to Flush Connection Pool failed because Pooling is disabled for pool : {0}", poolName);
        report.setMessage(i18nMsg);
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    try {
        PoolInfo poolInfo = new PoolInfo(poolName, applicationName, moduleName);
        _runtime.flushConnectionPool(poolInfo);
        report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
        Logger.getLogger("org.glassfish.connectors.admin.cli").log(Level.FINE, "Flush connection pool for {0} succeeded", poolName);
    } catch (ConnectorRuntimeException e) {
        report.setMessage(localStrings.getLocalString("flush.connection.pool.fail", "Flush connection pool for {0} failed", poolName));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(e);
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ConnectorConnectionPool(org.glassfish.connectors.config.ConnectorConnectionPool) JdbcConnectionPool(org.glassfish.jdbc.config.JdbcConnectionPool) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo) ActionReport(org.glassfish.api.ActionReport) Module(com.sun.enterprise.config.serverbeans.Module)

Example 33 with ConnectorRuntimeException

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

the class ConnectorMessageBeanClient method getResourceAdapterMid.

/**
 * derive the resource-adapter-mid in the following order <br/>
 * a) specified in the glassfish-ejb-jar / sun-ejb-jar descriptor<br/>
 * b) jms-ra message-listener of type javax.jms.MessageListener<br/>
 * c) Check the resource-adapters supporting the message-listener-type and
 * if there is only one use it, otherwise fail.<br/>
 * @param descriptor_ EJB Descriptor
 * @return resource-adapter-mid (resource-adapter-name)
 * @throws ConnectorRuntimeException
 */
private String getResourceAdapterMid(EjbMessageBeanDescriptor descriptor_) throws ConnectorRuntimeException {
    String resourceAdapterMid = descriptor_.getResourceAdapterMid();
    if (resourceAdapterMid == null) {
        resourceAdapterMid = System.getProperty(RA_MID);
    }
    if (resourceAdapterMid == null) {
        String messageListener = descriptor_.getMessageListenerType();
        // will take care of the case when the message-listener-type is not specified in the DD
        if (ConnectorConstants.JMS_MESSAGE_LISTENER.equals(messageListener)) {
            resourceAdapterMid = ConnectorRuntime.DEFAULT_JMS_ADAPTER;
            logger.fine("No ra-mid is specified, using default JMS Resource Adapter for message-listener-type " + "[" + descriptor_.getMessageListenerType() + "]");
        } else {
            List<String> resourceAdapters = ConnectorRegistry.getInstance().getConnectorsSupportingMessageListener(messageListener);
            if (resourceAdapters.size() == 1) {
                resourceAdapterMid = resourceAdapters.get(0);
                String message = localStrings.getString("msg-bean-client.defaulting.message-listener.supporting.rar", resourceAdapterMid, messageListener);
                logger.info(message);
            } else if (resourceAdapters.size() <= 0) {
                String message = localStrings.getString("msg-bean-client.could-not-detect-ra-mid", descriptor_.getMessageListenerType());
                throw new ConnectorRuntimeException(message);
            } else {
                String message = localStrings.getString("msg-bean-client.multiple-ras-supporting-message-listener", messageListener);
                throw new ConnectorRuntimeException(message);
            }
        }
    }
    return resourceAdapterMid;
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Example 34 with ConnectorRuntimeException

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

the class ConnectorMessageBeanClient method getActiveResourceAdapter.

private ActiveInboundResourceAdapter getActiveResourceAdapter(String resourceAdapterMid) throws Exception {
    Object activeRar = registry_.getActiveResourceAdapter(resourceAdapterMid);
    // (as of now, jms-ra is the only inbound system-rar)
    if (activeRar == null && ConnectorsUtil.belongsToSystemRA(resourceAdapterMid)) {
        ConnectorRuntime crt = ConnectorRuntime.getRuntime();
        crt.loadDeferredResourceAdapter(resourceAdapterMid);
        activeRar = registry_.getActiveResourceAdapter(resourceAdapterMid);
    }
    if (activeRar == null) {
        String msg = "Resource adapter " + resourceAdapterMid + " is not deployed";
        throw new ConnectorRuntimeException(msg);
    }
    if (!(activeRar instanceof ActiveInboundResourceAdapter)) {
        throw new Exception("Resource Adapter selected doesn't support Inbound");
    }
    return (ActiveInboundResourceAdapter) activeRar;
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) UnavailableException(javax.resource.spi.UnavailableException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) ConnectorRuntime(com.sun.enterprise.connectors.ConnectorRuntime)

Example 35 with ConnectorRuntimeException

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

the class ConnectorDescriptorProxy method create.

public Object create(Context ic) throws NamingException {
    // of this particular connector descriptor and also only for first time (initialization)
    synchronized (this) {
        if (desc == null) {
            try {
                desc = getConnectorRuntime().getConnectorDescriptor(rarName);
                ic.rebind(jndiName, desc);
            } catch (ConnectorRuntimeException e) {
                NamingException ne = new NamingException(e.getMessage());
                ne.initCause(e);
                throw ne;
            }
        }
    }
    return desc;
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) NamingException(javax.naming.NamingException)

Aggregations

ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)71 NamingException (javax.naming.NamingException)16 URISyntaxException (java.net.URISyntaxException)13 PoolInfo (org.glassfish.resourcebase.resources.api.PoolInfo)13 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 IOException (java.io.IOException)5 ConnectorConnectionPool (com.sun.enterprise.connectors.ConnectorConnectionPool)4 JdbcConnectionPool (org.glassfish.jdbc.config.JdbcConnectionPool)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