use of com.sun.enterprise.deployment.ConnectorDescriptor in project Payara by payara.
the class Verifier method verifyArchive.
private void verifyArchive() {
if (!getApplication().isVirtual()) {
// don't run app tests for standalone module
runVerifier(new ApplicationVerifier(verifierFrameworkContext));
}
for (Iterator itr = getApplication().getBundleDescriptors(EjbBundleDescriptor.class).iterator(); itr.hasNext(); ) {
EjbBundleDescriptor ejbd = (EjbBundleDescriptor) itr.next();
runVerifier(new EjbVerifier(verifierFrameworkContext, ejbd));
}
for (Iterator itr = getApplication().getBundleDescriptors(WebBundleDescriptor.class).iterator(); itr.hasNext(); ) {
WebBundleDescriptor webd = (WebBundleDescriptor) itr.next();
runVerifier(new WebVerifier(verifierFrameworkContext, webd));
}
for (Iterator itr = getApplication().getBundleDescriptors(ApplicationClientDescriptor.class).iterator(); itr.hasNext(); ) {
ApplicationClientDescriptor appClientDescriptor = (ApplicationClientDescriptor) itr.next();
runVerifier(new AppClientVerifier(verifierFrameworkContext, appClientDescriptor));
}
for (Iterator itr = getApplication().getBundleDescriptors(ConnectorDescriptor.class).iterator(); itr.hasNext(); ) {
ConnectorDescriptor cond = (ConnectorDescriptor) itr.next();
runVerifier(new ConnectorVerifier(verifierFrameworkContext, cond));
}
}
use of com.sun.enterprise.deployment.ConnectorDescriptor in project Payara by payara.
the class AuthenticationMechanismHandler method processAnnotation.
public HandlerProcessingResult processAnnotation(AnnotationInfo element) throws AnnotationProcessorException {
AnnotatedElementHandler aeHandler = element.getProcessingContext().getHandler();
AuthenticationMechanism authMechanism = (AuthenticationMechanism) element.getAnnotation();
if (aeHandler instanceof RarBundleContext) {
boolean isConnectionDefinition = hasConnectorAnnotation(element);
if (isConnectionDefinition) {
RarBundleContext rarContext = (RarBundleContext) aeHandler;
ConnectorDescriptor desc = rarContext.getDescriptor();
if (!desc.getOutBoundDefined()) {
OutboundResourceAdapter ora = new OutboundResourceAdapter();
desc.setOutboundResourceAdapter(ora);
}
OutboundResourceAdapter ora = desc.getOutboundResourceAdapter();
String[] description = authMechanism.description();
int authMechanismValue = getAuthMechVal(authMechanism.authMechanism());
AuthenticationMechanism.CredentialInterface ci = authMechanism.credentialInterface();
String credentialInterface = ora.getCredentialInterfaceName(ci);
// XXX: Siva: For now use the first description
String firstDesc = "";
if (description.length > 0) {
firstDesc = description[0];
}
AuthMechanism auth = new AuthMechanism(firstDesc, authMechanismValue, credentialInterface);
ora.addAuthMechanism(auth);
} else {
getFailureResult(element, "Not a @Connector annotation : @AuthenticationMechanism must " + "be specified along with @Connector annotation", true);
}
} else {
getFailureResult(element, "Not a rar bundle context", true);
}
return getDefaultProcessedResult();
}
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();
}
use of com.sun.enterprise.deployment.ConnectorDescriptor 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.deployment.ConnectorDescriptor in project Payara by payara.
the class ConnectorObjectFactory method getObjectInstance.
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable env) throws Exception {
Reference ref = (Reference) obj;
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "ConnectorObjectFactory: " + ref + " Name:" + name);
}
PoolInfo poolInfo = (PoolInfo) ref.get(0).getContent();
String moduleName = (String) ref.get(1).getContent();
ResourceInfo resourceInfo = (ResourceInfo) ref.get(2).getContent();
if (getRuntime().isACCRuntime() || getRuntime().isNonACCRuntime()) {
ConnectorDescriptor connectorDescriptor = null;
String descriptorJNDIName = ConnectorAdminServiceUtils.getReservePrefixedJNDINameForDescriptor(moduleName);
Context ic = new InitialContext(env);
connectorDescriptor = (ConnectorDescriptor) ic.lookup(descriptorJNDIName);
try {
getRuntime().createActiveResourceAdapter(connectorDescriptor, moduleName, null);
} catch (ConnectorRuntimeException e) {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Failed to look up ConnectorDescriptor from JNDI", moduleName);
}
NamingException ne = new NamingException("Failed to look up ConnectorDescriptor from JNDI");
ne.setRootCause(e);
throw ne;
}
}
ClassLoader loader = Thread.currentThread().getContextClassLoader();
if (!getRuntime().checkAccessibility(moduleName, loader)) {
String msg = localStrings.getString("cof.no_access_to_embedded_rar", moduleName);
throw new NamingException(msg);
}
Object cf = null;
try {
ManagedConnectionFactory mcf = getRuntime().obtainManagedConnectionFactory(poolInfo, env);
if (mcf == null) {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Failed to create MCF ", poolInfo);
}
throw new ConnectorRuntimeException("Failed to create MCF");
}
boolean forceNoLazyAssoc = false;
String jndiName = name.toString();
if (jndiName.endsWith(ConnectorConstants.PM_JNDI_SUFFIX)) {
forceNoLazyAssoc = true;
}
String derivedJndiName = ConnectorsUtil.deriveJndiName(jndiName, env);
ConnectionManagerImpl mgr = (ConnectionManagerImpl) getRuntime().obtainConnectionManager(poolInfo, forceNoLazyAssoc, resourceInfo);
mgr.setJndiName(derivedJndiName);
mgr.setRarName(moduleName);
String logicalName = (String) env.get(GlassfishNamingManager.LOGICAL_NAME);
if (logicalName != null) {
mgr.setLogicalName(logicalName);
}
mgr.initialize();
cf = mcf.createConnectionFactory(mgr);
if (cf == null) {
String msg = localStrings.getString("cof.no.resource.adapter");
throw new RuntimeException(new ConfigurationException(msg));
}
if (getRuntime().isServer() || getRuntime().isEmbedded()) {
ConnectorRegistry registry = ConnectorRegistry.getInstance();
if (registry.isTransparentDynamicReconfigPool(poolInfo)) {
Resources resources = getRuntime().getResources(poolInfo);
ResourcePool resourcePool = null;
if (resources != null) {
resourcePool = (ResourcePool) ConnectorsUtil.getResourceByName(resources, ResourcePool.class, poolInfo.getName());
if (resourcePool != null) {
ResourceDeployer deployer = getRuntime().getResourceDeployer(resourcePool);
if (deployer != null && deployer.supportsDynamicReconfiguration() && ConnectorsUtil.isDynamicReconfigurationEnabled(resourcePool)) {
Object o = env.get(ConnectorConstants.DYNAMIC_RECONFIGURATION_PROXY_CALL);
if (o == null || Boolean.valueOf(o.toString()).equals(false)) {
// TODO use list ? (even in the ResourceDeployer API)
Class[] classes = deployer.getProxyClassesForDynamicReconfiguration();
Class[] proxyClasses = new Class[classes.length + 1];
for (int i = 0; i < classes.length; i++) {
proxyClasses[i] = classes[i];
}
proxyClasses[proxyClasses.length - 1] = DynamicallyReconfigurableResource.class;
cf = getProxyObject(cf, proxyClasses, resourceInfo);
}
}
}
}
}
}
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Connection Factory:" + cf);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return cf;
}
Aggregations