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>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-log4j12</artifactId>
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
<version>1.6.4</version>
|
<version>1.6.4</version>
|
||||||
<scope>test</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<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>
|
* @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
|
* The Java Serialization API serial
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -16,14 +16,29 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.service;
|
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 java.util.Set;
|
||||||
|
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
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.Guice;
|
||||||
import com.google.inject.Inject;
|
|
||||||
import com.google.inject.Injector;
|
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.service.core.LoggingService;
|
||||||
import com.l2jserver.util.ClassUtils;
|
import com.l2jserver.util.ClassUtils;
|
||||||
import com.l2jserver.util.factory.CollectionFactory;
|
import com.l2jserver.util.factory.CollectionFactory;
|
||||||
@@ -37,31 +52,89 @@ public class ServiceManager {
|
|||||||
/**
|
/**
|
||||||
* The logger
|
* The logger
|
||||||
*/
|
*/
|
||||||
private final Logger logger;
|
private Logger logger;
|
||||||
/**
|
/**
|
||||||
* The Guice Injector
|
* 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
|
* List of all known services by this manager
|
||||||
*/
|
*/
|
||||||
private final Set<Service> knownServices = CollectionFactory.newSet();
|
private final Set<Service> knownServices = CollectionFactory.newSet();
|
||||||
|
/**
|
||||||
|
* The service descriptors
|
||||||
|
*/
|
||||||
|
private final Map<Class<? extends Service>, ServiceDescriptor<?>> descriptors = CollectionFactory
|
||||||
|
.newMap();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param injector
|
* @param file
|
||||||
* the {@link Guice} {@link Injector}
|
* 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
|
@SuppressWarnings("unchecked")
|
||||||
public ServiceManager(Injector injector) {
|
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;
|
this.injector = injector;
|
||||||
final LoggingService service = injector
|
final LoggingService service = injector
|
||||||
.getInstance(LoggingService.class);
|
.getInstance(LoggingService.class);
|
||||||
knownServices.add(service);
|
knownServices.add(service);
|
||||||
try {
|
service.start();
|
||||||
service.start();
|
configurationService = injector.getInstance(ConfigurationService.class);
|
||||||
} catch (ServiceStartException e) {
|
knownServices.add(configurationService);
|
||||||
throw new RuntimeException(e);
|
configurationService.start();
|
||||||
}
|
|
||||||
logger = LoggerFactory.getLogger(ServiceManager.class);
|
logger = LoggerFactory.getLogger(ServiceManager.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,6 +149,17 @@ public class ServiceManager {
|
|||||||
return injector.getInstance(serviceClass);
|
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
|
* Starts the given service implementation
|
||||||
*
|
*
|
||||||
@@ -87,6 +171,7 @@ public class ServiceManager {
|
|||||||
* @throws ServiceStartException
|
* @throws ServiceStartException
|
||||||
* if any error occur while starting service
|
* if any error occur while starting service
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
public <T extends Service> T start(Class<T> serviceClass)
|
public <T extends Service> T start(Class<T> serviceClass)
|
||||||
throws ServiceStartException {
|
throws ServiceStartException {
|
||||||
final T service = injector.getInstance(serviceClass);
|
final T service = injector.getInstance(serviceClass);
|
||||||
@@ -99,6 +184,13 @@ public class ServiceManager {
|
|||||||
startDependencies(service.getDependencies());
|
startDependencies(service.getDependencies());
|
||||||
logger.debug("{}: Starting service...",
|
logger.debug("{}: Starting service...",
|
||||||
serviceClass.getSimpleName());
|
serviceClass.getSimpleName());
|
||||||
|
if (service instanceof ConfigurableService) {
|
||||||
|
final ServiceConfiguration config = configurationService
|
||||||
|
.getServiceConfiguration(
|
||||||
|
(ConfigurableService<?>) service,
|
||||||
|
(Class<? extends Service>) serviceClass);
|
||||||
|
((ConfigurableService) service).setConfiguration(config);
|
||||||
|
}
|
||||||
service.start();
|
service.start();
|
||||||
logger.info("{} started", serviceClass.getSimpleName());
|
logger.info("{} started", serviceClass.getSimpleName());
|
||||||
return service;
|
return service;
|
||||||
@@ -152,6 +244,9 @@ public class ServiceManager {
|
|||||||
logger.debug("{0}: Stopping service...",
|
logger.debug("{0}: Stopping service...",
|
||||||
serviceClass.getSimpleName());
|
serviceClass.getSimpleName());
|
||||||
stopDependencies(service);
|
stopDependencies(service);
|
||||||
|
if (service instanceof ConfigurableService) {
|
||||||
|
((ConfigurableService<?>) service).setConfiguration(null);
|
||||||
|
}
|
||||||
service.stop();
|
service.stop();
|
||||||
logger.info("{0}: Service stopped!", serviceClass.getSimpleName());
|
logger.info("{0}: Service stopped!", serviceClass.getSimpleName());
|
||||||
} catch (ServiceStopException e) {
|
} catch (ServiceStopException e) {
|
||||||
@@ -245,4 +340,29 @@ public class ServiceManager {
|
|||||||
throw e;
|
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;
|
package com.l2jserver.service.configuration;
|
||||||
|
|
||||||
|
import com.l2jserver.service.ConfigurableService;
|
||||||
import com.l2jserver.service.Service;
|
import com.l2jserver.service.Service;
|
||||||
|
import com.l2jserver.service.ServiceConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The configuration service is responsible for reading and writing in
|
* The configuration service is responsible for reading and writing in
|
||||||
@@ -27,13 +29,15 @@ import com.l2jserver.service.Service;
|
|||||||
*/
|
*/
|
||||||
public interface ConfigurationService extends Service {
|
public interface ConfigurationService extends Service {
|
||||||
/**
|
/**
|
||||||
* Get the configuration object for <tt>config</tt>
|
* Get the configuration for the given service
|
||||||
*
|
*
|
||||||
* @param <C>
|
* @param service
|
||||||
* the configuration type
|
* the service
|
||||||
* @param config
|
* @param serviceInterface
|
||||||
* the configuration interface class
|
* the service interface
|
||||||
* @return the configuration object
|
* @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;
|
package com.l2jserver.service.configuration;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
@@ -26,23 +24,23 @@ import java.lang.reflect.Method;
|
|||||||
import java.lang.reflect.Proxy;
|
import java.lang.reflect.Proxy;
|
||||||
import java.util.Map;
|
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.XPathConstants;
|
||||||
import javax.xml.xpath.XPathExpressionException;
|
import javax.xml.xpath.XPathExpressionException;
|
||||||
import javax.xml.xpath.XPathFactory;
|
import javax.xml.xpath.XPathFactory;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.xml.sax.SAXException;
|
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.l2jserver.service.AbstractService;
|
import com.l2jserver.service.AbstractService;
|
||||||
import com.l2jserver.service.AbstractService.Depends;
|
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.ServiceStartException;
|
||||||
import com.l2jserver.service.cache.CacheService;
|
import com.l2jserver.service.cache.CacheService;
|
||||||
import com.l2jserver.service.configuration.Configuration.ConfigurationPropertyGetter;
|
import com.l2jserver.service.configuration.Configuration.ConfigurationPropertyGetter;
|
||||||
@@ -60,33 +58,16 @@ import com.l2jserver.util.transformer.TransformerFactory;
|
|||||||
@Depends({ LoggingService.class, CacheService.class })
|
@Depends({ LoggingService.class, CacheService.class })
|
||||||
public class XMLConfigurationService extends AbstractService implements
|
public class XMLConfigurationService extends AbstractService implements
|
||||||
ConfigurationService {
|
ConfigurationService {
|
||||||
/**
|
|
||||||
* The directory in which configuration files are stored
|
|
||||||
*/
|
|
||||||
private File file = new File("./config/config.xml");
|
|
||||||
/**
|
/**
|
||||||
* The logger
|
* The logger
|
||||||
*/
|
*/
|
||||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
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;
|
private final ServiceManager serviceManager;
|
||||||
/**
|
|
||||||
* 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();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the XPath for the configuration parameter
|
* Defines the XPath for the configuration parameter
|
||||||
@@ -103,50 +84,29 @@ public class XMLConfigurationService extends AbstractService implements
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new empty instance
|
* Creates a new empty instance
|
||||||
|
*
|
||||||
|
* @param serviceManager
|
||||||
|
* the service manager
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
protected XMLConfigurationService() {
|
protected XMLConfigurationService(ServiceManager serviceManager) {
|
||||||
}
|
this.serviceManager = serviceManager;
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new service instance. <b>This is used for tests</b>
|
|
||||||
*
|
|
||||||
* @param file
|
|
||||||
* the configuration file
|
|
||||||
*/
|
|
||||||
protected XMLConfigurationService(File file) {
|
|
||||||
this.file = file;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doStart() throws ServiceStartException {
|
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
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <C extends Configuration> C get(Class<C> config) {
|
public <C extends ServiceConfiguration> C getServiceConfiguration(
|
||||||
Preconditions.checkNotNull(config, "config");
|
ConfigurableService<?> service,
|
||||||
|
Class<? extends Service> serviceInterface) {
|
||||||
if (cache.containsKey(config))
|
final ServiceDescriptor<?> serviceDescriptor = serviceManager
|
||||||
return (C) cache.get(config);
|
.getServiceDescriptor(serviceInterface);
|
||||||
log.debug("Trying to create {} proxy", config);
|
return (C) Proxy.newProxyInstance(this.getClass().getClassLoader(),
|
||||||
|
new Class<?>[] { service.getConfigurationInterface() },
|
||||||
C proxy = (C) Proxy.newProxyInstance(this.getClass().getClassLoader(),
|
new ConfigInvocationHandler(serviceDescriptor.getNode()));
|
||||||
new Class<?>[] { config }, new ConfigInvocationHandler(
|
|
||||||
properties));
|
|
||||||
cache.put(config, proxy);
|
|
||||||
return proxy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -158,7 +118,7 @@ public class XMLConfigurationService extends AbstractService implements
|
|||||||
/**
|
/**
|
||||||
* The invocation handler properties
|
* The invocation handler properties
|
||||||
*/
|
*/
|
||||||
private final Document properties;
|
private final Node properties;
|
||||||
/**
|
/**
|
||||||
* The invocation cache
|
* The invocation cache
|
||||||
*/
|
*/
|
||||||
@@ -168,7 +128,7 @@ public class XMLConfigurationService extends AbstractService implements
|
|||||||
* @param properties
|
* @param properties
|
||||||
* the properties
|
* the properties
|
||||||
*/
|
*/
|
||||||
public ConfigInvocationHandler(Document properties) {
|
public ConfigInvocationHandler(Node properties) {
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,11 +305,4 @@ public class XMLConfigurationService extends AbstractService implements
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the configuration store directory
|
|
||||||
*/
|
|
||||||
public File getFile() {
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,42 +1,25 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of l2jserver2 <l2jserver2.com>.
|
* This file is part of l2jserver2 <l2jserver2.com>.
|
||||||
*
|
*
|
||||||
* l2jserver2 is free software: you can redistribute it and/or modify
|
* l2jserver2 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* l2jserver2 is distributed in the hope that it will be useful,
|
* l2jserver2 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with l2jserver2. If not, see <http://www.gnu.org/licenses/>.
|
* along with l2jserver2. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package com.l2jserver;
|
package com.l2jserver.service.core.vfs;
|
||||||
|
|
||||||
import com.google.inject.Guice;
|
/**
|
||||||
import com.google.inject.Injector;
|
* Configuration interface for {@link Java7VFSService}.
|
||||||
|
*
|
||||||
/**
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
* The L2JGameServer class
|
*/
|
||||||
*
|
public interface Java7VFSConfiguration extends VFSConfiguration {
|
||||||
* @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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -22,27 +22,23 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.l2jserver.service.AbstractService;
|
import com.l2jserver.service.AbstractConfigurableService;
|
||||||
import com.l2jserver.service.ServiceStartException;
|
import com.l2jserver.service.ServiceStartException;
|
||||||
import com.l2jserver.service.ServiceStopException;
|
import com.l2jserver.service.ServiceStopException;
|
||||||
import com.l2jserver.service.configuration.ConfigurationService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of {@link VFSService} using default Java7 APIs.
|
* Implementation of {@link VFSService} using default Java7 APIs.
|
||||||
*
|
*
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @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
|
* The logger
|
||||||
*/
|
*/
|
||||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
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
|
* The root {@link Path} of the server data
|
||||||
*/
|
*/
|
||||||
@@ -53,20 +49,11 @@ public class Java7VFSService extends AbstractService implements VFSService {
|
|||||||
private Path dataRoot;
|
private Path dataRoot;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration interface for {@link Java7VFSService}.
|
* Creates a new instance
|
||||||
*
|
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
|
||||||
*/
|
|
||||||
public interface Java7VFSConfiguration extends VFSConfiguration {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param configService
|
|
||||||
* the configuration service
|
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
protected Java7VFSService(final ConfigurationService configService) {
|
public Java7VFSService() {
|
||||||
this.config = configService.get(Java7VFSConfiguration.class);
|
super(Java7VFSConfiguration.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,37 +1,25 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of l2jserver2 <l2jserver2.com>.
|
* This file is part of l2jserver2 <l2jserver2.com>.
|
||||||
*
|
*
|
||||||
* l2jserver2 is free software: you can redistribute it and/or modify
|
* l2jserver2 is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* l2jserver2 is distributed in the hope that it will be useful,
|
* l2jserver2 is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with l2jserver2. If not, see <http://www.gnu.org/licenses/>.
|
* along with l2jserver2. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package com.l2jserver;
|
package com.l2jserver.service.core.vfs;
|
||||||
|
|
||||||
import com.google.inject.AbstractModule;
|
/**
|
||||||
import com.google.inject.Module;
|
* Configuration interface for {@link TrueZipVFSService}.
|
||||||
import com.l2jserver.model.id.provider.IDProviderModule;
|
*
|
||||||
import com.l2jserver.service.ServiceModule;
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
import com.l2jserver.service.database.OrientDBDAOModule;
|
*/
|
||||||
|
public interface TrueZipVFSConfiguration extends VFSConfiguration {
|
||||||
/**
|
}
|
||||||
* 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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -22,7 +22,7 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.l2jserver.service.AbstractService;
|
import com.l2jserver.service.AbstractConfigurableService;
|
||||||
import com.l2jserver.service.ServiceStartException;
|
import com.l2jserver.service.ServiceStartException;
|
||||||
import com.l2jserver.service.ServiceStopException;
|
import com.l2jserver.service.ServiceStopException;
|
||||||
import com.l2jserver.service.configuration.ConfigurationService;
|
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>
|
* @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
|
* The logger
|
||||||
*/
|
*/
|
||||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
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
|
* The root {@link Path} of the server data
|
||||||
*/
|
*/
|
||||||
@@ -55,21 +52,13 @@ public class TrueZipVFSService extends AbstractService implements VFSService {
|
|||||||
*/
|
*/
|
||||||
private TPath dataRoot;
|
private TPath dataRoot;
|
||||||
|
|
||||||
/**
|
|
||||||
* Configuration interface for {@link TrueZipVFSService}.
|
|
||||||
*
|
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
|
||||||
*/
|
|
||||||
public interface TrueZipVFSConfiguration extends VFSConfiguration {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param configService
|
* @param configService
|
||||||
* the configuration service
|
* the configuration service
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
protected TrueZipVFSService(final ConfigurationService configService) {
|
protected TrueZipVFSService(final ConfigurationService configService) {
|
||||||
this.config = configService.get(TrueZipVFSConfiguration.class);
|
super(TrueZipVFSConfiguration.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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;
|
package com.l2jserver.service.core.vfs;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
import com.l2jserver.service.Service;
|
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
|
* 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>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public interface VFSService extends Service {
|
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.
|
* Resolves an file. If the file cannot be resolved, null will be returned.
|
||||||
* <p>
|
* <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.Model;
|
||||||
import com.l2jserver.model.id.ID;
|
import com.l2jserver.model.id.ID;
|
||||||
import com.l2jserver.service.Service;
|
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.l2jserver.service.core.threading.AsyncFuture;
|
||||||
import com.mysema.query.sql.RelationalPath;
|
import com.mysema.query.sql.RelationalPath;
|
||||||
import com.mysema.query.sql.RelationalPathBase;
|
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>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public interface DatabaseService extends Service {
|
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.
|
* Executes several operations inside a single database transaction.
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -35,13 +35,11 @@ import com.l2jserver.model.Model;
|
|||||||
import com.l2jserver.model.Model.ObjectDesire;
|
import com.l2jserver.model.Model.ObjectDesire;
|
||||||
import com.l2jserver.model.id.ID;
|
import com.l2jserver.model.id.ID;
|
||||||
import com.l2jserver.model.id.object.allocator.IDAllocator;
|
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.ServiceStartException;
|
||||||
import com.l2jserver.service.ServiceStopException;
|
import com.l2jserver.service.ServiceStopException;
|
||||||
import com.l2jserver.service.cache.Cache;
|
import com.l2jserver.service.cache.Cache;
|
||||||
import com.l2jserver.service.cache.CacheService;
|
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.AbstractTask;
|
||||||
import com.l2jserver.service.core.threading.AsyncFuture;
|
import com.l2jserver.service.core.threading.AsyncFuture;
|
||||||
import com.l2jserver.service.core.threading.ScheduledAsyncFuture;
|
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>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractOrientDatabaseService extends AbstractService
|
public abstract class AbstractOrientDatabaseService extends
|
||||||
implements DatabaseService {
|
AbstractConfigurableService<OrientDatabaseConfiguration> implements
|
||||||
/**
|
DatabaseService {
|
||||||
* The configuration object
|
|
||||||
*/
|
|
||||||
private final OrientDatabaseConfiguration config;
|
|
||||||
/**
|
/**
|
||||||
* The logger
|
* The logger
|
||||||
*/
|
*/
|
||||||
@@ -136,60 +131,6 @@ public abstract class AbstractOrientDatabaseService extends AbstractService
|
|||||||
private final ThreadLocal<ODatabaseDocumentTx> transaction = new ThreadLocal<ODatabaseDocumentTx>();
|
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
|
* @param cacheService
|
||||||
* the cache service
|
* the cache service
|
||||||
* @param threadService
|
* @param threadService
|
||||||
@@ -198,10 +139,10 @@ public abstract class AbstractOrientDatabaseService extends AbstractService
|
|||||||
* the {@link DataAccessObject DAO} resolver
|
* the {@link DataAccessObject DAO} resolver
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
public AbstractOrientDatabaseService(ConfigurationService configService,
|
public AbstractOrientDatabaseService(
|
||||||
CacheService cacheService, ThreadService threadService,
|
CacheService cacheService, ThreadService threadService,
|
||||||
DAOResolver daoResolver) {
|
DAOResolver daoResolver) {
|
||||||
config = configService.get(OrientDatabaseConfiguration.class);
|
super(OrientDatabaseConfiguration.class);
|
||||||
this.cacheService = cacheService;
|
this.cacheService = cacheService;
|
||||||
this.threadService = threadService;
|
this.threadService = threadService;
|
||||||
this.daoResolver = daoResolver;
|
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.Model.ObjectDesire;
|
||||||
import com.l2jserver.model.id.ID;
|
import com.l2jserver.model.id.ID;
|
||||||
import com.l2jserver.model.id.object.allocator.IDAllocator;
|
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.ServiceStartException;
|
||||||
import com.l2jserver.service.ServiceStopException;
|
import com.l2jserver.service.ServiceStopException;
|
||||||
import com.l2jserver.service.cache.Cache;
|
import com.l2jserver.service.cache.Cache;
|
||||||
import com.l2jserver.service.cache.CacheService;
|
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.AbstractTask;
|
||||||
import com.l2jserver.service.core.threading.AsyncFuture;
|
import com.l2jserver.service.core.threading.AsyncFuture;
|
||||||
import com.l2jserver.service.core.threading.ScheduledAsyncFuture;
|
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>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractSQLDatabaseService extends AbstractService
|
public abstract class AbstractSQLDatabaseService extends
|
||||||
implements DatabaseService {
|
AbstractConfigurableService<JDBCDatabaseConfiguration> implements
|
||||||
/**
|
DatabaseService {
|
||||||
* The configuration object
|
|
||||||
*/
|
|
||||||
private final JDBCDatabaseConfiguration config;
|
|
||||||
/**
|
/**
|
||||||
* The logger
|
* The logger
|
||||||
*/
|
*/
|
||||||
@@ -173,120 +168,6 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
|||||||
private final Type<?>[] sqlTypes;
|
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
|
* @param cacheService
|
||||||
* the cache service
|
* the cache service
|
||||||
* @param threadService
|
* @param threadService
|
||||||
@@ -299,10 +180,10 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
|||||||
* the SQL mapping types
|
* the SQL mapping types
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
public AbstractSQLDatabaseService(ConfigurationService configService,
|
public AbstractSQLDatabaseService(CacheService cacheService,
|
||||||
CacheService cacheService, ThreadService threadService,
|
ThreadService threadService, VFSService vfsService,
|
||||||
VFSService vfsService, DAOResolver daoResolver, Type<?>... types) {
|
DAOResolver daoResolver, Type<?>... types) {
|
||||||
config = configService.get(JDBCDatabaseConfiguration.class);
|
super(JDBCDatabaseConfiguration.class);
|
||||||
this.cacheService = cacheService;
|
this.cacheService = cacheService;
|
||||||
this.threadService = threadService;
|
this.threadService = threadService;
|
||||||
this.vfsService = vfsService;
|
this.vfsService = vfsService;
|
||||||
@@ -409,6 +290,7 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
|||||||
}
|
}
|
||||||
log.info("Importing {} to {}", path, entity);
|
log.info("Importing {} to {}", path, entity);
|
||||||
try {
|
try {
|
||||||
|
conn.setAutoCommit(false);
|
||||||
CSVUtils.parseCSV(path, new CSVMapProcessor<Long>() {
|
CSVUtils.parseCSV(path, new CSVMapProcessor<Long>() {
|
||||||
@Override
|
@Override
|
||||||
public Long process(final Map<String, String> map) {
|
public Long process(final Map<String, String> map) {
|
||||||
@@ -433,8 +315,15 @@ public abstract class AbstractSQLDatabaseService extends AbstractService
|
|||||||
return insert.execute();
|
return insert.execute();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
conn.commit();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
try {
|
||||||
|
conn.rollback();
|
||||||
|
} catch (SQLException e1) {
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
|
conn.setAutoCommit(true);
|
||||||
conn.close();
|
conn.close();
|
||||||
} catch (SQLException e) {
|
} 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;
|
package com.l2jserver.util;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,6 +62,39 @@ public class ClassUtils {
|
|||||||
return false;
|
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
|
* 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
|
/log
|
||||||
/derby.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>
|
<baseDirectory></baseDirectory>
|
||||||
<fileSets>
|
<fileSets>
|
||||||
<fileSet>
|
<fileSet>
|
||||||
<directory>${project.basedir}/distribution/global</directory>
|
<directory>${project.basedir}/distribution</directory>
|
||||||
<outputDirectory>/</outputDirectory>
|
<outputDirectory>/</outputDirectory>
|
||||||
</fileSet>
|
</fileSet>
|
||||||
</fileSets>
|
</fileSets>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<baseDirectory></baseDirectory>
|
<baseDirectory></baseDirectory>
|
||||||
<fileSets>
|
<fileSets>
|
||||||
<fileSet>
|
<fileSet>
|
||||||
<directory>${project.basedir}/distribution/global</directory>
|
<directory>${project.basedir}/distribution</directory>
|
||||||
<outputDirectory>/</outputDirectory>
|
<outputDirectory>/</outputDirectory>
|
||||||
</fileSet>
|
</fileSet>
|
||||||
</fileSets>
|
</fileSets>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<baseDirectory></baseDirectory>
|
<baseDirectory></baseDirectory>
|
||||||
<fileSets>
|
<fileSets>
|
||||||
<fileSet>
|
<fileSet>
|
||||||
<directory>${project.basedir}/distribution/global</directory>
|
<directory>${project.basedir}/distribution</directory>
|
||||||
<outputDirectory>/</outputDirectory>
|
<outputDirectory>/</outputDirectory>
|
||||||
</fileSet>
|
</fileSet>
|
||||||
</fileSets>
|
</fileSets>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<baseDirectory></baseDirectory>
|
<baseDirectory></baseDirectory>
|
||||||
<fileSets>
|
<fileSets>
|
||||||
<fileSet>
|
<fileSet>
|
||||||
<directory>${project.basedir}/distribution/global</directory>
|
<directory>${project.basedir}/distribution</directory>
|
||||||
<outputDirectory>/</outputDirectory>
|
<outputDirectory>/</outputDirectory>
|
||||||
</fileSet>
|
</fileSet>
|
||||||
</fileSets>
|
</fileSets>
|
||||||
|
|||||||
@@ -16,8 +16,20 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver;
|
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.Service;
|
||||||
|
import com.l2jserver.service.ServiceException;
|
||||||
import com.l2jserver.service.ServiceManager;
|
import com.l2jserver.service.ServiceManager;
|
||||||
|
import com.l2jserver.service.ServiceStartException;
|
||||||
import com.l2jserver.service.ServiceStopException;
|
import com.l2jserver.service.ServiceStopException;
|
||||||
import com.l2jserver.service.cache.CacheService;
|
import com.l2jserver.service.cache.CacheService;
|
||||||
import com.l2jserver.service.configuration.ConfigurationService;
|
import com.l2jserver.service.configuration.ConfigurationService;
|
||||||
@@ -65,17 +77,38 @@ public class L2JGameServerMain {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
final L2JGameServer server = new L2JGameServer();
|
final ServiceManager serviceManager = new ServiceManager();
|
||||||
try {
|
try {
|
||||||
final ServiceManager serviceManager = server.getInjector()
|
serviceManager.load(Paths.get("services.xml"));
|
||||||
.getInstance(ServiceManager.class);
|
} 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<?>[] category : SERVICES) {
|
||||||
for (final Class<?> service : category) {
|
for (final Class<?> service : category) {
|
||||||
serviceManager.start((Class<? extends Service>) service);
|
serviceManager.start((Class<? extends Service>) service);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
|
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
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
|
public class GameServerJDBCDatabaseService extends AbstractSQLDatabaseService
|
||||||
implements DatabaseService {
|
implements DatabaseService {
|
||||||
/**
|
/**
|
||||||
* @param configService
|
|
||||||
* the config service
|
|
||||||
* @param cacheService
|
* @param cacheService
|
||||||
* the cache service
|
* the cache service
|
||||||
* @param threadService
|
* @param threadService
|
||||||
@@ -88,11 +86,10 @@ public class GameServerJDBCDatabaseService extends AbstractSQLDatabaseService
|
|||||||
* the {@link DataAccessObject DAO} resolver
|
* the {@link DataAccessObject DAO} resolver
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
public GameServerJDBCDatabaseService(ConfigurationService configService,
|
public GameServerJDBCDatabaseService(CacheService cacheService,
|
||||||
CacheService cacheService, ThreadService threadService,
|
ThreadService threadService, VFSService vfsService,
|
||||||
VFSService vfsService, DAOResolver daoResolver) {
|
DAOResolver daoResolver) {
|
||||||
super(
|
super(
|
||||||
configService,
|
|
||||||
cacheService,
|
cacheService,
|
||||||
threadService,
|
threadService,
|
||||||
vfsService,
|
vfsService,
|
||||||
@@ -120,7 +117,8 @@ public class GameServerJDBCDatabaseService extends AbstractSQLDatabaseService
|
|||||||
updateSchema(QLogChat.logChat);
|
updateSchema(QLogChat.logChat);
|
||||||
if (updateSchema(QNPC.npc)) {
|
if (updateSchema(QNPC.npc)) {
|
||||||
try {
|
try {
|
||||||
importData(vfsService.resolveDataFile("static/npc.csv"), QNPC.npc);
|
importData(vfsService.resolveDataFile("static/npc.csv"),
|
||||||
|
QNPC.npc);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new DatabaseException(e);
|
throw new DatabaseException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,8 +70,6 @@ public class GameServerOrientDatabaseService extends
|
|||||||
private final VFSService vfsService;
|
private final VFSService vfsService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param configService
|
|
||||||
* the config service
|
|
||||||
* @param cacheService
|
* @param cacheService
|
||||||
* the cache service
|
* the cache service
|
||||||
* @param threadService
|
* @param threadService
|
||||||
@@ -82,10 +80,10 @@ public class GameServerOrientDatabaseService extends
|
|||||||
* the {@link DataAccessObject DAO} resolver
|
* the {@link DataAccessObject DAO} resolver
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
public GameServerOrientDatabaseService(ConfigurationService configService,
|
public GameServerOrientDatabaseService(CacheService cacheService,
|
||||||
CacheService cacheService, ThreadService threadService,
|
ThreadService threadService, final VFSService vfsService,
|
||||||
final VFSService vfsService, DAOResolver daoResolver) {
|
DAOResolver daoResolver) {
|
||||||
super(configService, cacheService, threadService, daoResolver);
|
super(cacheService, threadService, daoResolver);
|
||||||
this.vfsService = vfsService;
|
this.vfsService = vfsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +98,8 @@ public class GameServerOrientDatabaseService extends
|
|||||||
updateSchema(QLogChat.logChat);
|
updateSchema(QLogChat.logChat);
|
||||||
if (updateSchema(QNPC.npc)) {
|
if (updateSchema(QNPC.npc)) {
|
||||||
try {
|
try {
|
||||||
importData(vfsService.resolveDataFile("static/npc.csv"), QNPC.npc);
|
importData(vfsService.resolveDataFile("static/npc.csv"),
|
||||||
|
QNPC.npc);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new DatabaseException(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.item.ItemTemplate;
|
||||||
import com.l2jserver.model.template.npc.NPCTemplate;
|
import com.l2jserver.model.template.npc.NPCTemplate;
|
||||||
import com.l2jserver.model.template.npc.TeleportationTemplate;
|
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.AbstractService.Depends;
|
||||||
import com.l2jserver.service.ServiceStartException;
|
import com.l2jserver.service.ServiceStartException;
|
||||||
import com.l2jserver.service.ServiceStopException;
|
import com.l2jserver.service.ServiceStopException;
|
||||||
import com.l2jserver.service.cache.Cache;
|
import com.l2jserver.service.cache.Cache;
|
||||||
import com.l2jserver.service.cache.CacheService;
|
import com.l2jserver.service.cache.CacheService;
|
||||||
import com.l2jserver.service.configuration.ConfigurationService;
|
import com.l2jserver.service.configuration.ConfigurationService;
|
||||||
import com.l2jserver.service.configuration.XMLConfigurationService.ConfigurationXPath;
|
|
||||||
import com.l2jserver.service.core.LoggingService;
|
import com.l2jserver.service.core.LoggingService;
|
||||||
import com.l2jserver.service.core.vfs.VFSService;
|
import com.l2jserver.service.core.vfs.VFSService;
|
||||||
import com.l2jserver.util.jaxb.CharacterTemplateIDAdapter;
|
import com.l2jserver.util.jaxb.CharacterTemplateIDAdapter;
|
||||||
@@ -72,7 +71,8 @@ import com.l2jserver.util.jaxb.TeleportationTemplateIDAdapter;
|
|||||||
*/
|
*/
|
||||||
@Depends({ LoggingService.class, VFSService.class, CacheService.class,
|
@Depends({ LoggingService.class, VFSService.class, CacheService.class,
|
||||||
ConfigurationService.class })
|
ConfigurationService.class })
|
||||||
public class XMLTemplateService extends AbstractService implements
|
public class XMLTemplateService extends
|
||||||
|
AbstractConfigurableService<XMLTemplateServiceConfiguration> implements
|
||||||
TemplateService {
|
TemplateService {
|
||||||
/**
|
/**
|
||||||
* The logger
|
* The logger
|
||||||
@@ -88,10 +88,6 @@ public class XMLTemplateService extends AbstractService implements
|
|||||||
*/
|
*/
|
||||||
private final CacheService cacheService;
|
private final CacheService cacheService;
|
||||||
|
|
||||||
/**
|
|
||||||
* The XML template service configuration
|
|
||||||
*/
|
|
||||||
private final XMLTemplateServiceConfiguration config;
|
|
||||||
/**
|
/**
|
||||||
* The npc template id adapter
|
* The npc template id adapter
|
||||||
*/
|
*/
|
||||||
@@ -132,36 +128,11 @@ public class XMLTemplateService extends AbstractService implements
|
|||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
private Cache<TemplateID, Template> templates;
|
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
|
* @param vfsService
|
||||||
* the vfs service
|
* the vfs service
|
||||||
* @param cacheService
|
* @param cacheService
|
||||||
* the cache service
|
* the cache servicef
|
||||||
* @param configService
|
|
||||||
* the configuration service
|
|
||||||
* @param npcTemplateIdAdapter
|
* @param npcTemplateIdAdapter
|
||||||
* the npc template id adapter
|
* the npc template id adapter
|
||||||
* @param itemTemplateIdAdapter
|
* @param itemTemplateIdAdapter
|
||||||
@@ -177,16 +148,16 @@ public class XMLTemplateService extends AbstractService implements
|
|||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
public XMLTemplateService(final VFSService vfsService,
|
public XMLTemplateService(final VFSService vfsService,
|
||||||
CacheService cacheService, ConfigurationService configService,
|
CacheService cacheService,
|
||||||
NPCTemplateIDAdapter npcTemplateIdAdapter,
|
NPCTemplateIDAdapter npcTemplateIdAdapter,
|
||||||
ItemTemplateIDAdapter itemTemplateIdAdapter,
|
ItemTemplateIDAdapter itemTemplateIdAdapter,
|
||||||
SkillTemplateIDAdapter skillTemplateIdAdapter,
|
SkillTemplateIDAdapter skillTemplateIdAdapter,
|
||||||
CharacterTemplateIDAdapter charIdTemplateAdapter,
|
CharacterTemplateIDAdapter charIdTemplateAdapter,
|
||||||
EffectTemplateIDAdapter effectIdTemplateAdapter,
|
EffectTemplateIDAdapter effectIdTemplateAdapter,
|
||||||
TeleportationTemplateIDAdapter teleportationIdTemplateAdapter) {
|
TeleportationTemplateIDAdapter teleportationIdTemplateAdapter) {
|
||||||
|
super(XMLTemplateServiceConfiguration.class);
|
||||||
this.vfsService = vfsService;
|
this.vfsService = vfsService;
|
||||||
this.cacheService = cacheService;
|
this.cacheService = cacheService;
|
||||||
this.config = configService.get(XMLTemplateServiceConfiguration.class);
|
|
||||||
this.npcTemplateIdAdapter = npcTemplateIdAdapter;
|
this.npcTemplateIdAdapter = npcTemplateIdAdapter;
|
||||||
this.itemTemplateIdAdapter = itemTemplateIdAdapter;
|
this.itemTemplateIdAdapter = itemTemplateIdAdapter;
|
||||||
this.skillTemplateIdAdapter = skillTemplateIdAdapter;
|
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.Lineage2PipelineFactory;
|
||||||
import com.l2jserver.game.net.packet.ServerPacket;
|
import com.l2jserver.game.net.packet.ServerPacket;
|
||||||
import com.l2jserver.model.id.object.CharacterID;
|
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.AbstractService.Depends;
|
||||||
import com.l2jserver.service.configuration.ConfigurationService;
|
|
||||||
import com.l2jserver.service.core.LoggingService;
|
import com.l2jserver.service.core.LoggingService;
|
||||||
import com.l2jserver.service.core.threading.ThreadPool;
|
import com.l2jserver.service.core.threading.ThreadPool;
|
||||||
import com.l2jserver.service.core.threading.ThreadPoolPriority;
|
import com.l2jserver.service.core.threading.ThreadPoolPriority;
|
||||||
@@ -58,7 +57,8 @@ import com.l2jserver.util.factory.CollectionFactory;
|
|||||||
*/
|
*/
|
||||||
@Depends({ LoggingService.class, ThreadService.class,
|
@Depends({ LoggingService.class, ThreadService.class,
|
||||||
BlowfishKeygenService.class, WorldService.class })
|
BlowfishKeygenService.class, WorldService.class })
|
||||||
public class NettyNetworkService extends AbstractService implements
|
public class NettyNetworkService extends
|
||||||
|
AbstractConfigurableService<NetworkServiceConfiguration> implements
|
||||||
NetworkService {
|
NetworkService {
|
||||||
/**
|
/**
|
||||||
* The logger
|
* The logger
|
||||||
@@ -70,10 +70,6 @@ public class NettyNetworkService extends AbstractService implements
|
|||||||
*/
|
*/
|
||||||
private final ThreadService threadService;
|
private final ThreadService threadService;
|
||||||
|
|
||||||
/**
|
|
||||||
* The network configuration object
|
|
||||||
*/
|
|
||||||
private final NetworkConfiguration config;
|
|
||||||
/**
|
/**
|
||||||
* The Google Guice {@link Injector}
|
* The Google Guice {@link Injector}
|
||||||
*/
|
*/
|
||||||
@@ -101,18 +97,15 @@ public class NettyNetworkService extends AbstractService implements
|
|||||||
private Set<Lineage2Client> clients = CollectionFactory.newSet();
|
private Set<Lineage2Client> clients = CollectionFactory.newSet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param configService
|
|
||||||
* the configuration service
|
|
||||||
* @param injector
|
* @param injector
|
||||||
* the {@link Guice} {@link Injector}
|
* the {@link Guice} {@link Injector}
|
||||||
* @param threadService
|
* @param threadService
|
||||||
* the {@link ThreadService}
|
* the {@link ThreadService}
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
public NettyNetworkService(ConfigurationService configService,
|
public NettyNetworkService(Injector injector, ThreadService threadService) {
|
||||||
Injector injector, ThreadService threadService) {
|
super(NetworkServiceConfiguration.class);
|
||||||
this.threadService = threadService;
|
this.threadService = threadService;
|
||||||
this.config = configService.get(NetworkConfiguration.class);
|
|
||||||
this.injector = injector;
|
this.injector = injector;
|
||||||
InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory());
|
InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.service.network;
|
package com.l2jserver.service.network;
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
|
|
||||||
import com.l2jserver.game.net.Lineage2Client;
|
import com.l2jserver.game.net.Lineage2Client;
|
||||||
import com.l2jserver.game.net.Lineage2Session;
|
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.id.object.CharacterID;
|
||||||
import com.l2jserver.model.world.L2Character;
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.service.Service;
|
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
|
* 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>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public interface NetworkService extends Service {
|
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
|
* 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.Guice;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Stage;
|
import com.google.inject.Stage;
|
||||||
import com.l2jserver.GameServerModule;
|
|
||||||
import com.l2jserver.model.dao.CharacterDAO;
|
import com.l2jserver.model.dao.CharacterDAO;
|
||||||
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
|
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
|
||||||
import com.l2jserver.model.world.L2Character;
|
import com.l2jserver.model.world.L2Character;
|
||||||
@@ -47,7 +46,7 @@ public class MySQL5CharacterDAOTest {
|
|||||||
* The {@link Guice} {@link Injector}
|
* The {@link Guice} {@link Injector}
|
||||||
*/
|
*/
|
||||||
private final Injector injector = Guice.createInjector(Stage.PRODUCTION,
|
private final Injector injector = Guice.createInjector(Stage.PRODUCTION,
|
||||||
new GameServerModule(), new AbstractModule() {
|
new AbstractModule() {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bind(CharacterMapper.class);
|
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.id.object.provider.CharacterIDProvider;
|
||||||
import com.l2jserver.model.world.L2Character;
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.service.ServiceManager;
|
import com.l2jserver.service.ServiceManager;
|
||||||
import com.l2jserver.service.ServiceModule;
|
|
||||||
import com.l2jserver.service.ServiceStartException;
|
import com.l2jserver.service.ServiceStartException;
|
||||||
import com.l2jserver.service.database.DatabaseService;
|
import com.l2jserver.service.database.DatabaseService;
|
||||||
import com.l2jserver.service.database.JDBCDAOModule;
|
import com.l2jserver.service.database.JDBCDAOModule;
|
||||||
@@ -44,8 +43,8 @@ public class CharacterIDProviderTest {
|
|||||||
/**
|
/**
|
||||||
* The {@link Guice} {@link Injector}
|
* The {@link Guice} {@link Injector}
|
||||||
*/
|
*/
|
||||||
private final Injector injector = Guice.createInjector(new ServiceModule(),
|
private final Injector injector = Guice.createInjector(new JDBCDAOModule(),
|
||||||
new JDBCDAOModule(), new IDProviderModule());
|
new IDProviderModule());
|
||||||
/**
|
/**
|
||||||
* The character id provider
|
* The character id provider
|
||||||
*/
|
*/
|
||||||
@@ -53,6 +52,7 @@ public class CharacterIDProviderTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepares the test
|
* Prepares the test
|
||||||
|
*
|
||||||
* @throws ServiceStartException
|
* @throws ServiceStartException
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
@@ -86,6 +86,7 @@ public class CharacterIDProviderTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests DAO aware ids
|
* Tests DAO aware ids
|
||||||
|
*
|
||||||
* @throws ServiceStartException
|
* @throws ServiceStartException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ import org.junit.Test;
|
|||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Stage;
|
import com.google.inject.Stage;
|
||||||
import com.l2jserver.GameServerModule;
|
|
||||||
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
|
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
|
||||||
import com.l2jserver.model.id.object.provider.ItemIDProvider;
|
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.Item;
|
||||||
import com.l2jserver.model.world.L2Character;
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.model.world.item.ItemDropEvent;
|
import com.l2jserver.model.world.item.ItemDropEvent;
|
||||||
@@ -74,7 +74,7 @@ public class WorldEventDispatcherImplTest {
|
|||||||
@Before
|
@Before
|
||||||
public void tearUp() throws ServiceStartException {
|
public void tearUp() throws ServiceStartException {
|
||||||
Injector injector = Guice.createInjector(Stage.PRODUCTION,
|
Injector injector = Guice.createInjector(Stage.PRODUCTION,
|
||||||
new GameServerModule());
|
new IDProviderModule());
|
||||||
|
|
||||||
injector.getInstance(ServiceManager.class).start(WorldIDService.class);
|
injector.getInstance(ServiceManager.class).start(WorldIDService.class);
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.l2jserver.GameServerModule;
|
|
||||||
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
|
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.Item;
|
||||||
import com.l2jserver.model.world.L2Character;
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.model.world.WorldObject;
|
import com.l2jserver.model.world.WorldObject;
|
||||||
@@ -36,6 +36,7 @@ import com.l2jserver.service.game.world.filter.impl.InstanceFilter;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link WorldServiceImpl}
|
* Tests for {@link WorldServiceImpl}
|
||||||
|
*
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public class WorldServiceImplTest {
|
public class WorldServiceImplTest {
|
||||||
@@ -50,11 +51,12 @@ public class WorldServiceImplTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Preparation for tests
|
* Preparation for tests
|
||||||
|
*
|
||||||
* @throws ServiceStartException
|
* @throws ServiceStartException
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void tearUp() throws ServiceStartException {
|
public void tearUp() throws ServiceStartException {
|
||||||
Injector injector = Guice.createInjector(new GameServerModule());
|
Injector injector = Guice.createInjector(new IDProviderModule());
|
||||||
|
|
||||||
world = injector.getInstance(ServiceManager.class).start(
|
world = injector.getInstance(ServiceManager.class).start(
|
||||||
WorldService.class);
|
WorldService.class);
|
||||||
|
|||||||
@@ -53,8 +53,6 @@ import com.l2jserver.service.database.sql.AbstractSQLDatabaseService;
|
|||||||
public class LoginServerSQLDatabaseService extends AbstractSQLDatabaseService
|
public class LoginServerSQLDatabaseService extends AbstractSQLDatabaseService
|
||||||
implements DatabaseService {
|
implements DatabaseService {
|
||||||
/**
|
/**
|
||||||
* @param configService
|
|
||||||
* the config service
|
|
||||||
* @param cacheService
|
* @param cacheService
|
||||||
* the cache service
|
* the cache service
|
||||||
* @param threadService
|
* @param threadService
|
||||||
@@ -64,11 +62,10 @@ public class LoginServerSQLDatabaseService extends AbstractSQLDatabaseService
|
|||||||
* @param daoResolver
|
* @param daoResolver
|
||||||
* the {@link DataAccessObject DAO} resolver
|
* the {@link DataAccessObject DAO} resolver
|
||||||
*/
|
*/
|
||||||
public LoginServerSQLDatabaseService(ConfigurationService configService,
|
public LoginServerSQLDatabaseService(CacheService cacheService,
|
||||||
CacheService cacheService, ThreadService threadService,
|
ThreadService threadService, VFSService vfsService,
|
||||||
VFSService vfsService, DAOResolver daoResolver) {
|
DAOResolver daoResolver) {
|
||||||
super(configService, cacheService, threadService, vfsService,
|
super(cacheService, threadService, vfsService, daoResolver);
|
||||||
daoResolver);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -16,12 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.service.gameserver;
|
package com.l2jserver.service.gameserver;
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
|
|
||||||
import com.l2jserver.service.Service;
|
import com.l2jserver.service.Service;
|
||||||
import com.l2jserver.service.ServiceConfiguration;
|
|
||||||
import com.l2jserver.service.configuration.Configuration;
|
|
||||||
import com.l2jserver.service.configuration.XMLConfigurationService.ConfigurationXPath;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* TODO
|
||||||
@@ -29,29 +25,4 @@ import com.l2jserver.service.configuration.XMLConfigurationService.Configuration
|
|||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public interface GameServerNetworkService extends Service {
|
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