use of com.sun.enterprise.deployment.ConnectorConfigProperty in project Payara by payara.
the class ActiveJmsResourceAdapter method createManagedConnectionFactory.
/**
* Creates ManagedConnection Factory instance. For any property that is
* for supporting AS7 imq properties, resource adapter has a set method
* setProperty(String,String). All as7 properties starts with "imq".
* MQ Adapter supports this only for backward compatibility.
*
* @param cpr <code>ConnectorConnectionPool</code> object
* @param loader Class Loader.
* @return
*/
@Override
public ManagedConnectionFactory createManagedConnectionFactory(com.sun.enterprise.connectors.ConnectorConnectionPool cpr, ClassLoader loader) {
ManagedConnectionFactory mcf = super.createManagedConnectionFactory(cpr, loader);
if (mcf != null) {
Set s = cpr.getConnectorDescriptorInfo().getMCFConfigProperties();
Iterator it = s.iterator();
while (it.hasNext()) {
ConnectorConfigProperty prop = (ConnectorConfigProperty) it.next();
String propName = prop.getName();
// setProperty(String,String) method.
if (propName.startsWith("imq") && !"".equals(prop.getValue())) {
try {
Method meth = mcf.getClass().getMethod(SETTER, new Class[] { java.lang.String.class, java.lang.String.class });
meth.invoke(mcf, new Object[] { prop.getName(), prop.getValueObject() });
} catch (NoSuchMethodException ex) {
if (_logger.isLoggable(Level.WARNING)) {
_logger.log(Level.WARNING, JMSLoggerInfo.NO_SUCH_METHOD, new Object[] { SETTER, mcf.getClass().getName() });
}
} catch (Exception ex) {
LogHelper.log(_logger, Level.SEVERE, JMSLoggerInfo.ERROR_EXECUTE_METHOD, ex, SETTER, mcf.getClass().getName());
}
}
}
// CR 6591307- Fix for properties getting overridden when setRA is called. Resetting the properties if the RA is the JMS RA
String moduleName = this.getModuleName();
if (ConnectorAdminServiceUtils.isJMSRA(moduleName)) {
try {
Set configProperties = cpr.getConnectorDescriptorInfo().getMCFConfigProperties();
Object[] array = configProperties.toArray();
for (int i = 0; i < array.length; i++) {
if (array[i] instanceof ConnectorConfigProperty) {
ConnectorConfigProperty property = (ConnectorConfigProperty) array[i];
if (ActiveJmsResourceAdapter.ADDRESSLIST.equals(property.getName())) {
if (property.getValue() == null || "".equals(property.getValue()) || "localhost".equals(property.getValue())) {
_logger.log(Level.FINE, "raraddresslist.default.value : " + property.getValue());
configProperties.remove(property);
}
}
}
}
SetMethodAction setMethodAction = new SetMethodAction(mcf, configProperties);
setMethodAction.run();
} catch (Exception Ex) {
final String mcfClass = cpr.getConnectorDescriptorInfo().getManagedConnectionFactoryClass();
if (_logger.isLoggable(Level.WARNING)) {
_logger.log(Level.WARNING, JMSLoggerInfo.RARDEPLOYMENT_MCF_ERROR, new Object[] { mcfClass, Ex.getMessage() });
}
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "rardeployment.mcfcreation_error", Ex);
}
}
}
}
return mcf;
}
use of com.sun.enterprise.deployment.ConnectorConfigProperty in project Payara by payara.
the class JdbcConnectionPoolDeployer method getMCFConfigProperties.
/**
* Pull out the MCF configuration properties and return them as an array
* of ConnectorConfigProperty
*
* @param adminPool - The JdbcConnectionPool to pull out properties from
* @param conConnPool - ConnectorConnectionPool which will be used by Resource Pool
* @param connDesc - The ConnectorDescriptor for this JDBC RA
* @return ConnectorConfigProperty [] array of MCF Config properties specified
* in this JDBC RA
*/
private ConnectorConfigProperty[] getMCFConfigProperties(JdbcConnectionPool adminPool, ConnectorConnectionPool conConnPool, ConnectorDescriptor connDesc) {
ArrayList propList = new ArrayList();
if (adminPool.getResType() != null) {
if (ConnectorConstants.JAVA_SQL_DRIVER.equals(adminPool.getResType())) {
propList.add(new ConnectorConfigProperty("ClassName", adminPool.getDriverClassname() == null ? "" : adminPool.getDriverClassname(), "The driver class name", "java.lang.String"));
} else {
propList.add(new ConnectorConfigProperty("ClassName", adminPool.getDatasourceClassname() == null ? "" : adminPool.getDatasourceClassname(), "The datasource class name", "java.lang.String"));
}
} else {
// When resType is null, one of these classnames would be specified
if (adminPool.getDriverClassname() != null) {
propList.add(new ConnectorConfigProperty("ClassName", adminPool.getDriverClassname() == null ? "" : adminPool.getDriverClassname(), "The driver class name", "java.lang.String"));
} else if (adminPool.getDatasourceClassname() != null) {
propList.add(new ConnectorConfigProperty("ClassName", adminPool.getDatasourceClassname() == null ? "" : adminPool.getDatasourceClassname(), "The datasource class name", "java.lang.String"));
}
}
propList.add(new ConnectorConfigProperty("ConnectionValidationRequired", adminPool.getIsConnectionValidationRequired() + "", "Is connection validation required", "java.lang.String"));
propList.add(new ConnectorConfigProperty("ValidationMethod", adminPool.getConnectionValidationMethod() == null ? "" : adminPool.getConnectionValidationMethod(), "How the connection is validated", "java.lang.String"));
propList.add(new ConnectorConfigProperty("ValidationTableName", adminPool.getValidationTableName() == null ? "" : adminPool.getValidationTableName(), "Validation Table name", "java.lang.String"));
propList.add(new ConnectorConfigProperty("ValidationClassName", adminPool.getValidationClassname() == null ? "" : adminPool.getValidationClassname(), "Validation Class name", "java.lang.String"));
propList.add(new ConnectorConfigProperty("TransactionIsolation", adminPool.getTransactionIsolationLevel() == null ? "" : adminPool.getTransactionIsolationLevel(), "Transaction Isolatin Level", "java.lang.String"));
propList.add(new ConnectorConfigProperty("GuaranteeIsolationLevel", adminPool.getIsIsolationLevelGuaranteed() + "", "Transaction Isolation Guarantee", "java.lang.String"));
propList.add(new ConnectorConfigProperty("StatementWrapping", adminPool.getWrapJdbcObjects() + "", "Statement Wrapping", "java.lang.String"));
propList.add(new ConnectorConfigProperty("LogJdbcCalls", adminPool.getLogJdbcCalls() + "", "Log JDBC Calls", "java.lang.String"));
propList.add(new ConnectorConfigProperty("SlowQueryThresholdInSeconds", adminPool.getSlowQueryThresholdInSeconds() + "", "Slow Query Threshold In Seconds", "java.lang.String"));
propList.add(new ConnectorConfigProperty("StatementTimeout", adminPool.getStatementTimeoutInSeconds() + "", "Statement Timeout", "java.lang.String"));
PoolInfo poolInfo = conConnPool.getPoolInfo();
propList.add(new ConnectorConfigProperty("PoolMonitoringSubTreeRoot", ConnectorsUtil.getPoolMonitoringSubTreeRoot(poolInfo, true) + "", "Pool Monitoring Sub Tree Root", "java.lang.String"));
propList.add(new ConnectorConfigProperty("PoolName", poolInfo.getName() + "", "Pool Name", "java.lang.String"));
if (poolInfo.getApplicationName() != null) {
propList.add(new ConnectorConfigProperty("ApplicationName", poolInfo.getApplicationName() + "", "Application Name", "java.lang.String"));
}
if (poolInfo.getModuleName() != null) {
propList.add(new ConnectorConfigProperty("ModuleName", poolInfo.getModuleName() + "", "Module name", "java.lang.String"));
}
propList.add(new ConnectorConfigProperty("StatementCacheSize", adminPool.getStatementCacheSize() + "", "Statement Cache Size", "java.lang.String"));
propList.add(new ConnectorConfigProperty("StatementCacheType", adminPool.getStatementCacheType() + "", "Statement Cache Type", "java.lang.String"));
propList.add(new ConnectorConfigProperty("InitSql", adminPool.getInitSql() + "", "InitSql", "java.lang.String"));
propList.add(new ConnectorConfigProperty("SqlTraceListeners", adminPool.getSqlTraceListeners() + "", "Sql Trace Listeners", "java.lang.String"));
propList.add(new ConnectorConfigProperty("StatementLeakTimeoutInSeconds", adminPool.getStatementLeakTimeoutInSeconds() + "", "Statement Leak Timeout in seconds", "java.lang.String"));
propList.add(new ConnectorConfigProperty("StatementLeakReclaim", adminPool.getStatementLeakReclaim() + "", "Statement Leak Reclaim", "java.lang.String"));
// dump user defined poperties into the list
Set connDefDescSet = connDesc.getOutboundResourceAdapter().getConnectionDefs();
// since this a 1.0 RAR, we will have only 1 connDefDesc
if (connDefDescSet.size() != 1) {
throw new MissingResourceException("Only one connDefDesc present", null, null);
}
Iterator iter = connDefDescSet.iterator();
// Now get the set of MCF config properties associated with each
// connection-definition . Each element here is an EnviromnentProperty
Set mcfConfigProps = null;
while (iter.hasNext()) {
mcfConfigProps = ((ConnectionDefDescriptor) iter.next()).getConfigProperties();
}
if (mcfConfigProps != null) {
Map mcfConPropKeys = new HashMap();
Iterator mcfConfigPropsIter = mcfConfigProps.iterator();
while (mcfConfigPropsIter.hasNext()) {
String key = ((ConnectorConfigProperty) mcfConfigPropsIter.next()).getName();
mcfConPropKeys.put(key.toUpperCase(locale), key);
}
String driverProperties = "";
for (Property rp : adminPool.getProperty()) {
if (rp == null) {
continue;
}
String name = rp.getName();
// making it easy to compare in the event of a reconfig
if ("MATCHCONNECTIONS".equals(name.toUpperCase(locale))) {
// JDBC - matchConnections if not set is decided by the ConnectionManager
// so default is false
conConnPool.setMatchConnections(toBoolean(rp.getValue(), false));
logFine("MATCHCONNECTIONS");
} else if ("ASSOCIATEWITHTHREAD".equals(name.toUpperCase(locale))) {
conConnPool.setAssociateWithThread(toBoolean(rp.getValue(), false));
logFine("ASSOCIATEWITHTHREAD");
} else if ("LAZYCONNECTIONASSOCIATION".equals(name.toUpperCase(locale))) {
ConnectionPoolObjectsUtils.setLazyEnlistAndLazyAssocProperties(rp.getValue(), adminPool.getProperty(), conConnPool);
logFine("LAZYCONNECTIONASSOCIATION");
} else if ("LAZYCONNECTIONENLISTMENT".equals(name.toUpperCase(Locale.getDefault()))) {
conConnPool.setLazyConnectionEnlist(toBoolean(rp.getValue(), false));
logFine("LAZYCONNECTIONENLISTMENT");
} else if ("POOLDATASTRUCTURE".equals(name.toUpperCase(Locale.getDefault()))) {
conConnPool.setPoolDataStructureType(rp.getValue());
logFine("POOLDATASTRUCTURE");
} else if (ConnectorConstants.DYNAMIC_RECONFIGURATION_FLAG.equals(name.toLowerCase(locale))) {
String value = rp.getValue();
try {
conConnPool.setDynamicReconfigWaitTimeout(Long.parseLong(rp.getValue()) * 1000L);
logFine(ConnectorConstants.DYNAMIC_RECONFIGURATION_FLAG);
} catch (NumberFormatException nfe) {
_logger.log(Level.WARNING, "Invalid value for " + "'" + ConnectorConstants.DYNAMIC_RECONFIGURATION_FLAG + "' : " + value);
}
} else if ("POOLWAITQUEUE".equals(name.toUpperCase(locale))) {
conConnPool.setPoolWaitQueue(rp.getValue());
logFine("POOLWAITQUEUE");
} else if ("DATASTRUCTUREPARAMETERS".equals(name.toUpperCase(locale))) {
conConnPool.setDataStructureParameters(rp.getValue());
logFine("DATASTRUCTUREPARAMETERS");
} else if ("USERNAME".equals(name.toUpperCase(Locale.getDefault())) || "USER".equals(name.toUpperCase(locale))) {
propList.add(new ConnectorConfigProperty("User", (String) TranslatedConfigView.getTranslatedValue(rp.getValue()), "user name", "java.lang.String"));
} else if ("PASSWORD".equals(name.toUpperCase(locale))) {
propList.add(new ConnectorConfigProperty("Password", (String) TranslatedConfigView.getTranslatedValue(rp.getValue()), "Password", "java.lang.String"));
} else if ("JDBC30DATASOURCE".equals(name.toUpperCase(locale))) {
propList.add(new ConnectorConfigProperty("JDBC30DataSource", rp.getValue(), "JDBC30DataSource", "java.lang.String"));
} else if ("PREFER-VALIDATE-OVER-RECREATE".equals(name.toUpperCase(Locale.getDefault()))) {
String value = rp.getValue();
conConnPool.setPreferValidateOverRecreate(toBoolean(value, false));
logFine("PREFER-VALIDATE-OVER-RECREATE : " + value);
} else if ("STATEMENT-CACHE-TYPE".equals(name.toUpperCase(Locale.getDefault()))) {
if (adminPool.getStatementCacheType() != null) {
propList.add(new ConnectorConfigProperty("StatementCacheType", rp.getValue(), "StatementCacheType", "java.lang.String"));
}
} else if ("NUMBER-OF-TOP-QUERIES-TO-REPORT".equals(name.toUpperCase(Locale.getDefault()))) {
propList.add(new ConnectorConfigProperty("NumberOfTopQueriesToReport", rp.getValue(), "NumberOfTopQueriesToReport", "java.lang.String"));
} else if ("TIME-TO-KEEP-QUERIES-IN-MINUTES".equals(name.toUpperCase(Locale.getDefault()))) {
propList.add(new ConnectorConfigProperty("TimeToKeepQueriesInMinutes", rp.getValue(), "TimeToKeepQueriesInMinutes", "java.lang.String"));
} else if ("MAXCACHESIZE".equals(name.toUpperCase(Locale.getDefault())) || "MAX-CACHE-SIZE".equals(name.toUpperCase(Locale.getDefault()))) {
propList.add(new ConnectorConfigProperty("MaxCacheSize", rp.getValue(), "MaxCacheSize", "java.lang.String"));
} else if (mcfConPropKeys.containsKey(name.toUpperCase(Locale.getDefault()))) {
propList.add(new ConnectorConfigProperty((String) mcfConPropKeys.get(name.toUpperCase(Locale.getDefault())), rp.getValue() == null ? "" : (String) TranslatedConfigView.getTranslatedValue(rp.getValue()), "Some property", "java.lang.String"));
} else {
driverProperties = driverProperties + "set" + escape(name) + "#" + escape((String) TranslatedConfigView.getTranslatedValue(rp.getValue())) + "##";
}
}
if (!driverProperties.equals("")) {
propList.add(new ConnectorConfigProperty("DriverProperties", driverProperties, "some proprietarty properties", "java.lang.String"));
}
}
propList.add(new ConnectorConfigProperty("Delimiter", "#", "delim", "java.lang.String"));
propList.add(new ConnectorConfigProperty("EscapeCharacter", "\\", "escapeCharacter", "java.lang.String"));
// create an array of EnvironmentProperties from above list
ConnectorConfigProperty[] eProps = new ConnectorConfigProperty[propList.size()];
ListIterator propListIter = propList.listIterator();
for (int i = 0; propListIter.hasNext(); i++) {
eProps[i] = (ConnectorConfigProperty) propListIter.next();
}
return eProps;
}
use of com.sun.enterprise.deployment.ConnectorConfigProperty in project Payara by payara.
the class ConnectorConnectionPool method toString.
/**
* return the String representation of the pool.
*
* @return String representation of pool
*/
public String toString() {
String returnVal = "";
StringBuffer sb = new StringBuffer("ConnectorConnectionPool :: ");
try {
sb.append(getName());
sb.append("\nsteady size: ");
sb.append(getSteadyPoolSize());
sb.append("\nmax pool size: ");
sb.append(getMaxPoolSize());
sb.append("\nmax wait time: ");
sb.append(getMaxWaitTimeInMillis());
sb.append("\npool resize qty: ");
sb.append(getPoolResizeQuantity());
sb.append("\nIdle timeout: ");
sb.append(getIdleTimeoutInSeconds());
sb.append("\nfailAllConnections: ");
sb.append(isFailAllConnections());
sb.append("\nTransaction Support Level: ");
sb.append(transactionSupport_);
sb.append("\nisConnectionValidationRequired_ ");
sb.append(isConnectionValidationRequired_);
sb.append("\npreferValidateOverRecreate_ ");
sb.append(preferValidateOverRecreate_);
sb.append("\nmatchConnections_ ");
sb.append(matchConnections_);
sb.append("\nassociateWithThread_ ");
sb.append(associateWithThread_);
sb.append("\nlazyConnectionAssoc_ ");
sb.append(lazyConnectionAssoc_);
sb.append("\nlazyConnectionEnlist_ ");
sb.append(lazyConnectionEnlist_);
sb.append("\nmaxConnectionUsage_ ");
sb.append(maxConnectionUsage);
sb.append("\npingPoolDuringCreation_ ");
sb.append(pingDuringPoolCreation);
sb.append("\npoolingOn_ ");
sb.append(poolingOn);
sb.append("\nvalidateAtmostOncePeriod_ ");
sb.append(validateAtmostOncePeriod_);
sb.append("\nconnectionLeakTracingTimeout_");
sb.append(connectionLeakTracingTimeout_);
sb.append("\nconnectionReclaim_");
sb.append(connectionReclaim_);
sb.append("\nconnectionCreationRetryAttempts_");
sb.append(conCreationRetryAttempts_);
sb.append("\nconnectionCreationRetryIntervalInMilliSeconds_");
sb.append(conCreationRetryInterval_);
sb.append("\nnonTransactional_ ");
sb.append(nonTransactional_);
sb.append("\nnonComponent_ ");
sb.append(nonComponent_);
sb.append("\nConnectorDescriptorInfo -> ");
sb.append("\nrarName: ");
if (connectorDescriptorInfo_ != null) {
sb.append(connectorDescriptorInfo_.getRarName());
sb.append("\nresource adapter class: ");
sb.append(connectorDescriptorInfo_.getResourceAdapterClassName());
sb.append("\nconnection def name: ");
sb.append(connectorDescriptorInfo_.getConnectionDefinitionName());
sb.append("\nMCF Config properties-> ");
for (Object o : connectorDescriptorInfo_.getMCFConfigProperties()) {
ConnectorConfigProperty ep = (ConnectorConfigProperty) o;
sb.append(ep.getName());
sb.append(":");
sb.append(("password".equalsIgnoreCase(ep.getName()) ? "****" : ep.getValue()));
sb.append("\n");
}
}
if (securityMaps != null) {
sb.append("SecurityMaps -> {");
for (ConnectorSecurityMap securityMap : securityMaps) {
if (securityMap != null && securityMap.getName() != null) {
sb.append(securityMap.getName());
sb.append(" ");
}
}
sb.append("}");
}
returnVal = sb.toString();
} catch (Exception e) {
_logger.log(Level.WARNING, "Exception while computing toString() of connection pool [ " + name + " ]", e);
}
return returnVal;
}
use of com.sun.enterprise.deployment.ConnectorConfigProperty in project Payara by payara.
the class ConnectorConnectionPoolAdminServiceImpl method getPropertyValue.
// END CR 6597868
/**
* Utility method to get property value from ConnectorDescriptorInfo.
* @param prop
* @return
*/
public String getPropertyValue(String prop, ConnectorConnectionPool connectorConnectionPool) {
String result = null;
ConnectorDescriptorInfo cdi = connectorConnectionPool.getConnectorDescriptorInfo();
Set mcfConfigProperties = cdi.getMCFConfigProperties();
Iterator mcfConfPropsIter = mcfConfigProperties.iterator();
while (mcfConfPropsIter.hasNext()) {
ConnectorConfigProperty envProp = (ConnectorConfigProperty) mcfConfPropsIter.next();
if (envProp.getName().toUpperCase(Locale.getDefault()).equals(prop)) {
result = envProp.getValue();
}
}
return (String) TranslatedConfigView.getTranslatedValue(result);
}
use of com.sun.enterprise.deployment.ConnectorConfigProperty in project Payara by payara.
the class ConnectorAdminServiceUtils method getDefaultResourcePrincipal.
/*
* Returns a ResourcePrincipal object populated with a pool's
* default USERNAME and PASSWORD
*
* @throws NamingException if poolname lookup fails
*/
public static ResourcePrincipal getDefaultResourcePrincipal(PoolInfo poolInfo) throws NamingException {
// All this to get the default user name and principal
ConnectorConnectionPool connectorConnectionPool = null;
try {
String jndiNameForPool = getReservePrefixedJNDINameForPool(poolInfo);
Context ic = ConnectorRuntime.getRuntime().getNamingManager().getInitialContext();
connectorConnectionPool = (ConnectorConnectionPool) ic.lookup(jndiNameForPool);
} catch (NamingException ne) {
throw ne;
}
ConnectorDescriptorInfo cdi = connectorConnectionPool.getConnectorDescriptorInfo();
Set mcfConfigProperties = cdi.getMCFConfigProperties();
Iterator mcfConfPropsIter = mcfConfigProperties.iterator();
String userName = "";
String password = "";
while (mcfConfPropsIter.hasNext()) {
ConnectorConfigProperty prop = (ConnectorConfigProperty) mcfConfPropsIter.next();
if (prop.getName().toUpperCase(Locale.getDefault()).equals("USERNAME") || prop.getName().toUpperCase(Locale.getDefault()).equals("USER")) {
userName = prop.getValue();
} else if (prop.getName().toUpperCase(Locale.getDefault()).equals("PASSWORD")) {
password = prop.getValue();
}
}
// Now return the ResourcePrincipal
return new ResourcePrincipal(userName, password);
}
Aggregations