Search in sources :

Example 11 with ConnectorDescriptor

use of com.sun.enterprise.deployment.ConnectorDescriptor in project Payara by payara.

the class ConnectorAnnotationHandler method processAnnotation.

public HandlerProcessingResult processAnnotation(AnnotationInfo element) throws AnnotationProcessorException {
    AnnotatedElementHandler aeHandler = element.getProcessingContext().getHandler();
    Connector connector = (Connector) element.getAnnotation();
    List<Class<? extends Annotation>> list = new ArrayList<Class<? extends Annotation>>();
    list.add(getAnnotationType());
    if (aeHandler instanceof RarBundleContext) {
        RarBundleContext rarContext = (RarBundleContext) aeHandler;
        ConnectorDescriptor desc = rarContext.getDescriptor();
        Class annotatedClass = (Class) element.getAnnotatedElement();
        if (desc.getResourceAdapterClass().equals("")) {
            desc.addConnectorAnnotation(element);
            return getSuccessfulProcessedResult(list);
        } else if (!isResourceAdapterClass(annotatedClass)) {
            desc.addConnectorAnnotation(element);
            return getSuccessfulProcessedResult(list);
        } else if (!desc.getResourceAdapterClass().equals(annotatedClass.getName())) {
            desc.addConnectorAnnotation(element);
            return getSuccessfulProcessedResult(list);
        } else {
            processDescriptor(annotatedClass, connector, desc);
            desc.setValidConnectorAnnotationProcessed(true);
        }
    } else {
        String logMessage = "Not a rar bundle context";
        return getFailureResult(element, logMessage, true);
    }
    return getSuccessfulProcessedResult(list);
}
Also used : Connector(javax.resource.spi.Connector) ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) ArrayList(java.util.ArrayList) RarBundleContext(com.sun.enterprise.deployment.annotation.context.RarBundleContext) Annotation(java.lang.annotation.Annotation)

Example 12 with ConnectorDescriptor

use of com.sun.enterprise.deployment.ConnectorDescriptor in project Payara by payara.

the class ConnectorConfigurationParserServiceImpl method getConnectionDefinitionNames.

/**
 * Obtains all the Connection definition names of a rar
 *  @param rarName rar moduleName
 *  @return Array of connection definition names.
 */
public String[] getConnectionDefinitionNames(String rarName) throws ConnectorRuntimeException {
    String[] result = new String[0];
    ConnectorDescriptor desc = getConnectorDescriptor(rarName);
    if (desc != null) {
        MCFConfigParser mcfConfigParser = (MCFConfigParser) ConnectorConfigParserFactory.getParser(ConnectorConfigParser.MCF);
        return mcfConfigParser.getConnectionDefinitionNames(desc);
    } else {
        return result;
    }
}
Also used : ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor)

Example 13 with ConnectorDescriptor

use of com.sun.enterprise.deployment.ConnectorDescriptor in project Payara by payara.

the class ConnectorService method createActiveResourceAdapterForEmbeddedRar.

public void createActiveResourceAdapterForEmbeddedRar(String rarModuleName) throws ConnectorRuntimeException {
    ConnectorDescriptor cdesc = loadConnectorDescriptorForEmbeddedRAR(rarModuleName);
    String appName = ConnectorAdminServiceUtils.getApplicationName(rarModuleName);
    String rarFileName = ConnectorAdminServiceUtils.getConnectorModuleName(rarModuleName) + ".rar";
    String loc = getResourcesUtil().getApplicationDeployLocation(appName);
    loc = loc + File.separator + FileUtils.makeFriendlyFilename(rarFileName);
    String path = null;
    try {
        URI uri = new URI(loc);
        path = uri.getPath();
    } catch (URISyntaxException use) {
        ConnectorRuntimeException cre = new ConnectorRuntimeException("Invalid path [ " + use.getMessage() + " ]");
        cre.setStackTrace(use.getStackTrace());
        _logger.log(Level.WARNING, cre.getMessage(), cre);
        throw cre;
    }
    // start RA
    _runtime.createActiveResourceAdapter(cdesc, rarModuleName, path);
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 14 with ConnectorDescriptor

use of com.sun.enterprise.deployment.ConnectorDescriptor in project Payara by payara.

the class ConnectorSecurityAdminServiceImpl method getAuthenticationService.

/**
 * Obtain the authentication service associated with rar module.
 * Currently only the BasicPassword authentication is supported.
 *
 * @param rarName  Rar module Name
 * @param poolInfo Name of the pool. Used for creation of
 *                 BasicPasswordAuthenticationService
 * @return AuthenticationService
 */
public AuthenticationService getAuthenticationService(String rarName, PoolInfo poolInfo) {
    ConnectorDescriptor cd = _registry.getDescriptor(rarName);
    OutboundResourceAdapter obra = cd.getOutboundResourceAdapter();
    Set authMechs = obra.getAuthMechanisms();
    for (Object authMech : authMechs) {
        AuthMechanism authMechanism = (AuthMechanism) authMech;
        String mech = authMechanism.getAuthMechType();
        if (mech.equals("BasicPassword")) {
            return new BasicPasswordAuthenticationService(rarName, poolInfo);
        }
    }
    return null;
}
Also used : ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) AuthMechanism(com.sun.enterprise.deployment.AuthMechanism) BasicPasswordAuthenticationService(com.sun.enterprise.connectors.authentication.BasicPasswordAuthenticationService) Set(java.util.Set) OutboundResourceAdapter(com.sun.enterprise.deployment.OutboundResourceAdapter)

