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);
}
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();
}
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);
}
}
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");
}
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;
}
Aggregations