mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-05 23:22:47 +00:00
Implements XML based service descriptor allowing to switch services
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>1.6.4</version>
|
||||
<scope>test</scope>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of l2jserver2 <l2jserver2.com>.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service;
|
||||
|
||||
import javolution.lang.Configurable;
|
||||
|
||||
/**
|
||||
* Implements basic management for configurable services
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
* @param <T>
|
||||
* the service configuration type
|
||||
*/
|
||||
public class AbstractConfigurableService<T extends ServiceConfiguration>
|
||||
extends AbstractService implements ConfigurableService<T> {
|
||||
/**
|
||||
* The service configuration
|
||||
*/
|
||||
protected T config;
|
||||
/**
|
||||
* The service configuration class
|
||||
*/
|
||||
private final Class<T> configType;
|
||||
|
||||
/**
|
||||
* @param configType
|
||||
* the service configuration class
|
||||
*/
|
||||
public AbstractConfigurableService(Class<T> configType) {
|
||||
this.configType = configType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transparently implements
|
||||
* {@link ConfigurableService#getConfigurationInterface()} without
|
||||
* implementing the interface
|
||||
*
|
||||
* @return the configuration interface set at {@link Configurable}
|
||||
* annotation, if present.
|
||||
*/
|
||||
@Override
|
||||
public Class<T> getConfigurationInterface() {
|
||||
return configType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfiguration(T configuration) {
|
||||
config = configuration;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* This file is part of l2jserver2 <l2jserver2.com>.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service;
|
||||
|
||||
/**
|
||||
* Marks whether an service can be configured or not
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
* @param <T>
|
||||
* the configuration interface type
|
||||
*/
|
||||
public interface ConfigurableService<T extends ServiceConfiguration> extends
|
||||
Service {
|
||||
/**
|
||||
* @return the configuration interface used by this service
|
||||
*/
|
||||
Class<T> getConfigurationInterface();
|
||||
|
||||
/**
|
||||
* Please note that this method will only be set at {@link Service#start()}.
|
||||
* Once {@link Service#stop()} is called, the configuration will be set to
|
||||
* <code>null</code>.
|
||||
*
|
||||
* @param configuration
|
||||
* the service configuration instance
|
||||
*/
|
||||
void setConfiguration(T configuration);
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* This file is part of l2jserver2 <l2jserver2.com>.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
* @param <T>
|
||||
* the service type
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
@XmlRootElement(name = "services")
|
||||
public class ServiceDescriptor<T extends Service> {
|
||||
/**
|
||||
* The service interface class
|
||||
*/
|
||||
@XmlAttribute(name = "interface")
|
||||
private final Class<T> serviceInterface;
|
||||
/**
|
||||
* The service implementation class
|
||||
*/
|
||||
@XmlAttribute(name = "implementation")
|
||||
private final Class<? extends T> serviceImplementation;
|
||||
/**
|
||||
* The node (will be used later for configuration purposes)
|
||||
*/
|
||||
private final Node node;
|
||||
|
||||
/**
|
||||
* @param serviceInterface
|
||||
* the service interface
|
||||
* @param serviceImplementation
|
||||
* the service implementation
|
||||
* @param node
|
||||
* the XML node
|
||||
*/
|
||||
public ServiceDescriptor(Class<T> serviceInterface,
|
||||
Class<? extends T> serviceImplementation, Node node) {
|
||||
this.serviceInterface = serviceInterface;
|
||||
this.serviceImplementation = serviceImplementation;
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the service interface class
|
||||
*/
|
||||
public Class<T> getServiceInterface() {
|
||||
return serviceInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the service implementation class
|
||||
*/
|
||||
public Class<? extends T> getServiceImplementation() {
|
||||
return serviceImplementation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the xml node
|
||||
*/
|
||||
public Node getNode() {
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param node
|
||||
* the XML node
|
||||
* @return a new {@link ServiceDescriptor} instance for the given service
|
||||
* XML node
|
||||
* @throws ClassNotFoundException
|
||||
* if any of the services class could not be found
|
||||
* @throws DOMException
|
||||
* if any error occur while parsing the XML data
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public static ServiceDescriptor fromNode(Node node)
|
||||
throws ClassNotFoundException, DOMException {
|
||||
final NamedNodeMap attrs = node.getAttributes();
|
||||
final Class<? extends Service> serviceInterface = (Class<? extends Service>) Class
|
||||
.forName(attrs.getNamedItem("interface").getNodeValue());
|
||||
final Class<? extends Service> serviceImplementation = (Class<? extends Service>) Class
|
||||
.forName(attrs.getNamedItem("implementation").getNodeValue());
|
||||
return new ServiceDescriptor(serviceInterface, serviceImplementation,
|
||||
node);
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import com.l2jserver.util.exception.L2Exception;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class ServiceException extends L2Exception {
|
||||
public class ServiceException extends L2Exception {
|
||||
/**
|
||||
* The Java Serialization API serial
|
||||
*/
|
||||
|
||||
@@ -16,14 +16,29 @@
|
||||
*/
|
||||
package com.l2jserver.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Inject;
|
||||
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;
|
||||
@@ -37,31 +52,89 @@ public class ServiceManager {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private final Logger logger;
|
||||
private Logger logger;
|
||||
/**
|
||||
* The Guice Injector
|
||||
*/
|
||||
private final Injector injector;
|
||||
private Injector injector;
|
||||
/**
|
||||
* The configuration service
|
||||
*/
|
||||
private ConfigurationService configurationService;
|
||||
/**
|
||||
* The DAO module
|
||||
*/
|
||||
private Class<? extends Module> daoModule;
|
||||
|
||||
/**
|
||||
* List of all known services by this manager
|
||||
*/
|
||||
private final Set<Service> knownServices = CollectionFactory.newSet();
|
||||
/**
|
||||
* The service descriptors
|
||||
*/
|
||||
private final Map<Class<? extends Service>, ServiceDescriptor<?>> descriptors = CollectionFactory
|
||||
.newMap();
|
||||
|
||||
/**
|
||||
* @param injector
|
||||
* the {@link Guice} {@link Injector}
|
||||
* @param file
|
||||
* the XML file
|
||||
* @throws SAXException
|
||||
* if any XML parsing error occur
|
||||
* @throws IOException
|
||||
* if any error occur while reading the file
|
||||
* @throws ParserConfigurationException
|
||||
* if any XML parsing error occur
|
||||
* @throws ClassNotFoundException
|
||||
* if the service class could not be found
|
||||
* @throws DOMException
|
||||
* if any XML parsing error occur
|
||||
* @throws ServiceException
|
||||
* if any service error occur
|
||||
*/
|
||||
@Inject
|
||||
public ServiceManager(Injector injector) {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void load(Path file) throws SAXException, IOException,
|
||||
ParserConfigurationException, ClassNotFoundException, DOMException,
|
||||
ServiceException {
|
||||
Document document = DocumentBuilderFactory.newInstance()
|
||||
.newDocumentBuilder().parse(Files.newInputStream(file));
|
||||
|
||||
final Map<Class<? extends Service>, ServiceDescriptor<?>> descriptors = CollectionFactory
|
||||
.newMap();
|
||||
final NodeList nodeList = document.getElementsByTagName("service");
|
||||
for (int i = 0; i < nodeList.getLength(); i++) {
|
||||
final Node node = nodeList.item(i);
|
||||
final ServiceDescriptor<?> descriptor = ServiceDescriptor
|
||||
.fromNode(node);
|
||||
descriptors.put(descriptor.getServiceInterface(), descriptor);
|
||||
}
|
||||
final Node node = document.getElementsByTagName("dao").item(0);
|
||||
if (node == null)
|
||||
throw new ServiceException("DAO module declaration not found");
|
||||
daoModule = (Class<? extends Module>) Class.forName(node
|
||||
.getAttributes().getNamedItem("module").getNodeValue());
|
||||
|
||||
this.descriptors.putAll(descriptors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the service manager
|
||||
*
|
||||
* @param injector
|
||||
* the injector instance
|
||||
* @throws ServiceStartException
|
||||
* if any error occur while starting logging or configuration
|
||||
* service
|
||||
*/
|
||||
public void init(Injector injector) throws ServiceStartException {
|
||||
this.injector = injector;
|
||||
final LoggingService service = injector
|
||||
.getInstance(LoggingService.class);
|
||||
knownServices.add(service);
|
||||
try {
|
||||
service.start();
|
||||
} catch (ServiceStartException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
service.start();
|
||||
configurationService = injector.getInstance(ConfigurationService.class);
|
||||
knownServices.add(configurationService);
|
||||
configurationService.start();
|
||||
logger = LoggerFactory.getLogger(ServiceManager.class);
|
||||
}
|
||||
|
||||
@@ -76,6 +149,17 @@ public class ServiceManager {
|
||||
return injector.getInstance(serviceClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param serviceClass
|
||||
* the service class
|
||||
* @return the {@link ServiceDescriptor} for the requested service
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Service> ServiceDescriptor<T> getServiceDescriptor(
|
||||
Class<T> serviceClass) {
|
||||
return (ServiceDescriptor<T>) descriptors.get(serviceClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the given service implementation
|
||||
*
|
||||
@@ -87,6 +171,7 @@ public class ServiceManager {
|
||||
* @throws ServiceStartException
|
||||
* if any error occur while starting service
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public <T extends Service> T start(Class<T> serviceClass)
|
||||
throws ServiceStartException {
|
||||
final T service = injector.getInstance(serviceClass);
|
||||
@@ -99,6 +184,13 @@ public class ServiceManager {
|
||||
startDependencies(service.getDependencies());
|
||||
logger.debug("{}: Starting service...",
|
||||
serviceClass.getSimpleName());
|
||||
if (service instanceof ConfigurableService) {
|
||||
final ServiceConfiguration config = configurationService
|
||||
.getServiceConfiguration(
|
||||
(ConfigurableService<?>) service,
|
||||
(Class<? extends Service>) serviceClass);
|
||||
((ConfigurableService) service).setConfiguration(config);
|
||||
}
|
||||
service.start();
|
||||
logger.info("{} started", serviceClass.getSimpleName());
|
||||
return service;
|
||||
@@ -152,6 +244,9 @@ public class ServiceManager {
|
||||
logger.debug("{0}: Stopping service...",
|
||||
serviceClass.getSimpleName());
|
||||
stopDependencies(service);
|
||||
if (service instanceof ConfigurableService) {
|
||||
((ConfigurableService<?>) service).setConfiguration(null);
|
||||
}
|
||||
service.stop();
|
||||
logger.info("{0}: Service stopped!", serviceClass.getSimpleName());
|
||||
} catch (ServiceStopException e) {
|
||||
@@ -245,4 +340,29 @@ public class ServiceManager {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a newly created {@link Guice} {@link Module} with all loaded
|
||||
* services
|
||||
*/
|
||||
public Module newGuiceModule() {
|
||||
return new AbstractModule() {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void configure() {
|
||||
bind(ServiceManager.class).toInstance(ServiceManager.this);
|
||||
try {
|
||||
install(daoModule.newInstance());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
for (@SuppressWarnings("rawtypes")
|
||||
final ServiceDescriptor descriptor : descriptors.values()) {
|
||||
bind(descriptor.getServiceInterface()).to(
|
||||
descriptor.getServiceImplementation()).in(
|
||||
Scopes.SINGLETON);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
*/
|
||||
package com.l2jserver.service.configuration;
|
||||
|
||||
import com.l2jserver.service.ConfigurableService;
|
||||
import com.l2jserver.service.Service;
|
||||
import com.l2jserver.service.ServiceConfiguration;
|
||||
|
||||
/**
|
||||
* The configuration service is responsible for reading and writing in
|
||||
@@ -27,13 +29,15 @@ import com.l2jserver.service.Service;
|
||||
*/
|
||||
public interface ConfigurationService extends Service {
|
||||
/**
|
||||
* Get the configuration object for <tt>config</tt>
|
||||
* Get the configuration for the given service
|
||||
*
|
||||
* @param <C>
|
||||
* the configuration type
|
||||
* @param config
|
||||
* the configuration interface class
|
||||
* @param service
|
||||
* the service
|
||||
* @param serviceInterface
|
||||
* the service interface
|
||||
* @return the configuration object
|
||||
*/
|
||||
<C extends Configuration> C get(Class<C> config);
|
||||
<C extends ServiceConfiguration> C getServiceConfiguration(
|
||||
ConfigurableService<?> service,
|
||||
Class<? extends Service> serviceInterface);
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
*/
|
||||
package com.l2jserver.service.configuration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -26,23 +24,23 @@ import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
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;
|
||||
@@ -60,33 +58,16 @@ import com.l2jserver.util.transformer.TransformerFactory;
|
||||
@Depends({ LoggingService.class, CacheService.class })
|
||||
public class XMLConfigurationService extends AbstractService implements
|
||||
ConfigurationService {
|
||||
/**
|
||||
* The directory in which configuration files are stored
|
||||
*/
|
||||
private File file = new File("./config/config.xml");
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
/**
|
||||
* The DOM {@link DocumentBuilderFactory}
|
||||
* The service manager. Will provide XML nodes for service configuration
|
||||
* interfaces
|
||||
*/
|
||||
private DocumentBuilderFactory factory;
|
||||
/**
|
||||
* The DOM {@link DocumentBuilder}
|
||||
*/
|
||||
private DocumentBuilder builder;
|
||||
|
||||
/**
|
||||
* The XML {@link Document} containing configuration data
|
||||
*/
|
||||
private Document properties;
|
||||
|
||||
/**
|
||||
* The cache of configuration objects
|
||||
*/
|
||||
private Map<Class<?>, Object> cache = CollectionFactory.newWeakMap();
|
||||
private final ServiceManager serviceManager;
|
||||
|
||||
/**
|
||||
* Defines the XPath for the configuration parameter
|
||||
@@ -103,50 +84,29 @@ public class XMLConfigurationService extends AbstractService implements
|
||||
|
||||
/**
|
||||
* Creates a new empty instance
|
||||
*
|
||||
* @param serviceManager
|
||||
* the service manager
|
||||
*/
|
||||
@Inject
|
||||
protected XMLConfigurationService() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new service instance. <b>This is used for tests</b>
|
||||
*
|
||||
* @param file
|
||||
* the configuration file
|
||||
*/
|
||||
protected XMLConfigurationService(File file) {
|
||||
this.file = file;
|
||||
protected XMLConfigurationService(ServiceManager serviceManager) {
|
||||
this.serviceManager = serviceManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStart() throws ServiceStartException {
|
||||
factory = DocumentBuilderFactory.newInstance();
|
||||
try {
|
||||
builder = factory.newDocumentBuilder();
|
||||
properties = builder.parse(file);
|
||||
} catch (ParserConfigurationException e) {
|
||||
throw new ServiceStartException(e);
|
||||
} catch (SAXException e) {
|
||||
throw new ServiceStartException(e);
|
||||
} catch (IOException e) {
|
||||
throw new ServiceStartException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <C extends Configuration> C get(Class<C> config) {
|
||||
Preconditions.checkNotNull(config, "config");
|
||||
|
||||
if (cache.containsKey(config))
|
||||
return (C) cache.get(config);
|
||||
log.debug("Trying to create {} proxy", config);
|
||||
|
||||
C proxy = (C) Proxy.newProxyInstance(this.getClass().getClassLoader(),
|
||||
new Class<?>[] { config }, new ConfigInvocationHandler(
|
||||
properties));
|
||||
cache.put(config, proxy);
|
||||
return proxy;
|
||||
public <C extends ServiceConfiguration> C getServiceConfiguration(
|
||||
ConfigurableService<?> service,
|
||||
Class<? extends Service> serviceInterface) {
|
||||
final ServiceDescriptor<?> serviceDescriptor = serviceManager
|
||||
.getServiceDescriptor(serviceInterface);
|
||||
return (C) Proxy.newProxyInstance(this.getClass().getClassLoader(),
|
||||
new Class<?>[] { service.getConfigurationInterface() },
|
||||
new ConfigInvocationHandler(serviceDescriptor.getNode()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,7 +118,7 @@ public class XMLConfigurationService extends AbstractService implements
|
||||
/**
|
||||
* The invocation handler properties
|
||||
*/
|
||||
private final Document properties;
|
||||
private final Node properties;
|
||||
/**
|
||||
* The invocation cache
|
||||
*/
|
||||
@@ -168,7 +128,7 @@ public class XMLConfigurationService extends AbstractService implements
|
||||
* @param properties
|
||||
* the properties
|
||||
*/
|
||||
public ConfigInvocationHandler(Document properties) {
|
||||
public ConfigInvocationHandler(Node properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@@ -345,11 +305,4 @@ public class XMLConfigurationService extends AbstractService implements
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the configuration store directory
|
||||
*/
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,42 +1,25 @@
|
||||
/*
|
||||
* This file is part of l2jserver2 <l2jserver2.com>.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* The L2JGameServer class
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class L2JGameServer {
|
||||
/**
|
||||
* The server injector
|
||||
*/
|
||||
private final Injector injector = Guice
|
||||
.createInjector(new GameServerModule());
|
||||
|
||||
/**
|
||||
* Get the injector
|
||||
*
|
||||
* @return the injector
|
||||
*/
|
||||
public Injector getInjector() {
|
||||
return injector;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of l2jserver2 <l2jserver2.com>.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.core.vfs;
|
||||
|
||||
/**
|
||||
* Configuration interface for {@link Java7VFSService}.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface Java7VFSConfiguration extends VFSConfiguration {
|
||||
}
|
||||
@@ -22,27 +22,23 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
import com.l2jserver.service.AbstractConfigurableService;
|
||||
import com.l2jserver.service.ServiceStartException;
|
||||
import com.l2jserver.service.ServiceStopException;
|
||||
import com.l2jserver.service.configuration.ConfigurationService;
|
||||
|
||||
/**
|
||||
* Implementation of {@link VFSService} using default Java7 APIs.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class Java7VFSService extends AbstractService implements VFSService {
|
||||
public class Java7VFSService extends
|
||||
AbstractConfigurableService<Java7VFSConfiguration> implements
|
||||
VFSService {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
/**
|
||||
* The Java 7 vfs configuration
|
||||
*/
|
||||
private final Java7VFSConfiguration config;
|
||||
|
||||
/**
|
||||
* The root {@link Path} of the server data
|
||||
*/
|
||||
@@ -53,20 +49,11 @@ public class Java7VFSService extends AbstractService implements VFSService {
|
||||
private Path dataRoot;
|
||||
|
||||
/**
|
||||
* Configuration interface for {@link Java7VFSService}.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface Java7VFSConfiguration extends VFSConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param configService
|
||||
* the configuration service
|
||||
* Creates a new instance
|
||||
*/
|
||||
@Inject
|
||||
protected Java7VFSService(final ConfigurationService configService) {
|
||||
this.config = configService.get(Java7VFSConfiguration.class);
|
||||
public Java7VFSService() {
|
||||
super(Java7VFSConfiguration.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,37 +1,25 @@
|
||||
/*
|
||||
* This file is part of l2jserver2 <l2jserver2.com>.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Module;
|
||||
import com.l2jserver.model.id.provider.IDProviderModule;
|
||||
import com.l2jserver.service.ServiceModule;
|
||||
import com.l2jserver.service.database.OrientDBDAOModule;
|
||||
|
||||
/**
|
||||
* The game server Google Guice {@link Module}.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class GameServerModule extends AbstractModule {
|
||||
@Override
|
||||
protected void configure() {
|
||||
install(new ServiceModule());
|
||||
install(new IDProviderModule());
|
||||
install(new OrientDBDAOModule());
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of l2jserver2 <l2jserver2.com>.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.core.vfs;
|
||||
|
||||
/**
|
||||
* Configuration interface for {@link TrueZipVFSService}.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface TrueZipVFSConfiguration extends VFSConfiguration {
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
import com.l2jserver.service.AbstractConfigurableService;
|
||||
import com.l2jserver.service.ServiceStartException;
|
||||
import com.l2jserver.service.ServiceStopException;
|
||||
import com.l2jserver.service.configuration.ConfigurationService;
|
||||
@@ -35,17 +35,14 @@ import de.schlichtherle.truezip.nio.file.TPath;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class TrueZipVFSService extends AbstractService implements VFSService {
|
||||
public class TrueZipVFSService extends
|
||||
AbstractConfigurableService<TrueZipVFSConfiguration> implements
|
||||
VFSService {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
/**
|
||||
* The Java 7 vfs configuration
|
||||
*/
|
||||
private final TrueZipVFSConfiguration config;
|
||||
|
||||
/**
|
||||
* The root {@link Path} of the server data
|
||||
*/
|
||||
@@ -55,21 +52,13 @@ public class TrueZipVFSService extends AbstractService implements VFSService {
|
||||
*/
|
||||
private TPath dataRoot;
|
||||
|
||||
/**
|
||||
* Configuration interface for {@link TrueZipVFSService}.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface TrueZipVFSConfiguration extends VFSConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param configService
|
||||
* the configuration service
|
||||
*/
|
||||
@Inject
|
||||
protected TrueZipVFSService(final ConfigurationService configService) {
|
||||
this.config = configService.get(TrueZipVFSConfiguration.class);
|
||||
super(TrueZipVFSConfiguration.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* This file is part of l2jserver2 <l2jserver2.com>.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.core.vfs;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import com.l2jserver.service.ServiceConfiguration;
|
||||
import com.l2jserver.service.configuration.Configuration;
|
||||
import com.l2jserver.service.configuration.XMLConfigurationService.ConfigurationXPath;
|
||||
|
||||
/**
|
||||
* VFS service configuration
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
* @see Configuration
|
||||
*/
|
||||
public interface VFSConfiguration extends ServiceConfiguration {
|
||||
/**
|
||||
* @return the VFS root {@link URI}
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "")
|
||||
@ConfigurationXPath("fileSystem/@root")
|
||||
Path getRoot();
|
||||
|
||||
/**
|
||||
* @param root
|
||||
* the new VFS root {@link URI}
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("fileSystem/@root")
|
||||
void setRoot(Path root);
|
||||
|
||||
/**
|
||||
* @return the VFS root {@link URI}
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "")
|
||||
@ConfigurationXPath("fileSystem/data/@root")
|
||||
String getDataPath();
|
||||
|
||||
/**
|
||||
* @param data
|
||||
* the new data root {@link URI}
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("fileSystem/data/@root")
|
||||
void setDataPath(String data);
|
||||
}
|
||||
@@ -16,13 +16,9 @@
|
||||
*/
|
||||
package com.l2jserver.service.core.vfs;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import com.l2jserver.service.Service;
|
||||
import com.l2jserver.service.ServiceConfiguration;
|
||||
import com.l2jserver.service.configuration.Configuration;
|
||||
import com.l2jserver.service.configuration.XMLConfigurationService.ConfigurationXPath;
|
||||
|
||||
/**
|
||||
* The VFS service is responsible for creating a Virtual File System that is
|
||||
@@ -31,44 +27,6 @@ import com.l2jserver.service.configuration.XMLConfigurationService.Configuration
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface VFSService extends Service {
|
||||
/**
|
||||
* VFS service configuration
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
* @see Configuration
|
||||
*/
|
||||
public interface VFSConfiguration extends ServiceConfiguration {
|
||||
/**
|
||||
* @return the VFS root {@link URI}
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "")
|
||||
@ConfigurationXPath("/configuration/services/vfs/root")
|
||||
Path getRoot();
|
||||
|
||||
/**
|
||||
* @param root
|
||||
* the new VFS root {@link URI}
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("/configuration/services/vfs/root")
|
||||
void setRoot(Path root);
|
||||
|
||||
/**
|
||||
* @return the VFS root {@link URI}
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "")
|
||||
@ConfigurationXPath("/configuration/services/vfs/data")
|
||||
String getDataPath();
|
||||
|
||||
/**
|
||||
* @param data
|
||||
* the new data root {@link URI}
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("/configuration/services/vfs/data")
|
||||
void setDataPath(String data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves an file. If the file cannot be resolved, null will be returned.
|
||||
* <p>
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of l2jserver2 <l2jserver2.com>.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.database;
|
||||
|
||||
import com.l2jserver.service.ServiceConfiguration;
|
||||
import com.l2jserver.service.configuration.Configuration;
|
||||
import com.l2jserver.service.configuration.XMLConfigurationService.ConfigurationXPath;
|
||||
|
||||
/**
|
||||
* Database service configuration
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
* @see Configuration
|
||||
*/
|
||||
public interface DatabaseConfiguration extends ServiceConfiguration {
|
||||
/**
|
||||
* @return the update schema state
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "true")
|
||||
@ConfigurationXPath("schema/@automaticUpdate")
|
||||
boolean isAutomaticSchemaUpdateEnabled();
|
||||
|
||||
/**
|
||||
* @param updateSchema
|
||||
* the new uodate schema state
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("schema/@automaticUpdate")
|
||||
void setUpdateSchema(boolean updateSchema);
|
||||
}
|
||||
@@ -22,9 +22,6 @@ import java.nio.file.Path;
|
||||
import com.l2jserver.model.Model;
|
||||
import com.l2jserver.model.id.ID;
|
||||
import com.l2jserver.service.Service;
|
||||
import com.l2jserver.service.ServiceConfiguration;
|
||||
import com.l2jserver.service.configuration.Configuration;
|
||||
import com.l2jserver.service.configuration.XMLConfigurationService.ConfigurationXPath;
|
||||
import com.l2jserver.service.core.threading.AsyncFuture;
|
||||
import com.mysema.query.sql.RelationalPath;
|
||||
import com.mysema.query.sql.RelationalPathBase;
|
||||
@@ -45,29 +42,6 @@ import com.mysema.query.sql.RelationalPathBase;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface DatabaseService extends Service {
|
||||
/**
|
||||
* Database service configuration
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
* @see Configuration
|
||||
*/
|
||||
public interface DatabaseConfiguration extends ServiceConfiguration {
|
||||
/**
|
||||
* @return the update schema state
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "true")
|
||||
@ConfigurationXPath("/configuration/services/database/automaticSchemaUpdate")
|
||||
boolean isAutomaticSchemaUpdateEnabled();
|
||||
|
||||
/**
|
||||
* @param updateSchema
|
||||
* the new uodate schema state
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("/configuration/services/database/automaticSchemaUpdate")
|
||||
void setUpdateSchema(boolean updateSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes several operations inside a single database transaction.
|
||||
* <p>
|
||||
|
||||
@@ -35,13 +35,11 @@ import com.l2jserver.model.Model;
|
||||
import com.l2jserver.model.Model.ObjectDesire;
|
||||
import com.l2jserver.model.id.ID;
|
||||
import com.l2jserver.model.id.object.allocator.IDAllocator;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
import com.l2jserver.service.AbstractConfigurableService;
|
||||
import com.l2jserver.service.ServiceStartException;
|
||||
import com.l2jserver.service.ServiceStopException;
|
||||
import com.l2jserver.service.cache.Cache;
|
||||
import com.l2jserver.service.cache.CacheService;
|
||||
import com.l2jserver.service.configuration.ConfigurationService;
|
||||
import com.l2jserver.service.configuration.XMLConfigurationService.ConfigurationXPath;
|
||||
import com.l2jserver.service.core.threading.AbstractTask;
|
||||
import com.l2jserver.service.core.threading.AsyncFuture;
|
||||
import com.l2jserver.service.core.threading.ScheduledAsyncFuture;
|
||||
@@ -96,12 +94,9 @@ import com.orientechnologies.orient.core.tx.OTransaction;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class AbstractOrientDatabaseService extends AbstractService
|
||||
implements DatabaseService {
|
||||
/**
|
||||
* The configuration object
|
||||
*/
|
||||
private final OrientDatabaseConfiguration config;
|
||||
public abstract class AbstractOrientDatabaseService extends
|
||||
AbstractConfigurableService<OrientDatabaseConfiguration> implements
|
||||
DatabaseService {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
@@ -136,60 +131,6 @@ public abstract class AbstractOrientDatabaseService extends AbstractService
|
||||
private final ThreadLocal<ODatabaseDocumentTx> transaction = new ThreadLocal<ODatabaseDocumentTx>();
|
||||
|
||||
/**
|
||||
* Configuration interface for {@link AbstractOrientDatabaseService}.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface OrientDatabaseConfiguration extends DatabaseConfiguration {
|
||||
/**
|
||||
* @return the orientdb url
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "local:data/database")
|
||||
@ConfigurationXPath("/configuration/services/database/orientdb/url")
|
||||
String getUrl();
|
||||
|
||||
/**
|
||||
* @param url
|
||||
* the new orientdb url
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("/configuration/services/database/orientdb/url")
|
||||
void setUrl(String url);
|
||||
|
||||
/**
|
||||
* @return the orientdb database username
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "admin")
|
||||
@ConfigurationXPath("/configuration/services/database/orientdb/username")
|
||||
String getUsername();
|
||||
|
||||
/**
|
||||
* @param username
|
||||
* the orientdb database username
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("/configuration/services/database/orientdb/username")
|
||||
void setUsername(String username);
|
||||
|
||||
/**
|
||||
* @return the orientdb database password
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "admin")
|
||||
@ConfigurationXPath("/configuration/services/database/orientdb/password")
|
||||
String getPassword();
|
||||
|
||||
/**
|
||||
* @param password
|
||||
* the jdbc database password
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("/configuration/services/database/jdbc/password")
|
||||
void setPassword(String password);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param configService
|
||||
* the configuration service
|
||||
* @param cacheService
|
||||
* the cache service
|
||||
* @param threadService
|
||||
@@ -198,10 +139,10 @@ public abstract class AbstractOrientDatabaseService extends AbstractService
|
||||
* the {@link DataAccessObject DAO} resolver
|
||||
*/
|
||||
@Inject
|
||||
public AbstractOrientDatabaseService(ConfigurationService configService,
|
||||
public AbstractOrientDatabaseService(
|
||||
CacheService cacheService, ThreadService threadService,
|
||||
DAOResolver daoResolver) {
|
||||
config = configService.get(OrientDatabaseConfiguration.class);
|
||||
super(OrientDatabaseConfiguration.class);
|
||||
this.cacheService = cacheService;
|
||||
this.threadService = threadService;
|
||||
this.daoResolver = daoResolver;
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* This file is part of l2jserver2 <l2jserver2.com>.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.database.orientdb;
|
||||
|
||||
import com.l2jserver.service.configuration.XMLConfigurationService.ConfigurationXPath;
|
||||
import com.l2jserver.service.database.DatabaseConfiguration;
|
||||
|
||||
/**
|
||||
* Configuration interface for {@link AbstractOrientDatabaseService}.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface OrientDatabaseConfiguration extends DatabaseConfiguration {
|
||||
/**
|
||||
* @return the orientdb url
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "local:data/database")
|
||||
@ConfigurationXPath("connection/@url")
|
||||
String getUrl();
|
||||
|
||||
/**
|
||||
* @param url
|
||||
* the new orientdb url
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("connection/@url")
|
||||
void setUrl(String url);
|
||||
|
||||
/**
|
||||
* @return the orientdb database username
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "admin")
|
||||
@ConfigurationXPath("connection/authentication/@username")
|
||||
String getUsername();
|
||||
|
||||
/**
|
||||
* @param username
|
||||
* the orientdb database username
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("connection/authentication/@username")
|
||||
void setUsername(String username);
|
||||
|
||||
/**
|
||||
* @return the orientdb database password
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "admin")
|
||||
@ConfigurationXPath("connection/authentication/@password")
|
||||
String getPassword();
|
||||
|
||||
/**
|
||||
* @param password
|
||||
* the jdbc database password
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("connection/authentication/@password")
|
||||
void setPassword(String password);
|
||||
}
|
||||
@@ -43,13 +43,11 @@ import com.l2jserver.model.Model;
|
||||
import com.l2jserver.model.Model.ObjectDesire;
|
||||
import com.l2jserver.model.id.ID;
|
||||
import com.l2jserver.model.id.object.allocator.IDAllocator;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
import com.l2jserver.service.AbstractConfigurableService;
|
||||
import com.l2jserver.service.ServiceStartException;
|
||||
import com.l2jserver.service.ServiceStopException;
|
||||
import com.l2jserver.service.cache.Cache;
|
||||
import com.l2jserver.service.cache.CacheService;
|
||||
import com.l2jserver.service.configuration.ConfigurationService;
|
||||
import com.l2jserver.service.configuration.XMLConfigurationService.ConfigurationXPath;
|
||||
import com.l2jserver.service.core.threading.AbstractTask;
|
||||
import com.l2jserver.service.core.threading.AsyncFuture;
|
||||
import com.l2jserver.service.core.threading.ScheduledAsyncFuture;
|
||||
@@ -101,12 +99,9 @@ import com.mysema.query.types.Path;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class AbstractSQLDatabaseService extends AbstractService
|
||||
implements DatabaseService {
|
||||
/**
|
||||
* The configuration object
|
||||
*/
|
||||
private final JDBCDatabaseConfiguration config;
|
||||
public abstract class AbstractSQLDatabaseService extends
|
||||
AbstractConfigurableService<JDBCDatabaseConfiguration> implements
|
||||
DatabaseService {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
@@ -173,120 +168,6 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
||||
private final Type<?>[] sqlTypes;
|
||||
|
||||
/**
|
||||
* Configuration interface for {@link AbstractSQLDatabaseService}.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface JDBCDatabaseConfiguration extends DatabaseConfiguration {
|
||||
/**
|
||||
* @return the jdbc url
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "jdbc:mysql://localhost/l2jserver2")
|
||||
@ConfigurationXPath("/configuration/services/database/jdbc/url")
|
||||
String getJdbcUrl();
|
||||
|
||||
/**
|
||||
* @param jdbcUrl
|
||||
* the new jdbc url
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("/configuration/services/database/jdbc/url")
|
||||
void setJdbcUrl(String jdbcUrl);
|
||||
|
||||
/**
|
||||
* @return the database engine class
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "com.l2jserver.service.database.sql.MySQLDatabaseEngine")
|
||||
@ConfigurationXPath("/configuration/services/database/jdbc/engine")
|
||||
Class<? extends DatabaseEngine> getDatabaseEngineClass();
|
||||
|
||||
/**
|
||||
* @param driver
|
||||
* the new database engine class
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("/configuration/services/database/jdbc/engine")
|
||||
void setDatabaseEngineClass(Class<? extends DatabaseEngine> driver);
|
||||
|
||||
/**
|
||||
* @return the jdbc database username
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "l2j")
|
||||
@ConfigurationXPath("/configuration/services/database/jdbc/username")
|
||||
String getUsername();
|
||||
|
||||
/**
|
||||
* @param username
|
||||
* the jdbc database username
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("/configuration/services/database/jdbc/username")
|
||||
void setUsername(String username);
|
||||
|
||||
/**
|
||||
* @return the jdbc database password
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "changeme")
|
||||
@ConfigurationXPath("/configuration/services/database/jdbc/password")
|
||||
String getPassword();
|
||||
|
||||
/**
|
||||
* @param password
|
||||
* the jdbc database password
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("/configuration/services/database/jdbc/password")
|
||||
void setPassword(String password);
|
||||
|
||||
/**
|
||||
* @return the maximum number of active connections
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "20")
|
||||
@ConfigurationXPath("/configuration/services/database/connections/active-maximum")
|
||||
int getMaxActiveConnections();
|
||||
|
||||
/**
|
||||
* @param password
|
||||
* the maximum number of active connections
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("/configuration/services/database/connections/active-maximum")
|
||||
void setMaxActiveConnections(int password);
|
||||
|
||||
/**
|
||||
* @return the maximum number of idle connections
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "20")
|
||||
@ConfigurationXPath("/configuration/services/database/connections/idle-maximum")
|
||||
int getMaxIdleConnections();
|
||||
|
||||
/**
|
||||
* @param password
|
||||
* the maximum number of idle connections
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("/configuration/services/database/connections/idle-maximum")
|
||||
void setMaxIdleConnections(int password);
|
||||
|
||||
/**
|
||||
* @return the minimum number of idle connections
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "5")
|
||||
@ConfigurationXPath("/configuration/services/database/connections/idle-minimum")
|
||||
int getMinIdleConnections();
|
||||
|
||||
/**
|
||||
* @param password
|
||||
* the minimum number of idle connections
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("/configuration/services/database/connections/idle-minimum")
|
||||
void setMinIdleConnections(int password);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param configService
|
||||
* the configuration service
|
||||
* @param cacheService
|
||||
* the cache service
|
||||
* @param threadService
|
||||
@@ -299,10 +180,10 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
||||
* the SQL mapping types
|
||||
*/
|
||||
@Inject
|
||||
public AbstractSQLDatabaseService(ConfigurationService configService,
|
||||
CacheService cacheService, ThreadService threadService,
|
||||
VFSService vfsService, DAOResolver daoResolver, Type<?>... types) {
|
||||
config = configService.get(JDBCDatabaseConfiguration.class);
|
||||
public AbstractSQLDatabaseService(CacheService cacheService,
|
||||
ThreadService threadService, VFSService vfsService,
|
||||
DAOResolver daoResolver, Type<?>... types) {
|
||||
super(JDBCDatabaseConfiguration.class);
|
||||
this.cacheService = cacheService;
|
||||
this.threadService = threadService;
|
||||
this.vfsService = vfsService;
|
||||
@@ -409,6 +290,7 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
||||
}
|
||||
log.info("Importing {} to {}", path, entity);
|
||||
try {
|
||||
conn.setAutoCommit(false);
|
||||
CSVUtils.parseCSV(path, new CSVMapProcessor<Long>() {
|
||||
@Override
|
||||
public Long process(final Map<String, String> map) {
|
||||
@@ -433,8 +315,15 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
||||
return insert.execute();
|
||||
}
|
||||
});
|
||||
conn.commit();
|
||||
} catch (SQLException e) {
|
||||
try {
|
||||
conn.rollback();
|
||||
} catch (SQLException e1) {
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
conn.setAutoCommit(true);
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* This file is part of l2jserver2 <l2jserver2.com>.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.database.sql;
|
||||
|
||||
import com.l2jserver.service.configuration.XMLConfigurationService.ConfigurationXPath;
|
||||
import com.l2jserver.service.database.DatabaseConfiguration;
|
||||
|
||||
/**
|
||||
* Configuration interface for {@link AbstractSQLDatabaseService}.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface JDBCDatabaseConfiguration extends DatabaseConfiguration {
|
||||
/**
|
||||
* @return the jdbc url
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "jdbc:mysql://localhost/l2jserver2")
|
||||
@ConfigurationXPath("connection/@url")
|
||||
String getJdbcUrl();
|
||||
|
||||
/**
|
||||
* @param jdbcUrl
|
||||
* the new jdbc url
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("connection/@url")
|
||||
void setJdbcUrl(String jdbcUrl);
|
||||
|
||||
/**
|
||||
* @return the database engine class
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "com.l2jserver.service.database.sql.MySQLDatabaseEngine")
|
||||
@ConfigurationXPath("connection/engine/@class")
|
||||
Class<? extends DatabaseEngine> getDatabaseEngineClass();
|
||||
|
||||
/**
|
||||
* @param driver
|
||||
* the new database engine class
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("connection/engine/@class")
|
||||
void setDatabaseEngineClass(Class<? extends DatabaseEngine> driver);
|
||||
|
||||
/**
|
||||
* @return the jdbc database username
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "l2j")
|
||||
@ConfigurationXPath("connection/authentication/@username")
|
||||
String getUsername();
|
||||
|
||||
/**
|
||||
* @param username
|
||||
* the jdbc database username
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("connection/authentication/@username")
|
||||
void setUsername(String username);
|
||||
|
||||
/**
|
||||
* @return the jdbc database password
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "changeme")
|
||||
@ConfigurationXPath("connection/authentication/@password")
|
||||
String getPassword();
|
||||
|
||||
/**
|
||||
* @param password
|
||||
* the jdbc database password
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("connection/authentication/@password")
|
||||
void setPassword(String password);
|
||||
|
||||
/**
|
||||
* @return the maximum number of active connections
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "20")
|
||||
@ConfigurationXPath("connection/pool/@max-active")
|
||||
int getMaxActiveConnections();
|
||||
|
||||
/**
|
||||
* @param maxActive
|
||||
* the maximum number of active connections
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("connection/pool/@max-active")
|
||||
void setMaxActiveConnections(int maxActive);
|
||||
|
||||
/**
|
||||
* @return the maximum number of idle connections
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "20")
|
||||
@ConfigurationXPath("connection/pool/@max-idle")
|
||||
int getMaxIdleConnections();
|
||||
|
||||
/**
|
||||
* @param maxIdle
|
||||
* the maximum number of idle connections
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("connection/pool/@max-idle")
|
||||
void setMaxIdleConnections(int maxIdle);
|
||||
|
||||
/**
|
||||
* @return the minimum number of idle connections
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "5")
|
||||
@ConfigurationXPath("connection/pool/@min-idle")
|
||||
int getMinIdleConnections();
|
||||
|
||||
/**
|
||||
* @param minIdle
|
||||
* the minimum number of idle connections
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("connection/pool/@min-idle")
|
||||
void setMinIdleConnections(int minIdle);
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.l2jserver.util;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
@@ -61,6 +62,39 @@ public class ClassUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively searches for an annotation <h1>Search order</h1>
|
||||
* <p>
|
||||
* <ol>
|
||||
* <li><code>cls</code> class</li>
|
||||
* <li><code>cls</code> implementing interfaces</code></li>
|
||||
* <li><code>cls</code> super class</code></li>
|
||||
* </ol>
|
||||
* If after all those steps, no annotation is found, <code>null</code> is
|
||||
* returned.
|
||||
*
|
||||
* @param annotationClass
|
||||
* the annotation class
|
||||
* @param cls
|
||||
* the class to start searching
|
||||
* @return the annotation, if found.
|
||||
*/
|
||||
public static <T extends Annotation> T getAnnotation(
|
||||
Class<T> annotationClass, Class<?> cls) {
|
||||
T annotation = cls.getAnnotation(annotationClass);
|
||||
if (annotation == null) {
|
||||
for (final Class<?> interfaceCls : cls.getInterfaces()) {
|
||||
annotation = getAnnotation(annotationClass, interfaceCls);
|
||||
if (annotation != null)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (annotation == null && cls.getSuperclass() != null
|
||||
&& cls.getSuperclass() != Object.class)
|
||||
annotation = getAnnotation(annotationClass, cls.getSuperclass());
|
||||
return annotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if class in member of the package
|
||||
*
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
/*
|
||||
* This file is part of l2jserver2 <l2jserver2.com>.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.configuration;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.l2jserver.service.ServiceStartException;
|
||||
import com.l2jserver.service.configuration.XMLConfigurationService.ConfigurationXPath;
|
||||
|
||||
/**
|
||||
* Tests for {@link XMLConfigurationService}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class XMLConfigurationServiceTest {
|
||||
/**
|
||||
* The {@link TestConfig} proxy
|
||||
*/
|
||||
private TestConfig config;
|
||||
|
||||
/**
|
||||
* Preparation for tests
|
||||
*
|
||||
* @throws ServiceStartException
|
||||
*/
|
||||
@Before
|
||||
public void tearUp() throws ServiceStartException {
|
||||
final XMLConfigurationService service = new XMLConfigurationService(
|
||||
new File("src/test/resources/test-config.xml"));
|
||||
service.start();
|
||||
config = service.get(TestConfig.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test config string
|
||||
*
|
||||
* @throws ServiceStartException
|
||||
*/
|
||||
@Test
|
||||
public void testString() throws ServiceStartException {
|
||||
Assert.assertEquals("test", config.getTestString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test default value
|
||||
*
|
||||
* @throws ServiceStartException
|
||||
*/
|
||||
@Test
|
||||
public void testDefaultValue() throws ServiceStartException {
|
||||
Assert.assertEquals("default", config.getDefaultTestString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test integer
|
||||
*
|
||||
* @throws ServiceStartException
|
||||
*/
|
||||
@Test
|
||||
public void testInteger() throws ServiceStartException {
|
||||
Assert.assertEquals(256, config.getTestInteger());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test setter
|
||||
*
|
||||
* @throws ServiceStartException
|
||||
*/
|
||||
@Test
|
||||
public void testSetter() throws ServiceStartException {
|
||||
config.setTestString("new-value");
|
||||
Assert.assertEquals("new-value", config.getTestString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test null setter
|
||||
*
|
||||
* @throws ServiceStartException
|
||||
*/
|
||||
@Test
|
||||
public void testNullSetter() throws ServiceStartException {
|
||||
config.setTestString(null);
|
||||
Assert.assertEquals("test-default", config.getTestString());
|
||||
}
|
||||
|
||||
/**
|
||||
* The TestConfig interface
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface TestConfig extends Configuration {
|
||||
/**
|
||||
* @return an configuration string
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "test-default")
|
||||
@ConfigurationXPath("/configuration/test/testvalue")
|
||||
String getTestString();
|
||||
|
||||
/**
|
||||
* @param value
|
||||
* any string
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("/configuration/test/testvalue")
|
||||
void setTestString(String value);
|
||||
|
||||
/**
|
||||
* @return an configuration string
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "default")
|
||||
@ConfigurationXPath("/configuration/test/nonexistentkey")
|
||||
String getDefaultTestString();
|
||||
|
||||
/**
|
||||
* @return an configuration integer
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "0")
|
||||
@ConfigurationXPath("/configuration/test/integer")
|
||||
int getTestInteger();
|
||||
|
||||
/**
|
||||
* @param n
|
||||
* any integer
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("/configuration/test/integer")
|
||||
void setTestInteger(Integer n);
|
||||
}
|
||||
}
|
||||
1
l2jserver2-gameserver/.gitignore
vendored
1
l2jserver2-gameserver/.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
/log
|
||||
/derby.log
|
||||
/services.xml
|
||||
|
||||
1
l2jserver2-gameserver/config/.gitignore
vendored
1
l2jserver2-gameserver/config/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
/config.xml
|
||||
@@ -1,92 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="configuration configuration.xsd"
|
||||
xsi:noNamespaceSchemaLocation="configuration">
|
||||
<!-- TODO -->
|
||||
<general>
|
||||
<!-- TODO -->
|
||||
<rates>
|
||||
<!-- TODO -->
|
||||
<experience>1.0</experience>
|
||||
<!-- TODO -->
|
||||
<sp>1.0</sp>
|
||||
</rates>
|
||||
</general>
|
||||
|
||||
<!-- Services configuration section -->
|
||||
<services>
|
||||
<!-- Parameters in this section are used by DatabaseService. If you are
|
||||
not sure on the usage of any parameter, read the "Configuration" section
|
||||
in wiki article about DatabaseService. -->
|
||||
<database>
|
||||
<!-- Whether or not the service should try to update and create missing
|
||||
tables at startup. This should be disabled after the first server start as
|
||||
it could cause data corruption. -->
|
||||
<automaticSchemaUpdate>true</automaticSchemaUpdate>
|
||||
|
||||
<!-- Configures OrientDB engine - plug-and-play -->
|
||||
<orientdb>
|
||||
<!-- The OrientDB storage location -->
|
||||
<url>local:data/database</url>
|
||||
<!-- The OrientDB username (local storage must use "admin") -->
|
||||
<username>admin</username>
|
||||
<!-- The OrientDB password (local storage must use "admin") -->
|
||||
<password>admin</password>
|
||||
</orientdb>
|
||||
|
||||
<!-- Configures JDBC engine - requires database server configuration -->
|
||||
<jdbc>
|
||||
<!-- Defines the connection URL used by JDBC to connect to the database. -->
|
||||
<url>jdbc:mysql://localhost/l2jserver2</url>
|
||||
|
||||
<!-- The engine used to connect to the database. -->
|
||||
<engine>com.l2jserver.service.database.sql.MySQLDatabaseEngine
|
||||
</engine>
|
||||
|
||||
<!-- The username used to login into the database. NOTE: Try not use
|
||||
"root" in production servers for security reasons. -->
|
||||
<username>l2j</username>
|
||||
|
||||
<!-- The password used to login into the database. -->
|
||||
<password>changeme</password>
|
||||
</jdbc>
|
||||
|
||||
<connections>
|
||||
<!-- The maximum number of active connections -->
|
||||
<active-maximum>20</active-maximum>
|
||||
<!-- The maximum number of idle connections -->
|
||||
<idle-maximum>20</idle-maximum>
|
||||
<!-- The minimum number of idle connections -->
|
||||
<idle-minimum>5</idle-minimum>
|
||||
</connections>
|
||||
</database>
|
||||
|
||||
<!-- Parameters in this section are used by NetworkService. If you are
|
||||
not sure on the usage of any parameter, read the "Configuration" section
|
||||
in wiki article about NetworkService. -->
|
||||
<network>
|
||||
<!-- The address and port in which the server will listen to -->
|
||||
<listen>0.0.0.0:7777</listen>
|
||||
</network>
|
||||
|
||||
<!-- Parameters in this section are used by VFSService. If you are not
|
||||
sure on the usage of any parameter, read the "Configuration" section in wiki
|
||||
article about VFSService. -->
|
||||
<vfs>
|
||||
<!-- The root of the filesystem -->
|
||||
<root></root>
|
||||
|
||||
<!-- The data folder. Relative to the root. Can be a ZIP file. -->
|
||||
<data>data/</data>
|
||||
</vfs>
|
||||
|
||||
<!-- Parameters in this section are used by VFSService. If you are not
|
||||
sure on the usage of any parameter, read the "Configuration" section in wiki
|
||||
article about VFSService. -->
|
||||
<template>
|
||||
<!-- The directory in which templates are stored. Relative to "vfs.data" -->
|
||||
<directory>template/</directory>
|
||||
</template>
|
||||
</services>
|
||||
<!-- /Services configuration section -->
|
||||
</configuration>
|
||||
@@ -1,92 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="configuration configuration.xsd"
|
||||
xsi:noNamespaceSchemaLocation="configuration">
|
||||
<!-- TODO -->
|
||||
<general>
|
||||
<!-- TODO -->
|
||||
<rates>
|
||||
<!-- TODO -->
|
||||
<experience>1.0</experience>
|
||||
<!-- TODO -->
|
||||
<sp>1.0</sp>
|
||||
</rates>
|
||||
</general>
|
||||
|
||||
<!-- Services configuration section -->
|
||||
<services>
|
||||
<!-- Parameters in this section are used by DatabaseService. If you are
|
||||
not sure on the usage of any parameter, read the "Configuration" section
|
||||
in wiki article about DatabaseService. -->
|
||||
<database>
|
||||
<!-- Whether or not the service should try to update and create missing
|
||||
tables at startup. This should be disabled after the first server start as
|
||||
it could cause data corruption. -->
|
||||
<automaticSchemaUpdate>true</automaticSchemaUpdate>
|
||||
|
||||
<!-- Configures OrientDB engine - plug-and-play -->
|
||||
<orientdb>
|
||||
<!-- The OrientDB storage location -->
|
||||
<url>local:data/database</url>
|
||||
<!-- The OrientDB username (local storage must use "admin") -->
|
||||
<username>admin</username>
|
||||
<!-- The OrientDB password (local storage must use "admin") -->
|
||||
<password>admin</password>
|
||||
</orientdb>
|
||||
|
||||
<!-- Configures JDBC engine - requires database server configuration -->
|
||||
<jdbc>
|
||||
<!-- Defines the connection URL used by JDBC to connect to the database. -->
|
||||
<url>jdbc:mysql://localhost/l2jserver2</url>
|
||||
|
||||
<!-- The engine used to connect to the database. -->
|
||||
<engine>com.l2jserver.service.database.sql.MySQLDatabaseEngine
|
||||
</engine>
|
||||
|
||||
<!-- The username used to login into the database. NOTE: Try not use
|
||||
"root" in production servers for security reasons. -->
|
||||
<username>l2j</username>
|
||||
|
||||
<!-- The password used to login into the database. -->
|
||||
<password>changeme</password>
|
||||
</jdbc>
|
||||
|
||||
<connections>
|
||||
<!-- The maximum number of active connections -->
|
||||
<active-maximum>20</active-maximum>
|
||||
<!-- The maximum number of idle connections -->
|
||||
<idle-maximum>20</idle-maximum>
|
||||
<!-- The minimum number of idle connections -->
|
||||
<idle-minimum>5</idle-minimum>
|
||||
</connections>
|
||||
</database>
|
||||
|
||||
<!-- Parameters in this section are used by NetworkService. If you are
|
||||
not sure on the usage of any parameter, read the "Configuration" section
|
||||
in wiki article about NetworkService. -->
|
||||
<network>
|
||||
<!-- The address and port in which the server will listen to -->
|
||||
<listen>0.0.0.0:7777</listen>
|
||||
</network>
|
||||
|
||||
<!-- Parameters in this section are used by VFSService. If you are not
|
||||
sure on the usage of any parameter, read the "Configuration" section in wiki
|
||||
article about VFSService. -->
|
||||
<vfs>
|
||||
<!-- The root of the filesystem -->
|
||||
<root></root>
|
||||
|
||||
<!-- The data folder. Relative to the root. Can be a ZIP file. -->
|
||||
<data>data/</data>
|
||||
</vfs>
|
||||
|
||||
<!-- Parameters in this section are used by VFSService. If you are not
|
||||
sure on the usage of any parameter, read the "Configuration" section in wiki
|
||||
article about VFSService. -->
|
||||
<template>
|
||||
<!-- The directory in which templates are stored. Relative to "vfs.data" -->
|
||||
<directory>template/</directory>
|
||||
</template>
|
||||
</services>
|
||||
<!-- /Services configuration section -->
|
||||
</configuration>
|
||||
@@ -1,92 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="configuration configuration.xsd"
|
||||
xsi:noNamespaceSchemaLocation="configuration">
|
||||
<!-- TODO -->
|
||||
<general>
|
||||
<!-- TODO -->
|
||||
<rates>
|
||||
<!-- TODO -->
|
||||
<experience>1.0</experience>
|
||||
<!-- TODO -->
|
||||
<sp>1.0</sp>
|
||||
</rates>
|
||||
</general>
|
||||
|
||||
<!-- Services configuration section -->
|
||||
<services>
|
||||
<!-- Parameters in this section are used by DatabaseService. If you are
|
||||
not sure on the usage of any parameter, read the "Configuration" section
|
||||
in wiki article about DatabaseService. -->
|
||||
<database>
|
||||
<!-- Whether or not the service should try to update and create missing
|
||||
tables at startup. This should be disabled after the first server start as
|
||||
it could cause data corruption. -->
|
||||
<automaticSchemaUpdate>true</automaticSchemaUpdate>
|
||||
|
||||
<!-- Configures OrientDB engine - plug-and-play -->
|
||||
<orientdb>
|
||||
<!-- The OrientDB storage location -->
|
||||
<url>local:data/database</url>
|
||||
<!-- The OrientDB username (local storage must use "admin") -->
|
||||
<username>admin</username>
|
||||
<!-- The OrientDB password (local storage must use "admin") -->
|
||||
<password>admin</password>
|
||||
</orientdb>
|
||||
|
||||
<!-- Configures JDBC engine - requires database server configuration -->
|
||||
<jdbc>
|
||||
<!-- Defines the connection URL used by JDBC to connect to the database. -->
|
||||
<url>jdbc:mysql://localhost/l2jserver2</url>
|
||||
|
||||
<!-- The engine used to connect to the database. -->
|
||||
<engine>com.l2jserver.service.database.sql.MySQLDatabaseEngine
|
||||
</engine>
|
||||
|
||||
<!-- The username used to login into the database. NOTE: Try not use
|
||||
"root" in production servers for security reasons. -->
|
||||
<username>l2j</username>
|
||||
|
||||
<!-- The password used to login into the database. -->
|
||||
<password>changeme</password>
|
||||
</jdbc>
|
||||
|
||||
<connections>
|
||||
<!-- The maximum number of active connections -->
|
||||
<active-maximum>20</active-maximum>
|
||||
<!-- The maximum number of idle connections -->
|
||||
<idle-maximum>20</idle-maximum>
|
||||
<!-- The minimum number of idle connections -->
|
||||
<idle-minimum>5</idle-minimum>
|
||||
</connections>
|
||||
</database>
|
||||
|
||||
<!-- Parameters in this section are used by NetworkService. If you are
|
||||
not sure on the usage of any parameter, read the "Configuration" section
|
||||
in wiki article about NetworkService. -->
|
||||
<network>
|
||||
<!-- The address and port in which the server will listen to -->
|
||||
<listen>0.0.0.0:7777</listen>
|
||||
</network>
|
||||
|
||||
<!-- Parameters in this section are used by VFSService. If you are not
|
||||
sure on the usage of any parameter, read the "Configuration" section in wiki
|
||||
article about VFSService. -->
|
||||
<vfs>
|
||||
<!-- The root of the filesystem -->
|
||||
<root></root>
|
||||
|
||||
<!-- The data folder. Relative to the root. Can be a ZIP file. -->
|
||||
<data>data.zip</data>
|
||||
</vfs>
|
||||
|
||||
<!-- Parameters in this section are used by VFSService. If you are not
|
||||
sure on the usage of any parameter, read the "Configuration" section in wiki
|
||||
article about VFSService. -->
|
||||
<template>
|
||||
<!-- The directory in which templates are stored. Relative to "vfs.data" -->
|
||||
<directory>template/</directory>
|
||||
</template>
|
||||
</services>
|
||||
<!-- /Services configuration section -->
|
||||
</configuration>
|
||||
114
l2jserver2-gameserver/distribution/services.xml
Normal file
114
l2jserver2-gameserver/distribution/services.xml
Normal file
@@ -0,0 +1,114 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<!-- DAO Module configuration -->
|
||||
<dao module="com.l2jserver.service.database.JDBCDAOModule" />
|
||||
|
||||
<!-- OrientDB database service -->
|
||||
<service interface="com.l2jserver.service.database.DatabaseService"
|
||||
implementation="com.l2jserver.service.database.GameServerOrientDatabaseService">
|
||||
<!-- Whether the database schema should be updated at startup -->
|
||||
<!-- Slows down a bit at start time, but guarantees consistency -->
|
||||
<!-- Recommended to only be enabled after an server update -->
|
||||
<schema automaticUpdate="true" />
|
||||
<!-- The connection URL defines where the database data is stored -->
|
||||
<connection url="local:data/database">
|
||||
<!-- Database authentication. Should not be touched unless you know what
|
||||
you are doing! -->
|
||||
<authentication username="admin" password="admin" />
|
||||
</connection>
|
||||
</service>
|
||||
|
||||
<!-- Virtual file system service -->
|
||||
<service interface="com.l2jserver.service.core.vfs.VFSService"
|
||||
implementation="com.l2jserver.service.core.vfs.TrueZipVFSService">
|
||||
<!-- Configures the root of the server data. Where all the files are placed. -->
|
||||
<fileSystem root="./">
|
||||
<!-- The "data file system" location. There, templates, static data and
|
||||
several other important files are located. This can be a zip or a directory. -->
|
||||
<!-- The "data file system" is relative to the file system root. -->
|
||||
<data root="data.zip" />
|
||||
</fileSystem>
|
||||
</service>
|
||||
|
||||
<!-- Template service configuration -->
|
||||
<service interface="com.l2jserver.service.game.template.TemplateService"
|
||||
implementation="com.l2jserver.service.game.template.XMLTemplateService">
|
||||
<!-- The root where template data is located. Relative to the "data file
|
||||
system" -->
|
||||
<templates root="template/" />
|
||||
</service>
|
||||
|
||||
<!-- Network service -->
|
||||
<service interface="com.l2jserver.service.network.NetworkService"
|
||||
implementation="com.l2jserver.service.network.NettyNetworkService">
|
||||
<!-- The port in which the server should listen for incoming connections -->
|
||||
<!-- NOTE: this port must be open manually on any firewall or router that
|
||||
is between you and other players. If you wish to play on the same machine
|
||||
you normally don't need to change anything here nor in the firewall. -->
|
||||
<server listen="0.0.0.0:7777" />
|
||||
</service>
|
||||
|
||||
<!-- ###################################################################### -->
|
||||
<!-- ########################### CORE SERVICES ############################ -->
|
||||
<!-- ###################################################################### -->
|
||||
<!-- Those services provide basic core features and are required for server
|
||||
startup process -->
|
||||
<service interface="com.l2jserver.service.core.LoggingService"
|
||||
implementation="com.l2jserver.service.core.Log4JLoggingService" />
|
||||
<service interface="com.l2jserver.service.core.threading.ThreadService"
|
||||
implementation="com.l2jserver.service.core.threading.ThreadServiceImpl" />
|
||||
<service interface="com.l2jserver.service.configuration.ConfigurationService"
|
||||
implementation="com.l2jserver.service.configuration.XMLConfigurationService" />
|
||||
<service interface="com.l2jserver.service.cache.CacheService"
|
||||
implementation="com.l2jserver.service.cache.SoftCacheService" />
|
||||
|
||||
|
||||
<!-- ###################################################################### -->
|
||||
<!-- ########################### GAME SERVICES ############################ -->
|
||||
<!-- ###################################################################### -->
|
||||
<!-- Those services provide all the in-game features and most of them are
|
||||
required for players to be able to login in the server -->
|
||||
<service interface="com.l2jserver.service.game.world.WorldIDService"
|
||||
implementation="com.l2jserver.service.game.world.CachedWorldIDService" />
|
||||
<service interface="com.l2jserver.service.game.map.pathing.PathingService"
|
||||
implementation="com.l2jserver.service.game.map.pathing.MapperPathingService" />
|
||||
<service interface="com.l2jserver.service.game.scripting.ScriptingService"
|
||||
implementation="com.l2jserver.service.game.scripting.ScriptingServiceImpl" />
|
||||
<service interface="com.l2jserver.service.game.chat.ChatService"
|
||||
implementation="com.l2jserver.service.game.chat.SimpleChatService" />
|
||||
<service interface="com.l2jserver.service.game.chat.ChatLoggingService"
|
||||
implementation="com.l2jserver.service.game.chat.DatabaseChatLoggingService" />
|
||||
<service interface="com.l2jserver.service.game.admin.AdministratorService"
|
||||
implementation="com.l2jserver.service.game.admin.AdministratorServiceImpl" />
|
||||
<service interface="com.l2jserver.service.game.spawn.SpawnService"
|
||||
implementation="com.l2jserver.service.game.spawn.SpawnServiceImpl" />
|
||||
<service interface="com.l2jserver.service.game.character.CharacterService"
|
||||
implementation="com.l2jserver.service.game.character.CharacterServiceImpl" />
|
||||
<service interface="com.l2jserver.service.game.character.ShortcutService"
|
||||
implementation="com.l2jserver.service.game.character.ShortcutServiceImpl" />
|
||||
<service interface="com.l2jserver.service.game.AttackService"
|
||||
implementation="com.l2jserver.service.game.AttackServiceImpl" />
|
||||
<service interface="com.l2jserver.service.game.npc.NPCService"
|
||||
implementation="com.l2jserver.service.game.npc.NPCServiceImpl" />
|
||||
<service interface="com.l2jserver.service.game.item.ItemService"
|
||||
implementation="com.l2jserver.service.game.item.ItemServiceImpl" />
|
||||
<service interface="com.l2jserver.service.game.world.WorldService"
|
||||
implementation="com.l2jserver.service.game.world.WorldServiceImpl" />
|
||||
<service interface="com.l2jserver.service.game.world.event.WorldEventDispatcher"
|
||||
implementation="com.l2jserver.service.game.world.event.WorldEventDispatcherImpl" />
|
||||
|
||||
|
||||
<!-- ####################################################################### -->
|
||||
<!-- ########################## NETWORK SERVICES ########################### -->
|
||||
<!-- ####################################################################### -->
|
||||
<!-- Those services all network related services that will communicate the
|
||||
server software to the player computer running the game client. Although
|
||||
not required, without them, becomes impossible to connect to the server in
|
||||
order to play the game. -->
|
||||
<service interface="com.l2jserver.service.network.keygen.BlowfishKeygenService"
|
||||
implementation="com.l2jserver.service.network.keygen.SecureBlowfishKeygenService" />
|
||||
<service interface="com.l2jserver.service.network.gameguard.GameGuardService"
|
||||
implementation="com.l2jserver.service.network.gameguard.GameGuardServiceImpl" />
|
||||
<service interface="com.l2jserver.service.network.broadcast.BroadcastService"
|
||||
implementation="com.l2jserver.service.network.broadcast.BroadcastServiceImpl" />
|
||||
</services>
|
||||
125
l2jserver2-gameserver/services-sample.xml
Normal file
125
l2jserver2-gameserver/services-sample.xml
Normal file
@@ -0,0 +1,125 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<!-- This file should be renamed as "services.xml" and configured according
|
||||
to your needs. Since "services.xml" has been added to ".gitignore", this
|
||||
means that your password won't be sent to the repository when you make a
|
||||
commit. -->
|
||||
<!-- IMPORTANT NOTE: Do not forget to edit "distribution/services.xml" with
|
||||
new services definitions. Only that file is included in the server's binary
|
||||
distributions -->
|
||||
<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<!-- DAO Module configuration -->
|
||||
<dao module="com.l2jserver.service.database.JDBCDAOModule" />
|
||||
|
||||
<!-- JDBC database service -->
|
||||
<service interface="com.l2jserver.service.database.DatabaseService"
|
||||
implementation="com.l2jserver.service.database.GameServerJDBCDatabaseService">
|
||||
<!-- Whether the database schema should be updated at startup -->
|
||||
<!-- Slows down a bit at start time, but guarantees consistency -->
|
||||
<!-- Enabled for development servers -->
|
||||
<schema automaticUpdate="true" />
|
||||
<!-- Defines the JDBC connection URL -->
|
||||
<connection url="jdbc:mysql://localhost/l2jserver2">
|
||||
<!-- The database authentication (username and password) -->
|
||||
<authentication username="l2jserver2" password="changeme" />
|
||||
<!-- Specifies the database engine to use - will load JDBC driver and
|
||||
SQL templates -->
|
||||
<engine class="com.l2jserver.service.database.sql.MySQLDatabaseEngine" />
|
||||
<!-- Defines the database connection pool limits -->
|
||||
<pool max-active="20" max-idle="20" min-idle="5" />
|
||||
</connection>
|
||||
</service>
|
||||
|
||||
<!-- Virtual file system service -->
|
||||
<service interface="com.l2jserver.service.core.vfs.VFSService"
|
||||
implementation="com.l2jserver.service.core.vfs.TrueZipVFSService">
|
||||
<!-- Configures the root of the server data. Where all the files are placed. -->
|
||||
<fileSystem root="./">
|
||||
<!-- The "data file system" location. There, templates, static data and
|
||||
several other important files are located. This can be a zip or a directory. -->
|
||||
<!-- The "data file system" is relative to the file system root. -->
|
||||
<data root="data/" />
|
||||
</fileSystem>
|
||||
</service>
|
||||
|
||||
<!-- Template service configuration -->
|
||||
<service interface="com.l2jserver.service.game.template.TemplateService"
|
||||
implementation="com.l2jserver.service.game.template.XMLTemplateService">
|
||||
<!-- The root where template data is located. Relative to the "data file
|
||||
system" -->
|
||||
<templates root="template/" />
|
||||
</service>
|
||||
|
||||
<!-- Network service -->
|
||||
<service interface="com.l2jserver.service.network.NetworkService"
|
||||
implementation="com.l2jserver.service.network.NettyNetworkService">
|
||||
<!-- The port in which the server should listen for incoming connections -->
|
||||
<!-- NOTE: this port must be open manually on any firewall or router that
|
||||
is between you and other players. If you wish to play on the same machine
|
||||
you normally don't need to change anything here nor in the firewall. -->
|
||||
<server listen="0.0.0.0:7777" />
|
||||
</service>
|
||||
|
||||
<!-- ###################################################################### -->
|
||||
<!-- ########################### CORE SERVICES ############################ -->
|
||||
<!-- ###################################################################### -->
|
||||
<!-- Those services provide basic core features and are required for server
|
||||
startup process -->
|
||||
<service interface="com.l2jserver.service.core.LoggingService"
|
||||
implementation="com.l2jserver.service.core.Log4JLoggingService" />
|
||||
<service interface="com.l2jserver.service.core.threading.ThreadService"
|
||||
implementation="com.l2jserver.service.core.threading.ThreadServiceImpl" />
|
||||
<service interface="com.l2jserver.service.configuration.ConfigurationService"
|
||||
implementation="com.l2jserver.service.configuration.XMLConfigurationService" />
|
||||
<service interface="com.l2jserver.service.cache.CacheService"
|
||||
implementation="com.l2jserver.service.cache.SoftCacheService" />
|
||||
|
||||
|
||||
<!-- ###################################################################### -->
|
||||
<!-- ########################### GAME SERVICES ############################ -->
|
||||
<!-- ###################################################################### -->
|
||||
<!-- Those services provide all the in-game features and most of them are
|
||||
required for players to be able to login in the server -->
|
||||
<service interface="com.l2jserver.service.game.world.WorldIDService"
|
||||
implementation="com.l2jserver.service.game.world.CachedWorldIDService" />
|
||||
<service interface="com.l2jserver.service.game.map.pathing.PathingService"
|
||||
implementation="com.l2jserver.service.game.map.pathing.MapperPathingService" />
|
||||
<service interface="com.l2jserver.service.game.scripting.ScriptingService"
|
||||
implementation="com.l2jserver.service.game.scripting.ScriptingServiceImpl" />
|
||||
<service interface="com.l2jserver.service.game.chat.ChatService"
|
||||
implementation="com.l2jserver.service.game.chat.SimpleChatService" />
|
||||
<service interface="com.l2jserver.service.game.chat.ChatLoggingService"
|
||||
implementation="com.l2jserver.service.game.chat.DatabaseChatLoggingService" />
|
||||
<service interface="com.l2jserver.service.game.admin.AdministratorService"
|
||||
implementation="com.l2jserver.service.game.admin.AdministratorServiceImpl" />
|
||||
<service interface="com.l2jserver.service.game.spawn.SpawnService"
|
||||
implementation="com.l2jserver.service.game.spawn.SpawnServiceImpl" />
|
||||
<service interface="com.l2jserver.service.game.character.CharacterService"
|
||||
implementation="com.l2jserver.service.game.character.CharacterServiceImpl" />
|
||||
<service interface="com.l2jserver.service.game.character.ShortcutService"
|
||||
implementation="com.l2jserver.service.game.character.ShortcutServiceImpl" />
|
||||
<service interface="com.l2jserver.service.game.AttackService"
|
||||
implementation="com.l2jserver.service.game.AttackServiceImpl" />
|
||||
<service interface="com.l2jserver.service.game.npc.NPCService"
|
||||
implementation="com.l2jserver.service.game.npc.NPCServiceImpl" />
|
||||
<service interface="com.l2jserver.service.game.item.ItemService"
|
||||
implementation="com.l2jserver.service.game.item.ItemServiceImpl" />
|
||||
<service interface="com.l2jserver.service.game.world.WorldService"
|
||||
implementation="com.l2jserver.service.game.world.WorldServiceImpl" />
|
||||
<service interface="com.l2jserver.service.game.world.event.WorldEventDispatcher"
|
||||
implementation="com.l2jserver.service.game.world.event.WorldEventDispatcherImpl" />
|
||||
|
||||
|
||||
<!-- ####################################################################### -->
|
||||
<!-- ########################## NETWORK SERVICES ########################### -->
|
||||
<!-- ####################################################################### -->
|
||||
<!-- Those services all network related services that will communicate the
|
||||
server software to the player computer running the game client. Although
|
||||
not required, without them, becomes impossible to connect to the server in
|
||||
order to play the game. -->
|
||||
<service interface="com.l2jserver.service.network.keygen.BlowfishKeygenService"
|
||||
implementation="com.l2jserver.service.network.keygen.SecureBlowfishKeygenService" />
|
||||
<service interface="com.l2jserver.service.network.gameguard.GameGuardService"
|
||||
implementation="com.l2jserver.service.network.gameguard.GameGuardServiceImpl" />
|
||||
<service interface="com.l2jserver.service.network.broadcast.BroadcastService"
|
||||
implementation="com.l2jserver.service.network.broadcast.BroadcastServiceImpl" />
|
||||
</services>
|
||||
@@ -9,7 +9,7 @@
|
||||
<baseDirectory></baseDirectory>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<directory>${project.basedir}/distribution/global</directory>
|
||||
<directory>${project.basedir}/distribution</directory>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<baseDirectory></baseDirectory>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<directory>${project.basedir}/distribution/global</directory>
|
||||
<directory>${project.basedir}/distribution</directory>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<baseDirectory></baseDirectory>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<directory>${project.basedir}/distribution/global</directory>
|
||||
<directory>${project.basedir}/distribution</directory>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<baseDirectory></baseDirectory>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<directory>${project.basedir}/distribution/global</directory>
|
||||
<directory>${project.basedir}/distribution</directory>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
|
||||
@@ -16,8 +16,20 @@
|
||||
*/
|
||||
package com.l2jserver;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.l2jserver.model.id.provider.IDProviderModule;
|
||||
import com.l2jserver.service.Service;
|
||||
import com.l2jserver.service.ServiceException;
|
||||
import com.l2jserver.service.ServiceManager;
|
||||
import com.l2jserver.service.ServiceStartException;
|
||||
import com.l2jserver.service.ServiceStopException;
|
||||
import com.l2jserver.service.cache.CacheService;
|
||||
import com.l2jserver.service.configuration.ConfigurationService;
|
||||
@@ -65,17 +77,38 @@ public class L2JGameServerMain {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void main(String[] args) {
|
||||
final L2JGameServer server = new L2JGameServer();
|
||||
final ServiceManager serviceManager = new ServiceManager();
|
||||
try {
|
||||
final ServiceManager serviceManager = server.getInjector()
|
||||
.getInstance(ServiceManager.class);
|
||||
serviceManager.load(Paths.get("services.xml"));
|
||||
} catch (ClassNotFoundException e) {
|
||||
System.out.println("Service class not found: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
return;
|
||||
} catch (SAXException | DOMException | IOException
|
||||
| ParserConfigurationException e) {
|
||||
System.out.println("Error parsing XML service descriptor");
|
||||
e.printStackTrace();
|
||||
return;
|
||||
} catch (ServiceException e) {
|
||||
System.out.println("Error loading XML service descriptor");
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
serviceManager.init(Guice.createInjector(new IDProviderModule(),
|
||||
serviceManager.newGuiceModule()));
|
||||
} catch (ServiceStartException e) {
|
||||
System.out.println("Error stating basic services");
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
for (final Class<?>[] category : SERVICES) {
|
||||
for (final Class<?> service : category) {
|
||||
serviceManager.start((Class<? extends Service>) service);
|
||||
}
|
||||
}
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
/*
|
||||
* This file is part of l2jserver2 <l2jserver2.com>.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Scopes;
|
||||
import com.l2jserver.service.cache.CacheService;
|
||||
import com.l2jserver.service.cache.SoftCacheService;
|
||||
import com.l2jserver.service.configuration.ConfigurationService;
|
||||
import com.l2jserver.service.configuration.XMLConfigurationService;
|
||||
import com.l2jserver.service.core.Log4JLoggingService;
|
||||
import com.l2jserver.service.core.LoggingService;
|
||||
import com.l2jserver.service.core.threading.ThreadService;
|
||||
import com.l2jserver.service.core.threading.ThreadServiceImpl;
|
||||
import com.l2jserver.service.core.vfs.TrueZipVFSService;
|
||||
import com.l2jserver.service.core.vfs.VFSService;
|
||||
import com.l2jserver.service.database.DatabaseService;
|
||||
import com.l2jserver.service.database.GameServerOrientDatabaseService;
|
||||
import com.l2jserver.service.game.AttackService;
|
||||
import com.l2jserver.service.game.AttackServiceImpl;
|
||||
import com.l2jserver.service.game.admin.AdministratorService;
|
||||
import com.l2jserver.service.game.admin.AdministratorServiceImpl;
|
||||
import com.l2jserver.service.game.character.CharacterService;
|
||||
import com.l2jserver.service.game.character.CharacterServiceImpl;
|
||||
import com.l2jserver.service.game.character.ShortcutService;
|
||||
import com.l2jserver.service.game.character.ShortcutServiceImpl;
|
||||
import com.l2jserver.service.game.chat.ChatLoggingService;
|
||||
import com.l2jserver.service.game.chat.ChatService;
|
||||
import com.l2jserver.service.game.chat.DatabaseChatLoggingService;
|
||||
import com.l2jserver.service.game.chat.SimpleChatService;
|
||||
import com.l2jserver.service.game.item.ItemService;
|
||||
import com.l2jserver.service.game.item.ItemServiceImpl;
|
||||
import com.l2jserver.service.game.map.pathing.MapperPathingService;
|
||||
import com.l2jserver.service.game.map.pathing.PathingService;
|
||||
import com.l2jserver.service.game.npc.NPCService;
|
||||
import com.l2jserver.service.game.npc.NPCServiceImpl;
|
||||
import com.l2jserver.service.game.scripting.ScriptingService;
|
||||
import com.l2jserver.service.game.scripting.ScriptingServiceImpl;
|
||||
import com.l2jserver.service.game.spawn.SpawnService;
|
||||
import com.l2jserver.service.game.spawn.SpawnServiceImpl;
|
||||
import com.l2jserver.service.game.template.TemplateService;
|
||||
import com.l2jserver.service.game.template.XMLTemplateService;
|
||||
import com.l2jserver.service.game.world.CachedWorldIDService;
|
||||
import com.l2jserver.service.game.world.WorldIDService;
|
||||
import com.l2jserver.service.game.world.WorldService;
|
||||
import com.l2jserver.service.game.world.WorldServiceImpl;
|
||||
import com.l2jserver.service.game.world.event.WorldEventDispatcher;
|
||||
import com.l2jserver.service.game.world.event.WorldEventDispatcherImpl;
|
||||
import com.l2jserver.service.network.NettyNetworkService;
|
||||
import com.l2jserver.service.network.NetworkService;
|
||||
import com.l2jserver.service.network.broadcast.BroadcastService;
|
||||
import com.l2jserver.service.network.broadcast.BroadcastServiceImpl;
|
||||
import com.l2jserver.service.network.gameguard.GameGuardService;
|
||||
import com.l2jserver.service.network.gameguard.GameGuardServiceImpl;
|
||||
import com.l2jserver.service.network.keygen.BlowfishKeygenService;
|
||||
import com.l2jserver.service.network.keygen.SecureBlowfishKeygenService;
|
||||
|
||||
/**
|
||||
* Google Guice {@link Module} for services
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class ServiceModule extends AbstractModule {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(ServiceManager.class).in(Scopes.SINGLETON);
|
||||
bind(LoggingService.class).to(Log4JLoggingService.class).in(
|
||||
Scopes.SINGLETON);
|
||||
bind(VFSService.class).to(TrueZipVFSService.class).in(Scopes.SINGLETON);
|
||||
bind(ThreadService.class).to(ThreadServiceImpl.class).in(
|
||||
Scopes.SINGLETON);
|
||||
bind(ConfigurationService.class).to(XMLConfigurationService.class).in(
|
||||
Scopes.SINGLETON);
|
||||
bind(CacheService.class).to(SoftCacheService.class)
|
||||
.in(Scopes.SINGLETON);
|
||||
|
||||
bind(DatabaseService.class).to(GameServerOrientDatabaseService.class)
|
||||
.in(Scopes.SINGLETON);
|
||||
bind(WorldIDService.class).to(CachedWorldIDService.class).in(
|
||||
Scopes.SINGLETON);
|
||||
|
||||
bind(PathingService.class).to(MapperPathingService.class).in(
|
||||
Scopes.SINGLETON);
|
||||
|
||||
bind(BlowfishKeygenService.class).to(SecureBlowfishKeygenService.class)
|
||||
.in(Scopes.SINGLETON);
|
||||
bind(NetworkService.class).to(NettyNetworkService.class).in(
|
||||
Scopes.SINGLETON);
|
||||
bind(GameGuardService.class).to(GameGuardServiceImpl.class).in(
|
||||
Scopes.SINGLETON);
|
||||
bind(ScriptingService.class).to(ScriptingServiceImpl.class).in(
|
||||
Scopes.SINGLETON);
|
||||
bind(TemplateService.class).to(XMLTemplateService.class).in(
|
||||
Scopes.SINGLETON);
|
||||
|
||||
bind(ChatService.class).to(SimpleChatService.class)
|
||||
.in(Scopes.SINGLETON);
|
||||
bind(ChatLoggingService.class).to(DatabaseChatLoggingService.class).in(
|
||||
Scopes.SINGLETON);
|
||||
bind(AdministratorService.class).to(AdministratorServiceImpl.class).in(
|
||||
Scopes.SINGLETON);
|
||||
bind(SpawnService.class).to(SpawnServiceImpl.class)
|
||||
.in(Scopes.SINGLETON);
|
||||
bind(BroadcastService.class).to(BroadcastServiceImpl.class).in(
|
||||
Scopes.SINGLETON);
|
||||
|
||||
bind(CharacterService.class).to(CharacterServiceImpl.class).in(
|
||||
Scopes.SINGLETON);
|
||||
bind(ShortcutService.class).to(ShortcutServiceImpl.class).in(
|
||||
Scopes.SINGLETON);
|
||||
|
||||
bind(AttackService.class).to(AttackServiceImpl.class).in(
|
||||
Scopes.SINGLETON);
|
||||
bind(NPCService.class).to(NPCServiceImpl.class).in(Scopes.SINGLETON);
|
||||
bind(ItemService.class).to(ItemServiceImpl.class).in(Scopes.SINGLETON);
|
||||
|
||||
bind(WorldService.class).to(WorldServiceImpl.class)
|
||||
.in(Scopes.SINGLETON);
|
||||
bind(WorldEventDispatcher.class).to(WorldEventDispatcherImpl.class).in(
|
||||
Scopes.SINGLETON);
|
||||
}
|
||||
}
|
||||
@@ -76,8 +76,6 @@ import com.mysema.query.sql.types.EnumByNameType;
|
||||
public class GameServerJDBCDatabaseService extends AbstractSQLDatabaseService
|
||||
implements DatabaseService {
|
||||
/**
|
||||
* @param configService
|
||||
* the config service
|
||||
* @param cacheService
|
||||
* the cache service
|
||||
* @param threadService
|
||||
@@ -88,11 +86,10 @@ public class GameServerJDBCDatabaseService extends AbstractSQLDatabaseService
|
||||
* the {@link DataAccessObject DAO} resolver
|
||||
*/
|
||||
@Inject
|
||||
public GameServerJDBCDatabaseService(ConfigurationService configService,
|
||||
CacheService cacheService, ThreadService threadService,
|
||||
VFSService vfsService, DAOResolver daoResolver) {
|
||||
public GameServerJDBCDatabaseService(CacheService cacheService,
|
||||
ThreadService threadService, VFSService vfsService,
|
||||
DAOResolver daoResolver) {
|
||||
super(
|
||||
configService,
|
||||
cacheService,
|
||||
threadService,
|
||||
vfsService,
|
||||
@@ -120,7 +117,8 @@ public class GameServerJDBCDatabaseService extends AbstractSQLDatabaseService
|
||||
updateSchema(QLogChat.logChat);
|
||||
if (updateSchema(QNPC.npc)) {
|
||||
try {
|
||||
importData(vfsService.resolveDataFile("static/npc.csv"), QNPC.npc);
|
||||
importData(vfsService.resolveDataFile("static/npc.csv"),
|
||||
QNPC.npc);
|
||||
} catch (IOException e) {
|
||||
throw new DatabaseException(e);
|
||||
}
|
||||
|
||||
@@ -70,8 +70,6 @@ public class GameServerOrientDatabaseService extends
|
||||
private final VFSService vfsService;
|
||||
|
||||
/**
|
||||
* @param configService
|
||||
* the config service
|
||||
* @param cacheService
|
||||
* the cache service
|
||||
* @param threadService
|
||||
@@ -82,10 +80,10 @@ public class GameServerOrientDatabaseService extends
|
||||
* the {@link DataAccessObject DAO} resolver
|
||||
*/
|
||||
@Inject
|
||||
public GameServerOrientDatabaseService(ConfigurationService configService,
|
||||
CacheService cacheService, ThreadService threadService,
|
||||
final VFSService vfsService, DAOResolver daoResolver) {
|
||||
super(configService, cacheService, threadService, daoResolver);
|
||||
public GameServerOrientDatabaseService(CacheService cacheService,
|
||||
ThreadService threadService, final VFSService vfsService,
|
||||
DAOResolver daoResolver) {
|
||||
super(cacheService, threadService, daoResolver);
|
||||
this.vfsService = vfsService;
|
||||
}
|
||||
|
||||
@@ -100,7 +98,8 @@ public class GameServerOrientDatabaseService extends
|
||||
updateSchema(QLogChat.logChat);
|
||||
if (updateSchema(QNPC.npc)) {
|
||||
try {
|
||||
importData(vfsService.resolveDataFile("static/npc.csv"), QNPC.npc);
|
||||
importData(vfsService.resolveDataFile("static/npc.csv"),
|
||||
QNPC.npc);
|
||||
} catch (IOException e) {
|
||||
throw new DatabaseException(e);
|
||||
}
|
||||
|
||||
@@ -47,14 +47,13 @@ import com.l2jserver.model.template.character.CharacterTemplate;
|
||||
import com.l2jserver.model.template.item.ItemTemplate;
|
||||
import com.l2jserver.model.template.npc.NPCTemplate;
|
||||
import com.l2jserver.model.template.npc.TeleportationTemplate;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
import com.l2jserver.service.AbstractConfigurableService;
|
||||
import com.l2jserver.service.AbstractService.Depends;
|
||||
import com.l2jserver.service.ServiceStartException;
|
||||
import com.l2jserver.service.ServiceStopException;
|
||||
import com.l2jserver.service.cache.Cache;
|
||||
import com.l2jserver.service.cache.CacheService;
|
||||
import com.l2jserver.service.configuration.ConfigurationService;
|
||||
import com.l2jserver.service.configuration.XMLConfigurationService.ConfigurationXPath;
|
||||
import com.l2jserver.service.core.LoggingService;
|
||||
import com.l2jserver.service.core.vfs.VFSService;
|
||||
import com.l2jserver.util.jaxb.CharacterTemplateIDAdapter;
|
||||
@@ -72,7 +71,8 @@ import com.l2jserver.util.jaxb.TeleportationTemplateIDAdapter;
|
||||
*/
|
||||
@Depends({ LoggingService.class, VFSService.class, CacheService.class,
|
||||
ConfigurationService.class })
|
||||
public class XMLTemplateService extends AbstractService implements
|
||||
public class XMLTemplateService extends
|
||||
AbstractConfigurableService<XMLTemplateServiceConfiguration> implements
|
||||
TemplateService {
|
||||
/**
|
||||
* The logger
|
||||
@@ -88,10 +88,6 @@ public class XMLTemplateService extends AbstractService implements
|
||||
*/
|
||||
private final CacheService cacheService;
|
||||
|
||||
/**
|
||||
* The XML template service configuration
|
||||
*/
|
||||
private final XMLTemplateServiceConfiguration config;
|
||||
/**
|
||||
* The npc template id adapter
|
||||
*/
|
||||
@@ -132,36 +128,11 @@ public class XMLTemplateService extends AbstractService implements
|
||||
@SuppressWarnings("rawtypes")
|
||||
private Cache<TemplateID, Template> templates;
|
||||
|
||||
/**
|
||||
* XML {@link TemplateService} configuration interface
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface XMLTemplateServiceConfiguration extends
|
||||
TemplateServiceConfiguration {
|
||||
/**
|
||||
* @return the directory in which templates are stored
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "template/")
|
||||
@ConfigurationXPath("/configuration/services/template/directory")
|
||||
String getTemplateDirectory();
|
||||
|
||||
/**
|
||||
* @param file
|
||||
* the directory in which templates are stored
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("/configuration/services/template/directory")
|
||||
void setTemplateDirectory(String file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vfsService
|
||||
* the vfs service
|
||||
* @param cacheService
|
||||
* the cache service
|
||||
* @param configService
|
||||
* the configuration service
|
||||
* the cache servicef
|
||||
* @param npcTemplateIdAdapter
|
||||
* the npc template id adapter
|
||||
* @param itemTemplateIdAdapter
|
||||
@@ -177,16 +148,16 @@ public class XMLTemplateService extends AbstractService implements
|
||||
*/
|
||||
@Inject
|
||||
public XMLTemplateService(final VFSService vfsService,
|
||||
CacheService cacheService, ConfigurationService configService,
|
||||
CacheService cacheService,
|
||||
NPCTemplateIDAdapter npcTemplateIdAdapter,
|
||||
ItemTemplateIDAdapter itemTemplateIdAdapter,
|
||||
SkillTemplateIDAdapter skillTemplateIdAdapter,
|
||||
CharacterTemplateIDAdapter charIdTemplateAdapter,
|
||||
EffectTemplateIDAdapter effectIdTemplateAdapter,
|
||||
TeleportationTemplateIDAdapter teleportationIdTemplateAdapter) {
|
||||
super(XMLTemplateServiceConfiguration.class);
|
||||
this.vfsService = vfsService;
|
||||
this.cacheService = cacheService;
|
||||
this.config = configService.get(XMLTemplateServiceConfiguration.class);
|
||||
this.npcTemplateIdAdapter = npcTemplateIdAdapter;
|
||||
this.itemTemplateIdAdapter = itemTemplateIdAdapter;
|
||||
this.skillTemplateIdAdapter = skillTemplateIdAdapter;
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* This file is part of l2jserver2 <l2jserver2.com>.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.game.template;
|
||||
|
||||
import com.l2jserver.service.configuration.XMLConfigurationService.ConfigurationXPath;
|
||||
import com.l2jserver.service.game.template.TemplateService.TemplateServiceConfiguration;
|
||||
|
||||
/**
|
||||
* XML {@link TemplateService} configuration interface
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface XMLTemplateServiceConfiguration extends
|
||||
TemplateServiceConfiguration {
|
||||
/**
|
||||
* @return the directory in which templates are stored
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "template/")
|
||||
@ConfigurationXPath("templates/@root")
|
||||
String getTemplateDirectory();
|
||||
|
||||
/**
|
||||
* @param file
|
||||
* the directory in which templates are stored
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("templates/@root")
|
||||
void setTemplateDirectory(String file);
|
||||
}
|
||||
@@ -39,9 +39,8 @@ import com.l2jserver.game.net.Lineage2Client;
|
||||
import com.l2jserver.game.net.Lineage2PipelineFactory;
|
||||
import com.l2jserver.game.net.packet.ServerPacket;
|
||||
import com.l2jserver.model.id.object.CharacterID;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
import com.l2jserver.service.AbstractConfigurableService;
|
||||
import com.l2jserver.service.AbstractService.Depends;
|
||||
import com.l2jserver.service.configuration.ConfigurationService;
|
||||
import com.l2jserver.service.core.LoggingService;
|
||||
import com.l2jserver.service.core.threading.ThreadPool;
|
||||
import com.l2jserver.service.core.threading.ThreadPoolPriority;
|
||||
@@ -58,7 +57,8 @@ import com.l2jserver.util.factory.CollectionFactory;
|
||||
*/
|
||||
@Depends({ LoggingService.class, ThreadService.class,
|
||||
BlowfishKeygenService.class, WorldService.class })
|
||||
public class NettyNetworkService extends AbstractService implements
|
||||
public class NettyNetworkService extends
|
||||
AbstractConfigurableService<NetworkServiceConfiguration> implements
|
||||
NetworkService {
|
||||
/**
|
||||
* The logger
|
||||
@@ -70,10 +70,6 @@ public class NettyNetworkService extends AbstractService implements
|
||||
*/
|
||||
private final ThreadService threadService;
|
||||
|
||||
/**
|
||||
* The network configuration object
|
||||
*/
|
||||
private final NetworkConfiguration config;
|
||||
/**
|
||||
* The Google Guice {@link Injector}
|
||||
*/
|
||||
@@ -101,18 +97,15 @@ public class NettyNetworkService extends AbstractService implements
|
||||
private Set<Lineage2Client> clients = CollectionFactory.newSet();
|
||||
|
||||
/**
|
||||
* @param configService
|
||||
* the configuration service
|
||||
* @param injector
|
||||
* the {@link Guice} {@link Injector}
|
||||
* @param threadService
|
||||
* the {@link ThreadService}
|
||||
*/
|
||||
@Inject
|
||||
public NettyNetworkService(ConfigurationService configService,
|
||||
Injector injector, ThreadService threadService) {
|
||||
public NettyNetworkService(Injector injector, ThreadService threadService) {
|
||||
super(NetworkServiceConfiguration.class);
|
||||
this.threadService = threadService;
|
||||
this.config = configService.get(NetworkConfiguration.class);
|
||||
this.injector = injector;
|
||||
InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory());
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package com.l2jserver.service.network;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import com.l2jserver.game.net.Lineage2Client;
|
||||
import com.l2jserver.game.net.Lineage2Session;
|
||||
@@ -25,9 +24,6 @@ import com.l2jserver.game.net.packet.ServerPacket;
|
||||
import com.l2jserver.model.id.object.CharacterID;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.service.Service;
|
||||
import com.l2jserver.service.ServiceConfiguration;
|
||||
import com.l2jserver.service.configuration.Configuration;
|
||||
import com.l2jserver.service.configuration.XMLConfigurationService.ConfigurationXPath;
|
||||
|
||||
/**
|
||||
* The network service is responsible for communicating the server with the game
|
||||
@@ -66,32 +62,6 @@ import com.l2jserver.service.configuration.XMLConfigurationService.Configuration
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface NetworkService extends Service {
|
||||
/**
|
||||
* The network {@link Configuration}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface NetworkConfiguration extends ServiceConfiguration {
|
||||
/**
|
||||
* Get the server listen address
|
||||
*
|
||||
* @return the listen address
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "0.0.0.0:7777")
|
||||
@ConfigurationXPath("/configuration/services/network/listen")
|
||||
InetSocketAddress getListenAddress();
|
||||
|
||||
/**
|
||||
* Set the server listen address
|
||||
*
|
||||
* @param addr
|
||||
* the listen address
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("/configuration/services/network/listen")
|
||||
void setListenAddress(InetSocketAddress addr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new client
|
||||
*
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* This file is part of l2jserver2 <l2jserver2.com>.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.network;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import com.l2jserver.service.ServiceConfiguration;
|
||||
import com.l2jserver.service.configuration.Configuration;
|
||||
import com.l2jserver.service.configuration.XMLConfigurationService.ConfigurationXPath;
|
||||
|
||||
/**
|
||||
* The network {@link Configuration}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface NetworkServiceConfiguration extends ServiceConfiguration {
|
||||
/**
|
||||
* Get the server listen address
|
||||
*
|
||||
* @return the listen address
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "0.0.0.0:7777")
|
||||
@ConfigurationXPath("server/@listen")
|
||||
InetSocketAddress getListenAddress();
|
||||
|
||||
/**
|
||||
* Set the server listen address
|
||||
*
|
||||
* @param addr
|
||||
* the listen address
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("server/@listen")
|
||||
void setListenAddress(InetSocketAddress addr);
|
||||
}
|
||||
@@ -23,7 +23,6 @@ import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Stage;
|
||||
import com.l2jserver.GameServerModule;
|
||||
import com.l2jserver.model.dao.CharacterDAO;
|
||||
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
@@ -47,7 +46,7 @@ public class MySQL5CharacterDAOTest {
|
||||
* The {@link Guice} {@link Injector}
|
||||
*/
|
||||
private final Injector injector = Guice.createInjector(Stage.PRODUCTION,
|
||||
new GameServerModule(), new AbstractModule() {
|
||||
new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(CharacterMapper.class);
|
||||
|
||||
@@ -28,7 +28,6 @@ import com.l2jserver.model.id.object.CharacterID;
|
||||
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.service.ServiceManager;
|
||||
import com.l2jserver.service.ServiceModule;
|
||||
import com.l2jserver.service.ServiceStartException;
|
||||
import com.l2jserver.service.database.DatabaseService;
|
||||
import com.l2jserver.service.database.JDBCDAOModule;
|
||||
@@ -44,8 +43,8 @@ public class CharacterIDProviderTest {
|
||||
/**
|
||||
* The {@link Guice} {@link Injector}
|
||||
*/
|
||||
private final Injector injector = Guice.createInjector(new ServiceModule(),
|
||||
new JDBCDAOModule(), new IDProviderModule());
|
||||
private final Injector injector = Guice.createInjector(new JDBCDAOModule(),
|
||||
new IDProviderModule());
|
||||
/**
|
||||
* The character id provider
|
||||
*/
|
||||
@@ -53,6 +52,7 @@ public class CharacterIDProviderTest {
|
||||
|
||||
/**
|
||||
* Prepares the test
|
||||
*
|
||||
* @throws ServiceStartException
|
||||
*/
|
||||
@Before
|
||||
@@ -86,6 +86,7 @@ public class CharacterIDProviderTest {
|
||||
|
||||
/**
|
||||
* Tests DAO aware ids
|
||||
*
|
||||
* @throws ServiceStartException
|
||||
*/
|
||||
@Test
|
||||
|
||||
@@ -25,9 +25,9 @@ import org.junit.Test;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Stage;
|
||||
import com.l2jserver.GameServerModule;
|
||||
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
|
||||
import com.l2jserver.model.id.object.provider.ItemIDProvider;
|
||||
import com.l2jserver.model.id.provider.IDProviderModule;
|
||||
import com.l2jserver.model.world.Item;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.item.ItemDropEvent;
|
||||
@@ -74,7 +74,7 @@ public class WorldEventDispatcherImplTest {
|
||||
@Before
|
||||
public void tearUp() throws ServiceStartException {
|
||||
Injector injector = Guice.createInjector(Stage.PRODUCTION,
|
||||
new GameServerModule());
|
||||
new IDProviderModule());
|
||||
|
||||
injector.getInstance(ServiceManager.class).start(WorldIDService.class);
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ import org.junit.Test;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.l2jserver.GameServerModule;
|
||||
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
|
||||
import com.l2jserver.model.id.provider.IDProviderModule;
|
||||
import com.l2jserver.model.world.Item;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.WorldObject;
|
||||
@@ -36,6 +36,7 @@ import com.l2jserver.service.game.world.filter.impl.InstanceFilter;
|
||||
|
||||
/**
|
||||
* Tests for {@link WorldServiceImpl}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class WorldServiceImplTest {
|
||||
@@ -50,11 +51,12 @@ public class WorldServiceImplTest {
|
||||
|
||||
/**
|
||||
* Preparation for tests
|
||||
*
|
||||
* @throws ServiceStartException
|
||||
*/
|
||||
@Before
|
||||
public void tearUp() throws ServiceStartException {
|
||||
Injector injector = Guice.createInjector(new GameServerModule());
|
||||
Injector injector = Guice.createInjector(new IDProviderModule());
|
||||
|
||||
world = injector.getInstance(ServiceManager.class).start(
|
||||
WorldService.class);
|
||||
|
||||
@@ -53,8 +53,6 @@ import com.l2jserver.service.database.sql.AbstractSQLDatabaseService;
|
||||
public class LoginServerSQLDatabaseService extends AbstractSQLDatabaseService
|
||||
implements DatabaseService {
|
||||
/**
|
||||
* @param configService
|
||||
* the config service
|
||||
* @param cacheService
|
||||
* the cache service
|
||||
* @param threadService
|
||||
@@ -64,11 +62,10 @@ public class LoginServerSQLDatabaseService extends AbstractSQLDatabaseService
|
||||
* @param daoResolver
|
||||
* the {@link DataAccessObject DAO} resolver
|
||||
*/
|
||||
public LoginServerSQLDatabaseService(ConfigurationService configService,
|
||||
CacheService cacheService, ThreadService threadService,
|
||||
VFSService vfsService, DAOResolver daoResolver) {
|
||||
super(configService, cacheService, threadService, vfsService,
|
||||
daoResolver);
|
||||
public LoginServerSQLDatabaseService(CacheService cacheService,
|
||||
ThreadService threadService, VFSService vfsService,
|
||||
DAOResolver daoResolver) {
|
||||
super(cacheService, threadService, vfsService, daoResolver);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
*/
|
||||
package com.l2jserver.service.gameserver;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import com.l2jserver.service.Service;
|
||||
import com.l2jserver.service.ServiceConfiguration;
|
||||
import com.l2jserver.service.configuration.Configuration;
|
||||
import com.l2jserver.service.configuration.XMLConfigurationService.ConfigurationXPath;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
@@ -29,29 +25,4 @@ import com.l2jserver.service.configuration.XMLConfigurationService.Configuration
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface GameServerNetworkService extends Service {
|
||||
/**
|
||||
* The network {@link Configuration}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface NetworkConfiguration extends ServiceConfiguration {
|
||||
/**
|
||||
* Get the server listen address
|
||||
*
|
||||
* @return the listen address
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "0.0.0.0:2104")
|
||||
@ConfigurationXPath("/configuration/services/network/listen")
|
||||
InetSocketAddress getListenAddress();
|
||||
|
||||
/**
|
||||
* Set the server listen address
|
||||
*
|
||||
* @param addr
|
||||
* the listen address
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("/configuration/services/network/listen")
|
||||
void setListenAddress(InetSocketAddress addr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* This file is part of l2jserver2 <l2jserver2.com>.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.gameserver;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import com.l2jserver.service.ServiceConfiguration;
|
||||
import com.l2jserver.service.configuration.Configuration;
|
||||
import com.l2jserver.service.configuration.Configuration.ConfigurationPropertyGetter;
|
||||
import com.l2jserver.service.configuration.Configuration.ConfigurationPropertySetter;
|
||||
import com.l2jserver.service.configuration.XMLConfigurationService.ConfigurationXPath;
|
||||
|
||||
/**
|
||||
* The network {@link Configuration}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface NetworkConfiguration extends ServiceConfiguration {
|
||||
/**
|
||||
* Get the server listen address
|
||||
*
|
||||
* @return the listen address
|
||||
*/
|
||||
@ConfigurationPropertyGetter(defaultValue = "0.0.0.0:2104")
|
||||
@ConfigurationXPath("/configuration/services/network/listen")
|
||||
InetSocketAddress getListenAddress();
|
||||
|
||||
/**
|
||||
* Set the server listen address
|
||||
*
|
||||
* @param addr
|
||||
* the listen address
|
||||
*/
|
||||
@ConfigurationPropertySetter
|
||||
@ConfigurationXPath("/configuration/services/network/listen")
|
||||
void setListenAddress(InetSocketAddress addr);
|
||||
}
|
||||
Reference in New Issue
Block a user