Search in sources :

Example 11 with JmsService

use of com.sun.enterprise.connectors.jms.config.JmsService in project Payara by payara.

the class DeleteJMSHost method execute.

/**
 * Executes the command with the command parameters passed as Properties
 * where the keys are the paramter names and the values the parameter values
 *
 * @param context information
 */
public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    Config targetConfig = domain.getConfigNamed(target);
    if (targetConfig != null)
        config = targetConfig;
    Server targetServer = domain.getServerNamed(target);
    if (targetServer != null) {
        config = domain.getConfigNamed(targetServer.getConfigRef());
    }
    com.sun.enterprise.config.serverbeans.Cluster cluster = domain.getClusterNamed(target);
    if (cluster != null) {
        config = domain.getConfigNamed(cluster.getConfigRef());
    }
    if (jmsHostName == null) {
        report.setMessage(localStrings.getLocalString("delete.jms.host.noHostName", "No JMS Host Name specified for JMS Host."));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    JmsService jmsService = config.getExtensionByType(JmsService.class);
    if (jmsService == null) {
        report.setMessage(localStrings.getLocalString("list.jms.host.invalidTarget", "Invalid Target specified."));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    JmsHost jmsHost = null;
    for (JmsHost r : jmsService.getJmsHost()) {
        if (jmsHostName.equals(r.getName())) {
            jmsHost = r;
            break;
        }
    }
    if (jmsHost == null) {
        report.setMessage(localStrings.getLocalString("list.jms.host.noJmsHostFound", "JMS Host {0} does not exist.", jmsHostName));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    final JmsHost jHost = jmsHost;
    try {
        ConfigSupport.apply(new SingleConfigCode<JmsService>() {

            public Object run(JmsService param) throws PropertyVetoException, TransactionFailure {
                return param.getJmsHost().remove(jHost);
            }
        }, jmsService);
    } catch (TransactionFailure tfe) {
        report.setMessage(localStrings.getLocalString("delete.jms.host.fail", "Unable to delete jms host {0}.", jmsHostName) + " " + tfe.getLocalizedMessage());
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(tfe);
    }
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) JmsService(com.sun.enterprise.connectors.jms.config.JmsService) ActionReport(org.glassfish.api.ActionReport) com.sun.enterprise.config.serverbeans(com.sun.enterprise.config.serverbeans) PropertyVetoException(java.beans.PropertyVetoException) JmsHost(com.sun.enterprise.connectors.jms.config.JmsHost)

Example 12 with JmsService

use of com.sun.enterprise.connectors.jms.config.JmsService in project Payara by payara.

the class JmsProviderLifecycle method postConstruct.

public void postConstruct() {
    final JmsService jmsService = config.getExtensionByType(JmsService.class);
    brokerType = BROKER_TYPE.valueOf(jmsService.getType());
    configureConfigListener();
    if (brokerType == BROKER_TYPE.DISABLED) {
        return;
    }
    if (eagerStartupRequired()) {
        try {
            initializeBroker();
        } catch (ConnectorRuntimeException e) {
            e.printStackTrace();
            // _logger.log(Level.WARNING, "Failed to start JMS RA");
            e.printStackTrace();
        }
    }
    try {
        activeJmsResourceAdapter.initializeLazyListener(jmsService);
    } catch (JmsInitialisationException ex) {
        Logger.getLogger(JmsProviderLifecycle.class.getName()).log(Level.SEVERE, null, ex);
        throw new IllegalStateException(ex);
    }
// createMonitoringConfig();
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) JmsService(com.sun.enterprise.connectors.jms.config.JmsService)

Example 13 with JmsService

use of com.sun.enterprise.connectors.jms.config.JmsService in project Payara by payara.

the class MQAddressList method defaultSetup.

/**
 * Default setup concatanates all JMSHosts in a JMSService to create the address list
 */
private void defaultSetup() throws Exception {
    logFine("performing defaultsetup");
    JmsService jmsService = Globals.get(JmsService.class);
    List hosts = jmsService.getJmsHost();
    for (int i = 0; i < hosts.size(); i++) {
        MQUrl url = createUrl((JmsHost) hosts.get(i));
        urlList.add(url);
    }
}
Also used : JmsService(com.sun.enterprise.connectors.jms.config.JmsService)

Example 14 with JmsService

use of com.sun.enterprise.connectors.jms.config.JmsService in project Payara by payara.

the class MQAddressList method getMasterJmsHostInCluster.

private JmsHost getMasterJmsHostInCluster(String clusterName) throws Exception {
    Domain domain = Globals.get(Domain.class);
    Cluster cluster = domain.getClusterNamed(clusterName);
    /*
           Since GF 3.1 - Added a new way to configure the master broker
           Check if a master broker has been configured by looking at jmsService.getMasterBroker
           If it is configured, return th
           If not, use the first configured server in the cluster list as the master broker
         */
    Config config = domain.getConfigNamed(cluster.getConfigRef());
    JmsService jmsService = config.getExtensionByType(JmsService.class);
    Server masterBrokerInstance = null;
    String masterBrokerInstanceName = jmsService.getMasterBroker();
    if (masterBrokerInstanceName != null) {
        masterBrokerInstance = domain.getServerNamed(masterBrokerInstanceName);
    } else {
        Server[] buddies = getServersInCluster(cluster);
        // there may be hosts attached to an NA that is down
        if (buddies.length > 0) {
            masterBrokerInstance = buddies[0];
        }
    }
    final JmsHost copy = getResolvedJmsHost(masterBrokerInstance);
    if (copy != null)
        return copy;
    else
        throw new RuntimeException("No JMS hosts available to select as Master");
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) JmsService(com.sun.enterprise.connectors.jms.config.JmsService) JmsHost(com.sun.enterprise.connectors.jms.config.JmsHost)

Example 15 with JmsService

use of com.sun.enterprise.connectors.jms.config.JmsService in project Payara by payara.

the class MQAddressList method getResolvedLocalJmsHostInServer.

/*static JmsHost jmsHostcopy = null;
     private JmsHost createJmsHostCopy(final JmsHost jmsHost, final Server server)
        {
        try {
            //jmsHost.deepCopy();
             ConfigSupport.apply(new SingleConfigCode<JmsService>() {
                public Object run(JmsService param) throws PropertyVetoException, TransactionFailure {

                    final JmsHost jmsHost = param.createChild(JmsHost.class); //TODO: need a way to create a JmsHost instance
                    jmsHost.setAdminPassword(jmsHost.getAdminPassword());
                    jmsHost.setAdminUserName(jmsHost.getAdminUserName());
                    jmsHost.setName(jmsHost.getName());
                    jmsHost.setHost(jmsHost.getHost());
                    jmsHost.setPort(jmsHost.getPort());
                    MQAddressList.jmsHostcopy = jmsHost;
                    return jmsHost;
                }
            }, getConfigForServer(server).getJmsService());
        } catch(TransactionFailure tfe) {
            //tfe.printStackTrace();//todo: handle this exception
        }
        return jmsHostcopy;
     }*/
private JmsHost getResolvedLocalJmsHostInServer(final Server server) {
    Config config = getConfigForServer(server);
    if (config != null) {
        JmsService jmsService = config.getExtensionByType(JmsService.class);
        JmsHost jmsHost = null;
        if (JMSServiceType.LOCAL.toString().equals(jmsService.getType()) || JMSServiceType.EMBEDDED.toString().equals(jmsService.getType())) {
            jmsHost = getDefaultJmsHost(jmsService);
        }
        return (jmsHost);
    }
    return null;
}
Also used : JmsService(com.sun.enterprise.connectors.jms.config.JmsService) JmsHost(com.sun.enterprise.connectors.jms.config.JmsHost)

Aggregations

JmsService (com.sun.enterprise.connectors.jms.config.JmsService)22 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)10 JmsHost (com.sun.enterprise.connectors.jms.config.JmsHost)10 PrivilegedActionException (java.security.PrivilegedActionException)6 ResourceAdapterInternalException (javax.resource.spi.ResourceAdapterInternalException)6 ActionReport (org.glassfish.api.ActionReport)6 PropertyVetoException (java.beans.PropertyVetoException)5 URISyntaxException (java.net.URISyntaxException)5 ExecutionException (java.util.concurrent.ExecutionException)5 MultiException (org.glassfish.hk2.api.MultiException)5 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)4 com.sun.enterprise.config.serverbeans (com.sun.enterprise.config.serverbeans)3 Cluster (com.sun.enterprise.config.serverbeans.Cluster)3 Server (com.sun.enterprise.config.serverbeans.Server)3 ServerContext (org.glassfish.internal.api.ServerContext)3 Domain (com.sun.enterprise.config.serverbeans.Domain)2 JmsAvailability (com.sun.enterprise.connectors.jms.config.JmsAvailability)2 ActiveJmsResourceAdapter (com.sun.enterprise.connectors.jms.system.ActiveJmsResourceAdapter)2 ConnectorConfigProperty (com.sun.enterprise.deployment.ConnectorConfigProperty)2 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)2