use of com.sun.enterprise.config.serverbeans.Resource in project Payara by payara.
the class DeleteJavaMailResourceTest method tearDown.
@After
public void tearDown() throws TransactionFailure {
ConfigSupport.apply(new SingleConfigCode<Resources>() {
public Object run(Resources param) throws PropertyVetoException, TransactionFailure {
Resource target = null;
for (Resource resource : param.getResources()) {
if (resource instanceof MailResource) {
MailResource r = (MailResource) resource;
if (r.getJndiName().equals("mail/MyMailSession")) {
target = resource;
break;
}
}
}
if (target != null) {
param.getResources().remove(target);
}
return null;
}
}, resources);
parameters = new ParameterMap();
}
use of com.sun.enterprise.config.serverbeans.Resource in project Payara by payara.
the class CreateJndiResourceTest method testExecuteWithOptionalValuesSet.
/**
* Test of execute method, of class CreateJndiResource.
* asadmin create-jndi-resource --restype=queue --factoryclass=sampleClass --jndilookupname=sample_jndi
* --enabled=false --description=External JNDI Resource
* sample_jndi_resource
*/
@Test
public void testExecuteWithOptionalValuesSet() {
parameters.set("jndilookupname", "sample_jndi");
parameters.set("restype", "queue");
parameters.set("factoryclass", "sampleClass");
parameters.set("enabled", "false");
parameters.set("description", "External JNDI Resource");
parameters.set("jndi_name", "sample_jndi_resource");
org.glassfish.resources.admin.cli.CreateJndiResource command = habitat.getService(org.glassfish.resources.admin.cli.CreateJndiResource.class);
cr.getCommandInvocation("create-jndi-resource", context.getActionReport(), adminSubject()).parameters(parameters).execute(command);
assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
boolean isCreated = false;
for (Resource resource : resources.getResources()) {
if (resource instanceof ExternalJndiResource) {
ExternalJndiResource r = (ExternalJndiResource) resource;
if (r.getJndiName().equals("sample_jndi_resource")) {
assertEquals("queue", r.getResType());
assertEquals("sampleClass", r.getFactoryClass());
assertEquals("sample_jndi", r.getJndiLookupName());
// expect enabled for the resource to be true as resource-ref's enabled
// would be set to false
assertEquals("true", r.getEnabled());
assertEquals("External JNDI Resource", r.getDescription());
isCreated = true;
logger.fine("Jndi Resource config bean sample_jndi_resource is created.");
break;
}
}
}
assertTrue(isCreated);
/*
ResourceRef ref = server.getResourceRef("sample_jndi_resource");
assertTrue(ref != null);
assertEquals("false", ref.getEnabled());
*/
logger.fine("msg: " + context.getActionReport().getMessage());
}
use of com.sun.enterprise.config.serverbeans.Resource in project Payara by payara.
the class DeleteJndiResourceTest method testExecuteSuccessDefaultTarget.
/**
* Test of execute method, of class DeleteJndiResource.
* asadmin create-jndi-resource --restype=queue --factoryclass=sampleClass --jndilookupname=sample_jndi
* sample_jndi_resource
* delete-jndi-resource sample_jndi_resource
*/
@Test
public void testExecuteSuccessDefaultTarget() {
parameters.set("restype", "topic");
parameters.set("jndilookupname", "sample_jndi");
parameters.set("factoryclass", "javax.naming.spi.ObjectFactory");
parameters.set("jndi_name", "sample_jndi_resource");
org.glassfish.resources.admin.cli.CreateJndiResource createCommand = habitat.getService(org.glassfish.resources.admin.cli.CreateJndiResource.class);
cr.getCommandInvocation("create-jndi-resource", context.getActionReport(), adminSubject()).parameters(parameters).execute(createCommand);
assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
parameters = new ParameterMap();
parameters.set("jndi_name", "sample_jndi_resource");
org.glassfish.resources.admin.cli.DeleteJndiResource deleteCommand = habitat.getService(org.glassfish.resources.admin.cli.DeleteJndiResource.class);
cr.getCommandInvocation("delete-jndi-resource", context.getActionReport(), adminSubject()).parameters(parameters).execute(deleteCommand);
assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode());
boolean isDeleted = true;
for (Resource resource : resources.getResources()) {
if (resource instanceof BindableResource) {
BindableResource jr = (BindableResource) resource;
if (jr.getJndiName().equals("sample_jndi_resource")) {
isDeleted = false;
logger.fine("Jndi Resource config bean sample_jndi_resource is created.");
break;
}
}
}
assertTrue(isDeleted);
logger.fine("msg: " + context.getActionReport().getMessage());
Servers servers = habitat.getService(Servers.class);
boolean isRefDeleted = true;
for (Server server : servers.getServer()) {
if (server.getName().equals(SystemPropertyConstants.DEFAULT_SERVER_INSTANCE_NAME)) {
for (ResourceRef ref : server.getResourceRef()) {
if (ref.getRef().equals("sample_jndi_resource")) {
isRefDeleted = false;
break;
}
}
}
}
assertTrue(isRefDeleted);
}
use of com.sun.enterprise.config.serverbeans.Resource in project Payara by payara.
the class ConnectorApplication method deployGlobalResources.
private void deployGlobalResources() {
Resources allResources = resourceManager.getAllResources();
Collection<Resource> resources = resourcesUtil.filterConnectorResources(allResources, moduleName, false);
resourceManager.deployResources(resources);
}
use of com.sun.enterprise.config.serverbeans.Resource in project Payara by payara.
the class ConnectorService method loadDeferredResources.
public void loadDeferredResources(Resource[] resourcesToLoad) throws Exception {
if (resourcesToLoad == null || resourcesToLoad.length == 0) {
return;
}
for (Resource resource : resourcesToLoad) {
if (resource == null) {
continue;
} else if (getResourcesUtil().isEnabled(resource)) {
try {
_runtime.getResourceDeployer(resource).deployResource(resource);
} catch (Exception e) {
ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage());
cre.initCause(e);
throw cre;
}
}
}
}
Aggregations