use of org.jvnet.hk2.config.ConfigModel.Property in project Payara by payara.
the class WebConfigListener method changed.
/**
* Handles HttpService change events
* @param events the PropertyChangeEvent
*/
@Override
public synchronized UnprocessedChangeEvents changed(PropertyChangeEvent[] events) {
return ConfigSupport.sortAndDispatch(events, new Changed() {
@Override
public <T extends ConfigBeanProxy> NotProcessed changed(TYPE type, Class<T> tClass, T t) {
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, LogFacade.CHANGE_INVOKED, new Object[] { type, tClass, t });
}
try {
if (tClass == HttpService.class) {
container.updateHttpService((HttpService) t);
} else if (tClass == NetworkListener.class) {
if (type == TYPE.ADD) {
container.addConnector((NetworkListener) t, httpService, true);
} else if (type == TYPE.REMOVE) {
container.deleteConnector((NetworkListener) t);
} else if (type == TYPE.CHANGE) {
container.updateConnector((NetworkListener) t, httpService);
}
} else if (tClass == VirtualServer.class) {
if (type == TYPE.ADD) {
container.createHost((VirtualServer) t, httpService, null);
container.loadDefaultWebModule((VirtualServer) t);
} else if (type == TYPE.REMOVE) {
container.deleteHost(httpService);
} else if (type == TYPE.CHANGE) {
container.updateHost((VirtualServer) t);
}
} else if (tClass == AccessLog.class) {
container.updateAccessLog(httpService);
} else if (tClass == ManagerProperties.class) {
return new NotProcessed("ManagerProperties requires restart");
} else if (tClass == WebContainerAvailability.class || tClass == AvailabilityService.class) {
// container.updateHttpService handles SingleSignOn valve configuration
container.updateHttpService(httpService);
} else if (tClass == NetworkListeners.class) {
// skip updates
} else if (tClass == Property.class) {
ConfigBeanProxy config = ((Property) t).getParent();
if (config instanceof HttpService) {
container.updateHttpService((HttpService) config);
} else if (config instanceof VirtualServer) {
container.updateHost((VirtualServer) config);
} else if (config instanceof NetworkListener) {
container.updateConnector((NetworkListener) config, httpService);
} else {
container.updateHttpService(httpService);
}
} else if (tClass == SystemProperty.class) {
if (((SystemProperty) t).getName().endsWith("LISTENER_PORT")) {
for (NetworkListener listener : networkConfig.getNetworkListeners().getNetworkListener()) {
if (listener.getPort().equals(((SystemProperty) t).getValue())) {
container.updateConnector(listener, httpService);
}
}
}
} else if (tClass == JavaConfig.class) {
JavaConfig jc = (JavaConfig) t;
final List<String> jvmOptions = new ArrayList<String>(jc.getJvmOptions());
for (String jvmOption : jvmOptions) {
if (jvmOption.startsWith("-DjvmRoute=")) {
container.updateJvmRoute(httpService, jvmOption);
}
}
} else {
// Ignore other unrelated events
}
} catch (LifecycleException le) {
logger.log(Level.SEVERE, LogFacade.EXCEPTION_WEB_CONFIG, le);
}
return null;
}
}, logger);
}
use of org.jvnet.hk2.config.ConfigModel.Property in project Payara by payara.
the class ActiveJmsResourceAdapter method getPhysicalDestinationFromConfiguration.
private String getPhysicalDestinationFromConfiguration(String logicalDest, String appName, String moduleName) throws ConnectorRuntimeException {
Property ep = null;
try {
// ServerContext sc = ApplicationServer.getServerContext();
// ConfigContext ctx = sc.getConfigContext();
// Resources rbeans = ServerBeansFactory.getDomainBean(ctx).getResources();
AdminObjectResource res = null;
res = (AdminObjectResource) ResourcesUtil.createInstance().getResource(logicalDest, appName, moduleName, AdminObjectResource.class);
// AdminObjectResource res = (AdminObjectResource) allResources.getAdminObjectResourceByJndiName(logicalDest);
if (res == null) {
String msg = sm.getString("ajra.err_getting_dest", logicalDest);
throw new ConnectorRuntimeException(msg);
}
// getElementPropertyByName(PHYSICAL_DESTINATION);
ep = res.getProperty(PHYSICAL_DESTINATION);
} catch (Exception ce) {
String msg = sm.getString("ajra.err_getting_dest", logicalDest);
ConnectorRuntimeException cre = new ConnectorRuntimeException(msg);
cre.initCause(ce);
throw cre;
}
if (ep == null) {
String msg = sm.getString("ajra.cannot_find_phy_dest", null);
throw new ConnectorRuntimeException(msg);
}
return ep.getValue();
}
use of org.jvnet.hk2.config.ConfigModel.Property in project Payara by payara.
the class ActiveJmsResourceAdapter method loadDBProperties.
private void loadDBProperties(JmsAvailability jmsAvailability, ClusterMode clusterMode) {
/*imq.cluster.nomasterbroker=[true|false] default false
imq.cluster.sharecc.persist.jdbc.dbVendor
imq.cluster.sharecc.persist.jdbc.<dbVendor>.user
imq.cluster.sharecc.persist.jdbc.<dbVendor>.property.<propname>=<propval>
imq.cluster.sharecc.persist.jdbc.<dbVendor>.table.MQSHARECC45=<table-schema>
These broker properties, including imq.cluster.clusterid, must be set to
same values in all broker instances in the conventional cluster
*/
String prefix = null;
if (ClusterMode.CONVENTIONAL_WITH_MASTER_BROKER == clusterMode) {
prefix = ENHANCED_CLUSTER_DB_PREFIX;
} else if (ClusterMode.CONVENTIONAL_OF_PEER_BROKERS == clusterMode) {
prefix = CONVENTIONAL_CLUSTER__OF_PEER_BROKERS_DB_PREFIX;
} else if (ClusterMode.ENHANCED == clusterMode) {
prefix = ENHANCED_CLUSTER_DB_PREFIX;
} else {
if (_logger.isLoggable(Level.FINE))
logFine("Unknown cluster mode: " + clusterMode.name() + ", imq DB properties are not set.");
return;
}
if (dbProps == null)
dbProps = new Properties();
dbProps.setProperty("imq.cluster.clusterid", getMQClusterName());
dbProps.setProperty("imq.persist.store", jmsAvailability.getMessageStoreType());
if (ClusterMode.CONVENTIONAL_WITH_MASTER_BROKER == clusterMode)
dbProps.setProperty("imq.cluster.nomasterbroker", "false");
else
dbProps.setProperty("imq.cluster.nomasterbroker", "true");
if (Boolean.valueOf(jmsAvailability.getAvailabilityEnabled()) == true || "jdbc".equals(jmsAvailability.getMessageStoreType()))
dbProps.setProperty("imq.brokerid", getBrokerInstanceName(getJmsService()));
String dbVendor = jmsAvailability.getDbVendor();
String dbuser = jmsAvailability.getDbUsername();
String dbPassword = jmsAvailability.getDbPassword();
String dbJdbcUrl = jmsAvailability.getDbUrl();
dbProps.setProperty(prefix + "dbVendor", dbVendor);
String fullprefix = prefix + dbVendor + ".";
if (dbuser != null)
dbProps.setProperty(fullprefix + "user", dbuser);
if (dbPassword != null)
dbProps.setProperty(fullprefix + "password", dbPassword);
List dbprops = jmsAvailability.getProperty();
String propertyPrefix = fullprefix + "property.";
if (dbJdbcUrl != null) {
if ("derby".equals(dbVendor))
dbProps.setProperty(fullprefix + "opendburl", dbJdbcUrl);
else
dbProps.setProperty(propertyPrefix + "url", dbJdbcUrl);
}
for (Object obj : dbprops) {
Property prop = (Property) obj;
String key = prop.getName();
String value = prop.getValue();
// don't set a prefix if the property name is already prefixed with "imq."
if (key.startsWith("imq."))
dbProps.setProperty(key, value);
else
dbProps.setProperty(propertyPrefix + key, value);
}
}
use of org.jvnet.hk2.config.ConfigModel.Property in project Payara by payara.
the class PropertyReaderImpl method getPropertyReaders.
public static PropertyReader[] getPropertyReaders(LbConfig _lbConfig) {
Properties properties = new Properties();
properties.setProperty(LoadbalancerReader.HTTPS_ROUTING, _lbConfig.getHttpsRouting());
properties.setProperty(LoadbalancerReader.REQ_MONITOR_DATA, _lbConfig.getMonitoringEnabled());
properties.setProperty(LoadbalancerReader.RELOAD_INTERVAL, _lbConfig.getReloadPollIntervalInSeconds());
properties.setProperty(LoadbalancerReader.RESP_TIMEOUT, _lbConfig.getResponseTimeoutInSeconds());
Iterator<Property> propertyList = _lbConfig.getProperty().iterator();
while (propertyList.hasNext()) {
Property property = propertyList.next();
if (property.getName().equals(LbConfig.LAST_APPLIED_PROPERTY) || property.getName().equals(LbConfig.LAST_EXPORTED_PROPERTY)) {
continue;
}
properties.setProperty(property.getName(), property.getValue());
}
return getPropertyReaders(properties);
}
use of org.jvnet.hk2.config.ConfigModel.Property 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;
}
Aggregations