use of com.sun.enterprise.deployment.Application 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.deployment.Application in project Payara by payara.
the class AppSpecificConnectorClassLoaderUtil method detectResourceInRA.
private void detectResourceInRA(Application app, String moduleName, String jndiName) {
// domain.xml
Resource res = null;
if (jndiName.startsWith(ConnectorConstants.JAVA_APP_SCOPE_PREFIX)) /*|| jndiName.startsWith("java:global/")*/
{
ApplicationInfo appInfo = appRegistry.get(app.getName());
res = getApplicationScopedResource(jndiName, BindableResource.class, appInfo);
} else if (jndiName.startsWith(ConnectorConstants.JAVA_MODULE_SCOPE_PREFIX)) {
ApplicationInfo appInfo = appRegistry.get(app.getName());
res = getModuleScopedResource(jndiName, moduleName, BindableResource.class, appInfo);
} else {
res = ConnectorsUtil.getResourceByName(getResources(), BindableResource.class, jndiName);
}
// (and .ear may refer to these resources in DD)
if (res != null) {
if (ConnectorResource.class.isAssignableFrom(res.getClass())) {
ConnectorResource connResource = (ConnectorResource) res;
String poolName = connResource.getPoolName();
Resource pool;
ApplicationInfo appInfo = appRegistry.get(app.getName());
if (jndiName.startsWith(ConnectorConstants.JAVA_APP_SCOPE_PREFIX)) /*|| jndiName.startsWith("java:global/")*/
{
pool = getApplicationScopedResource(poolName, ResourcePool.class, appInfo);
} else if (jndiName.startsWith(ConnectorConstants.JAVA_MODULE_SCOPE_PREFIX)) {
pool = getModuleScopedResource(poolName, moduleName, ResourcePool.class, appInfo);
} else {
pool = ConnectorsUtil.getResourceByName(getResources(), ResourcePool.class, poolName);
}
if (ConnectorConnectionPool.class.isAssignableFrom(pool.getClass())) {
String raName = ((ConnectorConnectionPool) pool).getResourceAdapterName();
app.addResourceAdapter(raName);
}
} else if (AdminObjectResource.class.isAssignableFrom(res.getClass())) {
String raName = ((AdminObjectResource) res).getResAdapter();
app.addResourceAdapter(raName);
}
} else {
boolean found = false;
// detect sun-ra.xml
// find all the standalone connector modules
List<com.sun.enterprise.config.serverbeans.Application> applications = getApplications().getApplicationsWithSnifferType(com.sun.enterprise.config.serverbeans.ServerTags.CONNECTOR, true);
Iterator itr = applications.iterator();
while (itr.hasNext()) {
com.sun.enterprise.config.serverbeans.Application application = (com.sun.enterprise.config.serverbeans.Application) itr.next();
String appName = application.getName();
ApplicationInfo appInfo = appRegistry.get(appName);
if (appInfo == null) {
// the app is not deployed on this node
continue;
}
Application dolApp = appInfo.getMetaData(Application.class);
Collection<ConnectorDescriptor> rarDescriptors = dolApp.getBundleDescriptors(ConnectorDescriptor.class);
for (ConnectorDescriptor desc : rarDescriptors) {
SunConnector sunraDesc = desc.getSunDescriptor();
if (sunraDesc != null) {
String sunRAJndiName = (String) sunraDesc.getResourceAdapter().getValue(ResourceAdapter.JNDI_NAME);
if (jndiName.equals(sunRAJndiName)) {
app.addResourceAdapter(desc.getName());
found = true;
break;
}
} else {
// check whether it is default resource in the connector
if (desc.getDefaultResourcesNames().contains(jndiName)) {
app.addResourceAdapter(desc.getName());
found = true;
break;
}
}
}
}
if (!found) {
if (DOLUtils.getDefaultLogger().isLoggable(Level.FINEST)) {
DOLUtils.getDefaultLogger().log(Level.FINEST, "could not find resource by name : " + jndiName);
}
}
}
}
use of com.sun.enterprise.deployment.Application in project Payara by payara.
the class DOLUtils method isRAConnectionFactory.
/**
* Returns true if there is a resource connection definition of the type with the application
* @param habitat
* @param type
* @param thisApp
* @return
*/
public static boolean isRAConnectionFactory(ServiceLocator habitat, String type, Application thisApp) {
// adapter in this application
if (isRAConnectionFactory(type, thisApp)) {
return true;
}
// then check if this is a connection factory defined in a standalone
// resource adapter
Applications applications = habitat.getService(Applications.class);
if (applications != null) {
List<com.sun.enterprise.config.serverbeans.Application> raApps = applications.getApplicationsWithSnifferType(com.sun.enterprise.config.serverbeans.ServerTags.CONNECTOR, true);
ApplicationRegistry appRegistry = habitat.getService(ApplicationRegistry.class);
for (com.sun.enterprise.config.serverbeans.Application raApp : raApps) {
ApplicationInfo appInfo = appRegistry.get(raApp.getName());
if (appInfo == null)
continue;
if (isRAConnectionFactory(type, appInfo.getMetaData(Application.class))) {
return true;
}
}
}
return false;
}
use of com.sun.enterprise.deployment.Application in project Payara by payara.
the class DOLUtils method getCurrentBundleForContext.
/**
* Gets the associated descriptor with the context
* @param context
* @return null if there is no associated application
*/
public static BundleDescriptor getCurrentBundleForContext(DeploymentContext context) {
ExtendedDeploymentContext ctx = (ExtendedDeploymentContext) context;
Application application = context.getModuleMetaData(Application.class);
// this can happen for non-JavaEE type deployment. e.g., issue 15869
if (application == null)
return null;
if (ctx.getParentContext() == null) {
if (application.isVirtual()) {
// standalone module
return application.getStandaloneBundleDescriptor();
} else {
// top level
return application;
}
} else {
// a sub module of ear
return application.getModuleByUri(ctx.getModuleUri());
}
}
use of com.sun.enterprise.deployment.Application in project Payara by payara.
the class DOLUtils method getApplicationFromEnv.
/**
* @param env
* @return
*/
public static Application getApplicationFromEnv(JndiNameEnvironment env) {
Application app = null;
if (env instanceof EjbDescriptor) {
// EJB component
EjbDescriptor ejbEnv = (EjbDescriptor) env;
app = ejbEnv.getApplication();
} else if (env instanceof EjbBundleDescriptor) {
EjbBundleDescriptor ejbBundle = (EjbBundleDescriptor) env;
app = ejbBundle.getApplication();
} else if (env instanceof WebBundleDescriptor) {
WebBundleDescriptor webEnv = (WebBundleDescriptor) env;
app = webEnv.getApplication();
} else if (env instanceof ApplicationClientDescriptor) {
ApplicationClientDescriptor appEnv = (ApplicationClientDescriptor) env;
app = appEnv.getApplication();
} else if (env instanceof ManagedBeanDescriptor) {
ManagedBeanDescriptor mb = (ManagedBeanDescriptor) env;
app = mb.getBundle().getApplication();
} else if (env instanceof Application) {
app = ((Application) env);
} else {
throw new IllegalArgumentException("IllegalJndiNameEnvironment : env");
}
return app;
}
Aggregations