Commit 899674ba authored by Yann Mombrun's avatar Yann Mombrun

#4 Now fully rely on commons-logging+log4j in launcher

parent f24bafcc
Pipeline #2806 passed with stages
in 15 minutes and 50 seconds
# Console appender limited to INFO
log4j.appender.console = org.apache.log4j.ConsoleAppender
log4j.appender.console.threshold = INFO
log4j.appender.console.encoding = UTF-8
log4j.appender.console.layout = org.apache.log4j.PatternLayout
log4j.appender.console.layout.conversionPattern =%m%n
# RollingFile appender limited to DEBUG
log4j.appender.rollingfile = org.apache.log4j.RollingFileAppender
log4j.appender.rollingfile.threshold = TRACE
log4j.appender.rollingfile.threshold = DEBUG
log4j.appender.rollingfile.layout = org.apache.log4j.PatternLayout
log4j.appender.rollingfile.layout.conversionPattern = %d{ISO8601} %-5p %c - %m%n
log4j.appender.rollingfile.file = weblab.log
log4j.appender.rollingfile.append = true
log4j.appender.rollingfile.encoding = UTF-8
log4j.appender.rollingfile.maxBackupIndex = 5
# Configuration of the Loggers
log4j.rootLogger = INFO, rollingfile
log4j.rootLogger = DEBUG, rollingfile
log4j.logger.org.springframework = INFO
log4j.logger.org.apache.cxf = INFO
log4j.logger.weblab.launcher = DEBUG, console
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
......@@ -22,6 +23,11 @@ In case something goes wrong, explains, as much as possible, where it failed and
</properties>
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
......@@ -41,6 +47,7 @@ In case something goes wrong, explains, as much as possible, where it failed and
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
......
......@@ -27,10 +27,9 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.common.SolrException;
......@@ -77,7 +76,7 @@ public class Launcher {
private static final String START = "start";
public static Logger logger = Utils.getLogger();
private static final Log logger = Utils.getLogger();
/**
......@@ -95,8 +94,8 @@ public class Launcher {
// set weblab.home system property if not already defined
if (System.getProperty("weblab.home") == null) {
System.setProperty("weblab.home", PathUtils.getWebLabHome(""));
if (Launcher.logger.isLoggable(Level.FINEST)) {
Launcher.logger.finest("weblab.home system property not set, setting it at : " + PathUtils.getWebLabHome(""));
if (Launcher.logger.isDebugEnabled()) {
Launcher.logger.debug("weblab.home system property not set, setting it at : " + PathUtils.getWebLabHome(""));
}
}
// set conf and data dir
......@@ -107,18 +106,16 @@ public class Launcher {
// load configuration
Launcher.configuration = Utils.loadConfiguration();
} catch (final Exception exception) {
Launcher.logger.severe("Could not load configuration file. Make sure you neither make a mistake in configuration.xml nor forget to provide external libraries.");
Launcher.logger.log(Level.SEVERE, exception.getMessage(), exception);
Launcher.logger.error("Could not load configuration file. Make sure you neither make a mistake in configuration.xml nor forget to provide external libraries.", exception);
Launcher.end(Constants.COMMAND_FAILED);
}
Launcher.logger = Utils.getLogger();
// check if it is the first launch
Launcher.initChecks();
Launcher.logger.finest("Logger level: " + Launcher.logger.getLevel());
Launcher.logger.finest("Given args: " + args.length + " " + Arrays.asList(args));
if (Launcher.logger.isDebugEnabled()) {
Launcher.logger.debug("Given args: " + args.length + " " + Arrays.asList(args));
}
if (args.length < 1) {
Launcher.end(Constants.COMMAND_FAILED);
......@@ -132,11 +129,11 @@ public class Launcher {
final boolean force = Launcher.parseArgs(args, "--force");
if (Launcher.logger.isLoggable(Level.FINEST)) {
Launcher.logger.finest("Loading Chain commander manager");
if (Launcher.logger.isDebugEnabled()) {
Launcher.logger.debug("Loading Chain commander manager");
}
if (Launcher.logger.isLoggable(Level.FINEST)) {
Launcher.logger.finest("Loading Servers commander manager");
if (Launcher.logger.isDebugEnabled()) {
Launcher.logger.debug("Loading Servers commander manager");
}
final ServerManager serverManager = new ServerManager(Launcher.logger, Launcher.configuration);
......@@ -285,7 +282,7 @@ public class Launcher {
continue;
}
if (!solr.isServerFullyStarted(false)) {
Launcher.logger.warning("Solr server " + solr.getName() + " is not started. Unable to clean index for " + Launcher.configuration.getName()
Launcher.logger.warn("Solr server " + solr.getName() + " is not started. Unable to clean index for " + Launcher.configuration.getName()
+ ". Please ensure solr and zookeper instances are started.");
return;
}
......@@ -301,7 +298,7 @@ public class Launcher {
continue;
}
if (!zookeeper.isServerFullyStarted(false)) {
Launcher.logger.warning("Zookeeper server " + zookeeper.getName() + " is not started. Unable to clean index for " + Launcher.configuration.getName()
Launcher.logger.warn("Zookeeper server " + zookeeper.getName() + " is not started. Unable to clean index for " + Launcher.configuration.getName()
+ ". Please ensure solr and zookeper instances are started.");
return;
}
......@@ -343,7 +340,7 @@ public class Launcher {
break;
}
} catch (final SolrException e) {
Launcher.logger.warning(e.getMessage() + " while checking solr status -> will try to restart it");
Launcher.logger.warn(e.getMessage() + " while checking solr status -> will try to restart it");
needRestart = true;
break;
}
......@@ -414,7 +411,7 @@ public class Launcher {
// webdav
final String webdavURL = Launcher.configuration.getWebdavUrl();
if (webdavURL == null) {
Launcher.logger.fine("No webDAV access found. Nothing to delete from webDAV repository.");
Launcher.logger.debug("No webDAV access found. Nothing to delete from webDAV repository.");
} else if (Launcher.configuration.getPortal().isServerFullyStarted(false)) {
final String user = Launcher.configuration.getWebdavUser();
final String password = Launcher.configuration.getWebdavPassword();
......@@ -434,19 +431,21 @@ public class Launcher {
Launcher.logger.info("Executing additional reset script");
ProcessUtils.runProcess(Launcher.logger, script.getParent(), Env.defaut(), (System.getProperty("os.name").contains("Windows") ? "" : "./") + script.getName());
} else {
Launcher.logger.severe("Additional reset script provided does not exists at " + script.getAbsolutePath() + " based on provided " + resetScript + ".");
Launcher.logger.error("Additional reset script provided does not exists at " + script.getAbsolutePath() + " based on provided " + resetScript + ".");
}
}
} catch (final IOException | SolrServerException | InterruptedException exception) {
Launcher.logger.log(Level.SEVERE, exception.getLocalizedMessage(), exception);
Launcher.logger.error(exception.getLocalizedMessage(), exception);
}
}
/**
* @param repositoryPath
* THe location of the repository folder to be cleaned
* @throws IOException
* If an error occured cleaning the target folder
*/
protected static void cleanFolderIfExist(final String repositoryPath) throws IOException {
final File repository = new File(repositoryPath);
......@@ -465,14 +464,14 @@ public class Launcher {
private static void check() {
final int cores = Runtime.getRuntime().availableProcessors();
if (cores < 2) {
Launcher.logger.warning(
Launcher.logger.warn(
"Warning: there is only 1 processor available. This could lead to issues because of the Service Oriented Architecture of the " + Launcher.configuration.getName() + " Platform.");
Launcher.logger.warning("Warning: do not use this configuration for prodution use.");
Launcher.logger.warn("Warning: do not use this configuration for prodution use.");
}
final long maxMemory = Runtime.getRuntime().maxMemory();
if (maxMemory < 1500000000) {
Launcher.logger.warning("Warning: Maximum memory is " + maxMemory + " bytes. It could lead to issues when running " + Launcher.configuration.getName() + "; some server might not start.");
Launcher.logger.warn("Warning: Maximum memory is " + maxMemory + " bytes. It could lead to issues when running " + Launcher.configuration.getName() + "; some server might not start.");
}
}
......@@ -521,7 +520,7 @@ public class Launcher {
// check JVM version, stop if JVM does not expected class version spec
if (Float.parseFloat(System.getProperty("java.class.version")) < Launcher.configuration.getClassVersion()) {
Launcher.logger.warning("The current JVM is not compatible with required java class version: " + Launcher.configuration.getClassVersion()
Launcher.logger.warn("The current JVM is not compatible with required java class version: " + Launcher.configuration.getClassVersion()
+ ", please upgrade your installation.\nProcessing chains and GUI might not work properly, do you want to start WebLab anyway? (Yes/No, default=No )");
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
final String answer = br.readLine();
......@@ -529,7 +528,7 @@ public class Launcher {
return;
}
} catch (final IOException ioe) {
Launcher.logger.log(Level.FINEST, ioe.getLocalizedMessage(), ioe);
Launcher.logger.debug(ioe.getLocalizedMessage(), ioe);
}
}
......
......@@ -17,8 +17,6 @@
*/
package org.ow2.weblab.bundle.server;
import java.util.logging.Level;
import org.ow2.weblab.bundle.utils.ProcessUtils;
/**
......@@ -48,9 +46,7 @@ public abstract class AbstractApplicationServer extends WebLabServer {
// check if configured
this.checkConfiguration();
if (this.logger.isLoggable(Level.INFO)) {
this.logger.info(this.getName() + " is starting ...");
}
this.logger.info(this.getName() + " is starting ...");
return ProcessUtils.runProcess(this.logger, this.getBinDirectory(), this.getEnv(), this.getStartScript());
}
......@@ -58,9 +54,7 @@ public abstract class AbstractApplicationServer extends WebLabServer {
@Override
public void stop() {
if (this.logger.isLoggable(Level.INFO)) {
this.logger.info(this.getName() + " is stopping ...");
}
this.logger.info(this.getName() + " is stopping ...");
if (this.getStopScript() != null) {
ProcessUtils.runProcess(this.logger, this.getBinDirectory(), this.getEnv(), this.getStopScript());
......@@ -74,4 +68,5 @@ public abstract class AbstractApplicationServer extends WebLabServer {
protected void checkConfiguration() {
// Nothing to do
}
}
......@@ -18,7 +18,6 @@
package org.ow2.weblab.bundle.server;
import java.io.IOException;
import java.util.logging.Level;
import javax.management.MBeanServerConnection;
import javax.management.MBeanServerInvocationHandler;
......@@ -122,7 +121,7 @@ public class ActiveMQServer extends AbstractApplicationServer {
try {
activeMQ = new ObjectName("org.apache.activemq:type=Broker,brokerName=" + this.getHost());
} catch (final MalformedObjectNameException mone) {
this.logger.log(Level.WARNING, "Invalid object name Broker!", mone);
this.logger.warn("Invalid object name Broker!", mone);
return null;
}
......@@ -145,7 +144,7 @@ public class ActiveMQServer extends AbstractApplicationServer {
+ queueMbean.getEnqueueCount() + " message(s) have been enqueued.");
}
} catch (final IOException ioe) {
this.logger.log(Level.WARNING, "Unable to list queues due to a connection issue.", ioe);
this.logger.warn("Unable to list queues due to a connection issue.", ioe);
}
}
......@@ -176,11 +175,11 @@ public class ActiveMQServer extends AbstractApplicationServer {
}
} catch (final Exception e) {
queueFound = true; // To prevent from another log message after
this.logger.log(Level.WARNING, "An error occurred purging queue " + queue + ".", e);
this.logger.warn("An error occurred purging queue " + queue + ".", e);
}
if (!queueFound) {
this.logger.warning("Queue " + queue + " does not exist. Nothing to purge.");
this.logger.warn("Queue " + queue + " does not exist. Nothing to purge.");
}
}
......
......@@ -20,7 +20,6 @@ package org.ow2.weblab.bundle.server;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.logging.Level;
import javax.management.remote.JMXConnector;
......@@ -67,18 +66,18 @@ public class Fuseki extends WebLabServer {
try (final CloseableHttpClient client = HttpClients.custom().build();) {
final HttpGet httpget = new HttpGet(new URL("http", this.getHost(), this.getPort(), "/$/datasets").toURI());
final String result = client.execute(httpget, new BasicResponseHandler());
this.logger.finest(result);
this.logger.debug(result);
final JsonObject json = new JsonParser().parse(result).getAsJsonObject();
final JsonArray datasets = json.get("datasets").getAsJsonArray();
for (final JsonElement datasetElm : datasets) {
this.logger.info("\tDataset: " + datasetElm.getAsJsonObject().get("ds.name").getAsString() + ".");
}
} catch (final IOException ioe) {
this.logger.log(Level.SEVERE, "Unable to talk with Fuseki.", ioe);
this.logger.error("Unable to talk with Fuseki.", ioe);
} catch (final URISyntaxException urise) {
this.logger.log(Level.SEVERE, "Unable to talk with Fuseki.", urise);
this.logger.error("Unable to talk with Fuseki.", urise);
} catch (final Exception e) {
this.logger.log(Level.SEVERE, "Unable to parse result from Fuseki.", e);
this.logger.error("Unable to parse result from Fuseki.", e);
}
}
return true;
......@@ -108,7 +107,7 @@ public class Fuseki extends WebLabServer {
} else if ("status".equals(command)) {
this.logger.info(this.getName() + " getting status...");
} else {
this.logger.warning("Command " + command + " is not handled by " + this.getName());
this.logger.warn("Command " + command + " is not handled by " + this.getName());
return null;
}
return this.execute(this.getEnv(), command);
......@@ -125,14 +124,14 @@ public class Fuseki extends WebLabServer {
public Process start() {
// check status
if (this.status() != State.STOPPED) {
this.logger.severe(this.getName() + " is not stopped! Aborting start...");
this.logger.error(this.getName() + " is not stopped! Aborting start...");
return null;
}
// check pid file
if (ProcessUtils.checkPidFile(this.logger, this, false)) {
// server already started; we abort.
this.logger.severe(this.getName() + " already started! Aborting...");
this.logger.error(this.getName() + " already started! Aborting...");
return null;
}
......
......@@ -27,7 +27,6 @@ import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import javax.management.remote.JMXConnector;
import javax.xml.bind.JAXBContext;
......@@ -97,7 +96,7 @@ public class Heritrix extends WebLabServer {
final HttpGet httpget = new HttpGet(new URL("https", this.getUiHost(), this.getPort(), "/engine").toURI());
httpget.setHeader("Accept", "application/xml");
final String result = client.execute(httpget, new BasicResponseHandler());
this.logger.finest(result);
this.logger.debug(result);
final Engine engine = JAXBContext.newInstance(Engine.class).createUnmarshaller().unmarshal(new StreamSource(new StringReader(result)), Engine.class).getValue();
for (final Job job : engine.jobs) {
......@@ -105,7 +104,7 @@ public class Heritrix extends WebLabServer {
}
} catch (final Exception e) {
this.logger.log(Level.SEVERE, "An error occured trying to talk with WebUI.", e);
this.logger.error("An error occured trying to talk with WebUI.", e);
}
}
return true;
......@@ -123,14 +122,14 @@ public class Heritrix extends WebLabServer {
}
// check status
if (this.status() != State.STOPPED) {
this.logger.severe(this.getName() + " is not stopped ! Aborting start...");
this.logger.error(this.getName() + " is not stopped ! Aborting start...");
return null;
}
// check pid file
if (ProcessUtils.checkPidFile(this.logger, this, false)) {
// server already started; we abort.
this.logger.severe(this.getName() + " already started ! Aborting ...");
this.logger.error(this.getName() + " already started ! Aborting ...");
return null;
}
......@@ -160,21 +159,21 @@ public class Heritrix extends WebLabServer {
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
final String result = client.execute(httppost, new BasicResponseHandler());
this.logger.finest(result);
this.logger.debug(result);
this.logger.info(this.getName() + " stopped");
} catch (final URISyntaxException urise) {
this.logger.log(Level.SEVERE, "Wrong URL format when talking to Heritrix WebUI.", urise);
this.logger.error("Wrong URL format when talking to Heritrix WebUI.", urise);
} catch (final ClientProtocolException cpe) {
this.logger.log(Level.SEVERE, "Wrong protocol while talking to Heritrix WebUI.", cpe);
this.logger.error("Wrong protocol while talking to Heritrix WebUI.", cpe);
} catch (final IOException ioe) {
this.logger.log(Level.SEVERE, "An error occured while talking to Heritrix WebUI.", ioe);
this.logger.error("An error occured while talking to Heritrix WebUI.", ioe);
} catch (final KeyManagementException kme) {
this.logger.log(Level.SEVERE, "Unable to create SSL context to talk with WebUI.", kme);
this.logger.error("Unable to create SSL context to talk with WebUI.", kme);
} catch (final NoSuchAlgorithmException nsae) {
this.logger.log(Level.SEVERE, "Unable to create SSL context to talk with WebUI.", nsae);
this.logger.error("Unable to create SSL context to talk with WebUI.", nsae);
} catch (final KeyStoreException kse) {
this.logger.log(Level.SEVERE, "Unable to create SSL context to talk with WebUI.", kse);
this.logger.error("Unable to create SSL context to talk with WebUI.", kse);
}
}
......
......@@ -18,7 +18,6 @@
package org.ow2.weblab.bundle.server;
import java.io.File;
import java.util.logging.Level;
import javax.management.remote.JMXConnector;
......@@ -44,7 +43,7 @@ public class JettyServer extends WebLabServer {
public JettyServer() {
super();
this.logger.finest("JettyServer started.");
this.logger.debug("JettyServer started.");
}
......@@ -55,7 +54,7 @@ public class JettyServer extends WebLabServer {
if (this.isLocked()) {
// Server has already been started at least one time. Checking if it is really running (file is not deleted in case of dirty stop).
if (Utils.isPortAvailable(this.logger, this.getHost(), this.getPort())) {
this.logger.severe("Port " + this.getPort() + " is available but lock file " + this.getLockFile() + " exists. Strange!");
this.logger.error("Port " + this.getPort() + " is available but lock file " + this.getLockFile() + " exists. Strange!");
return -1;
}
final File pidFile = this.getLockFile();
......@@ -63,8 +62,8 @@ public class JettyServer extends WebLabServer {
return Integer.valueOf(FileUtils.readFileToString(pidFile).trim()).intValue();
} catch (final Exception e) {
final String msg = "Unable to get pid from file " + pidFile + ".";
this.logger.severe(msg);
this.logger.log(Level.FINE, msg, e);
this.logger.error(msg);
this.logger.debug(msg, e);
}
}
return -1;
......@@ -88,7 +87,7 @@ public class JettyServer extends WebLabServer {
@Override
public String getProcessIdentificationClue() {
this.logger.finest("getProcessIdentificationClue is not implemented by JettyServer.");
this.logger.debug("getProcessIdentificationClue is not implemented by JettyServer.");
return this.getHome();
}
......@@ -137,7 +136,7 @@ public class JettyServer extends WebLabServer {
this.stop();
return this.start();
} else {
this.logger.warning("Command " + command + " is not handled by " + this.getName());
this.logger.warn("Command " + command + " is not handled by " + this.getName());
return null;
}
return this.execute(this.getEnv(), command);
......@@ -156,14 +155,14 @@ public class JettyServer extends WebLabServer {
// check status
if (this.status() != State.STOPPED) {
this.logger.severe(this.getName() + " is not stopped! Aborting start...");
this.logger.error(this.getName() + " is not stopped! Aborting start...");
return null;
}
// check pid file
if (ProcessUtils.checkPidFile(this.logger, this, false)) {
// server already started; we abort.
this.logger.severe(this.getName() + " already started! Aborting...");
this.logger.error(this.getName() + " already started! Aborting...");
return null;
}
......@@ -171,7 +170,7 @@ public class JettyServer extends WebLabServer {
this.logger.info(this.getName() + " has not been stopped correctly. Removing lock file.");
final File lockFile = this.getLockFile();
if (!lockFile.delete()) {
this.logger.severe("Unable to remove lock file " + lockFile + ". Please try to remove it manually. Aborting...");
this.logger.error("Unable to remove lock file " + lockFile + ". Please try to remove it manually. Aborting...");
return null;
}
......
......@@ -24,7 +24,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
import java.util.logging.Level;
import javax.management.JMX;
import javax.management.MBeanServerConnection;
......@@ -60,42 +59,50 @@ public class Karaf extends Bus {
public Karaf() {
// Nothing to do
}
public String getJmxUser() {
return this.jmxUser;
}
public void setJmxUser(final String jmxUser) {
this.jmxUser = jmxUser;
}
public String getJmxPassword() {
return this.jmxPassword;
}
public void setJmxPassword(final String jmxPassword) {
this.jmxPassword = jmxPassword;
}
public String getJmxHost() {
return this.jmxHost;
}
public void setJmxHost(final String jmxHost) {
this.jmxHost = jmxHost;
}
@Override
public Process execute(final String command) {
if (!this.isEnabled()) {
this.logger.info(this.getName() + " discarded command " + command + " since control is disabled.");
return ProcessUtils.dummyProccess();
......@@ -120,13 +127,14 @@ public class Karaf extends Bus {
*/
@Override
protected void checkConfiguration() {
final String configweb = PathUtils.createPath(this.getHome(), "etc") + "org.ops4j.pax.web.cfg";
try {
// check if the file exists
final File configFile = new File(configweb);
if (!configFile.exists()) {
if (this.logger.isLoggable(Level.FINEST)) {
this.logger.finest("Updating " + this.getName() + " web console listening port.");
if (this.logger.isDebugEnabled()) {
this.logger.debug("Updating " + this.getName() + " web console listening port.");
}
FileUtils.writeStringToFile(new File(configweb), "org.osgi.service.http.port=" + this.getPort());
} else {
......@@ -135,19 +143,21 @@ public class Karaf extends Bus {
}
} catch (final IOException ioe) {
this.logger.log(Level.SEVERE, this.getName() + " could not set web console port to " + this.getPort() + " beacuse of the following error: ", ioe);
this.logger.error(this.getName() + " could not set web console port to " + this.getPort() + " beacuse of the following error: ", ioe);
}
}
@Override
public String getProcessIdentificationClue() {
return this.getHome();
}
@Override
public boolean isServerFullyStarted(final boolean showDetails) {
if (!this.isEnabled()) {
this.logger.info("Can not check if " + this.getName() + " is started since control is disabled.");
return true;
......@@ -163,6 +173,7 @@ public class Karaf extends Bus {
private Process detailedStatus() {
final String ext = System.getProperty("os.name").contains("Windows") ? ".bat" : "";
return ProcessUtils.runProcess(this.logger, this.getBinDirectory(), this.getEnv(), PathUtils.createPath(this.getHome(), "bin") + "status" + ext);
}
......@@ -170,12 +181,14 @@ public class Karaf extends Bus {
@Override
public JMXConnector getJMXConnector() {
return ProcessUtils.createJMXclient(this.jmxHost, this.getJmxPort(), this.jmxUser, this.jmxPassword, this.jmxName, 2000, false, this.logger);
}
@Override
public String[] getStartScript() {
String script = this.getScript();
if (script == null) {
final String ext = System.getProperty("os.name").contains("Windows") ? ".bat" : "";
......@@ -187,6 +200,7 @@ public class Karaf extends Bus {
@Override
public String[] getStopScript() {
String script = this.stopScript;
if (script == null) {
final String ext = System.getProperty("os.name").contains("Windows") ? ".bat" : "";
......@@ -197,6 +211,7 @@ public class Karaf extends Bus {
public void setStopScript(final String stopScript) {
this.stopScript = stopScript;
}
......@@ -206,8 +221,10 @@ public class Karaf extends Bus {
*
* @return a MbeanServerConnection to karaf
* @throws IOException
* If an error occurs openning the connection
*/
protected JMXConnector connect() throws IOException {
final JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + this.jmxHost + ":" + this.getJmxPort() + "/" + this.jmxName);
final Hashtable<String, Object> env = new Hashtable<>();
env.put("java.naming.factory.initial", "com.sun.jndi.rmi.registry.RegistryContextFactory");
......@@ -219,6 +236,7 @@ public class Karaf extends Bus {
@Override
public void listChains() {
try (final JMXConnector jmx = this.connect()) {
final MBeanServerConnection conns = jmx.getMBeanServerConnection();
final Set<ObjectInstance> objects = conns.queryMBeans(new ObjectName("org.apache.camel:context=*,type=routes,name=*"), null);
......@@ -236,7 +254,7 @@ public class Karaf extends Bus {
}
} catch (final Exception exception) {
this.logger.log(Level.SEVERE, exception.getMessage(), exception);
this.logger.error(exception.getMessage(), exception);
}
}
......@@ -258,6 +276,7 @@ public class Karaf extends Bus {
@Override
public boolean startChain(final String routeId) {
try (final JMXConnector jmx = this.connect()) {
final MBeanServerConnection conns = jmx.getMBeanServerConnection();
final ManagedSuspendableRouteMBean route = Karaf.getRoute(conns, routeId);
......@@ -267,7 +286,7 @@ public class Karaf extends Bus {