use of org.jvnet.hk2.config.Changed.TYPE in project Payara by payara.
the class GrizzlyService method postConstruct.
/**
* The component has been injected with any dependency and
* will be placed into commission by the subsystem.
*/
@Override
public void postConstruct() {
events.register(this);
final NetworkConfig networkConfig = config.getNetworkConfig();
configListener = new DynamicConfigListener(config, LOGGER);
ObservableBean bean = (ObservableBean) ConfigSupport.getImpl(networkConfig.getNetworkListeners());
bean.addListener(configListener);
bean = (ObservableBean) ConfigSupport.getImpl(config.getHttpService());
bean.addListener(configListener);
transactions.addListenerForType(SystemProperty.class, configListener);
configListener.setGrizzlyService(this);
try {
boolean isAtLeastOneProxyStarted = false;
futures = new ArrayList<>();
// Record how long it took for the listeners to start up
final long startTime = System.currentTimeMillis();
// Keep a list of successfully started listeners
List<NetworkListener> startedListeners = new ArrayList<>();
for (NetworkListener listener : networkConfig.getNetworkListeners().getNetworkListener()) {
if (createNetworkProxy(listener) != null) {
isAtLeastOneProxyStarted = true;
startedListeners.add(listener);
}
}
if (isAtLeastOneProxyStarted) {
// Get the startup time
final long startupTime = System.currentTimeMillis() - startTime;
// Log the listeners which started.
String boundAddresses = Arrays.toString(startedListeners.stream().map(listener -> listener.getName() + ":" + getRealPort(listener)).collect(Collectors.toList()).toArray());
LOGGER.log(Level.INFO, KernelLoggerInfo.grizzlyStarted, new Object[] { Grizzly.getDotedVersion(), startupTime, boundAddresses });
registerContainerAdapters();
}
} catch (RuntimeException e) {
// So far postConstruct can not throw any other exception type
LOGGER.log(Level.SEVERE, KernelLoggerInfo.grizzlyCantStart, e);
for (NetworkProxy proxy : proxies) {
try {
proxy.stop();
} catch (Exception proxyStopException) {
LOGGER.log(Level.SEVERE, KernelLoggerInfo.grizzlyCloseException, new Object[] { proxy.getPort(), proxyStopException });
}
}
throw e;
}
registerMonitoringStatsProviders();
}
use of org.jvnet.hk2.config.Changed.TYPE in project Payara by payara.
the class HealthCheckService method getCollectiveHealthChecks.
private Map<String, Set<HealthCheck>> getCollectiveHealthChecks(HealthCheckType type) {
final Map<String, Set<HealthCheck>> healthChecks;
if (type == READINESS) {
healthChecks = readiness;
} else if (type == LIVENESS) {
healthChecks = liveness;
} else if (type == STARTUP) {
healthChecks = startup;
} else {
// Make sure we do a deep-copy first, otherwise the first map the foreach consumer gets used on will be a
// shallow copy: the two maps will essentially be the same map (changes to one affecting the other)
healthChecks = readiness.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey(), entry -> new HashSet(entry.getValue())));
BiConsumer<? super String, ? super Set<HealthCheck>> mergeHealthCheckMap = (key, value) -> healthChecks.merge(key, value, (oldValue, newValue) -> {
oldValue.addAll(newValue);
return oldValue;
});
liveness.forEach(mergeHealthCheckMap);
startup.forEach(mergeHealthCheckMap);
}
return healthChecks;
}
use of org.jvnet.hk2.config.Changed.TYPE in project Payara by payara.
the class ConfigDomainParser method parseIDEntry.
private void parseIDEntry(ProviderConfig pConfig, Map<String, GFServerConfigProvider.InterceptEntry> newConfig, String intercept) throws IOException {
String id = pConfig.getProviderId();
String type = pConfig.getProviderType();
String moduleClass = pConfig.getClassName();
MessagePolicy requestPolicy = parsePolicy((RequestPolicy) pConfig.getRequestPolicy());
MessagePolicy responsePolicy = parsePolicy((ResponsePolicy) pConfig.getResponsePolicy());
// get the module options
Map<String, Object> options = new HashMap<>();
List<Property> pList = pConfig.getProperty();
if (pList != null) {
Iterator<Property> pit = pList.iterator();
while (pit.hasNext()) {
Property property = pit.next();
try {
options.put(property.getName(), expand(property.getValue()));
} catch (IllegalStateException ee) {
// interpret value itself.
if (_logger.isLoggable(FINE)) {
_logger.log(FINE, "jaspic.unexpandedproperty");
}
options.put(property.getName(), property.getValue());
}
}
}
if (_logger.isLoggable(FINE)) {
_logger.fine("ID Entry: " + "\n module class: " + moduleClass + "\n id: " + id + "\n type: " + type + "\n request policy: " + requestPolicy + "\n response policy: " + responsePolicy + "\n options: " + options);
}
// create ID entry
GFServerConfigProvider.IDEntry idEntry = new GFServerConfigProvider.IDEntry(type, moduleClass, requestPolicy, responsePolicy, options);
GFServerConfigProvider.InterceptEntry intEntry = newConfig.get(intercept);
if (intEntry == null) {
throw new IOException("intercept entry for " + intercept + " must be specified before ID entries");
}
if (intEntry.idMap == null) {
intEntry.idMap = new HashMap<>();
}
// map id to Intercept
intEntry.idMap.put(id, idEntry);
}
use of org.jvnet.hk2.config.Changed.TYPE in project Payara by payara.
the class ActiveJmsResourceAdapter method setLifecycleProperties.
/**
* Set MQ4.0 RA lifecycle properties
*/
private void setLifecycleProperties() throws Exception, ConnectorRuntimeException {
// ConfigContext ctx = ApplicationServer.getServerContext().getConfigContext();
// If PE:
// EMBEDDED/LOCAL goto jms-service, get defaultjmshost info and set
// accordingly
// if EE:
// EMBEDDED/LOCAL get this instance and cluster name, search for a
// jms-host wth this this name in jms-service gets its proeprties
// and set
// @siva As of now use default JMS host. As soon as changes for modifying EE
// cluster to LOCAL is brought in, change this to use system properties
// for EE to get port, host, adminusername, adminpassword.
// JmsService jmsService = ServerBeansFactory.getJmsServiceBean(ctx);
String defaultJmsHost = getJmsService().getDefaultJmsHost();
if (_logger.isLoggable(Level.FINE))
logFine("Default JMS Host :: " + defaultJmsHost);
JmsHost jmsHost = getJmsHost();
if (jmsHost != null) {
// todo: && jmsHost.isEnabled()) {
JavaConfig javaConfig = (JavaConfig) Globals.get(JavaConfig.class);
;
String java_home = javaConfig.getJavaHome();
// Get broker type from JMS Service.
// String brokerType = jmsService.getType();
/*
* XXX: adjust the brokertype for the new DIRECT mode in 4.1
* uncomment the line below once we have an MQ integration
* that has DIRECT mode support
*/
String brokerType = adjustForDirectMode(getJmsService().getType());
String brokerPort = jmsHost.getPort();
brkrPort = brokerPort;
String adminUserName = jmsHost.getAdminUserName();
String adminPassword = JmsRaUtil.getUnAliasedPwd(jmsHost.getAdminPassword());
List jmsHostProps = getJmsService().getProperty();
String username = null;
String password = null;
if (jmsHostProps != null) {
for (int i = 0; i < jmsHostProps.size(); i++) {
Property jmsProp = (Property) jmsHostProps.get(i);
String propName = jmsProp.getName();
String propValue = jmsProp.getValue();
if ("user-name".equals(propName)) {
username = propValue;
} else if ("password".equals(propName)) {
password = propValue;
}
// Add more properties as and when you want.
}
}
if (_logger.isLoggable(Level.FINE))
logFine("Broker UserName = " + username);
createMQVarDirectoryIfNecessary();
String brokerVarDir = getMQVarDir();
String tmpString = getJmsService().getStartArgs();
if (tmpString == null) {
tmpString = "";
}
String brokerArgs = tmpString;
// by adding the start-args for the broker configuration
if (!tmpString.contains("-jrehome") && availableJDKForStartArgs()) {
brokerArgs = brokerArgs + buildStartArgsForJREHome(java_home);
}
// XX: Extract the information from the optional properties.
List jmsProperties = getJmsService().getProperty();
List jmsHostProperties = jmsHost.getProperty();
Properties jmsServiceProp = listToProperties(jmsProperties);
Properties jmsHostProp = listToProperties(jmsHostProperties);
jmsServiceProp.putAll(jmsHostProp);
if (jmsServiceProp.size() > 0) {
if (dbProps == null)
dbProps = new Properties();
dbProps.putAll(jmsServiceProp);
}
/*
String jmsPropertiesStr = null ;
if(jmsServiceProp.size() > 0)
{
try{
StringWriter writer = new StringWriter();
jmsServiceProp.store(writer, "Properties defined in JMSService and JMSHost");
jmsPropertiesStr = writer.toString();
}catch(Exception e){}//todo: log error;
} */
String brokerHomeDir = getBrokerHomeDir();
String brokerLibDir = getBrokerLibDir();
if (brokerInstanceName == null) {
brokerInstanceName = getBrokerInstanceName(getJmsService());
}
long brokerTimeOut = getBrokerTimeOut(getJmsService());
// Need to set the following properties
// BrokerType, BrokerInstanceName, BrokerPort,
// BrokerArgs, BrokerHomeDir, BrokerVarDir, BrokerStartTimeout
// adminUserName, adminPassword
ConnectorDescriptor cd = getDescriptor();
/*if(jmsPropertiesStr != null){
ConnectorConfigProperty envProp = new ConnectorConfigProperty (
"BrokerProps", jmsPropertiesStr, "Broker Props", "java.lang.String");
setProperty(cd, envProp);
} */
ConnectorConfigProperty envProp1 = new ConnectorConfigProperty(BROKERTYPE, brokerType, "Broker Type", "java.lang.String");
setProperty(cd, envProp1);
ConnectorConfigProperty envProp2 = new ConnectorConfigProperty(BROKERINSTANCENAME, brokerInstanceName, "Broker Instance Name", "java.lang.String");
setProperty(cd, envProp2);
ConnectorConfigProperty envProp3 = new ConnectorConfigProperty(BROKERPORT, brokerPort, "Broker Port", "java.lang.String");
setProperty(cd, envProp3);
ConnectorConfigProperty envProp4 = new ConnectorConfigProperty(BROKERARGS, brokerArgs, "Broker Args", "java.lang.String");
setProperty(cd, envProp4);
ConnectorConfigProperty envProp5 = new ConnectorConfigProperty(BROKERHOMEDIR, brokerHomeDir, "Broker Home Dir", "java.lang.String");
setProperty(cd, envProp5);
ConnectorConfigProperty envProp14 = new ConnectorConfigProperty(BROKERLIBDIR, brokerLibDir, "Broker Lib Dir", "java.lang.String");
setProperty(cd, envProp14);
ConnectorConfigProperty envProp6 = new ConnectorConfigProperty(BROKERJAVADIR, java_home, "Broker Java Dir", "java.lang.String");
setProperty(cd, envProp6);
ConnectorConfigProperty envProp7 = new ConnectorConfigProperty(BROKERVARDIR, brokerVarDir, "Broker Var Dir", "java.lang.String");
setProperty(cd, envProp7);
ConnectorConfigProperty envProp8 = new ConnectorConfigProperty(BROKERSTARTTIMEOUT, "" + brokerTimeOut, "Broker Start Timeout", "java.lang.String");
setProperty(cd, envProp8);
ConnectorConfigProperty envProp9 = new ConnectorConfigProperty(ADMINUSERNAME, adminUserName, "Broker admin username", "java.lang.String");
setProperty(cd, envProp9);
ConnectorConfigProperty envProp10 = new ConnectorConfigProperty(ADMINPASSWORD, adminPassword, "Broker admin password", "java.lang.String");
setProperty(cd, envProp10);
ConnectorConfigProperty envProp11 = new ConnectorConfigProperty(USERNAME, username, "Broker username", "java.lang.String");
setProperty(cd, envProp11);
ConnectorConfigProperty envProp12 = new ConnectorConfigProperty(PASSWORD, password, "Broker password", "java.lang.String");
setProperty(cd, envProp12);
/* //set adminpassfile
if (!getJmsService().getType().equals(REMOTE)) {
//For LOCAL and EMBEDDED, we pass in the admin pass file path
//containing the MQ admin password to enable authenticated
//startup of the broker.
String adminPassFilePath = getAdminPassFilePath(adminPassword);
if (adminPassFilePath != null) {
ConnectorConfigProperty envProp13 = new ConnectorConfigProperty (
ADMINPASSFILE , adminPassFilePath ,
"Broker admin password", "java.lang.String");
setProperty(cd, envProp13);
}
}*/
}
// Optional
// BrokerBindAddress, RmiRegistryPort
}
use of org.jvnet.hk2.config.Changed.TYPE in project Payara by payara.
the class JDBCResourceManager method delete.
public ResourceStatus delete(final Resources resources, final String jndiName, final String target) throws Exception {
if (jndiName == null) {
String msg = localStrings.getLocalString("jdbc.resource.noJndiName", "No JNDI name defined for JDBC resource.");
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
// ensure we already have this resource
if (ConnectorsUtil.getResourceByName(resources, JdbcResource.class, jndiName) == null) {
String msg = localStrings.getLocalString("delete.jdbc.resource.notfound", "A JDBC resource named {0} does not exist.", jndiName);
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
if (environment.isDas()) {
if ("domain".equals(target)) {
if (resourceUtil.getTargetsReferringResourceRef(jndiName).size() > 0) {
String msg = localStrings.getLocalString("delete.jdbc.resource.resource-ref.exist", "jdbc-resource [ {0} ] is referenced in an" + "instance/cluster target, Use delete-resource-ref on appropriate target", jndiName);
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
} else {
if (!resourceUtil.isResourceRefInTarget(jndiName, target)) {
String msg = localStrings.getLocalString("delete.jdbc.resource.no.resource-ref", "jdbc-resource [ {0} ] is not referenced in target [ {1} ]", jndiName, target);
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
if (resourceUtil.getTargetsReferringResourceRef(jndiName).size() > 1) {
String msg = localStrings.getLocalString("delete.jdbc.resource.multiple.resource-refs", "jdbc resource [ {0} ] is referenced in multiple " + "instance/cluster targets, Use delete-resource-ref on appropriate target", jndiName);
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
}
}
try {
JdbcResource jdbcResource = (JdbcResource) ConnectorsUtil.getResourceByName(resources, JdbcResource.class, jndiName);
if (ResourceConstants.SYSTEM_ALL_REQ.equals(jdbcResource.getObjectType())) {
String msg = localStrings.getLocalString("delete.jdbc.resource.system-all-req.object-type", "The jdbc resource [ {0} ] cannot be deleted as it is required to be configured in the system.", jndiName);
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
// delete resource-ref
resourceUtil.deleteResourceRef(jndiName, target);
// delete jdbc-resource
if (ConfigSupport.apply(new SingleConfigCode<Resources>() {
public Object run(Resources param) throws PropertyVetoException, TransactionFailure {
JdbcResource resource = (JdbcResource) ConnectorsUtil.getResourceByName(resources, JdbcResource.class, jndiName);
return param.getResources().remove(resource);
}
}, resources) == null) {
String msg = localStrings.getLocalString("jdbc.resource.deletionFailed", "JDBC resource {0} delete failed ", jndiName);
return new ResourceStatus(ResourceStatus.FAILURE, msg);
}
} catch (TransactionFailure tfe) {
String msg = localStrings.getLocalString("jdbc.resource.deletionFailed", "JDBC resource {0} delete failed ", jndiName);
ResourceStatus status = new ResourceStatus(ResourceStatus.FAILURE, msg);
status.setException(tfe);
return status;
}
String msg = localStrings.getLocalString("jdbc.resource.deleteSuccess", "JDBC resource {0} deleted successfully", jndiName);
return new ResourceStatus(ResourceStatus.SUCCESS, msg);
}
Aggregations