use of com.sun.appserv.connectors.internal.api.ConnectorClassFinder in project Payara by payara.
the class ConnectorDeployer method load.
/**
* Loads a previously prepared application in its execution environment and
* return a ContractProvider instance that will identify this environment in
* future communications with the application's container runtime.
*
* @param container in which the application will reside
* @param context of the deployment
* @return an ApplicationContainer instance identifying the running application
*/
@Override
public ConnectorApplication load(ConnectorContainer container, DeploymentContext context) {
super.load(container, context);
File sourceDir = context.getSourceDir();
String sourcePath = sourceDir.getAbsolutePath();
String moduleName = sourceDir.getName();
ConnectorDescriptor connDesc = context.getModuleMetaData(ConnectorDescriptor.class);
if (connDesc != null) {
connDesc.setClassLoader(context.getClassLoader());
}
if (_logger.isLoggable(Level.FINEST)) {
_logger.finest("connector-descriptor during load : " + connDesc);
}
boolean isEmbedded = ConnectorsUtil.isEmbedded(context);
ConnectorClassFinder ccf = null;
ClassLoader classLoader = null;
// this check is not needed as system-rars are never deployed, just to be safe.
if (!ConnectorsUtil.belongsToSystemRA(moduleName)) {
try {
// for a connector deployer, classloader will always be ConnectorClassFinder
classLoader = context.getClassLoader();
// for embedded .rar, compute the embedded .rar name
if (isEmbedded) {
moduleName = ConnectorsUtil.getEmbeddedRarModuleName(ConnectorsUtil.getApplicationName(context), moduleName);
}
if (!(isEmbedded)) {
ccf = (ConnectorClassFinder) context.getClassLoader();
clh.getConnectorClassLoader(null).addDelegate(ccf);
}
registerBeanValidator(moduleName, context.getSource(), classLoader);
runtime.createActiveResourceAdapter(connDesc, moduleName, sourcePath, classLoader);
} catch (Exception cre) {
Object[] params = new Object[] { moduleName, cre };
_logger.log(Level.WARNING, "unable.to.load.ra", params);
// since resource-adapter creation has failed, remove the class-loader for the RAR
if (!(isEmbedded) && ccf != null) {
clh.getConnectorClassLoader(null).removeDelegate(ccf);
}
// since resource-adapter creation has failed, unregister bean validator of the RAR
unregisterBeanValidator(moduleName);
throw new RuntimeException(cre.getMessage(), cre);
}
}
return new ConnectorApplication(moduleName, ConnectorsUtil.getApplicationName(context), resourceManager, asrManager, classLoader, runtime, events, connDesc);
}
Aggregations