Search in sources :

Example 16 with ConnectorConfigProperty

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

the class ActiveJmsResourceAdapter method setLifecycleProperties.

/**
 * Set MQ4.0 RA lifecycle properties
 */
private void setLifecycleProperties() throws Exception, ConnectorRuntimeException {
    // ConfigContext ctx = ApplicationServer.getServerContext().getConfigContext();
    // If PE:
    // EMBEDDED/LOCAL goto jms-service, get defaultjmshost info and set
    // accordingly
    // if EE:
    // EMBEDDED/LOCAL get this instance and cluster name, search for a
    // jms-host wth this this name in jms-service gets its proeprties
    // and set
    // @siva As of now use default JMS host. As soon as changes for modifying EE
    // cluster to LOCAL is brought in, change this to use system properties
    // for EE to get port, host, adminusername, adminpassword.
    // JmsService jmsService = ServerBeansFactory.getJmsServiceBean(ctx);
    String defaultJmsHost = getJmsService().getDefaultJmsHost();
    if (_logger.isLoggable(Level.FINE))
        logFine("Default JMS Host :: " + defaultJmsHost);
    JmsHost jmsHost = getJmsHost();
    if (jmsHost != null) {
        // todo: && jmsHost.isEnabled()) {
        JavaConfig javaConfig = (JavaConfig) Globals.get(JavaConfig.class);
        ;
        String java_home = javaConfig.getJavaHome();
        // Get broker type from JMS Service.
        // String brokerType = jmsService.getType();
        /*
             * XXX: adjust the brokertype for the new DIRECT mode in 4.1
             * uncomment the line below once we have an MQ integration
             * that has DIRECT mode support
             */
        String brokerType = adjustForDirectMode(getJmsService().getType());
        String brokerPort = jmsHost.getPort();
        brkrPort = brokerPort;
        String adminUserName = jmsHost.getAdminUserName();
        String adminPassword = JmsRaUtil.getUnAliasedPwd(jmsHost.getAdminPassword());
        List jmsHostProps = getJmsService().getProperty();
        String username = null;
        String password = null;
        if (jmsHostProps != null) {
            for (int i = 0; i < jmsHostProps.size(); i++) {
                Property jmsProp = (Property) jmsHostProps.get(i);
                String propName = jmsProp.getName();
                String propValue = jmsProp.getValue();
                if ("user-name".equals(propName)) {
                    username = propValue;
                } else if ("password".equals(propName)) {
                    password = propValue;
                }
            // Add more properties as and when you want.
            }
        }
        if (_logger.isLoggable(Level.FINE))
            logFine("Broker UserName = " + username);
        createMQVarDirectoryIfNecessary();
        String brokerVarDir = getMQVarDir();
        String tmpString = getJmsService().getStartArgs();
        if (tmpString == null) {
            tmpString = "";
        }
        String brokerArgs = tmpString;
        // XX: Extract the information from the optional properties.
        List jmsProperties = getJmsService().getProperty();
        List jmsHostProperties = jmsHost.getProperty();
        Properties jmsServiceProp = listToProperties(jmsProperties);
        Properties jmsHostProp = listToProperties(jmsHostProperties);
        jmsServiceProp.putAll(jmsHostProp);
        if (jmsServiceProp.size() > 0) {
            if (dbProps == null)
                dbProps = new Properties();
            dbProps.putAll(jmsServiceProp);
        }
        /*
	   String jmsPropertiesStr =  null ;
	   if(jmsServiceProp.size() > 0)
	   {
	   try{
	   	StringWriter writer = new StringWriter();
	   	jmsServiceProp.store(writer, "Properties defined in JMSService and JMSHost");
	   	jmsPropertiesStr =  writer.toString();
	   }catch(Exception e){}//todo: log error;
	   } */
        String brokerHomeDir = getBrokerHomeDir();
        String brokerLibDir = getBrokerLibDir();
        if (brokerInstanceName == null) {
            brokerInstanceName = getBrokerInstanceName(getJmsService());
        }
        long brokerTimeOut = getBrokerTimeOut(getJmsService());
        // Need to set the following properties
        // BrokerType, BrokerInstanceName, BrokerPort,
        // BrokerArgs, BrokerHomeDir, BrokerVarDir, BrokerStartTimeout
        // adminUserName, adminPassword
        ConnectorDescriptor cd = getDescriptor();
        /*if(jmsPropertiesStr != null){
            	ConnectorConfigProperty  envProp = new ConnectorConfigProperty  (
                    "BrokerProps", jmsPropertiesStr, "Broker Props", "java.lang.String");
            	setProperty(cd, envProp);
	    }  */
        ConnectorConfigProperty envProp1 = new ConnectorConfigProperty(BROKERTYPE, brokerType, "Broker Type", "java.lang.String");
        setProperty(cd, envProp1);
        ConnectorConfigProperty envProp2 = new ConnectorConfigProperty(BROKERINSTANCENAME, brokerInstanceName, "Broker Instance Name", "java.lang.String");
        setProperty(cd, envProp2);
        ConnectorConfigProperty envProp3 = new ConnectorConfigProperty(BROKERPORT, brokerPort, "Broker Port", "java.lang.String");
        setProperty(cd, envProp3);
        ConnectorConfigProperty envProp4 = new ConnectorConfigProperty(BROKERARGS, brokerArgs, "Broker Args", "java.lang.String");
        setProperty(cd, envProp4);
        ConnectorConfigProperty envProp5 = new ConnectorConfigProperty(BROKERHOMEDIR, brokerHomeDir, "Broker Home Dir", "java.lang.String");
        setProperty(cd, envProp5);
        ConnectorConfigProperty envProp14 = new ConnectorConfigProperty(BROKERLIBDIR, brokerLibDir, "Broker Lib Dir", "java.lang.String");
        setProperty(cd, envProp14);
        ConnectorConfigProperty envProp6 = new ConnectorConfigProperty(BROKERJAVADIR, java_home, "Broker Java Dir", "java.lang.String");
        setProperty(cd, envProp6);
        ConnectorConfigProperty envProp7 = new ConnectorConfigProperty(BROKERVARDIR, brokerVarDir, "Broker Var Dir", "java.lang.String");
        setProperty(cd, envProp7);
        ConnectorConfigProperty envProp8 = new ConnectorConfigProperty(BROKERSTARTTIMEOUT, "" + brokerTimeOut, "Broker Start Timeout", "java.lang.String");
        setProperty(cd, envProp8);
        ConnectorConfigProperty envProp9 = new ConnectorConfigProperty(ADMINUSERNAME, adminUserName, "Broker admin username", "java.lang.String");
        setProperty(cd, envProp9);
        ConnectorConfigProperty envProp10 = new ConnectorConfigProperty(ADMINPASSWORD, adminPassword, "Broker admin password", "java.lang.String");
        setProperty(cd, envProp10);
        ConnectorConfigProperty envProp11 = new ConnectorConfigProperty(USERNAME, username, "Broker username", "java.lang.String");
        setProperty(cd, envProp11);
        ConnectorConfigProperty envProp12 = new ConnectorConfigProperty(PASSWORD, password, "Broker password", "java.lang.String");
        setProperty(cd, envProp12);
    /* //set adminpassfile
            if (!getJmsService().getType().equals(REMOTE)) {
                //For LOCAL and EMBEDDED, we pass in the admin pass file path
                //containing the MQ admin password to enable authenticated
                //startup of the broker.
                String adminPassFilePath = getAdminPassFilePath(adminPassword);
                if (adminPassFilePath != null) {
                    ConnectorConfigProperty  envProp13 = new ConnectorConfigProperty  (
                            ADMINPASSFILE , adminPassFilePath ,
                            "Broker admin password", "java.lang.String");
                    setProperty(cd, envProp13);
                }
            }*/
    }
// Optional
// BrokerBindAddress, RmiRegistryPort
}
Also used : JavaConfig(com.sun.enterprise.config.serverbeans.JavaConfig) ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) ArrayList(java.util.ArrayList) List(java.util.List) JmsHost(com.sun.enterprise.connectors.jms.config.JmsHost) Properties(java.util.Properties) Property(org.jvnet.hk2.config.types.Property) EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty) ConnectorConfigProperty(com.sun.enterprise.deployment.ConnectorConfigProperty) ConnectorConfigProperty(com.sun.enterprise.deployment.ConnectorConfigProperty)

