private Server createAndConfigureServer() Server server = new Server(); server.setName(configuration.getProfileName()); server.setHttpPort(httpPort()); server.setRmiPort(rmiPort()); server.setHost(configuration.getBindAddress()); server.setHasWebServer(!configuration.isUseRmiPortForAliveCheck()); server.setUsername("admin"); server.setPassword("admin"); server.setPartition(configuration.getPartition()); server.setPartition(Long.toHexString(System.currentTimeMillis())); prop.setKey("jbosstest.udp.ip_ttl"); prop.setValue("0"); server.addSysProperty(prop); prop = new Property(); prop.setKey("java.endorsed.dirs"); prop.setValue(new File(configuration.getJbossHome(), "lib/endorsed").getAbsolutePath()); server.addSysProperty(prop);
private void setServerVMArgs(Server server, String arguments) { for(String argument: arguments.split(" ")) { Argument arg = new Argument(); arg.setValue(argument); server.addJvmArg(arg); } } }
/** * Starts the Application Server * * @param serverConfigName * @param jvmargs * @return The unique name of the Server started * @exception IOException */ public String startJbossAs(String serverConfigName, Collection<String> jvmargs) throws IOException { Server server = setupServer(serverConfigName, jvmargs); ServerManager serverManager = setupServerManager(server); // Start the Server serverManager.startServer(server.getName()); // Return the name of the Server we've started return server.getName(); }
@Override public void stop() throws LifecycleException { Server server = manager.getServer(configuration.getProfileName()); if(!server.isRunning()) { throw new LifecycleException("Can not stop server. Server is not started"); } try { removeFailedUnDeployments(); } catch (Exception e) { throw new LifecycleException("Could not clean up failed undeployments", e); } try { manager.stopServer(server.getName()); } catch (Exception e) { throw new LifecycleException("Could not stop server", e); } }
/** * Undeployes the artifact from the named server. * * @param serverConfigName * @param jvmargs * @param artifact * @throws IOException */ public void undeploy(String serverConfigName, Collection<String> jvmargs, File artifact) throws IOException { // Obtain the server Server server = getServer(serverConfigName, jvmargs); // Undeploy try { server.undeploy(artifact); } catch (Exception e) { throw new RuntimeException("Could not undeploy file: " + artifact, e); } }
/** * Deploys the artifact to the named server. * * @param serverConfigName * @param jvmargs * @param artifact * @throws IOException */ public void deploy(String serverConfigName, Collection<String> jvmargs, File artifact) throws IOException { // Obtain the server Server server = getServer(serverConfigName, jvmargs); // Deploy try { server.deploy(artifact); } catch (Exception e) { throw new RuntimeException("Could not deploy file: " + artifact, e); } }
private void initProfileService(Server server) throws Exception { Context ctx = server.getNamingContext(); contextInst.set(ctx); profileService = (ProfileService) ctx.lookup("ProfileService"); deploymentManager = profileService.getDeploymentManager(); ProfileKey defaultKey = new ProfileKey(DEFAULT_PROFILE_KEY_NAME); deploymentManager.loadProfile(defaultKey); }
private void removeFailedUnDeployments() throws IOException { Server server = manager.getServer(configuration.getProfileName()); List<String> remainingDeployments = new ArrayList<String>(); for (String name : failedUndeployments) { try { server.undeploy(new File(name)); } catch (Exception e) { IOException ioe = new IOException(); ioe.initCause(e); throw ioe; } } if (remainingDeployments.size() > 0) { log.severe("Failed to undeploy these artifacts: " + remainingDeployments); } failedUndeployments.clear(); }
@Override public void start() throws LifecycleException { try { Server server = manager.getServer(configuration.getProfileName()); if(ServerController.isServerStarted(server)) { throw new LifecycleException( "The server is already running! " + "Managed containers does not support connecting to running server instances due to the " + "possible harmfull effect of connecting to the wrong server. Please stop server before running or " + "change to another type of container."); } manager.startServer(server.getName()); initProfileService(server); } catch (Exception e) { throw new LifecycleException("Could not start remote container", e); } }