use of com.sun.enterprise.config.serverbeans.JavaConfig 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 com.sun.enterprise.config.serverbeans.JavaConfig in project Payara by payara.
the class DirectAccessTest method doTest.
public void doTest() throws TransactionFailure {
NetworkConfig networkConfig = habitat.getService(NetworkConfig.class);
final NetworkListener listener = networkConfig.getNetworkListeners().getNetworkListener().get(0);
final Http http = listener.findHttpProtocol().getHttp();
ConfigBean config = (ConfigBean) ConfigBean.unwrap(http.getFileCache());
ConfigBean config2 = (ConfigBean) ConfigBean.unwrap(http);
Map<ConfigBean, Map<String, String>> changes = new HashMap<ConfigBean, Map<String, String>>();
Map<String, String> configChanges = new HashMap<String, String>();
configChanges.put("max-age-seconds", "12543");
configChanges.put("max-cache-size-bytes", "1200");
Map<String, String> config2Changes = new HashMap<String, String>();
config2Changes.put("http2-enabled", "false");
changes.put(config, configChanges);
changes.put(config2, config2Changes);
JavaConfig javaConfig = habitat.getService(JavaConfig.class);
ConfigBean javaConfigBean = (ConfigBean) ConfigBean.unwrap(javaConfig);
Map<String, String> javaConfigChanges = new HashMap<String, String>();
javaConfigChanges.put("jvm-options", "-XFooBar=false");
changes.put(javaConfigBean, javaConfigChanges);
getHabitat().<ConfigSupport>getService(ConfigSupport.class).apply(changes);
}
use of com.sun.enterprise.config.serverbeans.JavaConfig in project Payara by payara.
the class DirectCreationTest method doTest.
public void doTest() throws TransactionFailure {
AdminService service = habitat.getService(AdminService.class);
ConfigBean serviceBean = (ConfigBean) ConfigBean.unwrap(service);
Class<?>[] subTypes = null;
try {
subTypes = ConfigSupport.getSubElementsTypes(serviceBean);
} catch (ClassNotFoundException e) {
// To change body of catch statement use File | Settings | File Templates.
e.printStackTrace();
throw new RuntimeException(e);
}
ConfigSupport support = getBaseServiceLocator().getService(ConfigSupport.class);
assertNotNull("ConfigSupport not found", support);
for (Class<?> subType : subTypes) {
// TODO: JL force compilation error to mark this probably edit point for grizzly config
if (subType.getName().endsWith("DasConfig")) {
Map<String, String> configChanges = new HashMap<String, String>();
configChanges.put("dynamic-reload-enabled", "true");
configChanges.put("autodeploy-dir", "funky-dir");
support.createAndSet(serviceBean, (Class<? extends ConfigBeanProxy>) subType, configChanges);
break;
}
}
support.createAndSet(serviceBean, DasConfig.class, (List) null);
List<AttributeChanges> profilerChanges = new ArrayList<AttributeChanges>();
String[] values = { "-Xmx512m", "-RFtrq", "-Xmw24" };
ConfigSupport.MultipleAttributeChanges multipleChanges = new ConfigSupport.MultipleAttributeChanges("jvm-options", values);
String[] values1 = { "profile" };
ConfigSupport.MultipleAttributeChanges multipleChanges1 = new ConfigSupport.MultipleAttributeChanges("name", values1);
profilerChanges.add(multipleChanges);
profilerChanges.add(multipleChanges1);
support.createAndSet((ConfigBean) ConfigBean.unwrap(habitat.<JavaConfig>getService(JavaConfig.class)), Profiler.class, profilerChanges);
}
use of com.sun.enterprise.config.serverbeans.JavaConfig in project Payara by payara.
the class JavaConfigSubTypesTest method testSubTypesOfDomain.
@Test
public void testSubTypesOfDomain() {
JavaConfig config = super.getHabitat().getService(JavaConfig.class);
try {
Class<?>[] subTypes = ConfigSupport.getSubElementsTypes((ConfigBean) ConfigBean.unwrap(config));
boolean found = false;
for (Class subType : subTypes) {
Logger.getAnonymousLogger().fine("Found class " + subType);
if (subType.getName().equals(List.class.getName())) {
found = true;
}
}
Assert.assertTrue(found);
;
} catch (ClassNotFoundException e) {
logger.log(Level.SEVERE, e.getMessage(), e);
}
}
use of com.sun.enterprise.config.serverbeans.JavaConfig in project Payara by payara.
the class CreateProfilerTest method tearDown.
@After
public void tearDown() throws TransactionFailure {
// Delete the created profiler
ConfigSupport.apply(new SingleConfigCode<JavaConfig>() {
public Object run(JavaConfig param) throws PropertyVetoException, TransactionFailure {
if (param.getProfiler() != null) {
param.setProfiler(null);
}
return null;
}
}, javaConfig);
parameters = new ParameterMap();
}
Aggregations