use of com.sun.enterprise.connectors.ActiveResourceAdapter in project Payara by payara.
the class ResourceAdapterAdminServiceImpl method createActiveResourceAdapter.
/**
* Creates Active resource Adapter which abstracts the rar module. During
* the creation of ActiveResourceAdapter, default pools and resources also
* are created.
*
* @param connectorDescriptor object which abstracts the connector deployment descriptor
* i.e rar.xml and sun-ra.xml.
* @param moduleName Name of the module
* @param moduleDir Directory where rar module is exploded.
* @param loader Classloader to use
* @throws ConnectorRuntimeException if creation fails.
*/
public void createActiveResourceAdapter(ConnectorDescriptor connectorDescriptor, String moduleName, String moduleDir, ClassLoader loader) throws ConnectorRuntimeException {
synchronized (_registry.getLockObject(moduleName)) {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("ResourceAdapterAdminServiceImpl :: createActiveRA " + moduleName + " at " + moduleDir);
}
ActiveResourceAdapter activeResourceAdapter = _registry.getActiveResourceAdapter(moduleName);
if (activeResourceAdapter != null) {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "rardeployment.resourceadapter.already.started", moduleName);
}
return;
}
// TODO V3 works fine ?
if (loader == null) {
try {
loader = connectorDescriptor.getClassLoader();
} catch (Exception ex) {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "No classloader available with connector descriptor");
}
loader = null;
}
}
ConnectorRuntime connectorRuntime = ConnectorRuntime.getRuntime();
ModuleDescriptor moduleDescriptor = null;
Application application = null;
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("ResourceAdapterAdminServiceImpl :: createActiveRA " + moduleName + " at " + moduleDir + " loader :: " + loader);
}
// (standalone + embedded)
if (loader == null && ConnectorsUtil.belongsToSystemRA(moduleName)) {
if (connectorRuntime.isServer()) {
loader = connectorRuntime.getSystemRARClassLoader(moduleName);
}
} else {
connectorDescriptor.setClassLoader(null);
moduleDescriptor = connectorDescriptor.getModuleDescriptor();
application = connectorDescriptor.getApplication();
connectorDescriptor.setModuleDescriptor(null);
connectorDescriptor.setApplication(null);
}
try {
activeResourceAdapter = connectorRuntime.getActiveRAFactory().createActiveResourceAdapter(connectorDescriptor, moduleName, loader);
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("ResourceAdapterAdminServiceImpl :: createActiveRA " + moduleName + " at " + moduleDir + " adding to registry " + activeResourceAdapter);
}
_registry.addActiveResourceAdapter(moduleName, activeResourceAdapter);
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("ResourceAdapterAdminServiceImpl:: createActiveRA " + moduleName + " at " + moduleDir + " env =server ? " + (connectorRuntime.isServer()));
}
if (connectorRuntime.isServer()) {
// Update RAConfig in Connector Descriptor and bind in JNDI
// so that ACC clients could use RAConfig
updateRAConfigInDescriptor(connectorDescriptor, moduleName);
String descriptorJNDIName = ConnectorAdminServiceUtils.getReservePrefixedJNDINameForDescriptor(moduleName);
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("ResourceAdapterAdminServiceImpl :: createActiveRA " + moduleName + " at " + moduleDir + " publishing descriptor " + descriptorJNDIName);
}
_runtime.getNamingManager().publishObject(descriptorJNDIName, connectorDescriptor, true);
activeResourceAdapter.setup();
if (System.getSecurityManager() != null) {
String securityWarningMessage = connectorRuntime.getSecurityPermissionSpec(moduleName);
// To i18N.
if (securityWarningMessage != null) {
_logger.log(Level.WARNING, securityWarningMessage);
}
}
}
} catch (NullPointerException npEx) {
ConnectorRuntimeException cre = new ConnectorRuntimeException("Error in creating active RAR");
cre.initCause(npEx);
_logger.log(Level.SEVERE, "rardeployment.nullPointerException", moduleName);
_logger.log(Level.SEVERE, "", cre);
throw cre;
} catch (NamingException ne) {
ConnectorRuntimeException cre = new ConnectorRuntimeException("Error in creating active RAR");
cre.initCause(ne);
_logger.log(Level.SEVERE, "rardeployment.jndi_publish_failure");
_logger.log(Level.SEVERE, "", cre);
throw cre;
} finally {
if (moduleDescriptor != null) {
connectorDescriptor.setModuleDescriptor(moduleDescriptor);
connectorDescriptor.setApplication(application);
connectorDescriptor.setClassLoader(loader);
}
}
}
}
use of com.sun.enterprise.connectors.ActiveResourceAdapter in project Payara by payara.
the class ResourceAdapterAdminServiceImpl method stopAllActiveResourceAdapters.
/**
* Calls the stop method for all J2EE Connector 1.5/1.0 spec compliant RARs
*/
public void stopAllActiveResourceAdapters() {
ActiveResourceAdapter[] resourceAdapters = ConnectorRegistry.getInstance().getAllActiveResourceAdapters();
// stop system-rars after stopping all other rars.
Set<ActiveResourceAdapter> systemRAs = new HashSet<ActiveResourceAdapter>();
List<Future> rarExitStatusList = new ArrayList<Future>();
for (ActiveResourceAdapter resourceAdapter : resourceAdapters) {
if (!ConnectorsUtil.belongsToSystemRA(resourceAdapter.getModuleName())) {
RAShutdownHandler handler = new RAShutdownHandler(resourceAdapter.getModuleName());
rarExitStatusList.add(execService.submit(handler));
} else {
systemRAs.add(resourceAdapter);
}
}
for (Future future : rarExitStatusList) {
try {
future.get();
} catch (InterruptedException e) {
// ignore as the child task will log any failures
} catch (ExecutionException e) {
// ignore as the child task will log any failures
}
}
rarExitStatusList.clear();
for (ActiveResourceAdapter resourceAdapter : systemRAs) {
RAShutdownHandler handler = new RAShutdownHandler(resourceAdapter.getModuleName());
rarExitStatusList.add(execService.submit(handler));
}
for (Future future : rarExitStatusList) {
try {
future.get();
} catch (InterruptedException e) {
// ignore as the child task will log any failures
} catch (ExecutionException e) {
// ignore as the child task will log any failures
}
}
}
use of com.sun.enterprise.connectors.ActiveResourceAdapter in project Payara by payara.
the class ResourceAdapterAdminServiceImpl method createActiveResourceAdapter.
/**
* Creates Active resource Adapter which abstracts the rar module. During
* the creation of ActiveResourceAdapter, default pools and resources also
* are created.
*
* @param moduleDir Directory where rar module is exploded.
* @param moduleName Name of the module
* @throws ConnectorRuntimeException if creation fails.
*/
public void createActiveResourceAdapter(String moduleDir, String moduleName, ClassLoader loader) throws ConnectorRuntimeException {
synchronized (_registry.getLockObject(moduleName)) {
ActiveResourceAdapter activeResourceAdapter = _registry.getActiveResourceAdapter(moduleName);
if (activeResourceAdapter != null) {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "rardeployment.resourceadapter.already.started", moduleName);
}
return;
}
if (ConnectorsUtil.belongsToSystemRA(moduleName)) {
moduleDir = ConnectorsUtil.getSystemModuleLocation(moduleName);
}
ConnectorDescriptor connectorDescriptor = ConnectorDDTransformUtils.getConnectorDescriptor(moduleDir, moduleName);
if (connectorDescriptor == null) {
ConnectorRuntimeException cre = new ConnectorRuntimeException("Failed to obtain the connectorDescriptor");
_logger.log(Level.SEVERE, "rardeployment.connector_descriptor_notfound", moduleName);
_logger.log(Level.SEVERE, "", cre);
throw cre;
}
createActiveResourceAdapter(connectorDescriptor, moduleName, moduleDir, loader);
}
}
use of com.sun.enterprise.connectors.ActiveResourceAdapter in project Payara by payara.
the class ConnectorMessageBeanClient method close.
/**
* Does endpoint deactivation with the resource adapter.
* Also remove sthe <code>MessageEndpointFactoryInfo</code>
* from house keeping.
*/
public void close() {
logger.logp(Level.FINEST, "ConnectorMessageBeanClient", "close", "called...");
// no longer available
started_ = false;
String resourceAdapterMid = null;
try {
resourceAdapterMid = getResourceAdapterMid(descriptor_);
} catch (ConnectorRuntimeException e) {
String message = localStrings.getString("msg-bean-client.could-not-derive-ra-mid", descriptor_.getName());
logger.log(Level.WARNING, message, e);
}
ActiveResourceAdapter activeRar = registry_.getActiveResourceAdapter(resourceAdapterMid);
if (activeRar instanceof ActiveInboundResourceAdapter) {
// in case the RA is already undeployed
ActiveInboundResourceAdapter rar = (ActiveInboundResourceAdapter) activeRar;
MessageEndpointFactoryInfo info = rar.getEndpointFactoryInfo(beanID_);
if (info != null) {
rar.getResourceAdapter().endpointDeactivation(info.getEndpointFactory(), info.getActivationSpec());
rar.removeEndpointFactoryInfo(beanID_);
} else {
logger.log(Level.FINE, "Not de-activating the end point, since it is not activated");
}
}
}
use of com.sun.enterprise.connectors.ActiveResourceAdapter in project Payara by payara.
the class ConnectorService method checkAccessibility.
/**
* Check whether ClassLoader is permitted to access this resource adapter.
* If the RAR is deployed and is not a standalone RAR, then only the ClassLoader
* that loaded the archive (any of its child) should be able to access it. Otherwise everybody can
* access the RAR.
*
* @param rarName Resource adapter module name.
* @param loader <code>ClassLoader</code> to verify.
*/
public boolean checkAccessibility(String rarName, ClassLoader loader) {
ActiveResourceAdapter ar = _registry.getActiveResourceAdapter(rarName);
if (ar != null && loader != null) {
// If RA is deployed
ClassLoader rarLoader = ar.getClassLoader();
// If the RAR is not standalone.
if (rarLoader != null && ConnectorAdminServiceUtils.isEmbeddedConnectorModule(rarName)) /*&& (!(rarLoader instanceof ConnectorClassFinder))*/
{
ClassLoader rarLoaderParent = rarLoader.getParent();
ClassLoader parent = loader;
while (true) {
if (parent.equals(rarLoaderParent)) {
return true;
}
final ClassLoader temp = parent;
Object obj = AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
return temp.getParent();
}
});
if (obj == null) {
break;
} else {
parent = (ClassLoader) obj;
}
}
// If no parent matches return false;
return false;
}
}
return true;
}
Aggregations