use of org.jvnet.hk2.config.ConfigCode in project Payara by payara.
the class InstallerThread method install.
/**
* <p> Install the admingui.war file.</p>
*/
private void install() throws Exception {
if (domain.getSystemApplicationReferencedFrom(env.getInstanceName(), AdminConsoleAdapter.ADMIN_APP_NAME) != null) {
// Application is already installed
adapter.setStateMsg(AdapterState.APPLICATION_INSTALLED_BUT_NOT_LOADED);
return;
}
// Set the adapter state
adapter.setStateMsg(AdapterState.INSTALLING);
if (log.isLoggable(Level.FINE)) {
log.log(Level.FINE, "Installing the Admin Console Application...");
}
// create the application entry in domain.xml
ConfigCode code = new ConfigCode() {
@Override
public Object run(ConfigBeanProxy... proxies) throws PropertyVetoException, TransactionFailure {
SystemApplications sa = (SystemApplications) proxies[0];
Application app = sa.createChild(Application.class);
sa.getModules().add(app);
app.setName(AdminConsoleAdapter.ADMIN_APP_NAME);
app.setEnabled(Boolean.TRUE.toString());
// TODO
app.setObjectType("system-admin");
app.setDirectoryDeployed("true");
app.setContextRoot(contextRoot);
try {
app.setLocation("${com.sun.aas.installRootURI}/lib/install/applications/" + AdminConsoleAdapter.ADMIN_APP_NAME);
} catch (Exception me) {
// can't do anything
throw new RuntimeException(me);
}
Module singleModule = app.createChild(Module.class);
app.getModule().add(singleModule);
singleModule.setName(app.getName());
Engine webe = singleModule.createChild(Engine.class);
webe.setSniffer("web");
Engine sece = singleModule.createChild(Engine.class);
sece.setSniffer("security");
singleModule.getEngines().add(webe);
singleModule.getEngines().add(sece);
Server s = (Server) proxies[1];
List<ApplicationRef> arefs = s.getApplicationRef();
ApplicationRef aref = s.createChild(ApplicationRef.class);
aref.setRef(app.getName());
aref.setEnabled(Boolean.TRUE.toString());
// TODO
aref.setVirtualServers(getVirtualServerList());
arefs.add(aref);
return true;
}
};
Server server = domain.getServerNamed(env.getInstanceName());
ConfigSupport.apply(code, domain.getSystemApplications(), server);
// Set the adapter state
adapter.setStateMsg(AdapterState.APPLICATION_INSTALLED_BUT_NOT_LOADED);
if (log.isLoggable(Level.FINE)) {
log.log(Level.FINE, "Admin Console Application Installed.");
}
}
use of org.jvnet.hk2.config.ConfigCode in project Payara by payara.
the class WebContainerImpl method removeListener.
private void removeListener(String name) {
try {
NetworkListeners networkListeners = networkConfig.getNetworkListeners();
final NetworkListener listenerToBeRemoved = networkConfig.getNetworkListener(name);
final Protocols protocols = networkConfig.getProtocols();
final Protocol protocol = networkConfig.findProtocol(name);
if (listenerToBeRemoved == null) {
log.severe("Network Listener " + name + " doesn't exist");
} else {
final com.sun.enterprise.config.serverbeans.VirtualServer virtualServer = httpService.getVirtualServerByName(listenerToBeRemoved.findHttpProtocol().getHttp().getDefaultVirtualServer());
ConfigSupport.apply(new ConfigCode() {
public Object run(ConfigBeanProxy... params) throws PropertyVetoException {
final NetworkListeners listeners = (NetworkListeners) params[0];
final com.sun.enterprise.config.serverbeans.VirtualServer server = (com.sun.enterprise.config.serverbeans.VirtualServer) params[1];
listeners.getNetworkListener().remove(listenerToBeRemoved);
server.removeNetworkListener(listenerToBeRemoved.getName());
return listenerToBeRemoved;
}
}, networkListeners, virtualServer);
ConfigSupport.apply(new ConfigCode() {
public Object run(ConfigBeanProxy... params) throws PropertyVetoException {
final Protocols protocols = (Protocols) params[0];
final Protocol protocol = (Protocol) params[1];
protocols.getProtocol().remove(protocol);
return protocol;
}
}, protocols, protocol);
}
} catch (TransactionFailure e) {
log.severe("Remove listener " + name + " failed " + e.getMessage());
}
}
Aggregations