use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.
the class ActiveJmsResourceAdapter method startResourceAdapter.
@Override
protected void startResourceAdapter(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
JmsService jmsService = getJmsService();
if (jmsService != null && jmsService.getType().equals("DISABLED")) {
return;
}
try {
if (this.moduleName_.equals(ConnectorRuntime.DEFAULT_JMS_ADAPTER)) {
if (connectorRuntime.isServer()) {
Domain domain = Globals.get(Domain.class);
ServerContext serverContext = Globals.get(ServerContext.class);
Server server = domain.getServerNamed(serverContext.getInstanceName());
try {
initializeLazyListener(jmsService);
} catch (Throwable ex) {
Logger.getLogger(ActiveJmsResourceAdapter.class.getName()).log(Level.SEVERE, null, ex);
throw new ResourceAdapterInternalException(ex);
}
}
// System.setProperty("imq.jmsra.direct.clustered", "true");
AccessController.doPrivileged(new java.security.PrivilegedExceptionAction() {
public Object run() throws ResourceAdapterInternalException {
// set the JMSRA system property to enable XA JOINS
// disabling this due to issue - 8727
// System.setProperty(XA_JOIN_ALLOWED, "true");
// to prevent classloader leaks in new threads clear invocation manager before bootstrapping JMS
resourceadapter_.start(bootStrapContextImpl);
return null;
}
});
// setResourceAdapter(resourceadapter_);
} else {
resourceadapter_.start(bootStrapContextImpl);
}
} catch (PrivilegedActionException ex) {
throw new ResourceAdapterInternalException(ex);
}
}
use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.
the class ActiveJmsResourceAdapter method isDBEnabled.
private boolean isDBEnabled() {
Domain domain = Globals.get(Domain.class);
ServerContext serverContext = Globals.get(ServerContext.class);
Server server = domain.getServerNamed(serverContext.getInstanceName());
AvailabilityService as = server.getConfig().getAvailabilityService();
if (as != null) {
JmsAvailability jmsAvailability = as.getExtensionByType(JmsAvailability.class);
if (jmsAvailability.getAvailabilityEnabled() != null && Boolean.parseBoolean(jmsAvailability.getAvailabilityEnabled())) {
return true;
} else if (jmsAvailability.getConfigStoreType() != null && !"MASTERBROKER".equalsIgnoreCase(jmsAvailability.getConfigStoreType()))
return true;
}
return false;
}
use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.
the class JMSPing 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();
Server targetServer = domain.getServerNamed(target);
// String configRef = targetServer.getConfigRef();
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());
}
JmsService jmsservice = config.getExtensionByType(JmsService.class);
/* for (Config c : configs.getConfig()) {
if(configRef.equals(c.getName()))
jmsservice = c.getJmsService();
} */
String defaultJmshostStr = jmsservice.getDefaultJmsHost();
JmsHost defaultJmsHost = null;
for (JmsHost jmshost : jmsservice.getJmsHost()) {
if (jmshost.getName().equals(defaultJmshostStr)) {
defaultJmsHost = jmshost;
}
}
if (defaultJmsHost == null) {
report.setMessage(localStrings.getLocalString("jms-ping.noDefaultJMSHost", "Unable to PING the JMS Broker as no Default JMS Host is configured on the DAS"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
String tmpJMSResource = "test_jms_adapter";
ActionReport subReport = report.addSubActionsReport();
createJMSResource(defaultJmsHost, subReport, tmpJMSResource, context.getSubject());
if (ActionReport.ExitCode.FAILURE.equals(subReport.getActionExitCode())) {
report.setMessage(localStrings.getLocalString("jms-ping.cannotCreateJMSResource", "Unable to create a temporary Connection Factory to the JMS Host"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
try {
boolean value = pingConnectionPool(tmpJMSResource + JNDINAME_APPENDER);
if (!value) {
report.setMessage(localStrings.getLocalString("jms-ping.pingConnectionPoolFailed", "Pinging to the JMS Host failed."));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
} else {
report.setMessage(localStrings.getLocalString("jms-ping.pingConnectionPoolSuccess", "JMS-ping command executed successfully"));
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
} catch (ResourceException e) {
report.setMessage(localStrings.getLocalString("jms-ping.pingConnectionPoolException", "An exception occured while trying to ping the JMS Host.", e.getMessage()));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
}
deleteJMSResource(subReport, tmpJMSResource, context.getSubject());
if (ActionReport.ExitCode.FAILURE.equals(subReport.getActionExitCode())) {
report.setMessage(localStrings.getLocalString("jms-ping.cannotdeleteJMSResource", "Unable to delete the temporary JMS Resource " + tmpJMSResource + ". Please delete this manually.", tmpJMSResource));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
}
use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.
the class MigrateTimers method validateCluster.
private String validateCluster() {
// verify fromServer is clusteredInstance
Cluster fromServerCluster = targetUtil.getClusterForInstance(fromServer);
if (fromServerCluster == null) {
return localStrings.getString("migrate.timers.fromServerNotClusteredInstance", fromServer);
}
// verify fromServer is not running
if (isServerRunning(fromServer)) {
return localStrings.getString("migrate.timers.migrateFromServerStillRunning", fromServer);
}
// in the same cluster as fromServer
if (target.equals(SystemPropertyConstants.DEFAULT_SERVER_INSTANCE_NAME)) {
List<Server> instances = fromServerCluster.getInstances();
for (Server instance : instances) {
if (instance.isRunning()) {
target = instance.getName();
needRedirect = true;
}
}
// if destination is still DAS, that means no running server is available
if (target.equals(SystemPropertyConstants.DEFAULT_SERVER_INSTANCE_NAME)) {
return localStrings.getString("migrate.timers.noRunningInstanceToChoose", target);
}
} else {
// verify fromServer and destinationServer are in the same cluster, and
// verify destination is a clustered instance.
Cluster destinationServerCluster = targetUtil.getClusterForInstance(target);
if (!fromServerCluster.getName().equals(destinationServerCluster.getName())) {
return localStrings.getString("migrate.timers.fromServerAndTargetNotInSameCluster", fromServer, target);
}
// verify destinationServer is running
if (!isServerRunning(target)) {
return localStrings.getString("migrate.timers.destinationServerIsNotAlive", target);
}
}
return null;
}
use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.
the class GetHostAndPortCommand method getAccessChecks.
@Override
public Collection<? extends AccessCheck> getAccessChecks() {
final List<AccessCheck> accessChecks = new ArrayList<AccessCheck>();
String configName = null;
Server server = domain.getServerNamed(target);
if (server != null) {
configName = server.getConfigRef();
} else {
Cluster cluster = domain.getClusterNamed(target);
if (cluster != null) {
configName = cluster.getConfigRef();
}
}
config = configs.getConfigByName(configName);
if (config != null) {
accessChecks.add(new AccessCheck(AccessRequired.Util.resourceNameFromConfigBeanProxy(config), "read"));
}
return accessChecks;
}
Aggregations