Example 17 with ConnectorConfigProperty

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

the class ActiveJmsResourceAdapter method setClusterRABeanProperties.

// //@Siva: provide an API to read JMX information from RA and return it.
// private
/**
 * Sets the SE/EE specific MQ-RA bean properties
 * @throws ConnectorRuntimeException
 */
private void setClusterRABeanProperties() throws ConnectorRuntimeException {
    ConnectorDescriptor cd = super.getDescriptor();
    try {
        if (isClustered()) {
            JmsService jmsService = (JmsService) Globals.get(JmsService.class);
            /* ConfigContext ctx = ApplicationServer.getServerContext().
                    getConfigContext();
            JmsService jmsService = ServerBeansFactory.
                getConfigBean(ctx).getJmsService();    */
            String val = getGroupName();
            ConnectorConfigProperty envProp = new ConnectorConfigProperty(GROUPNAME, val, "Group Name", "java.lang.String");
            setProperty(cd, envProp);
            if (_logger.isLoggable(Level.FINE))
                logFine("CLUSTERED instance - setting groupname as" + val);
            boolean inClusteredContainer = false;
            if (jmsService.getType().equals(EMBEDDED) || jmsService.getType().equals(LOCAL))
                inClusteredContainer = true;
            ConnectorConfigProperty envProp1 = new ConnectorConfigProperty(CLUSTERCONTAINER, Boolean.toString(inClusteredContainer), "Cluster container flag", "java.lang.Boolean");
            setProperty(cd, envProp1);
            if (_logger.isLoggable(Level.FINE))
                logFine("CLUSTERED instance - setting inclusteredcontainer as" + inClusteredContainer);
            if (jmsService.getType().equals(REMOTE)) {
                /*
                * Do not set master broker for remote broker.
                * The RA might ignore it if we set, but we have to
                        * be certain from our end.
                */
                return;
            } else {
                if (!isDBEnabled()) {
                    String masterbrkr = getMasterBroker();
                    ConnectorConfigProperty envProp2 = new ConnectorConfigProperty(MASTERBROKER, masterbrkr, "Master  Broker", "java.lang.String");
                    setProperty(cd, envProp2);
                    if (_logger.isLoggable(Level.FINE))
                        logFine("MASTERBROKER - setting master broker val" + masterbrkr);
                }
            }
        } else {
            if (_logger.isLoggable(Level.FINE))
                logFine("Instance not Clustered and hence not setting " + "groupname");
        }
    } 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) JmsService(com.sun.enterprise.connectors.jms.config.JmsService) 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)

