/** * Add a server. * * @param server the server */ public void addServer(Server server) { ConfigManagerTask.manager.addServer(server); }
/** * JAVA_HOME to start jboss with. * @param javaHome */ public void setJavaHome(String javaHome) { ConfigManagerTask.manager.setJavaHome(javaHome); }
/** * JBoss dist to start. * @param jbossHome */ public void setJbossHome(String jbossHome) { ConfigManagerTask.manager.setJbossHome(jbossHome); }
/** * Configures the Server Manager and add's the specified server to it. * * @param server * @return * @throws IOException */ private ServerManager setupServerManager(Server server) throws IOException { // Create ServerManager ServerManager serverManager = this.getServerManager(); // Set JVM / JBOSS_HOME serverManager.setJavaHome(this.getJavaHome()); serverManager.setJbossHome(this.getJbossHome()); // Add a Server serverManager.addServer(server); return serverManager; }
@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); } }
@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); } }
public void startServer() throws BuildException { ServerManager manager = ConfigManagerTask.getServerManager(getProject()); try { manager.startServer(name); } catch (IOException e) { throw new BuildException("Error starting server \"" + name + "\": " + e.getMessage(), e); } }
/** * Stops the specified server with the specified registered name * * @param serverName * @exception IOException */ public void stopJbossAs(String serverName) throws IOException { // Delegate to ServerManager to stop the server this.getServerManager().stopServer(serverName); }
public ServerManager getServerManager() { if (JbossAsRuntimeDelegate.serverManager == null) { JbossAsRuntimeDelegate.serverManager = new ServerManager(); } return JbossAsRuntimeDelegate.serverManager; }
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(); }
/** * JVM command to use default is "java" * @param jvm */ public void setJvm(String jvm) { ConfigManagerTask.manager.setJvm(jvm); }
/** * The UDP group to pass to org.jboss.Main using * the -u option. * * @param udpGroup the udp group */ public void setUdpGroup(String udpGroup) { ConfigManagerTask.manager.setUdpGroup(udpGroup); } }
private ServerManager createAndConfigureServerManager() { ServerManager manager = new ArquillianServerManager( configuration.getStartupTimeoutInSeconds(), configuration.getShutdownTimeoutInSeconds() ); if(configuration.getJbossHome() != null) { manager.setJbossHome(configuration.getJbossHome()); } if(configuration.getJavaHome() != null) { manager.setJavaHome(configuration.getJavaHome()); } manager.addServer(createAndConfigureServer()); return manager; }
/** * 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(); }
public void stopServer() throws BuildException { ServerManager manager = ConfigManagerTask.getServerManager(getProject()); try { manager.stopServer(name); } catch (IOException e) { if (e instanceof ServerShutdownException && ignoreerrors) { // do nothing } else if (e instanceof ServerShutdownException && !failonerror) { log("Unable to shutdown server properly: " + e, Project.MSG_ERR); } else { throw new BuildException("Error stopping server \"" + name + "\": " + e.toString(), e); } } }
/** * Create a new ConfigManagerTask. * * */ public ConfigManagerTask() { if (ConfigManagerTask.manager == null) { // set TCL and save the original TCL to restore it later Thread curThread = Thread.currentThread(); ClassLoader orgCl = curThread.getContextClassLoader(); curThread.setContextClassLoader(getClassLoader()); /* Create ServerManager with the appropriate TCL, otherwise the clean-up thread wouldn't be able to shutdown servers cleanly. Then reset the context classloader. */ try { ConfigManagerTask.manager = new ServerManager(); } finally { curThread.setContextClassLoader(orgCl); } } }
/** * Given a server name, checks with the server manager and returns an existing instance, or * returns a newly created one. * * @param serverConfigName * @param jvmargs * @return an existing or new server instance. * @throws IOException */ private Server getServer(String serverConfigName, Collection<String> jvmargs) throws IOException { // the server instance we will work with Server server; // is there an existing server instance? try { server = this.getServerManager().getServer(serverConfigName); } catch (IllegalArgumentException e) { // server with name serverConfigName doesn't exist //try to obtain instance server = setupServer(serverConfigName, jvmargs); // setup the server manager setupServerManager(server); } return server; }