Search in sources :

Example 1 with ConnectorDescriptor

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));
    }
}
Also used : ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) AppClientVerifier(com.sun.enterprise.tools.verifier.appclient.AppClientVerifier) EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) WebVerifier(com.sun.enterprise.tools.verifier.web.WebVerifier) ApplicationVerifier(com.sun.enterprise.tools.verifier.app.ApplicationVerifier) Iterator(java.util.Iterator) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) EjbVerifier(com.sun.enterprise.tools.verifier.ejb.EjbVerifier) ConnectorVerifier(com.sun.enterprise.tools.verifier.connector.ConnectorVerifier) ApplicationClientDescriptor(com.sun.enterprise.deployment.ApplicationClientDescriptor)

Example 2 with ConnectorDescriptor

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();
}
Also used : ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) AuthMechanism(com.sun.enterprise.deployment.AuthMechanism) AuthenticationMechanism(javax.resource.spi.AuthenticationMechanism) RarBundleContext(com.sun.enterprise.deployment.annotation.context.RarBundleContext) OutboundResourceAdapter(com.sun.enterprise.deployment.OutboundResourceAdapter)

Example 3 with ConnectorDescriptor

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();
}
Also used : ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) RarBundleContext(com.sun.enterprise.deployment.annotation.context.RarBundleContext) SecurityPermission(javax.resource.spi.SecurityPermission)

Example 4 with ConnectorDescriptor

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);
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) ActiveResourceAdapter(com.sun.enterprise.connectors.ActiveResourceAdapter)

Example 5 with ConnectorDescriptor

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;
}
Also used : Context(javax.naming.Context) InitialContext(javax.naming.InitialContext) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) ConnectionManagerImpl(com.sun.enterprise.connectors.ConnectionManagerImpl) Reference(javax.naming.Reference) ResourcePool(com.sun.enterprise.config.serverbeans.ResourcePool) InitialContext(javax.naming.InitialContext) ConfigurationException(javax.naming.ConfigurationException) NamingException(javax.naming.NamingException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) ManagedConnectionFactory(javax.resource.spi.ManagedConnectionFactory) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ConfigurationException(javax.naming.ConfigurationException) ResourceDeployer(org.glassfish.resourcebase.resources.api.ResourceDeployer) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo) NamingException(javax.naming.NamingException) Resources(com.sun.enterprise.config.serverbeans.Resources) ConnectorRegistry(com.sun.enterprise.connectors.ConnectorRegistry)

Aggregations

ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)40 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)11 ConnectorConfigProperty (com.sun.enterprise.deployment.ConnectorConfigProperty)9 RarBundleContext (com.sun.enterprise.deployment.annotation.context.RarBundleContext)8 OutboundResourceAdapter (com.sun.enterprise.deployment.OutboundResourceAdapter)5 Iterator (java.util.Iterator)5 AuthMechanism (com.sun.enterprise.deployment.AuthMechanism)4 URISyntaxException (java.net.URISyntaxException)4 ConnectionDefDescriptor (com.sun.enterprise.deployment.ConnectionDefDescriptor)3 DeploymentDescriptorNode (com.sun.enterprise.deployment.node.DeploymentDescriptorNode)3 ResourcePool (com.sun.enterprise.config.serverbeans.ResourcePool)2 ActiveResourceAdapter (com.sun.enterprise.connectors.ActiveResourceAdapter)2 ConnectorDescriptorInfo (com.sun.enterprise.connectors.ConnectorDescriptorInfo)2 ConnectorRegistry (com.sun.enterprise.connectors.ConnectorRegistry)2 ConnectorRuntime (com.sun.enterprise.connectors.ConnectorRuntime)2 JmsService (com.sun.enterprise.connectors.jms.config.JmsService)2 JmsRaUtil (com.sun.enterprise.connectors.jms.util.JmsRaUtil)2 MessageListener (com.sun.enterprise.deployment.MessageListener)2 AdministeredObjectResource (com.sun.enterprise.resource.beans.AdministeredObjectResource)2 URI (java.net.URI)2