use of org.jvnet.hk2.config.ConfigModel.Property in project Payara by payara.
the class ListResourceAdapterConfigs method execute.
/**
* Executes the command with the command parameters passed as Properties
* where the keys are the paramter names and the values the parameter values
*
* @param context information
*/
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
try {
HashMap<String, List<Property>> raMap = new HashMap<String, List<Property>>();
boolean raExists = false;
Collection<ResourceAdapterConfig> resourceAdapterConfigs = domain.getResources().getResources(ResourceAdapterConfig.class);
for (ResourceAdapterConfig r : resourceAdapterConfigs) {
if (raName != null && !raName.isEmpty()) {
if (r.getResourceAdapterName().equals(raName)) {
raMap.put(raName, r.getProperty());
raExists = true;
break;
}
} else {
raMap.put(r.getResourceAdapterName(), r.getProperty());
}
}
if (raName != null && !raName.isEmpty() && !raExists) {
report.setMessage(localStrings.getLocalString("delete.resource.adapter.config.notfound", "Resource adapter {0} not found.", raName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
/**
* get the properties if long_opt=true. Otherwise return the name.
*/
if (long_opt) {
for (Entry<String, List<Property>> raEntry : raMap.entrySet()) {
final ActionReport.MessagePart part = report.getTopMessagePart().addChild();
part.setMessage(raEntry.getKey());
for (Property prop : raEntry.getValue()) {
final ActionReport.MessagePart propPart = part.addChild();
propPart.setMessage("\t" + prop.getName() + "=" + prop.getValue());
}
}
} else {
for (String ra : raMap.keySet()) {
final ActionReport.MessagePart part = report.getTopMessagePart().addChild();
part.setMessage(ra);
}
}
} catch (Exception e) {
String failMsg = localStrings.getLocalString("list.resource.adapter.configs.fail", "Unable to list resource adapter configs.");
Logger.getLogger(ListResourceAdapterConfigs.class.getName()).log(Level.SEVERE, failMsg, e);
report.setMessage(failMsg + " " + e.getLocalizedMessage());
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
use of org.jvnet.hk2.config.ConfigModel.Property in project Payara by payara.
the class AppSpecificConnectorClassLoaderUtil method getRequiredResourceAdapters.
public Collection<String> getRequiredResourceAdapters(String appName) {
List<String> requiredRars = new ArrayList<String>();
if (appName != null) {
ConnectorService connectorService = connectorServiceProvider.get();
if (connectorService != null) {
if (appName.trim().length() > 0) {
Property property = connectorService.getProperty(appName.trim());
if (property != null) {
String requiredRarsString = property.getValue();
StringTokenizer tokenizer = new StringTokenizer(requiredRarsString, ",");
while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken().trim();
requiredRars.add(token);
}
}
}
}
}
return requiredRars;
}
use of org.jvnet.hk2.config.ConfigModel.Property in project Payara by payara.
the class ActiveOutboundResourceAdapter method loadRAConfiguration.
/**
* Loads RA javabean. This method is protected, so that any system
* resource adapter can have specific configuration done during the
* loading.
*
* @throws ConnectorRuntimeException if there is a failure.
*/
protected void loadRAConfiguration() throws ConnectorRuntimeException {
try {
Set mergedProps;
ConnectorRegistry registry = ConnectorRegistry.getInstance();
ResourceAdapterConfig raConfig = registry.getResourceAdapterConfig(moduleName_);
List<Property> raConfigProps = new ArrayList<Property>();
mergedProps = mergeRAConfiguration(raConfig, raConfigProps);
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;
}
}
use of org.jvnet.hk2.config.ConfigModel.Property in project Payara by payara.
the class ConnectorDDTransformUtils method mergeProps.
/**
* merges the properties mentioned in first parameter with the Set of
* properties mentioned in second parameter.
* Values of first parameter takes precedence over second.
* First parameter represents properties present in domain.xml
* Second parameter contains values mentioned in deployment descriptors.
*
* @param props Array of properties that needs to be merged with
* properties mentioned in deployment descriptor. These values
* takes precedence over values present in deployment descriptors.
* @param propertiesToSkip properties to be skipped while merging. They will be skipped
* only when both its name as well as its value match.
* @return Set of merged properties.
*/
public static Set mergeProps(List<Property> props, Set defaultMCFProps, Properties propertiesToSkip) {
HashSet mergedSet = new HashSet();
if (defaultMCFProps != null) {
Object[] defaultProps = defaultMCFProps.toArray();
for (int i = 0; i < defaultProps.length; i++) {
ConnectorConfigProperty ep1 = (ConnectorConfigProperty) defaultProps[i];
if (propertiesToSkip.containsKey(ep1.getName())) {
// Skip the property if the values are equal
String propertyValue = (String) propertiesToSkip.get(ep1.getName());
if (ep1.getValue() != null && propertyValue != null) {
if (ep1.getValue().equals(propertyValue)) {
continue;
}
}
}
mergedSet.add(defaultProps[i]);
}
}
for (Property property : props) {
ConnectorConfigProperty ep = new ConnectorConfigProperty(property.getName(), property.getValue(), null);
if (defaultMCFProps.contains(ep)) {
// get the environment property in the mergedset
Iterator iter = defaultMCFProps.iterator();
while (iter.hasNext()) {
ConnectorConfigProperty envProp = (ConnectorConfigProperty) iter.next();
if (envProp.equals(ep)) {
if (envProp.getType() != null) {
ep.setType(envProp.getType());
}
// Make sure that the new environment property inherits
// confidential flag from the DD's property.
ep.setConfidential(envProp.isConfidential());
}
}
if (_logger.isLoggable(Level.FINER)) {
_logger.log(Level.FINER, "After merging props with defaultMCFProps: envPropName: " + ep.getName() + " envPropValue : " + ep.getValue());
}
mergedSet.remove(ep);
}
mergedSet.add(ep);
}
return mergedSet;
}
use of org.jvnet.hk2.config.ConfigModel.Property in project Payara by payara.
the class ConnectorConnectionPoolDeployer method redeployResource.
/**
* {@inheritDoc}
*/
public synchronized void redeployResource(Object resource) throws Exception {
// Connector connection pool reconfiguration or
// change in security maps
org.glassfish.connectors.config.ConnectorConnectionPool domainCcp = (org.glassfish.connectors.config.ConnectorConnectionPool) resource;
List<SecurityMap> securityMaps = domainCcp.getSecurityMap();
// Since 8.1 PE/SE/EE, only if pool has already been deployed in this
// server-instance earlier, reconfig this pool
PoolInfo poolInfo = ConnectorsUtil.getPoolInfo(domainCcp);
if (!runtime.isConnectorConnectionPoolDeployed(poolInfo)) {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("The connector connection pool " + poolInfo + " is either not referred or not yet created in " + "this server instance and pool and hence " + "redeployment is ignored");
}
return;
}
String rarName = domainCcp.getResourceAdapterName();
String connDefName = domainCcp.getConnectionDefinitionName();
List<Property> props = domainCcp.getProperty();
ConnectorConnectionPool ccp = getConnectorConnectionPool(domainCcp, poolInfo);
populateConnectorConnectionPool(ccp, connDefName, rarName, props, securityMaps);
boolean poolRecreateRequired = false;
try {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Calling reconfigure pool");
}
poolRecreateRequired = runtime.reconfigureConnectorConnectionPool(ccp, new HashSet());
} catch (ConnectorRuntimeException cre) {
Object[] params = new Object[] { poolInfo, cre };
_logger.log(Level.WARNING, "error.reconfiguring.pool", params);
}
if (poolRecreateRequired) {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Pool recreation required");
}
runtime.recreateConnectorConnectionPool(ccp);
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Pool recreation done");
}
}
}
Aggregations