use of org.glassfish.resourcebase.resources.api.ResourceStatus 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 org.glassfish.resourcebase.resources.api.ResourceStatus in project Payara by payara.
the class JndiResourceManager method isValid.
private ResourceStatus isValid(Resources resources, boolean validateResourceRef, String target) {
ResourceStatus status;
if (resType == null) {
String msg = localStrings.getLocalString("create.jndi.resource.noResType", "No type defined for JNDI resource.");
return new ResourceStatus(ResourceStatus.FAILURE, msg, true);
}
if (factoryClass == null) {
String msg = localStrings.getLocalString("create.jndi.resource.noFactoryClassName", "No Factory class name defined for JNDI resource.");
return new ResourceStatus(ResourceStatus.FAILURE, msg, true);
}
if (jndiLookupName == null) {
String msg = localStrings.getLocalString("create.jndi.resource.noJndiLookupName", "No Jndi Lookup name defined for JNDI resource.");
return new ResourceStatus(ResourceStatus.FAILURE, msg, true);
}
status = resourcesHelper.validateBindableResourceForDuplicates(resources, jndiName, validateResourceRef, target, ExternalJndiResource.class);
if (status.getStatus() == ResourceStatus.FAILURE) {
return status;
}
return status;
}
use of org.glassfish.resourcebase.resources.api.ResourceStatus in project Payara by payara.
the class ConnectorConnectionPoolManager method isValidRAName.
private ResourceStatus isValidRAName(String raName) {
// TODO turn on validation. For now, turn validation off until connector modules ready
// boolean retVal = false;
ResourceStatus status = new ResourceStatus(ResourceStatus.SUCCESS, "");
if ((raName == null) || (raName.equals(""))) {
String msg = localStrings.getLocalString("admin.mbeans.rmb.null_res_adapter", "Resource Adapter Name is null.");
status = new ResourceStatus(ResourceStatus.FAILURE, msg);
} else {
// System RA, so don't validate
if (!ConnectorsUtil.getNonJdbcSystemRars().contains(raName)) {
// Check if the raName contains double underscore or hash.
// If that is the case then this is the case of an embedded rar,
// hence look for the application which embeds this rar,
// otherwise look for the webconnector module with this raName.
int indx = raName.indexOf(EMBEDDEDRAR_NAME_DELIMITER);
if (indx != -1) {
String appName = raName.substring(0, indx);
Application app = applications.getModule(Application.class, appName);
if (app == null) {
String msg = localStrings.getLocalString("admin.mbeans.rmb.invalid_ra_app_not_found", "Invalid raname. Application with name {0} not found.", appName);
status = new ResourceStatus(ResourceStatus.FAILURE, msg);
}
} else {
Application app = applications.getModule(Application.class, raName);
if (app == null) {
String msg = localStrings.getLocalString("admin.mbeans.rmb.invalid_ra_cm_not_found", "Invalid raname. Connector Module with name {0} not found.", raName);
status = new ResourceStatus(ResourceStatus.FAILURE, msg);
}
}
}
}
return status;
}
use of org.glassfish.resourcebase.resources.api.ResourceStatus in project Payara by payara.
the class ConnectorConnectionPoolManager method createConfigBean.
public Resource createConfigBean(Resources resources, HashMap attributes, Properties properties, boolean validate) throws Exception {
setParams(attributes);
ResourceStatus status = null;
if (!validate) {
status = new ResourceStatus(ResourceStatus.SUCCESS, "");
} else {
status = isValid(resources, false);
}
if (status.getStatus() == ResourceStatus.SUCCESS) {
return createConfigBean(resources, properties);
} else {
throw new ResourceException(status.getMessage());
}
}
use of org.glassfish.resourcebase.resources.api.ResourceStatus in project Payara by payara.
the class ManagedThreadFactoryManager method isValid.
private ResourceStatus isValid(Resources resources, boolean validateResourceRef, String target) {
ResourceStatus status;
if (jndiName == null) {
String msg = localStrings.getLocalString("managed.thread.factory.noJndiName", "No JNDI name defined for managed thread factory.");
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
status = resourcesHelper.validateBindableResourceForDuplicates(resources, jndiName, validateResourceRef, target, ManagedThreadFactory.class);
return status;
}
Aggregations