use of com.sun.enterprise.deployment.ConnectorConfigProperty in project Payara by payara.
the class ConnectorDescriptorInfo method compareMCFConfigProperties.
/**
* Compare the MCF Config properties in this object with the
* passed ones. The properties in the Set of excluded properties
* are not compared against
*
* @param cdi - The ConnDescInfo object whose MCF config props are to
* to be comapred against our props
* @param excluded - list of properties to be excluded from comparison
* @return true - if the config properties are the same
* false otherwise
*/
public ReconfigAction compareMCFConfigProperties(ConnectorDescriptorInfo cdi, Set excluded) {
Set mcfConfigProps = cdi.getMCFConfigProperties();
if (mcfConfigProps.size() != mcfConfigProperties_.size()) {
// Cannot determine anything due to size disparity - assume restart
return ReconfigAction.RECREATE_POOL;
}
boolean same = false;
for (Object mcfConfigProp : mcfConfigProps) {
ConnectorConfigProperty prop = (ConnectorConfigProperty) mcfConfigProp;
// see if this property is in our list of excludes
if (excluded.contains(prop.getName())) {
// _logger.finest("mcfProp ignored : " + prop.getName() );
continue;
}
for (ConnectorConfigProperty property : mcfConfigProperties_) {
if (isEnvPropEqual(prop, property)) {
// we have a match
same = true;
// _logger.finest("mcfprop matched : " + prop.getName());
break;
}
}
if (!same) {
// return false;
return ReconfigAction.RECREATE_POOL;
}
same = false;
}
return ReconfigAction.NO_OP;
}
use of com.sun.enterprise.deployment.ConnectorConfigProperty 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.enterprise.deployment.ConnectorConfigProperty in project Payara by payara.
the class ActiveOutboundResourceAdapter method logMergedProperties.
private void logMergedProperties(Set mergedProps) {
if (_logger.isLoggable(Level.FINE)) {
_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(); ) {
ConnectorConfigProperty element = (ConnectorConfigProperty) iter.next();
b.append("\nName: " + element.getName() + " Value: " + element.getValue());
}
_logger.fine(b.toString());
}
}
use of com.sun.enterprise.deployment.ConnectorConfigProperty in project Payara by payara.
the class ConnectorsRecoveryResourceHandler method getdbUserPasswordOfConnectorConnectionPool.
private String[] getdbUserPasswordOfConnectorConnectionPool(ConnectorConnectionPool connectorConnectionPool) {
String[] userPassword = new String[2];
userPassword[0] = null;
userPassword[1] = null;
List<Property> properties = connectorConnectionPool.getProperty();
if (properties != null) {
boolean foundUserPassword = false;
for (Property elementProperty : properties) {
String prop = elementProperty.getName().toUpperCase(locale);
if ("USERNAME".equals(prop) || "USER".equals(prop)) {
userPassword[0] = elementProperty.getValue();
foundUserPassword = true;
} else if ("PASSWORD".equals(prop)) {
userPassword[1] = elementProperty.getValue();
foundUserPassword = true;
}
}
if (foundUserPassword == true) {
return userPassword;
}
}
PoolInfo poolInfo = ConnectorsUtil.getPoolInfo(connectorConnectionPool);
String rarName = connectorConnectionPool.getResourceAdapterName();
String connectionDefName = connectorConnectionPool.getConnectionDefinitionName();
ConnectorRegistry connectorRegistry = ConnectorRegistry.getInstance();
ConnectorDescriptor connectorDescriptor = connectorRegistry.getDescriptor(rarName);
ConnectionDefDescriptor cdd = connectorDescriptor.getConnectionDefinitionByCFType(connectionDefName);
Set configProps = cdd.getConfigProperties();
for (Iterator iter = configProps.iterator(); iter.hasNext(); ) {
ConnectorConfigProperty envProp = (ConnectorConfigProperty) iter.next();
String prop = envProp.getName().toUpperCase(locale);
if ("USER".equals(prop) || "USERNAME".equals(prop)) {
userPassword[0] = envProp.getValue();
} else if ("PASSWORD".equals(prop)) {
userPassword[1] = envProp.getValue();
}
}
if (userPassword[0] != null && !"".equals(userPassword[0].trim())) {
return userPassword;
}
// else read the default username and password from the ra.xml
ManagedConnectionFactory mcf = connectorRegistry.getManagedConnectionFactory(poolInfo);
userPassword[0] = ConnectionPoolObjectsUtils.getValueFromMCF("UserName", poolInfo, mcf);
userPassword[1] = ConnectionPoolObjectsUtils.getValueFromMCF("Password", poolInfo, mcf);
return userPassword;
}
use of com.sun.enterprise.deployment.ConnectorConfigProperty in project Payara by payara.
the class ActiveJmsResourceAdapter method setJmsServiceProperties.
private void setJmsServiceProperties(JmsService service) throws ConnectorRuntimeException {
JmsRaUtil jmsraUtil = new JmsRaUtil(service);
jmsraUtil.setupAddressList();
urlList = jmsraUtil.getUrlList();
addressList = urlList.toString();
if (_logger.isLoggable(Level.INFO)) {
_logger.log(Level.INFO, JMSLoggerInfo.ADDRESSLIST_JMSPROVIDER, new Object[] { addressList });
}
ConnectorDescriptor cd = super.getDescriptor();
setConnectionURL(service, urlList);
String val = "" + jmsraUtil.getReconnectEnabled();
ConnectorConfigProperty envProp2 = new ConnectorConfigProperty(RECONNECTENABLED, val, val, "java.lang.Boolean");
setProperty(cd, envProp2);
// convert to milliseconds
int newval = Integer.parseInt(jmsraUtil.getReconnectInterval()) * 1000;
val = "" + newval;
ConnectorConfigProperty envProp3 = new ConnectorConfigProperty(RECONNECTINTERVAL, val, val, "java.lang.Integer");
setProperty(cd, envProp3);
val = "" + jmsraUtil.getReconnectAttempts();
ConnectorConfigProperty envProp4 = new ConnectorConfigProperty(RECONNECTATTEMPTS, val, val, "java.lang.Integer");
setProperty(cd, envProp4);
val = "" + jmsraUtil.getAddressListBehaviour();
ConnectorConfigProperty envProp5 = new ConnectorConfigProperty(ADRLIST_BEHAVIOUR, val, val, "java.lang.String");
setProperty(cd, envProp5);
val = "" + jmsraUtil.getAddressListIterations();
ConnectorConfigProperty envProp6 = new ConnectorConfigProperty(ADRLIST_ITERATIONS, val, val, "java.lang.Integer");
setProperty(cd, envProp6);
boolean useExternal = shouldUseExternalRmiRegistry(jmsraUtil);
val = Boolean.valueOf(useExternal).toString();
ConnectorConfigProperty envProp7 = new ConnectorConfigProperty(USEEXTERNALRMIREGISTRY, val, val, "java.lang.Boolean");
setProperty(cd, envProp7);
_logger.log(Level.FINE, "Start RMI registry set as " + val);
// If MQ RA needs to use AS RMI Registry Port, then set
// the RMI registry port, else MQ RA uses its default RMI
// Registry port [as of now 1099]
String configuredRmiRegistryPort = null;
if (!useExternal) {
configuredRmiRegistryPort = getRmiRegistryPort();
} else {
/* We will be here if we are LOCAL or REMOTE, standalone
* or clustered. We could set the Rmi registry port.
* The RA should ignore the port if REMOTE and use it only
* for LOCAL cases.
*/
configuredRmiRegistryPort = getUniqueRmiRegistryPort();
}
val = configuredRmiRegistryPort;
if (val != null) {
ConnectorConfigProperty envProp8 = new ConnectorConfigProperty(RMIREGISTRYPORT, val, val, "java.lang.Integer");
setProperty(cd, envProp8);
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "RMI registry port set as " + val);
}
} else {
if (_logger.isLoggable(Level.WARNING)) {
_logger.log(Level.WARNING, JMSLoggerInfo.INVALID_RMI_PORT);
}
}
}
Aggregations