Example 18 with ConnectorConfigProperty

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

the class ActiveJmsResourceAdapter method mergeRAConfiguration.

/**
 * This is a HACK to remove the connection URL
 * in the case of PE LOCAL/EMBEDDED before setting the properties
 * to the RA. If this was not done, MQ RA incorrectly assumed
 * that the passed in connection URL is one additional
 * URL, apart from the default URL derived from brokerhost:brokerport
 * and reported a PE connection url limitation.
 *
 * @return
 */
@Override
protected Set mergeRAConfiguration(ResourceAdapterConfig raConfig, List<Property> raConfigProps) {
    // private void hackMergedProps(Set mergedProps) {
    if (!(connectorRuntime.isServer())) {
        return super.mergeRAConfiguration(raConfig, raConfigProps);
    }
    Set mergedProps = super.mergeRAConfiguration(raConfig, raConfigProps);
    String brokerType = null;
    for (Iterator iter = mergedProps.iterator(); iter.hasNext(); ) {
        ConnectorConfigProperty element = (ConnectorConfigProperty) iter.next();
        if (element.getName().equals(ActiveJmsResourceAdapter.BROKERTYPE)) {
            brokerType = element.getValue();
        }
    }
    boolean cluster = false;
    try {
        cluster = isClustered();
    } catch (Exception e) {
        e.printStackTrace();
    }
    // hack is required only for nonclustered nonremote brokers.
    if (!cluster) {
        if (brokerType.equals(ActiveJmsResourceAdapter.LOCAL) || brokerType.equals(ActiveJmsResourceAdapter.EMBEDDED) || brokerType.equals(ActiveJmsResourceAdapter.DIRECT)) {
            for (Iterator iter = mergedProps.iterator(); iter.hasNext(); ) {
                ConnectorConfigProperty element = (ConnectorConfigProperty) iter.next();
                if (element.getName().equals(ActiveJmsResourceAdapter.CONNECTION_URL)) {
                    iter.remove();
                }
            }
        }
    }
    return mergedProps;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Iterator(java.util.Iterator) 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)

Example 19 with ConnectorConfigProperty

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

the class JmsRaUtil method configureDescriptor.

public void configureDescriptor(ConnectorDescriptor cd) {
    Object[] envProps = cd.getConfigProperties().toArray();
    for (int i = 0; i < envProps.length; i++) {
        ConnectorConfigProperty envProp = (ConnectorConfigProperty) envProps[i];
        String name = envProp.getName();
        if (!name.equals("ConnectionURL")) {
            continue;
        }
        String userValue = getUrl();
        if (userValue != null) {
            cd.removeConfigProperty(envProp);
            cd.addConfigProperty(new ConnectorConfigProperty(name, userValue, userValue, envProp.getType()));
        }
    }
}
Also used : ConnectorConfigProperty(com.sun.enterprise.deployment.ConnectorConfigProperty)

Aggregations

ConnectorConfigProperty (com.sun.enterprise.deployment.ConnectorConfigProperty)19 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)9 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)6 URISyntaxException (java.net.URISyntaxException)6 Set (java.util.Set)6 PrivilegedActionException (java.security.PrivilegedActionException)5 HashSet (java.util.HashSet)5 Iterator (java.util.Iterator)5 ExecutionException (java.util.concurrent.ExecutionException)5 ResourceAdapterInternalException (javax.resource.spi.ResourceAdapterInternalException)5 MultiException (org.glassfish.hk2.api.MultiException)5 ArrayList (java.util.ArrayList)3 ManagedConnectionFactory (javax.resource.spi.ManagedConnectionFactory)3 Property (org.jvnet.hk2.config.types.Property)3 JmsService (com.sun.enterprise.connectors.jms.config.JmsService)2 JmsRaUtil (com.sun.enterprise.connectors.jms.util.JmsRaUtil)2 SetMethodAction (com.sun.enterprise.connectors.util.SetMethodAction)2 Method (java.lang.reflect.Method)2 NamingException (javax.naming.NamingException)2 PoolInfo (org.glassfish.resourcebase.resources.api.PoolInfo)2