String host = InetAddress.getLocalHost().getHostName();
ServerSocket socket = new ServerSocket(0);
int port = socket.getLocalPort();
socket.close();
ServletHostExtensionPoint servletHosts = domainManagementRuntime.getExtensionPointRegistry().getExtensionPoint(ServletHostExtensionPoint.class);
for (ServletHost servletHost: servletHosts.getServletHosts()) {
servletHost.setDefaultPort(port);
if (path != null && path.length() > 0 && !path.equals("/")) {
servletHost.setContextPath(path);
}
}
// make the node available to the model
// this causes the runtime to start registering binding-sca service endpoints
// with the domain proxy
// TODO - This code is due to be pulled out and combined with the register and
// resolution code that appears in this class
ModelFactoryExtensionPoint factories = domainManagementRuntime.getExtensionPointRegistry().getExtensionPoint(ModelFactoryExtensionPoint.class);
nodeFactory = new NodeFactoryImpl(node);
factories.addFactory(nodeFactory);
// Create an in-memory domain level management composite
AssemblyFactory assemblyFactory = domainManagementRuntime.getAssemblyFactory();
domainManagementComposite = assemblyFactory.createComposite();
domainManagementComposite.setName(new QName(Constants.SCA10_NS, "domainManagement"));
domainManagementComposite.setURI(domainModel.getDomainURI() + "/Management");
} else {
domainManagementRuntime = (ReallySmallRuntime)((SCANodeSPI)node).getNodeRuntime();
domainManagementComposite = domainManagementRuntime.getCompositeActivator().getDomainComposite();
// set the context path for the node
String path = URI.create(node.getURI()).getPath();
if (path != null && path.length() > 0 && !path.equals("/")) {
ServletHostExtensionPoint servletHosts = domainManagementRuntime.getExtensionPointRegistry().getExtensionPoint(ServletHostExtensionPoint.class);
for (ServletHost servletHost: servletHosts.getServletHosts()) {
servletHost.setContextPath(path);
}
}
}