Methods Summary |
---|
public static ConnectorConnectionPool | createDefaultConnectorPoolObject(java.lang.String poolName, java.lang.String rarName)Creates default ConnectorConnectionPool consisting of default
pool values.
ConnectorConnectionPool connectorPoolObj =
new ConnectorConnectionPool(poolName);
connectorPoolObj.setMaxPoolSize("20");
connectorPoolObj.setSteadyPoolSize("10");
connectorPoolObj.setMaxWaitTimeInMillis("7889");
connectorPoolObj.setIdleTimeoutInSeconds("789");
connectorPoolObj.setPoolResizeQuantity("2");
connectorPoolObj.setFailAllConnections(false);
connectorPoolObj.setMatchConnections(true); //always
setDefaultAdvancedPoolAttributes(connectorPoolObj);
try {
connectorPoolObj.setTransactionSupport(getTransactionSupportFromRaXml(rarName));
} catch (Exception ex) {
_logger.fine("error in setting txSupport");
}
return connectorPoolObj;
|
public static javax.security.auth.Subject | createSubject(javax.resource.spi.ManagedConnectionFactory mcf, ResourcePrincipal prin)
final Subject tempSubject = new Subject();
if( prin != null) {
String password = prin.getPassword();
if (password != null) {
final PasswordCredential pc =
new PasswordCredential(prin.getName(),
password.toCharArray());
pc.setManagedConnectionFactory(mcf);
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
tempSubject.getPrincipals().add(prin);
tempSubject.getPrivateCredentials().add(pc);
return null;
}
});
}
}
return tempSubject;
|
public static ConnectorConnectionPool | createSunRaConnectorPoolObject(java.lang.String poolName, ConnectorDescriptor desc, java.lang.String rarName)Creates ConnectorConnectionPool object pertaining to the pool props
mentioned in the sun-ra/xml i.e it represents the pool mentioned in the
sun-ra.xm.
ConnectorConnectionPool connectorPoolObj =
new ConnectorConnectionPool(poolName);
SunConnector sundesc = desc.getSunDescriptor();
ResourceAdapter sunRAXML = sundesc.getResourceAdapter();
connectorPoolObj.setMaxPoolSize(
(String) sunRAXML.getValue(ResourceAdapter.MAX_POOL_SIZE));
connectorPoolObj.setSteadyPoolSize(
(String) sunRAXML.getValue(ResourceAdapter.STEADY_POOL_SIZE));
connectorPoolObj.setMaxWaitTimeInMillis((String) sunRAXML.getValue(
ResourceAdapter.MAX_WAIT_TIME_IN_MILLIS));
connectorPoolObj.setIdleTimeoutInSeconds((String) sunRAXML.getValue(
ResourceAdapter.IDLE_TIMEOUT_IN_SECONDS));
connectorPoolObj.setPoolResizeQuantity((String) "2");
connectorPoolObj.setFailAllConnections(false);
connectorPoolObj.setMatchConnections(true); //always
setDefaultAdvancedPoolAttributes(connectorPoolObj);
try {
connectorPoolObj.setTransactionSupport(getTransactionSupportFromRaXml(rarName));
} catch (Exception ex) {
_logger.fine("error in setting txSupport");
}
boolean validateAtmostEveryIdleSecs = false;
//For SunRAPool, get the value of system property VALIDATE_ATMOST_EVERY_IDLE_SECS.
if (validateAtmostEveryIdleSecsProperty != null && validateAtmostEveryIdleSecsProperty.equalsIgnoreCase("TRUE")) {
validateAtmostEveryIdleSecs = true;
_logger.log(Level.FINE, "CCP.ValidateAtmostEveryIdleSecs.Set", poolName);
}
connectorPoolObj.setValidateAtmostEveryIdleSecs(validateAtmostEveryIdleSecs);
return connectorPoolObj;
|
public static com.sun.appserv.connectors.spi.TransactionSupport | getTransactionSupport(int ts)A utility method to map TransactionSupport ints as represented
in ConnectorConstants to the new TransactionSupport enum
switch (ts) {
case ConnectorConstants.NO_TRANSACTION_INT:
return TransactionSupport.NO_TRANSACTION;
case ConnectorConstants.LOCAL_TRANSACTION_INT:
return TransactionSupport.LOCAL_TRANSACTION;
case ConnectorConstants.XA_TRANSACTION_INT:
return TransactionSupport.XA_TRANSACTION;
}
return null;
|
public static int | getTransactionSupportFromRaXml(java.lang.String rarName)
String txSupport =
ConnectorRuntime.getRuntime().getConnectorDescriptor( rarName ).
getOutboundResourceAdapter().getTransSupport() ;
return parseTransactionSupportString( txSupport );
|
public static java.lang.String | getValueFromMCF(java.lang.String prop, java.lang.String poolName, javax.resource.spi.ManagedConnectionFactory mcf)
String result = null;
try {
Method m = mcf.getClass().getMethod("get"+prop, (java.lang.Class[])null);
result = (String) m.invoke(mcf,(java.lang.Object[])null);
} catch (Throwable t) {
_logger.log(Level.FINE, t.getMessage(), t);
}
return result == null ? "" : result;
|
public static boolean | isPoolSystemPool(com.sun.enterprise.config.serverbeans.ConnectorConnectionPool domainCcp)
String poolName = domainCcp.getName();
return isPoolSystemPool(poolName);
|
public static boolean | isPoolSystemPool(java.lang.String poolName)
Pattern pattern = Pattern.compile("#");
Matcher matcher = pattern.matcher(poolName);
// If the pool name does not contain #, return false
if (!matcher.find()){
return false;
}
matcher.reset();
String moduleNameFromPoolName = null;
int matchCount=0;
while (matcher.find()){
matchCount++;
int patternStart = matcher.start();
moduleNameFromPoolName = poolName.substring(0,patternStart);
}
// If pool name contains more than 2 #, return false as the
// default system pool will have exacly one # for a standalone rar
// and exactly two #s for an embedded rar
ResourcesUtil resUtil = ResourcesUtil.createInstance();
switch (matchCount){
case 1:
if (resUtil.belongToStandAloneRar(moduleNameFromPoolName))
return true;
case 2:
if (resUtil.belongToEmbeddedRar(moduleNameFromPoolName))
return true;
default:
return false;
}
|
public static int | parseTransactionSupportString(java.lang.String txSupport)Return the integer representation of the transaction-support attribure
int txSupportIntVal = ConnectorConstants.UNDEFINED_TRANSACTION_INT;
if ( txSupport == null ) {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("txSupport is null");
}
return txSupportIntVal;
}
if (_logger.isLoggable(Level.FINE) ) {
_logger.fine("parseTransactionSupportString: passed in " +
"txSupport =>" + txSupport);
}
if (ConnectorConstants.NO_TRANSACTION_TX_SUPPORT_STRING.equals(txSupport) ) {
txSupportIntVal = ConnectorConstants.NO_TRANSACTION_INT;
} else if (ConnectorConstants.LOCAL_TRANSACTION_TX_SUPPORT_STRING.equals(txSupport)) {
txSupportIntVal = ConnectorConstants.LOCAL_TRANSACTION_INT;
} else if (ConnectorConstants.XA_TRANSACTION_TX_SUPPORT_STRING.equals(txSupport)) {
txSupportIntVal = ConnectorConstants.XA_TRANSACTION_INT;
}
return txSupportIntVal;
|
private static void | setDefaultAdvancedPoolAttributes(ConnectorConnectionPool connectorPoolObj)Sets default values for advanced pool properties
//Other advanced attributes like connection-leak-reclaim, lazy-connection-enlistment,
//lazy-connection-association, associate-with-thread are boolean values which are not required
//to be explicitly initialized to default values.
connectorPoolObj.setMaxConnectionUsage(ConnectorConnectionPool.DEFAULT_MAX_CONNECTION_USAGE);
connectorPoolObj.setConnectionLeakTracingTimeout(ConnectorConnectionPool.DEFAULT_LEAK_TIMEOUT);
connectorPoolObj.setConCreationRetryAttempts(ConnectorConnectionPool.DEFAULT_CON_CREATION_RETRY_ATTEMPTS);
connectorPoolObj.setConCreationRetryInterval(ConnectorConnectionPool.DEFAULT_CON_CREATION_RETRY_INTERVAL);
connectorPoolObj.setValidateAtmostOncePeriod(ConnectorConnectionPool.DEFAULT_VALIDATE_ATMOST_ONCE_PERIOD);
|
public static void | setLazyEnlistAndLazyAssocProperties(java.lang.String lazyAssocString, com.sun.enterprise.config.ConfigBean adminPool, ConnectorConnectionPool conConnPool)Validates and sets the values for LazyConnectionEnlistment and LazyConnectionAssociation.
//Get LazyEnlistment value.
//To set LazyAssoc to true, LazyEnlist also need to be true.
//If LazyAssoc is true and LazyEnlist is not set, set it to true.
//If LazyAssoc is true and LazyEnlist is false, throw exception.
ElementProperty[] o = (ElementProperty[])adminPool.getValues(ELEMENT_PROPERTY);
if (o == null) return ;
ElementProperty lazyEnlistElement = null;
for (int i=0; i < o.length; i++) {
if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equalsIgnoreCase("LAZYCONNECTIONENLISTMENT")) {
lazyEnlistElement = o[i];
break;
}
}
boolean lazyAssoc = toBoolean( lazyAssocString, false );
if(lazyEnlistElement != null){
boolean lazyEnlist = toBoolean(lazyEnlistElement.getValue(),false);
if(lazyAssoc){
if(lazyEnlist){
conConnPool.setLazyConnectionAssoc( true) ;
conConnPool.setLazyConnectionEnlist( true);
}else{
_logger.log(Level.SEVERE,"conn_pool_obj_utils.lazy_enlist-lazy_assoc-invalid-combination",conConnPool.getName());
String i18nMsg = localStrings.getString(
"cpou.lazy_enlist-lazy_assoc-invalid-combination");
throw new RuntimeException(i18nMsg + conConnPool.getName());
}
}else{
conConnPool.setLazyConnectionAssoc(false);
}
}else{
if(lazyAssoc){
conConnPool.setLazyConnectionAssoc( true) ;
conConnPool.setLazyConnectionEnlist( true);
}else{
conConnPool.setLazyConnectionAssoc( false) ;
}
}
|
private static boolean | toBoolean(java.lang.Object prop, boolean defaultVal)
if ( prop == null ) {
return defaultVal;
}
return Boolean.valueOf(((String) prop).toLowerCase());
|