use of com.sun.enterprise.deployment.ConnectorDescriptor in project Payara by payara.
the class ConnectorMessageBeanClient method setup.
/**
* Gets executed as part of message bean deployment. Creates the
* <code>ActivationSpec</code> javabean and does endpointfactory
* activation with the resource adapter. This code also converts
* all J2EE 1.3 MDB properties to MQ resource adapter activation
* spec properties, if user doesnt specifies resource adapter
* module name in sun-ejb-jar.xml of the MDB. This is done using
* <code>com.sun.enterprise.connector.system.ActiveJmsResourceAdapter
* </code>
*
* @param messageBeanPM <code>MessageBeanProtocolManager</code> object.
*/
public void setup(MessageBeanProtocolManager messageBeanPM) throws Exception {
ClassLoader loader = descriptor_.getEjbBundleDescriptor().getClassLoader();
if (loader == null) {
loader = Thread.currentThread().getContextClassLoader();
}
beanClass_ = loader.loadClass(descriptor_.getEjbClassName());
messageBeanPM_ = messageBeanPM;
String resourceAdapterMid = getResourceAdapterMid(descriptor_);
ActiveInboundResourceAdapter aira = getActiveResourceAdapter(resourceAdapterMid);
aira.updateMDBRuntimeInfo(descriptor_, messageBeanPM_.getPoolDescriptor());
// the resource adapter this MDB client is deployed to
ResourceAdapter ra = aira.getResourceAdapter();
if (ra == null) {
String i18nMsg = localStrings.getString("msg-bean-client.ra.class.not.specified", resourceAdapterMid);
throw new ConnectorRuntimeException(i18nMsg);
}
ConnectorDescriptor desc = aira.getDescriptor();
MessageListener msgListener = getMessageListener(desc);
String activationSpecClassName = null;
if (msgListener != null) {
activationSpecClassName = msgListener.getActivationSpecClass();
}
if (activationSpecClassName != null) {
if (logger.isLoggable(Level.FINEST)) {
String msg = "ActivationSpecClassName = " + activationSpecClassName;
logger.log(Level.FINEST, msg);
}
try {
ActivationSpec activationSpec = getActivationSpec(aira, activationSpecClassName);
activationSpec.setResourceAdapter(ra);
// at this stage, activation-spec is created, config properties merged with ejb-descriptor.
// validate activation-spec now
ConnectorRuntime runtime = ConnectorRuntime.getRuntime();
runtime.getConnectorBeanValidator().validateJavaBean(activationSpec, resourceAdapterMid);
aira.validateActivationSpec(activationSpec);
myState = BLOCKED;
ra.endpointActivation(this, activationSpec);
aira.addEndpointFactoryInfo(beanID_, new MessageEndpointFactoryInfo(this, activationSpec));
} catch (Exception ex) {
Object[] args = new Object[] { resourceAdapterMid, activationSpecClassName, ex };
logger.log(Level.WARNING, "endpoint.activation.failure", args);
throw (Exception) (new Exception()).initCause(ex);
}
} else {
// FIXME throw some exception here.
throw new Exception("Unsupported message listener type");
}
}
use of com.sun.enterprise.deployment.ConnectorDescriptor 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.ConnectorDescriptor in project Payara by payara.
the class InBoundRANode method writeDescriptor.
/**
* write the descriptor class to a DOM tree and return it
*
* @param parent node for the DOM tree
* @param the descriptor to write
* @return the DOM tree top node
*/
public Node writeDescriptor(Node connectorNode, Descriptor descriptor) {
Node inBoundNode = appendChild(connectorNode, ConnectorTagNames.INBOUND_RESOURCE_ADAPTER);
appendInBoundNode(inBoundNode, (InboundResourceAdapter) ((ConnectorDescriptor) descriptor).getInboundResourceAdapter());
return connectorNode;
}
use of com.sun.enterprise.deployment.ConnectorDescriptor 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);
}
use of com.sun.enterprise.deployment.ConnectorDescriptor in project Payara by payara.
the class SecurityPermissionHandler method processAnnotation.
public HandlerProcessingResult processAnnotation(AnnotationInfo element) throws AnnotationProcessorException {
AnnotatedElementHandler aeHandler = element.getProcessingContext().getHandler();
SecurityPermission securityPermission = (SecurityPermission) element.getAnnotation();
if (aeHandler instanceof RarBundleContext) {
boolean isConnectionDefinition = hasConnectorAnnotation(element);
if (isConnectionDefinition) {
RarBundleContext rarContext = (RarBundleContext) aeHandler;
ConnectorDescriptor desc = rarContext.getDescriptor();
// XXX: Siva : For now use the first provided description
String firstDesc = "";
if (securityPermission.description().length > 0) {
firstDesc = securityPermission.description()[0];
}
com.sun.enterprise.deployment.SecurityPermission permission = new com.sun.enterprise.deployment.SecurityPermission(firstDesc, securityPermission.permissionSpec());
desc.addSecurityPermission(permission);
} else {
getFailureResult(element, "Not a @Connector annotation : @SecurityPermission must " + "be specified along with @Connector annotation", true);
}
} else {
getFailureResult(element, "Not a rar bundle context", true);
}
return getDefaultProcessedResult();
}
Aggregations