use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.
the class ConnectorMessageBeanClient method getResourceAdapterMid.
/**
* derive the resource-adapter-mid in the following order <br/>
* a) specified in the glassfish-ejb-jar / sun-ejb-jar descriptor<br/>
* b) jms-ra message-listener of type javax.jms.MessageListener<br/>
* c) Check the resource-adapters supporting the message-listener-type and
* if there is only one use it, otherwise fail.<br/>
* @param descriptor_ EJB Descriptor
* @return resource-adapter-mid (resource-adapter-name)
* @throws ConnectorRuntimeException
*/
private String getResourceAdapterMid(EjbMessageBeanDescriptor descriptor_) throws ConnectorRuntimeException {
String resourceAdapterMid = descriptor_.getResourceAdapterMid();
if (resourceAdapterMid == null) {
resourceAdapterMid = System.getProperty(RA_MID);
}
if (resourceAdapterMid == null) {
String messageListener = descriptor_.getMessageListenerType();
// will take care of the case when the message-listener-type is not specified in the DD
if (ConnectorConstants.JMS_MESSAGE_LISTENER.equals(messageListener)) {
resourceAdapterMid = ConnectorRuntime.DEFAULT_JMS_ADAPTER;
logger.fine("No ra-mid is specified, using default JMS Resource Adapter for message-listener-type " + "[" + descriptor_.getMessageListenerType() + "]");
} else {
List<String> resourceAdapters = ConnectorRegistry.getInstance().getConnectorsSupportingMessageListener(messageListener);
if (resourceAdapters.size() == 1) {
resourceAdapterMid = resourceAdapters.get(0);
String message = localStrings.getString("msg-bean-client.defaulting.message-listener.supporting.rar", resourceAdapterMid, messageListener);
logger.info(message);
} else if (resourceAdapters.size() <= 0) {
String message = localStrings.getString("msg-bean-client.could-not-detect-ra-mid", descriptor_.getMessageListenerType());
throw new ConnectorRuntimeException(message);
} else {
String message = localStrings.getString("msg-bean-client.multiple-ras-supporting-message-listener", messageListener);
throw new ConnectorRuntimeException(message);
}
}
}
return resourceAdapterMid;
}
use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.
the class ConnectorDescriptorProxy method create.
public Object create(Context ic) throws NamingException {
// of this particular connector descriptor and also only for first time (initialization)
synchronized (this) {
if (desc == null) {
try {
desc = getConnectorRuntime().getConnectorDescriptor(rarName);
ic.rebind(jndiName, desc);
} catch (ConnectorRuntimeException e) {
NamingException ne = new NamingException(e.getMessage());
ne.initCause(e);
throw ne;
}
}
}
return desc;
}
use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException 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 com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.
the class ActiveOutboundResourceAdapter method addAdminObject.
/**
* Creates an admin object.
*
* @param appName Name of application, in case of embedded rar.
* @param connectorName Module name of the resource adapter.
* @param jndiName JNDI name to be registered.
* @param adminObjectType Interface name of the admin object.
* @param props <code>Properties</code> object containing name/value
* pairs of properties.
*/
public void addAdminObject(String appName, String connectorName, ResourceInfo resourceInfo, String adminObjectType, String adminObjectClassName, Properties props) throws ConnectorRuntimeException {
if (props == null) {
// empty properties
props = new Properties();
}
ConnectorRegistry registry = ConnectorRegistry.getInstance();
ConnectorDescriptor desc = registry.getDescriptor(connectorName);
AdminObject aoDesc = null;
// or the combination of the both names.
if (adminObjectClassName == null || adminObjectClassName.trim().equals("")) {
// get AO through interface name
List<AdminObject> adminObjects = desc.getAdminObjectsByType(adminObjectType);
if (adminObjects.size() > 1) {
String msg = localStrings.getString("aor.could_not_determine_aor_type", adminObjectType);
throw new ConnectorRuntimeException(msg);
} else {
aoDesc = adminObjects.get(0);
}
} else if (adminObjectType == null || adminObjectType.trim().equals("")) {
// get AO through class name
List<AdminObject> adminObjects = desc.getAdminObjectsByClass(adminObjectClassName);
if (adminObjects.size() > 1) {
String msg = localStrings.getString("aor.could_not_determine_aor_class", adminObjectClassName);
throw new ConnectorRuntimeException(msg);
} else {
aoDesc = adminObjects.get(0);
}
} else {
// get AO through interface name and class name
aoDesc = desc.getAdminObject(adminObjectType, adminObjectClassName);
}
if (aoDesc == null) {
String msg = localStrings.getString("aor.could_not_determine_aor", adminObjectType, adminObjectClassName);
throw new ConnectorRuntimeException(msg);
}
AdministeredObjectResource aor = new AdministeredObjectResource(resourceInfo);
aor.initialize(aoDesc);
aor.setResourceAdapter(connectorName);
Object[] envProps = aoDesc.getConfigProperties().toArray();
// Override them if same config properties are provided by the user
for (int i = 0; i < envProps.length; i++) {
ConnectorConfigProperty envProp = (ConnectorConfigProperty) envProps[i];
String name = envProp.getName();
String userValue = (String) props.remove(name);
if (userValue != null)
aor.addConfigProperty(new ConnectorConfigProperty(name, userValue, userValue, envProp.getType()));
else
aor.addConfigProperty(envProp);
}
// Add non-default config properties provided by the user to aor
Iterator iter = props.keySet().iterator();
while (iter.hasNext()) {
String name = (String) iter.next();
String userValue = props.getProperty(name);
if (userValue != null)
aor.addConfigProperty(new ConnectorConfigProperty(name, userValue, userValue));
}
// bind to JNDI namespace
try {
Reference ref = aor.createAdminObjectReference();
connectorRuntime_.getResourceNamingService().publishObject(resourceInfo, ref, true);
} catch (NamingException ex) {
String i18nMsg = localStrings.getString("aira.cannot_bind_admin_obj");
throw new ConnectorRuntimeException(i18nMsg, ex);
}
}
use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.
the class ActiveOutboundResourceAdapter method validateWorkContextSupport.
/**
* check whether the <i>required-work-context</i> list mandated by the resource-adapter
* is supported by the application server
* @param desc ConnectorDescriptor
* @throws ConnectorRuntimeException when unable to support any of the requested work-context type.
*/
private void validateWorkContextSupport(ConnectorDescriptor desc) throws ConnectorRuntimeException {
Set workContexts = desc.getRequiredWorkContexts();
Iterator workContextsIterator = workContexts.iterator();
WorkContextHandler workContextHandler = connectorRuntime_.getWorkContextHandler();
workContextHandler.init(moduleName_, jcl_);
while (workContextsIterator.hasNext()) {
String ic = (String) workContextsIterator.next();
boolean supported = workContextHandler.isContextSupported(true, ic);
if (!supported) {
String errorMsg = "Unsupported work context [ " + ic + " ] ";
Object[] params = new Object[] { ic, desc.getName() };
_logger.log(Level.WARNING, "unsupported.work.context", params);
throw new ConnectorRuntimeException(errorMsg);
}
}
}
Aggregations