diff --git a/l2jserver2-common/src/main/java/com/l2jserver/service/ServiceManager.java b/l2jserver2-common/src/main/java/com/l2jserver/service/ServiceManager.java
index 0225f00ce..ca9e13c55 100644
--- a/l2jserver2-common/src/main/java/com/l2jserver/service/ServiceManager.java
+++ b/l2jserver2-common/src/main/java/com/l2jserver/service/ServiceManager.java
@@ -39,7 +39,6 @@ import com.google.inject.Injector;
import com.google.inject.Module;
import com.google.inject.Scopes;
import com.l2jserver.service.configuration.ConfigurationService;
-import com.l2jserver.service.core.LoggingService;
import com.l2jserver.util.ClassUtils;
import com.l2jserver.util.factory.CollectionFactory;
@@ -52,7 +51,7 @@ public class ServiceManager {
/**
* The logger
*/
- private Logger logger;
+ private final Logger logger = LoggerFactory.getLogger(ServiceManager.class);
/**
* The Guice Injector
*/
@@ -131,14 +130,15 @@ public class ServiceManager {
*/
public void init(Injector injector) throws ServiceStartException {
this.injector = injector;
- final LoggingService service = injector
- .getInstance(LoggingService.class);
- knownServices.add(service);
- service.start();
- configurationService = injector.getInstance(ConfigurationService.class);
- knownServices.add(configurationService);
- configurationService.start();
- logger = LoggerFactory.getLogger(ServiceManager.class);
+// final LoggingService service = injector
+// .getInstance(LoggingService.class);
+// knownServices.add(service);
+// service.start();
+ configurationService = start(ConfigurationService.class);
+ //start(LoggingService.class);
+ //knownServices.add(configurationService);
+ //start(ConfigurationService.class);
+ //configurationService.start();
}
/**
diff --git a/l2jserver2-common/src/main/java/com/l2jserver/service/configuration/XMLConfigurationService.java b/l2jserver2-common/src/main/java/com/l2jserver/service/configuration/XMLConfigurationService.java
index 3db56bb67..9226515e0 100644
--- a/l2jserver2-common/src/main/java/com/l2jserver/service/configuration/XMLConfigurationService.java
+++ b/l2jserver2-common/src/main/java/com/l2jserver/service/configuration/XMLConfigurationService.java
@@ -35,16 +35,13 @@ import org.w3c.dom.Node;
import com.google.common.base.Preconditions;
import com.google.inject.Inject;
import com.l2jserver.service.AbstractService;
-import com.l2jserver.service.AbstractService.Depends;
import com.l2jserver.service.ConfigurableService;
import com.l2jserver.service.Service;
import com.l2jserver.service.ServiceConfiguration;
import com.l2jserver.service.ServiceDescriptor;
import com.l2jserver.service.ServiceManager;
import com.l2jserver.service.ServiceStartException;
-import com.l2jserver.service.cache.CacheService;
import com.l2jserver.service.configuration.Configuration.ConfigurationPropertyGetter;
-import com.l2jserver.service.core.LoggingService;
import com.l2jserver.util.factory.CollectionFactory;
import com.l2jserver.util.transformer.Transformer;
import com.l2jserver.util.transformer.TransformerFactory;
@@ -55,7 +52,6 @@ import com.l2jserver.util.transformer.TransformerFactory;
*
* @author Rogiel
*/
-@Depends({ LoggingService.class, CacheService.class })
public class XMLConfigurationService extends AbstractService implements
ConfigurationService {
/**
@@ -174,12 +170,16 @@ public class XMLConfigurationService extends AbstractService implements
return cache.get(xpath.value());
Object o;
try {
- o = untransform(getRaw(xpath.value(), getter.defaultValue()),
- type);
+ if (type == Node.class) {
+ o = getNode(xpath.value());
+ } else {
+ o = untransform(
+ getRaw(xpath.value(), getter.defaultValue()), type);
+ cache.put(xpath.value(), o);
+ }
} catch (XPathExpressionException e) {
return null;
}
- cache.put(xpath.value(), o);
return o;
}
@@ -201,8 +201,12 @@ public class XMLConfigurationService extends AbstractService implements
.compile(xpath.value())
.evaluate(properties, XPathConstants.NODE);
if (value != null) {
- node.setNodeValue(transform(value.toString(), type));
- cache.put(xpath.value(), value);
+ if (type == Node.class) {
+ node.getParentNode().replaceChild(node, (Node) value);
+ } else {
+ node.setNodeValue(transform(value.toString(), type));
+ cache.put(xpath.value(), value);
+ }
} else {
node.getParentNode().removeChild(node);
cache.remove(xpath.value());
@@ -274,6 +278,20 @@ public class XMLConfigurationService extends AbstractService implements
return defaultValue;
return value;
}
+
+ /**
+ * Retrieve the node object from the property file
+ *
+ * @param key
+ * the key
+ * @return the node returned by the xpath query
+ * @throws XPathExpressionException
+ * if any XPath exception occur
+ */
+ private Node getNode(String key) throws XPathExpressionException {
+ return (Node) XPathFactory.newInstance().newXPath().compile(key)
+ .evaluate(properties, XPathConstants.NODE);
+ }
}
/**
diff --git a/l2jserver2-common/src/main/java/com/l2jserver/service/core/Log4JLoggingService.java b/l2jserver2-common/src/main/java/com/l2jserver/service/core/Log4JLoggingService.java
index b94b1a557..7b3a45c6b 100644
--- a/l2jserver2-common/src/main/java/com/l2jserver/service/core/Log4JLoggingService.java
+++ b/l2jserver2-common/src/main/java/com/l2jserver/service/core/Log4JLoggingService.java
@@ -22,8 +22,11 @@ import org.apache.log4j.Layout;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
-import com.l2jserver.service.AbstractService;
+import com.l2jserver.service.AbstractConfigurableService;
import com.l2jserver.service.ServiceStartException;
import com.l2jserver.service.ServiceStopException;
@@ -32,39 +35,42 @@ import com.l2jserver.service.ServiceStopException;
*
* @author Rogiel
*/
-public class Log4JLoggingService extends AbstractService implements
+public class Log4JLoggingService extends
+ AbstractConfigurableService implements
LoggingService {
/**
* The root logger
*/
private Logger rootLogger;
+
/**
- * The l2j logger
+ * Creates a new instance
*/
- private Logger l2jLogger;
- /**
- * The netty logger
- */
- private Logger nettyLogger;
+ public Log4JLoggingService() {
+ super(LoggingServiceConfiguration.class);
+ }
@Override
protected void doStart() throws ServiceStartException {
final Layout layout = new PatternLayout(
- "[%p %d{yyyy-MM-dd HH-mm-ss}] %c:%L - %m%n");
-
- BasicConfigurator.configure();
+ "[%p %d] %c{1} - %m%n");
rootLogger = Logger.getRootLogger();
- l2jLogger = Logger.getLogger("com.l2jserver");
- nettyLogger = Logger.getLogger("org.jboss.netty");
rootLogger.removeAllAppenders();
- rootLogger.setLevel(Level.WARN);
+ // rootLogger.setLevel(config.getLoggersNode().);
rootLogger.addAppender(new ConsoleAppender(layout, "System.err"));
- l2jLogger.setLevel(Level.INFO);
- nettyLogger.setLevel(Level.DEBUG);
- Logger.getLogger("com.l2jserver.model.id.object.allocator").setLevel(
- Level.WARN);
+ final NodeList nodes = config.getLoggersNode().getChildNodes();
+ for (int i = 0; i < nodes.getLength(); i++) {
+ final Node node = nodes.item(i);
+ if (!"logger".equals(node.getNodeName()))
+ continue;
+ final NamedNodeMap attributes = node.getAttributes();
+ final Logger logger = Logger.getLogger(attributes.getNamedItem(
+ "name").getNodeValue());
+ logger.setLevel(Level.toLevel(attributes.getNamedItem("level")
+ .getNodeValue()));
+ }
}
@Override
diff --git a/l2jserver2-common/src/main/java/com/l2jserver/service/core/LoggingServiceConfiguration.java b/l2jserver2-common/src/main/java/com/l2jserver/service/core/LoggingServiceConfiguration.java
new file mode 100644
index 000000000..eeea26269
--- /dev/null
+++ b/l2jserver2-common/src/main/java/com/l2jserver/service/core/LoggingServiceConfiguration.java
@@ -0,0 +1,42 @@
+/*
+ * This file is part of l2jserver2 .
+ *
+ * l2jserver2 is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * l2jserver2 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with l2jserver2. If not, see .
+ */
+package com.l2jserver.service.core;
+
+import org.w3c.dom.Node;
+
+import com.l2jserver.service.ServiceConfiguration;
+import com.l2jserver.service.configuration.XMLConfigurationService.ConfigurationXPath;
+
+/**
+ * @author Rogiel
+ */
+public interface LoggingServiceConfiguration extends ServiceConfiguration {
+ /**
+ * @return the loggers node
+ */
+ @ConfigurationPropertyGetter
+ @ConfigurationXPath(".")
+ Node getLoggersNode();
+
+ /**
+ * @param loggersNode
+ * the loggers node
+ */
+ @ConfigurationPropertySetter
+ @ConfigurationXPath(".")
+ void setLoggersNode(Node loggersNode);
+}
diff --git a/l2jserver2-gameserver/distribution/services.xml b/l2jserver2-gameserver/distribution/services.xml
index db8f71a41..db1a96ffd 100644
--- a/l2jserver2-gameserver/distribution/services.xml
+++ b/l2jserver2-gameserver/distribution/services.xml
@@ -47,14 +47,19 @@
you normally don't need to change anything here nor in the firewall. -->
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
-