Methods Summary |
---|
public void | createConnectorResource(java.lang.String jndiName, java.lang.String poolName, java.lang.String resourceType)Creates the connector resource on a given connection pool
String errMsg = "rardeployment.jndi_lookup_failed";
String name = poolName;
try {
ConnectorConnectionPool connectorConnectionPool = null;
String jndiNameForPool = ConnectorAdminServiceUtils.
getReservePrefixedJNDINameForPool(poolName);
InitialContext ic = new InitialContext();
try {
connectorConnectionPool =
(ConnectorConnectionPool) ic.lookup(jndiNameForPool);
} catch(NamingException ne) {
checkAndLoadPoolResource(poolName);
}
connectorConnectionPool =
(ConnectorConnectionPool) ic.lookup(jndiNameForPool);
ConnectorDescriptorInfo cdi = connectorConnectionPool.
getConnectorDescriptorInfo();
javax.naming.Reference ref=new javax.naming.Reference(
connectorConnectionPool.getConnectorDescriptorInfo().
getConnectionFactoryClass(),
"com.sun.enterprise.naming.factory.ConnectorObjectFactory",
null);
StringRefAddr addr = new StringRefAddr("poolName",poolName);
ref.add(addr);
addr = new StringRefAddr("rarName", cdi.getRarName() );
ref.add(addr);
errMsg = "Failed to bind connector resource in JNDI";
name = jndiName;
Switch.getSwitch().getNamingManager().publishObject(
jndiName,ref,true);
//To notify that a connector resource rebind has happened.
ConnectorResourceNamingEventNotifier.getInstance().
notifyListeners(
new ConnectorNamingEvent(
jndiName,ConnectorNamingEvent.EVENT_OBJECT_REBIND));
} catch(NamingException ne) {
ConnectorRuntimeException cre =
new ConnectorRuntimeException(errMsg);
cre.initCause(ne);
_logger.log(Level.SEVERE,errMsg, name);
_logger.log(Level.SEVERE,"", cre);
throw cre;
}
|
public void | deleteConnectorResource(java.lang.String jndiName)Deletes the connector resource.
try {
InitialContext ic = new InitialContext();
ic.unbind(jndiName);
} catch(NamingException ne) {
ResourcesUtil resUtil = ResourcesUtil.createInstance();
if(resUtil.resourceBelongsToSystemRar(jndiName)) {
return;
}
if(ne instanceof NameNotFoundException){
_logger.log(Level.FINE,
"rardeployment.connectorresource_removal_from_jndi_error",
jndiName);
_logger.log(Level.FINE,"", ne);
return;
}
ConnectorRuntimeException cre = new ConnectorRuntimeException(
"Failed to delete connector resource from jndi");
cre.initCause(ne);
_logger.log(Level.SEVERE,
"rardeployment.connectorresource_removal_from_jndi_error",
jndiName);
_logger.log(Level.SEVERE,"", cre);
throw cre;
}
|
public ConnectorNamingEventNotifier | getResourceRebindEventNotifier()Gets Connector Resource Rebind Event notifier.
return ConnectorResourceNamingEventNotifier.getInstance();
|
private java.lang.String | getValidSuffix(java.lang.String name)
if (name != null) {
for (String validSuffix : ConnectorConstants.JNDI_SUFFIX_VALUES) {
if (name.endsWith(validSuffix)) {
return validSuffix;
}
}
}
return null;
|
public boolean | isValidJndiSuffix(java.lang.String suffix)If the suffix is one of the valid context return true.
Return false, if that is not the case.
if (suffix != null) {
for (String validSuffix : ConnectorConstants.JNDI_SUFFIX_VALUES) {
if (validSuffix.equals(suffix)) {
return true;
}
}
}
return false;
|
public java.lang.Object | lookup(java.lang.String name)Look up the JNDI name with appropriate suffix.
Suffix can be either __pm or __nontx.
Hashtable ht = null;
String suffix = getValidSuffix(name);
if (suffix != null) {
ht = new Hashtable();
ht.put(ConnectorConstants.JNDI_SUFFIX_PROPERTY, suffix);
name = name.substring(0, name.lastIndexOf(suffix));
}
InitialContext ic = new InitialContext(ht);
return ic.lookup(name);
|
protected java.lang.Object | lookupDataSourceInDAS(java.lang.String jndiName)Get a wrapper datasource specified by the jdbcjndi name
This API is intended to be used in the DAS. The motivation for having this
API is to provide the CMP backend/ JPA-Java2DB a means of acquiring a connection during
the codegen phase. If a user is trying to deploy an JPA-Java2DB app on a remote server,
without this API, a resource reference has to be present both in the DAS
and the server instance. This makes the deployment more complex for the
user since a resource needs to be forcibly created in the DAS Too.
This API will mitigate this need.
MyDataSource myDS = new MyDataSource();
myDS.setJndiName(jndiName);
return myDS;
|