Methods Summary |
---|
public boolean | checkAccessibility(java.lang.String rarName, java.lang.ClassLoader loader)Check whether ClassLoader is permitted to access this resource adapter.
If the RAR is deployed and is not a standalone RAR, then only ClassLoader
that loader the archive should be able to access it. Otherwise everybody can
access the RAR.
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 && (!(rarLoader instanceof ConnectorClassLoader))) {
ClassLoader parent = loader;
while (true) {
if (parent.equals(rarLoader)) {
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;
|
public boolean | checkAndLoadPoolResource(java.lang.String poolName)
ResourcesUtil resutil = ResourcesUtil.createInstance();
DeferredResourceConfig defResConfig = resutil.getDeferredPoolConfig(
poolName);
return loadResourcesAndItsRar(defResConfig);
|
public boolean | checkAndLoadResource(java.lang.String resname)Internal API to lazily load Connector/JDBC/JMS and other resources on
first lookup. All dependent resources and related infrastructure are also
loaded.
//Resolve actual JNDI name. Connector and JDBC connection Pools are
//internally reserve prefixed while binding in JNDI.
//The Connector backend OTOH uses the actual JNDI name for all checks.
//So unmap the transformation here before proceeding to load the resource
//and its dependents
resname = ConnectorAdminServiceUtils.getOriginalResourceName(resname);
_logger.fine("ConnectorServiceImpl :: checkAndLoadResource resolved to " +
"load " + resname);
ResourcesUtil resutil = ResourcesUtil.createInstance();
DeferredResourceConfig defResConfig = resutil.getDeferredResourceConfig(
resname);
return loadResourcesAndItsRar(defResConfig);
|
public void | create()These two methods are NOP. They will be used for future
enhancements.
|
public void | destroy()
|
public ConnectorDescriptor | getConnectorDescriptor(java.lang.String rarName)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.
if(rarName == null) {
return null;
}
ConnectorDescriptor desc = null;
desc = _registry.getDescriptor(rarName);
if(desc != null) {
return desc;
}
String moduleDir = null;
ResourcesUtil resUtil = ResourcesUtil.createInstance();
//If the RAR is embedded try loading the descriptor directly
//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(resUtil.belongToSystemRar(rarName)){
ResourceInstaller installer =
Switch.getSwitch().getResourceInstaller();
moduleDir = installer.getSystemModuleLocation(rarName);
} else {
moduleDir = resUtil.getLocation(rarName);
}
if (moduleDir != null) {
desc = ConnectorDDTransformUtils.getConnectorDescriptor(moduleDir);
} else {
_logger.log(Level.SEVERE,
"rardeployment.no_module_deployed", rarName);
}
return desc;
|
public java.lang.String | getDefaultPoolName(java.lang.String jndiName)Returns the generated default poolName of JMS resources.
//This is called by the JMS Deployers alone
return jndiName;
|
public java.lang.String | getDefaultPoolName(java.lang.String moduleName, java.lang.String connectionDefName)Returns the generated default connection poolName for a
connection definition.
return moduleName+POOLNAME_APPENDER+connectionDefName;
|
public java.lang.String | getDefaultResourceName(java.lang.String moduleName, java.lang.String connectionDefName)Returns the generated default connector resource for a
connection definition.
//Construct the default resource name as
// <JNDIName_of_RA>#<connectionDefnName>
String resourceJNDIName = ConnectorAdminServiceUtils.
getReservePrefixedJNDINameForResource(moduleName);
return resourceJNDIName + RESOURCENAME_APPENDER + connectionDefName;
|
public static int | getEnviron()Returns the execution environment.
return environment;
|
protected ConnectorRuntime | getRuntime()
return ConnectorRuntime.getRuntime();
|
public void | ifSystemRarLoad(java.lang.String rarName)
ResourcesUtil resUtil = ResourcesUtil.createInstance();
if(resUtil.belongToSystemRar(rarName)){
loadDeferredResourceAdapter(rarName);
}
|
public static void | initialize(int environ)Initializes the execution environment. If the execution environment
is appserv runtime it is set to ConnectorConstants.SERVER else
it is set ConnectorConstants.CLIENT
environment = environ;
|
public void | initializeConnectorMonitoring()Initialize the monitoring listeners for connection pools, work management
and message end point factory related stats
Switch.getSwitch().getPoolManager().initializeMonitoring();
initializeWorkMgmtAndEndPointMonitoring();
|
private void | initializeWorkMgmtAndEndPointMonitoring()Initialize the monitoring listeners for connection pools, work management
and message end point factory related stats
try {
final ConnectorWorkMonitoringLevelListener cwmll
= new ConnectorWorkMonitoringLevelListener();
//@todo Do for Connector EPF Monitoring as well
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
ServerContext ctxt = ApplicationServer.getServerContext();
if (ctxt != null) {
MonitoringRegistry monitoringRegistry_
= ctxt.getMonitoringRegistry();
//@todo: for EFT level listeners
monitoringRegistry_.registerMonitoringLevelListener(cwmll,
MonitoredObjectType.CONNECTOR_WORKMGMT);
/* monitoringRegistry_.registerMonitoringLevelListener(
ccpPoolMonitoringLevelListener_,
MonitoredObjectType.CONNECTOR_CONN_POOL );
*/
}
return null;
}
});
_logger.log( Level.FINE, "poolmon.init_monitoring_registry");
} catch(Exception e) {
_logger.log( Level.INFO, "poolmon.error_registering_listener",
e);
}
|
public static boolean | isServer()Checks whether the executing environment is application server
if(getEnviron() == SERVER) {
return true;
} else {
return false;
}
|
private ConnectorDescriptor | loadConnectorDescriptorForEmbeddedRAR(java.lang.String rarName)
//If the RAR is embedded try loading the descriptor directly
//using the applicationarchivist
try {
String appName = rarName.substring(0, rarName.indexOf(ConnectorConstants.EMBEDDEDRAR_NAME_DELIMITER));
String actualRarName = rarName.substring(rarName.indexOf(ConnectorConstants.EMBEDDEDRAR_NAME_DELIMITER) + 1);
String appDeployLocation = ResourcesUtil.createInstance().getApplicationDeployLocation(appName);
FileArchive in = new FileArchive();
in.open(appDeployLocation);
ApplicationArchivist archivist = new ApplicationArchivist();
Application application = (Application) archivist.open(in);
//get all RAR descriptors and try searching for this embedded RAR
Set s = application.getRarDescriptors();
for (Iterator iter = s.iterator(); iter.hasNext();) {
ConnectorDescriptor element = (ConnectorDescriptor) iter.next();
//Strip ".rar" from deployname before using it.
String rardescname = element.getDeployName().substring(
0, element.getDeployName().indexOf(".rar"));
if(rardescname.equals(actualRarName)){
return element;
}
}
} catch (SAXParseException e) {
ConnectorRuntimeException crex = new ConnectorRuntimeException("" +
"SAXParseException while trying to load connector descriptor for embedded RAR");
crex.initCause(e);
throw crex;
} catch (IOException e) {
ConnectorRuntimeException crex = new ConnectorRuntimeException("" +
"SAXParseException while trying to load connector descriptor for embedded RAR");
crex.initCause(e);
throw crex;
}
return null;
|
public void | loadDeferredResourceAdapter(java.lang.String rarName)
try {
ManagerFactory.getSAConnectorModulesManager().
loadOneSystemApp(rarName, true);
} catch (Exception e) {
ConnectorRuntimeException ce =
new ConnectorRuntimeException(e.getMessage());
ce.initCause(e);
throw ce;
}
|
public void | loadDeferredResources(ConfigBean[] resourcesToLoad)
if(resourcesToLoad == null || resourcesToLoad.length == 0) {
return;
}
String resourceType = null;
ResourceDeployer deployer = null;
ResourcesUtil resourceUtil = ResourcesUtil.createInstance();
for(int i=0;i<resourcesToLoad.length;++i) {
if(resourcesToLoad[i] == null) {
continue;
} else if (resourceUtil.isEnabled(resourcesToLoad[i])) {
resourceType = resourceUtil.getResourceType(resourcesToLoad[i]);
ResourceDeployerFactory factory = new ResourceDeployerFactory();
deployer = factory.getResourceDeployer(resourceType);
if(deployer != null) {
deployer.deployResource(resourcesToLoad[i]);
}
}
}
|
public boolean | loadResourcesAndItsRar(DeferredResourceConfig defResConfig)
if(defResConfig != null) {
try {
loadDeferredResources(defResConfig.getResourceAdapterConfig());
String rarName = defResConfig.getRarName();
loadDeferredResourceAdapter(rarName);
final ConfigBean[] resToLoad = defResConfig.getResourcesToLoad();
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
try {
loadDeferredResources(resToLoad);
} catch(Exception ex) {
_logger.log( Level.SEVERE,
"failed to load resources/ResourceAdapter");
_logger.log(Level.SEVERE,"" ,ex);
}
return null;
}
});
} catch(Exception ex) {
_logger.log(
Level.SEVERE,"failed to load resources/ResourceAdapter");
_logger.log(Level.SEVERE,"" ,ex);
return false;
}
return true;
}
return false;
|
public void | switchOnMatching(java.lang.String rarName, java.lang.String poolName)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.
// At present it is applicable to only JDBC resource adapters
// Later other resource adapters also become applicable.
if (rarName.equals(ConnectorRuntime.JDBCDATASOURCE_RA_NAME) ||
rarName.equals(ConnectorRuntime.JDBCCONNECTIONPOOLDATASOURCE_RA_NAME) ||
rarName.equals(ConnectorRuntime.JDBCXA_RA_NAME)) {
PoolManager poolMgr = Switch.getSwitch().getPoolManager();
boolean result = poolMgr.switchOnMatching(poolName);
if (result == false) {
try {
getRuntime().switchOnMatchingInJndi(poolName);
} catch (ConnectorRuntimeException cre) {
// This will never happen.
}
}
}
|