use of com.sun.enterprise.config.serverbeans.Domain in project Payara by payara.
the class ConcurrentModificationsTest method collectionTest.
@Test(expected = TransactionFailure.class)
public void collectionTest() throws TransactionFailure {
ServiceLocator habitat = super.getHabitat();
final Resources resources = habitat.<Domain>getService(Domain.class).getResources();
assertTrue(resources != null);
ConfigSupport.apply(new SingleConfigCode<Resources>() {
public Object run(Resources writeableResources) throws PropertyVetoException, TransactionFailure {
assertTrue(writeableResources != null);
JdbcResource newResource = writeableResources.createChild(JdbcResource.class);
newResource.setJndiName("foo");
newResource.setDescription("Random ");
newResource.setPoolName("bar");
newResource.setEnabled("true");
writeableResources.getResources().add(newResource);
// now let's check I have my copy...
boolean found = false;
for (Resource resource : writeableResources.getResources()) {
if (resource instanceof JdbcResource) {
JdbcResource jdbc = (JdbcResource) resource;
if (jdbc.getJndiName().equals("foo")) {
found = true;
break;
}
}
}
assertTrue(found);
// now let's check that my readonly copy does not see it...
boolean shouldNot = false;
for (Resource resource : resources.getResources()) {
if (resource instanceof JdbcResource) {
JdbcResource jdbc = (JdbcResource) resource;
if (jdbc.getJndiName().equals("foo")) {
shouldNot = true;
break;
}
}
}
assertFalse(shouldNot);
// now I am throwing a transaction failure since I don't care about saving it
throw new TransactionFailure("Test passed", null);
}
}, resources);
}
use of com.sun.enterprise.config.serverbeans.Domain 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.Domain in project Payara by payara.
the class ActiveJmsResourceAdapter method getClusterName.
private String getClusterName() {
ServerContext serverctx = Globals.get(ServerContext.class);
String instanceName = serverctx.getInstanceName();
Domain domain = Globals.get(Domain.class);
Server server = domain.getServerNamed(instanceName);
return server.getCluster() != null ? server.getCluster().getName() : null;
/*ClusterHelper.getClusterForInstance(this.serverContxt.
.getConfigContext(),
serverContxt.getInstanceName()).getName();*/
}
use of com.sun.enterprise.config.serverbeans.Domain 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.Domain in project Payara by payara.
the class ListJavaMailResourcesTest method setUp.
@Before
public void setUp() {
habitat = getHabitat();
parameters = new ParameterMap();
cr = habitat.getService(CommandRunner.class);
assertTrue(cr != null);
Resources resources = habitat.<Domain>getService(Domain.class).getResources();
context = new AdminCommandContextImpl(LogDomains.getLogger(ListJavaMailResourcesTest.class, LogDomains.ADMIN_LOGGER), new PropsFileActionReporter());
for (Resource resource : resources.getResources()) {
if (resource instanceof MailResource) {
origNum = origNum + 1;
}
}
}
Aggregations