Methods Summary |
---|
public void | addAdminObject(java.lang.String appName, java.lang.String connectorName, java.lang.String jndiName, java.lang.String adminObjectType, java.util.Properties props)Creates an admin object.
if (props == null) {
// empty properties
props = new Properties();
}
ConnectorRegistry registry = null;
try{
registry = ConnectorRegistry.getInstance();
}catch(Exception e) {
}
ConnectorDescriptor desc = registry.getDescriptor(connectorName);
AdminObject aoDesc =
desc.getAdminObjectByType(adminObjectType);
AdministeredObjectResource aor = new AdministeredObjectResource(
jndiName);
aor.initialize(aoDesc);
aor.setResourceAdapter(connectorName);
Object[] envProps = aoDesc.getConfigProperties().toArray();
//Add default config properties to aor
//Override them if same config properties are provided by the user
for (int i = 0; i < envProps.length; i++) {
EnvironmentProperty envProp = (EnvironmentProperty) envProps[i];
String name = envProp.getName();
String userValue = (String)props.remove(name);
if (userValue != null)
aor.addConfigProperty(new EnvironmentProperty(
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 EnvironmentProperty(
name, userValue, userValue));
}
// bind to JNDI namespace
try{
Reference ref = aor.createAdminObjectReference();
NamingManager nm = Switch.getSwitch().getNamingManager();
nm.publishObject(jndiName, ref, true);
} catch (NamingException ex) {
String i18nMsg = localStrings.getString(
"aira.cannot_bind_admin_obj");
throw new ConnectorRuntimeException( i18nMsg );
}
|
public void | addEndpointFactoryInfo(java.lang.String id, com.sun.enterprise.connectors.inflow.MessageEndpointFactoryInfo info)Adds endpoint factory information.
factories_.put(id, info);
|
public javax.resource.spi.ManagedConnectionFactory | createManagedConnectionFactory(ConnectorConnectionPool pool, java.lang.ClassLoader jcl)Creates an instance of ManagedConnectionFactory
object using the connection pool properties. Also set the
ResourceAdapterAssociation
ManagedConnectionFactory mcf = null;
mcf = super.createManagedConnectionFactory(pool,jcl);
if (mcf instanceof ResourceAdapterAssociation) {
try{
((ResourceAdapterAssociation) mcf).setResourceAdapter(
this.resourceadapter_);
}catch(ResourceException ex) {
_logger.log(Level.SEVERE,"rardeployment.assoc_failed",ex);
}
}
return mcf;
|
public void | destroy()Destroys default pools and resources. Stops the Resource adapter
java bean.
if(isServer() && (connectionDefs_ != null) &&
(connectionDefs_.length != 0)) {
destroyAllConnectorResources();
//deactivateEndpoints as well!
Iterator<MessageEndpointFactoryInfo> iter = getAllEndpointFactories().iterator();
while (iter.hasNext()) {
MessageEndpointFactoryInfo element = iter.next();
try {
this.resourceadapter_.endpointDeactivation(
element.getEndpointFactory(),element.getActivationSpec());
} catch (RuntimeException e) {
_logger.warning(e.getMessage());
_logger.log(Level.FINE, "Error during endpointDeactivation ", e);
}
}
}
try {
_logger.fine("Calling Resource Adapter stop" +
this.getModuleName());
resourceadapter_.stop();
_logger.fine("Resource Adapter stop call of " +
this.getModuleName() + "returned successfully");
_logger.log(Level.FINE, "rar_stop_call_successful");
} catch (Throwable t) {
_logger.log(Level.SEVERE,"rardeployment.stop_warning",t);
}
|
public java.util.Collection | getAllEndpointFactories()Retrieves the information about all endpoint factories.
return factories_.values();
|
public java.util.Set | getAllEndpointFactoryInfo()
Hashtable infos = (Hashtable<String, MessageEndpointFactoryInfo>) factories_.clone();
return infos.entrySet();
|
public javax.resource.spi.BootstrapContext | getBootStrapContext()
return this.bootStrapContextImpl;
|
public com.sun.enterprise.connectors.inflow.MessageEndpointFactoryInfo | getEndpointFactoryInfo(java.lang.String id)Returns information about endpoint factory.
return factories_.get(id);
|
public javax.resource.spi.ResourceAdapter | getResourceAdapter()Retrieves the resource adapter java bean.
return this.resourceadapter_;
|
private com.sun.enterprise.admin.monitor.registry.MonitoringLevel | getWorkStatsMonitoringLevel()
Config cfg = null;
MonitoringLevel off = MonitoringLevel.OFF;
MonitoringLevel l = null;
try {
cfg = ServerBeansFactory.getConfigBean(
ApplicationServer.getServerContext().getConfigContext());
String lvl = null;
lvl = cfg.getMonitoringService().getModuleMonitoringLevels().getConnectorService();
l = MonitoringLevel.instance( lvl );
if (l == null ) {
//dont bother to throw an exception
return off;
}
return l;
} catch (Exception e) {
return off;
}
|
private void | hackMergedProps(java.util.Set mergedProps)This is a HACK to remove the connection URL
in the case of PE LOCAL/EMBEDDED before setting the properties
to the RA. If this was not done, MQ RA incorrectly assumed
that the passed in connection URL is one additional
URL, apart from the default URL derived from brokerhost:brokerport
and reported a PE connection url limitation.
String brokerType = null;
for (Iterator iter = mergedProps.iterator(); iter.hasNext();) {
EnvironmentProperty element = (EnvironmentProperty) iter.next();
if (element.getName().equals(ActiveJmsResourceAdapter.BROKERTYPE)) {
brokerType = element.getValue();
}
}
boolean cluster = false;
try {
cluster = JmsRaUtil.isClustered();
} catch (Exception e) {
e.printStackTrace();
}
// hack is required only for nonclustered nonremote brokers.
if (!cluster) {
if (brokerType.equals(ActiveJmsResourceAdapter.LOCAL)
|| brokerType.equals(ActiveJmsResourceAdapter.EMBEDDED)
|| brokerType.equals(ActiveJmsResourceAdapter.DIRECT))
{
for (Iterator iter = mergedProps.iterator(); iter.hasNext();) {
EnvironmentProperty element = (EnvironmentProperty) iter.next();
if (element.getName().equals(ActiveJmsResourceAdapter.CONNECTION_URL)) {
iter.remove();
}
}
}
}
|
protected void | loadRAConfiguration()Loads RA javabean. This method is protected, so that any system
resource adapter can have specific configuration done during the
loading.
try {
ElementProperty[] raConfigProps = null;
Set mergedProps = null;
ConnectorRegistry registry = ConnectorRegistry.getInstance();
ResourceAdapterConfig raConfig =
registry.getResourceAdapterConfig(moduleName_);
if(raConfig != null) {
raConfigProps = raConfig.getElementProperty();
}
if(raConfigProps != null) {
mergedProps = ConnectorDDTransformUtils.mergeProps(
raConfigProps,getDescriptor().getConfigProperties());
} else {
mergedProps = ConnectorDDTransformUtils.mergeProps(
new ElementProperty[]{},
getDescriptor().getConfigProperties());
}
//HACK !
if (this.moduleName_.equals(ConnectorRuntime.DEFAULT_JMS_ADAPTER)) {
if (ConnectorRuntime.getRuntime().isServer()) {
hackMergedProps(mergedProps);
}
}
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;
}
|
private void | logMergedProperties(java.util.Set mergedProps)
_logger.fine("Passing in the following properties " +
"before calling RA.start of " + this.moduleName_);
StringBuffer b = new StringBuffer();
for (Iterator iter = mergedProps.iterator(); iter.hasNext();) {
EnvironmentProperty element = (EnvironmentProperty) iter.next();
b.append( "\nName: " + element.getName()
+ " Value: " + element.getValue() );
}
_logger.fine(b.toString());
|
private void | obtainServerXMLvalue()
|
private void | registerWorkStats()
if (getWorkStatsMonitoringLevel() != MonitoringLevel.OFF) {
((MonitorableWorkManager)this.getBootStrapContext().getWorkManager())
.setMonitoringEnabled(true);
AccessController.doPrivileged( new PrivilegedAction() {
public Object run() {
try {
ServerContext ctxt = ApplicationServer.getServerContext();
MonitoringRegistry monRegistry = ctxt.getMonitoringRegistry();
String moduleName = ActiveInboundResourceAdapter.this.getModuleName();
//@todo :: after MBeans are modified
//Dont register system RARs as of now until MBean changes are complete.
if (ResourcesUtil.createInstance().belongToSystemRar(moduleName)) {
if (!ConnectorAdminServiceUtils.isJMSRA(moduleName)) {
return null;
}
}
ConnectorWorkMgmtStatsImpl workstatsimpl =
new ConnectorWorkMgmtStatsImpl(ActiveInboundResourceAdapter.this);
monRegistry.registerConnectorWorkMgmtStats(
workstatsimpl,
ConnectorAdminServiceUtils.getApplicationName(moduleName),
ConnectorAdminServiceUtils.getConnectorModuleName(moduleName),
ConnectorAdminServiceUtils.isJMSRA(moduleName),
null);
} catch( Exception mre ) {
_logger.log( Level.INFO, "poolmon.cannot_reg",
mre.getMessage() );
}
return null;
}
});
if ( _logger.isLoggable( Level.FINE ) ) {
_logger.fine("Enabled work monitoring at IBRA creation for "
+ this.getModuleName());
}
}
|
public void | removeEndpointFactoryInfo(java.lang.String id)Removes information about an endpoint factory
factories_.remove(id);
|
public void | setup()Does the necessary initial setup. Creates the default pool and
resource.
if(connectionDefs_ == null || connectionDefs_.length == 0) {
return;
}
obtainServerXMLvalue();
ResourcesUtil resUtil = ResourcesUtil.createInstance();
if(isServer() && !resUtil.belongToSystemRar(moduleName_)) {
createAllConnectorResources();
}
|
private void | setupMonitoring()
//if monitoring enabled - register workstatsimpl for
//this inbound resource adapter and endpointfactory stats
//for inbound-resource-adapter&message-listener-type
registerWorkStats();
|
private void | unRegisterWorkStats()
if ( getWorkStatsMonitoringLevel() != MonitoringLevel.OFF ) {
AccessController.doPrivileged( new PrivilegedAction() {
public Object run() {
try {
ServerContext ctxt = ApplicationServer.getServerContext();
MonitoringRegistry monRegistry = ctxt.getMonitoringRegistry();
String moduleName = ActiveInboundResourceAdapter.this.getModuleName();
monRegistry.unregisterConnectorWorkMgmtStats(
ConnectorAdminServiceUtils.getApplicationName(moduleName),
ConnectorAdminServiceUtils.getConnectorModuleName(moduleName),
ConnectorAdminServiceUtils.isJMSRA(moduleName));
} catch( Exception mre) {
_logger.log( Level.INFO, "poolmon.cannot_unreg",
mre.getMessage() );
}
return null;
}
});
}
|
private void | unSetupMonitoring()
//if monitoring enabled - register workstatsimpl for
//this inbound resource adapter and endpointfactory stats
//for inbound-resource-adapter&message-listener-type
unRegisterWorkStats();
|
private void | writePoolResourceToServerXML()
|