use of org.jvnet.hk2.config.ConfigBean in project Payara by payara.
the class ApplicationLifecycle method prepareAppConfigChanges.
// prepare application config change for later registering
// in the domain.xml
@Override
public Transaction prepareAppConfigChanges(final DeploymentContext context) throws TransactionFailure {
final Properties appProps = context.getAppProps();
final DeployCommandParameters deployParams = context.getCommandParameters(DeployCommandParameters.class);
Transaction tx = null;
Application app_w = null;
if (deployParams.hotDeploy) {
app_w = applications.getApplication(deployParams.name);
}
if (app_w == null) {
try {
tx = new Transaction();
// prepare the application element
ConfigBean newBean = ((ConfigBean) Dom.unwrap(applications)).allocate(Application.class);
Application app = newBean.createProxy();
app_w = tx.enroll(app);
setInitialAppAttributes(app_w, deployParams, appProps, context);
} catch (TransactionFailure e) {
tx.rollback();
throw e;
} catch (Exception e) {
tx.rollback();
throw new TransactionFailure(e.getMessage(), e);
}
}
context.addTransientAppMetaData(ServerTags.APPLICATION, app_w);
return tx;
}
use of org.jvnet.hk2.config.ConfigBean 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 org.jvnet.hk2.config.ConfigBean in project Payara by payara.
the class DirectRemovalTest method doTest.
public void doTest() throws TransactionFailure {
NetworkListeners listeners = habitat.getService(NetworkListeners.class);
ConfigBean serviceBean = (ConfigBean) ConfigBean.unwrap(listeners);
for (NetworkListener listener : listeners.getNetworkListener()) {
if (listener.getName().endsWith("http-listener-1")) {
ConfigSupport.deleteChild(serviceBean, (ConfigBean) ConfigBean.unwrap(listener));
break;
}
}
}
use of org.jvnet.hk2.config.ConfigBean in project Payara by payara.
the class ConfigTest method testGetConfigBean.
// @Test
public void testGetConfigBean() {
SimpleConnector sc = habitat.getService(SimpleConnector.class);
final EjbContainerAvailability ejb = sc.getEjbContainerAvailability();
ConfigBean ejbConfigBean = (ConfigBean) ConfigBean.unwrap(ejb);
assert (ejbConfigBean != null);
}
use of org.jvnet.hk2.config.ConfigBean in project Payara by payara.
the class WriteableView method removeNestedElements.
boolean removeNestedElements(Object object) {
InvocationHandler h = Proxy.getInvocationHandler(object);
if (!(h instanceof WriteableView)) {
// h instanceof ConfigView
ConfigBean bean = (ConfigBean) ((ConfigView) h).getMasterView();
h = bean.getWriteableView();
if (h == null) {
ConfigBeanProxy writable;
try {
writable = currentTx.enroll((ConfigBeanProxy) object);
} catch (TransactionFailure e) {
// something is seriously wrong
throw new RuntimeException(e);
}
h = Proxy.getInvocationHandler(writable);
} else {
// so oldValue was already processed
return false;
}
}
WriteableView writableView = (WriteableView) h;
synchronized (writableView) {
writableView.isDeleted = true;
}
boolean removed = false;
for (Property property : writableView.bean.model.elements.values()) {
if (property.isCollection()) {
Object nested = writableView.getter(property, parameterizedType);
ProtectedList<?> list = (ProtectedList<?>) nested;
if (list.size() > 0) {
list.clear();
removed = true;
}
} else if (!property.isLeaf()) {
// Element
Object oldValue = writableView.getter(property, ConfigBeanProxy.class);
if (oldValue != null) {
writableView.setter(property, null, Dom.class);
removed = true;
removeNestedElements(oldValue);
}
}
}
return removed;
}
Aggregations