Example 15 with ConnectorDescriptor

use of com.sun.enterprise.deployment.ConnectorDescriptor in project Payara by payara.

the class ActiveJmsResourceAdapter method setAvailabilityProperties.

/*

     * Set Availability related properties
     * If JMS availability true set availability properties
     * read configured pool information and set.
     */
private void setAvailabilityProperties() throws ConnectorRuntimeException {
    if (!isClustered())
        return;
    try {
        Domain domain = Globals.get(Domain.class);
        ServerContext serverContext = Globals.get(ServerContext.class);
        Server server = domain.getServerNamed(serverContext.getInstanceName());
        JmsService jmsService = server.getConfig().getExtensionByType(JmsService.class);
        if (jmsService.getType().equals(REMOTE)) {
            // been configured with the right properties.
            return;
        }
        AvailabilityService as = server.getConfig().getAvailabilityService();
        if (as == null) {
            if (_logger.isLoggable(Level.FINE))
                logFine("Availability Service is null. Not setting AvailabilityProperties.");
            return;
        }
        boolean useMasterBroker = true;
        if (as.getExtensionByType(JmsAvailability.class) != null && !MASTERBROKER.equalsIgnoreCase(as.getExtensionByType(JmsAvailability.class).getConfigStoreType()))
            useMasterBroker = false;
        // jmsService.getUseMasterBroker() != null ? Boolean.valueOf(jmsService.getUseMasterBroker()) :true;
        boolean isJmsAvailabilityEnabled = this.isJMSAvailabilityOn(as);
        if (_logger.isLoggable(Level.FINE))
            logFine("Setting AvailabilityProperties .. ");
        if (!useMasterBroker || isJmsAvailabilityEnabled) {
            // For conventional cluster of peer brokers and Enhanced Broker Cluster.
            ConnectorDescriptor cd = getDescriptor();
            String clusterName = getMQClusterName();
            ConnectorConfigProperty envProp1 = new ConnectorConfigProperty(CLUSTERID, clusterName, "Cluster Id", "java.lang.String");
            setProperty(cd, envProp1);
            if (brokerInstanceName == null) {
                brokerInstanceName = getBrokerInstanceName(jmsService);
            }
            ConnectorConfigProperty envProp2 = new ConnectorConfigProperty(BROKERID, brokerInstanceName, "Broker Id", "java.lang.String");
            setProperty(cd, envProp2);
            // Only if JMS availability is true - Enhanced Broker Cluster only.
            if (isJmsAvailabilityEnabled) {
                // Set HARequired as true - irrespective of whether it is REMOTE or
                // LOCAL
                ConnectorConfigProperty envProp3 = new ConnectorConfigProperty(HAREQUIRED, "true", "HA Required", "java.lang.String");
                setProperty(cd, envProp3);
                /* The broker has a property to control whether
               * it starts in HA mode or not and that's represented on
               * the RA by BrokerEnableHA.
               * On the MQ Client connection side it is HARequired -
               * this does not control the broker, it just is a client
               * side requirement.
               * So for AS EE, if BrokerType is LOCAL or EMBEDDED,
               * and AS HA is enabled for JMS then both these must be
               * set to true. */
                ConnectorConfigProperty envProp4 = new ConnectorConfigProperty(BROKERENABLEHA, "true", "BrokerEnableHA flag", "java.lang.Boolean");
                setProperty(cd, envProp4);
                String nodeHostName = domain.getNodeNamed(server.getNodeRef()).getNodeHost();
                if (nodeHostName != null) {
                    ConnectorConfigProperty envProp5 = new ConnectorConfigProperty(BROKERBINDADDRESS, nodeHostName, "Broker Bind Address", "java.lang.String");
                    setProperty(cd, envProp5);
                }
                loadDBProperties(as.getExtensionByType(JmsAvailability.class), ClusterMode.ENHANCED);
            } else {
                // Conventional cluster of peer brokers
                JmsAvailability jmsAvailability = as.getExtensionByType(JmsAvailability.class);
                if ("jdbc".equals(jmsAvailability.getMessageStoreType()))
                    loadDBProperties(jmsAvailability, ClusterMode.ENHANCED);
                loadDBProperties(jmsAvailability, ClusterMode.CONVENTIONAL_OF_PEER_BROKERS);
            }
        /*
            ConnectorConfigProperty  envProp4 = new ConnectorConfigProperty  (
                            DBTYPE , DBTYPE_HADB,"DBType",
                            "java.lang.String");
            setProperty(cd, envProp4);



            * The broker has a property to control whether
            * it starts in HA mode or not and that's represented on
            * the RA by BrokerEnableHA.
            * On the MQ Client connection side it is HARequired -
            * this does not control the broker, it just is a client
            * side requirement.
            * So for AS EE, if BrokerType is LOCAL or EMBEDDED,
            * and AS HA is enabled for JMS then both these must be
            * set to true.

            ConnectorConfigProperty  envProp5 = new ConnectorConfigProperty  (
                        BROKERENABLEHA , "true",
                        "BrokerEnableHA flag","java.lang.Boolean");
            setProperty(cd, envProp5);

            String nodeHostName = domain.getNodeNamed(server.getNode()).getNodeHost();
            if (nodeHostName != null)  {
              ConnectorConfigProperty  envProp6 = new ConnectorConfigProperty  (
                          BROKERBINDADDRESS , nodeHostName,
                          "Broker Bind Address","java.lang.String");
              setProperty(cd, envProp6);
            }
            //get pool name
            String poolJNDIName = as.getJmsAvailability().getMqStorePoolName();
            //If no MQ store pool name is specified, use default poolname
            //XXX: default pool name is jdbc/hastore but asadmin
            //configure-ha-cluster creates a resource called
            //"jdbc/<asclustername>-hastore" which needs to be used.
            if (poolJNDIName == null || poolJNDIName =="" ) {
              //get Web container's HA store's pool name
              poolJNDIName = as.getWebContainerAvailability().
                                getHttpSessionStorePoolName();
              logFine("HTTP Session store pool jndi name " +
                         "is " + poolJNDIName);
            }
            //XXX: request HADB team mq-store-pool name to be
            //populated as part of configure-ha-cluster

            JdbcConnectionPool jdbcConPool = getJDBCConnectionPoolInfo(
                                                poolJNDIName);
            //DBProps: compute values from pool object
            String userName = getPropertyFromPool(jdbcConPool, DUSERNAME);
            logFine("HA username is " + userName);

            String password = getPropertyFromPool(jdbcConPool, DPASSWORD);
            logFine("HA Password is " + password);

            String driverClass = jdbcConPool.getDatasourceClassname();
            logFine("HA driverclass" + driverClass);

            dbProps = new Properties();
            dbProps.setProperty(DB_HADB_USER, userName);
            dbProps.setProperty(DB_HADB_PASSWORD, password);
            dbProps.setProperty(DB_HADB_DRIVERCLASS, driverClass);

            //DSProps: compute values from pool object
            String serverList = getPropertyFromPool(jdbcConPool, DSERVERLIST);
            logFine("HADB server list is " + serverList);
            dsProps = new Properties();

            if (serverList != null) {
                dsProps.setProperty(DS_HADB_SERVERLIST, serverList);
            } else {
                _logger.warning("ajra.incorrect_hadb_server_list");
            }

            //set all other properties in dsProps as well.
            Properties p = getDSPropertiesFromThePool(jdbcConPool);
            Iterator iterator = p.keySet().iterator();
            while (iterator.hasNext()) {
                String key = (String) iterator.next();
                String val = (String)p.get(key);
                dsProps.setProperty(key, val);
            }*/
        } else {
            // Conventional cluster with master broker.
            if ("jdbc".equals(as.getExtensionByType(JmsAvailability.class).getMessageStoreType()))
                loadDBProperties(as.getExtensionByType(JmsAvailability.class), ClusterMode.CONVENTIONAL_WITH_MASTER_BROKER);
        }
    } catch (Exception e) {
        ConnectorRuntimeException crex = new ConnectorRuntimeException(e.getMessage());
        throw (ConnectorRuntimeException) crex.initCause(e);
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) AvailabilityService(com.sun.enterprise.config.serverbeans.AvailabilityService) ServerContext(org.glassfish.internal.api.ServerContext) Server(com.sun.enterprise.config.serverbeans.Server) JmsService(com.sun.enterprise.connectors.jms.config.JmsService) JmsAvailability(com.sun.enterprise.connectors.jms.config.JmsAvailability) Domain(com.sun.enterprise.config.serverbeans.Domain) ConnectorConfigProperty(com.sun.enterprise.deployment.ConnectorConfigProperty) MultiException(org.glassfish.hk2.api.MultiException) PrivilegedActionException(java.security.PrivilegedActionException) ExecutionException(java.util.concurrent.ExecutionException) ResourceAdapterInternalException(javax.resource.spi.ResourceAdapterInternalException) URISyntaxException(java.net.URISyntaxException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

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