use of org.glassfish.connectors.config.ResourceAdapterConfig in project Payara by payara.
the class ActiveOutboundResourceAdapter method init.
/**
* Creates an active inbound resource adapter. Sets all RA java bean
* properties and issues a start.
*
* @param ra <code>ResourceAdapter<code> java bean.
* @param desc <code>ConnectorDescriptor</code> object.
* @param moduleName Resource adapter module name.
* @param jcl <code>ClassLoader</code> instance.
* @throws ConnectorRuntimeException If there is a failure in loading
* or starting the resource adapter.
*/
public void init(ResourceAdapter ra, ConnectorDescriptor desc, String moduleName, ClassLoader jcl) throws ConnectorRuntimeException {
super.init(ra, desc, moduleName, jcl);
this.resourceadapter_ = ra;
if (resourceadapter_ != null) {
try {
loadRAConfiguration();
// now the RA bean would have been fully configured (taking into account, resource-adapter-config),
// validate the RA bean now.
beanValidator.validateJavaBean(ra, moduleName);
ConnectorRegistry registry = ConnectorRegistry.getInstance();
String poolId = null;
ResourceAdapterConfig raConfig = registry.getResourceAdapterConfig(moduleName_);
if (raConfig != null) {
poolId = raConfig.getThreadPoolIds();
}
this.bootStrapContextImpl = new BootstrapContextImpl(poolId, moduleName_, jcl);
validateWorkContextSupport(desc);
startResourceAdapter(bootStrapContextImpl);
} catch (ResourceAdapterInternalException ex) {
_logger.log(Level.SEVERE, "rardeployment.start_failed", ex);
String i18nMsg = localStrings.getString("rardeployment.start_failed", ex.getMessage());
ConnectorRuntimeException cre = new ConnectorRuntimeException(i18nMsg);
cre.initCause(ex);
throw cre;
} catch (Throwable t) {
_logger.log(Level.SEVERE, "rardeployment.start_failed", t);
String i18nMsg = localStrings.getString("rardeployment.start_failed", t.getMessage());
ConnectorRuntimeException cre = new ConnectorRuntimeException(i18nMsg);
if (t.getCause() != null) {
cre.initCause(t.getCause());
} else {
cre.initCause(t);
}
throw cre;
}
}
}
use of org.glassfish.connectors.config.ResourceAdapterConfig in project Payara by payara.
the class ListResourceAdapterConfigs 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();
try {
HashMap<String, List<Property>> raMap = new HashMap<String, List<Property>>();
boolean raExists = false;
Collection<ResourceAdapterConfig> resourceAdapterConfigs = domain.getResources().getResources(ResourceAdapterConfig.class);
for (ResourceAdapterConfig r : resourceAdapterConfigs) {
if (raName != null && !raName.isEmpty()) {
if (r.getResourceAdapterName().equals(raName)) {
raMap.put(raName, r.getProperty());
raExists = true;
break;
}
} else {
raMap.put(r.getResourceAdapterName(), r.getProperty());
}
}
if (raName != null && !raName.isEmpty() && !raExists) {
report.setMessage(localStrings.getLocalString("delete.resource.adapter.config.notfound", "Resource adapter {0} not found.", raName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
/**
* get the properties if long_opt=true. Otherwise return the name.
*/
if (long_opt) {
for (Entry<String, List<Property>> raEntry : raMap.entrySet()) {
final ActionReport.MessagePart part = report.getTopMessagePart().addChild();
part.setMessage(raEntry.getKey());
for (Property prop : raEntry.getValue()) {
final ActionReport.MessagePart propPart = part.addChild();
propPart.setMessage("\t" + prop.getName() + "=" + prop.getValue());
}
}
} else {
for (String ra : raMap.keySet()) {
final ActionReport.MessagePart part = report.getTopMessagePart().addChild();
part.setMessage(ra);
}
}
} catch (Exception e) {
String failMsg = localStrings.getLocalString("list.resource.adapter.configs.fail", "Unable to list resource adapter configs.");
Logger.getLogger(ListResourceAdapterConfigs.class.getName()).log(Level.SEVERE, failMsg, e);
report.setMessage(failMsg + " " + e.getLocalizedMessage());
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
use of org.glassfish.connectors.config.ResourceAdapterConfig in project Payara by payara.
the class ActiveOutboundResourceAdapter method loadRAConfiguration.
/**
* Loads RA javabean. This method is protected, so that any system
* resource adapter can have specific configuration done during the
* loading.
*
* @throws ConnectorRuntimeException if there is a failure.
*/
protected void loadRAConfiguration() throws ConnectorRuntimeException {
try {
Set mergedProps;
ConnectorRegistry registry = ConnectorRegistry.getInstance();
ResourceAdapterConfig raConfig = registry.getResourceAdapterConfig(moduleName_);
List<Property> raConfigProps = new ArrayList<Property>();
mergedProps = mergeRAConfiguration(raConfig, raConfigProps);
logMergedProperties(mergedProps);
SetMethodAction setMethodAction = new SetMethodAction(this.resourceadapter_, mergedProps);
setMethodAction.run();
} catch (Exception e) {
String i18nMsg = localStrings.getString("ccp_adm.wrong_params_for_create", e.getMessage());
ConnectorRuntimeException cre = new ConnectorRuntimeException(i18nMsg);
cre.initCause(e);
throw cre;
}
}
use of org.glassfish.connectors.config.ResourceAdapterConfig in project Payara by payara.
the class ResourceAdapterConfigDeployer method undeployResource.
/**
* {@inheritDoc}
*/
public synchronized void undeployResource(Object resource) throws Exception {
ResourceAdapterConfig domainConfig = (ResourceAdapterConfig) resource;
String rarName = domainConfig.getResourceAdapterName();
ConnectorRuntime crt = getConnectorRuntime();
crt.deleteResourceAdapterConfig(rarName);
}
use of org.glassfish.connectors.config.ResourceAdapterConfig in project Payara by payara.
the class ResourceAdapterConfigDeployer method deployResource.
/**
* {@inheritDoc}
*/
public synchronized void deployResource(Object resource) throws Exception {
ResourceAdapterConfig domainConfig = (ResourceAdapterConfig) resource;
String rarName = domainConfig.getResourceAdapterName();
ConnectorRuntime crt = getConnectorRuntime();
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Calling backend to add resource adapterConfig ", rarName);
}
crt.addResourceAdapterConfig(rarName, domainConfig);
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Added resource adapterConfig in backend", rarName);
}
}
Aggregations