use of com.sun.enterprise.config.serverbeans.Resources in project Payara by payara.
the class JndiResourceManager method create.
public ResourceStatus create(Resources resources, HashMap attributes, final Properties properties, String target) throws Exception {
setAttributes(attributes, target);
ResourceStatus validationStatus = isValid(resources, true, target);
if (validationStatus.getStatus() == ResourceStatus.FAILURE) {
return validationStatus;
}
try {
ConfigSupport.apply(new SingleConfigCode<Resources>() {
public Object run(Resources param) throws PropertyVetoException, TransactionFailure {
return createResource(param, properties);
}
}, resources);
resourceUtil.createResourceRef(jndiName, enabledValueForTarget, target);
} catch (TransactionFailure tfe) {
String msg = localStrings.getLocalString("create.jndi.resource.fail", "Unable to create jndi resource {0}.", jndiName) + " " + tfe.getLocalizedMessage();
return new ResourceStatus(ResourceStatus.FAILURE, msg, true);
}
String msg = localStrings.getLocalString("create.jndi.resource.success", "jndi resource {0} created.", jndiName);
return new ResourceStatus(ResourceStatus.SUCCESS, msg, true);
}
use of com.sun.enterprise.config.serverbeans.Resources 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;
}
}
}
use of com.sun.enterprise.config.serverbeans.Resources in project Payara by payara.
the class DeleteJndiResource 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();
// ensure we already have this resource
if (!doesResourceExist(domain.getResources(), jndiName)) {
report.setMessage(localStrings.getLocalString("delete.jndi.resource.notfound", "A jndi resource named {0} does not exist.", jndiName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
if (environment.isDas()) {
if ("domain".equals(target)) {
if (resourceUtil.getTargetsReferringResourceRef(jndiName).size() > 0) {
report.setMessage(localStrings.getLocalString("delete.jndi.resource.resource-ref.exist", "external-jndi-resource [ {0} ] is referenced in an" + "instance/cluster target, Use delete-resource-ref on appropriate target", jndiName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
} else {
if (!resourceUtil.isResourceRefInTarget(jndiName, target)) {
report.setMessage(localStrings.getLocalString("delete.jndi.resource.no.resource-ref", "external-jndi-resource [ {0} ] is not referenced in target [ {1} ]", jndiName, target));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
if (resourceUtil.getTargetsReferringResourceRef(jndiName).size() > 1) {
report.setMessage(localStrings.getLocalString("delete.jndi.resource.multiple.resource-refs", "external-jndi-resource [ {0} ] is referenced in multiple " + "instance/cluster targets, Use delete-resource-ref on appropriate target", jndiName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
}
}
try {
// delete resource-ref
resourceUtil.deleteResourceRef(jndiName, target);
// delete external-jndi-resource
ConfigSupport.apply(new SingleConfigCode<Resources>() {
public Object run(Resources param) throws PropertyVetoException, TransactionFailure {
ExternalJndiResource resource = (ExternalJndiResource) domain.getResources().getResourceByName(ExternalJndiResource.class, jndiName);
if (resource.getJndiName().equals(jndiName)) {
return param.getResources().remove(resource);
}
return null;
}
}, domain.getResources());
report.setMessage(localStrings.getLocalString("" + "delete.jndi.resource.success", "Jndi resource {0} deleted.", jndiName));
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
} catch (TransactionFailure tfe) {
report.setMessage(localStrings.getLocalString("" + "delete.jndi.resource.fail", "Unable to delete jndi resource {0}.", jndiName) + " " + tfe.getLocalizedMessage());
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(tfe);
}
}
use of com.sun.enterprise.config.serverbeans.Resources in project Payara by payara.
the class JdbcConnectionPoolDeployer method handlePoolRecreationForExistingProxies.
private void handlePoolRecreationForExistingProxies(ConnectorConnectionPool connConnPool) {
recreatePool(connConnPool);
Collection<BindableResource> resourcesList;
if (!connConnPool.isApplicationScopedResource()) {
resourcesList = JdbcResourcesUtil.getResourcesOfPool(domain.getResources(), connConnPool.getName());
} else {
PoolInfo poolInfo = connConnPool.getPoolInfo();
Resources resources = ResourcesUtil.createInstance().getResources(poolInfo);
resourcesList = JdbcResourcesUtil.getResourcesOfPool(resources, connConnPool.getName());
}
for (BindableResource bindableResource : resourcesList) {
ResourceInfo resourceInfo = ConnectorsUtil.getResourceInfo(bindableResource);
ConnectorRegistry.getInstance().updateResourceInfoVersion(resourceInfo);
}
}
use of com.sun.enterprise.config.serverbeans.Resources in project Payara by payara.
the class JdbcRecoveryResourceHandler method getAllJdbcResources.
private Collection<JdbcResource> getAllJdbcResources() {
Collection<JdbcResource> allResources = new ArrayList<JdbcResource>();
Collection<JdbcResource> jdbcResources = domain.getResources().getResources(JdbcResource.class);
allResources.addAll(jdbcResources);
for (Application app : applications.getApplications()) {
if (ResourcesUtil.createInstance().isEnabled(app)) {
Resources appScopedResources = app.getResources();
if (appScopedResources != null && appScopedResources.getResources() != null) {
allResources.addAll(appScopedResources.getResources(JdbcResource.class));
}
List<Module> modules = app.getModule();
if (modules != null) {
for (Module module : modules) {
Resources msr = module.getResources();
if (msr != null && msr.getResources() != null) {
allResources.addAll(msr.getResources(JdbcResource.class));
}
}
}
}
}
return allResources;
}
Aggregations