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);
}
}
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);
}
}
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;
}
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;
}
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;
}
Aggregations