1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-09 08:52:51 +00:00

First commit

Change-Id: I4d273faba7286288d2b9a214c87c39a76724d787
This commit is contained in:
rogiel
2011-04-28 18:49:39 -03:00
commit 6d52f44278
112 changed files with 1746 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
package com.l2jserver.service;
public interface Service {
/**
* Start this service
*
* @throws ServiceStartException
* if an error occurred
*/
void start() throws ServiceStartException;
/**
* Stop this service
*
* @throws ServiceStartException
* if an error occurred
*/
void stop() throws ServiceStopException;
}

View File

@@ -0,0 +1,21 @@
package com.l2jserver.service;
public class ServiceException extends Exception {
private static final long serialVersionUID = 1L;
public ServiceException() {
super();
}
public ServiceException(String message, Throwable cause) {
super(message, cause);
}
public ServiceException(String message) {
super(message);
}
public ServiceException(Throwable cause) {
super(cause);
}
}

View File

@@ -0,0 +1,23 @@
package com.l2jserver.service;
import com.google.inject.AbstractModule;
import com.google.inject.Scopes;
import com.l2jserver.service.configuration.ConfigurationService;
import com.l2jserver.service.configuration.ProxyConfigurationService;
import com.l2jserver.service.database.DB4ODatabaseService;
import com.l2jserver.service.database.DatabaseService;
import com.l2jserver.service.network.NettyNetworkService;
import com.l2jserver.service.network.NetworkService;
public class ServiceModule extends AbstractModule {
@Override
protected void configure() {
bind(ConfigurationService.class).to(ProxyConfigurationService.class)
.in(Scopes.SINGLETON);
bind(DatabaseService.class).to(DB4ODatabaseService.class).in(
Scopes.SINGLETON);
bind(NetworkService.class).to(NettyNetworkService.class).in(
Scopes.SINGLETON);
}
}

View File

@@ -0,0 +1,21 @@
package com.l2jserver.service;
public class ServiceStartException extends ServiceException {
private static final long serialVersionUID = 1L;
public ServiceStartException() {
super();
}
public ServiceStartException(String message, Throwable cause) {
super(message, cause);
}
public ServiceStartException(String message) {
super(message);
}
public ServiceStartException(Throwable cause) {
super(cause);
}
}

View File

@@ -0,0 +1,21 @@
package com.l2jserver.service;
public class ServiceStopException extends ServiceException {
private static final long serialVersionUID = 1L;
public ServiceStopException() {
super();
}
public ServiceStopException(String message, Throwable cause) {
super(message, cause);
}
public ServiceStopException(String message) {
super(message);
}
public ServiceStopException(Throwable cause) {
super(cause);
}
}

View File

@@ -0,0 +1,8 @@
package com.l2jserver.service.compiler;
import com.l2jserver.service.Service;
public interface CompilerService extends Service {
Class<?> compile(byte[] clazz);
ClassLoader getClassLoader();
}

View File

@@ -0,0 +1,11 @@
package com.l2jserver.service.compiler;
public class DynamicClassLoader extends ClassLoader {
public DynamicClassLoader() {
super();
}
public DynamicClassLoader(ClassLoader parent) {
super(parent);
}
}

View File

@@ -0,0 +1,29 @@
package com.l2jserver.service.compiler;
import com.l2jserver.service.ServiceStartException;
import com.l2jserver.service.ServiceStopException;
public class JavacCompilerService implements CompilerService {
@Override
public void start() throws ServiceStartException {
// TODO Auto-generated method stub
}
@Override
public Class<?> compile(byte[] clazz) {
// TODO Auto-generated method stub
return null;
}
@Override
public ClassLoader getClassLoader() {
// TODO Auto-generated method stub
return null;
}
@Override
public void stop() throws ServiceStopException {
}
}

View File

@@ -0,0 +1,24 @@
package com.l2jserver.service.configuration;
import com.l2jserver.service.configuration.Configuration.ConfigurationName;
@ConfigurationName("l2j")
public interface Configuration {
public @interface ConfigurationName {
String value();
}
public @interface ConfigurationPrefix {
String value();
}
public @interface ConfigurationPropertyGetter {
String name();
String defaultValue() default "";
}
public @interface ConfigurationPropertySetter {
String name();
}
}

View File

@@ -0,0 +1,5 @@
package com.l2jserver.service.configuration;
public interface ConfigurationService {
<C extends Configuration> C get(Class<C> config);
}

View File

@@ -0,0 +1,12 @@
package com.l2jserver.service.configuration;
import java.util.Properties;
public class ProxyConfigurationService implements ConfigurationService {
private Properties properties;
@Override
public <C extends Configuration> C get(Class<C> config) {
return null;
}
}

View File

@@ -0,0 +1,16 @@
package com.l2jserver.service.database;
import com.google.inject.Inject;
public abstract class AbstractDAO implements DataAccessObject {
protected final DatabaseService database;
@Inject
protected AbstractDAO(DatabaseService database) {
this.database = database;
}
public DatabaseService getDatabase() {
return database;
}
}

View File

@@ -0,0 +1,15 @@
package com.l2jserver.service.database;
public class DB4ODatabaseService implements DatabaseService {
@Override
public void start() {
// TODO Auto-generated method stub
}
@Override
public void stop() {
// TODO Auto-generated method stub
}
}

View File

@@ -0,0 +1,10 @@
package com.l2jserver.service.database;
/**
* The DAO interface
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface DataAccessObject {
}

View File

@@ -0,0 +1,11 @@
package com.l2jserver.service.database;
import com.l2jserver.service.configuration.Configuration;
import com.l2jserver.service.configuration.Configuration.ConfigurationName;
import com.l2jserver.service.configuration.Configuration.ConfigurationPrefix;
@ConfigurationName("database")
@ConfigurationPrefix("database")
public interface DatabaseConfiguration extends Configuration {
}

View File

@@ -0,0 +1,7 @@
package com.l2jserver.service.database;
import com.l2jserver.service.Service;
public interface DatabaseService extends Service {
}

View File

@@ -0,0 +1,25 @@
package com.l2jserver.service.database;
import com.google.inject.Inject;
import com.l2jserver.service.configuration.ConfigurationService;
public class MySQL5DatabaseService implements DatabaseService {
private final MySQLDatabaseConfiguration config;
@Inject
public MySQL5DatabaseService(ConfigurationService configService) {
config = configService.get(MySQLDatabaseConfiguration.class);
}
@Override
public void start() {
// TODO Auto-generated method stub
}
@Override
public void stop() {
// TODO Auto-generated method stub
}
}

View File

@@ -0,0 +1,31 @@
package com.l2jserver.service.database;
import com.l2jserver.service.configuration.Configuration.ConfigurationPrefix;
@ConfigurationPrefix("mysql")
public interface MySQLDatabaseConfiguration extends DatabaseConfiguration {
/**
* @return the jdbc url
*/
@ConfigurationPropertyGetter(name = "jdbc.url", defaultValue = "jdbc:mysql://localhost/l2jserver-gs")
String getJdbcUrl();
/**
* @param jdbcUrl
* the new jdbc url
*/
@ConfigurationPropertySetter(name = "jdbc.url")
void setJdbcUrl(String jdbcUrl);
@ConfigurationPropertyGetter(name = "jdbc.username", defaultValue = "root")
String getUsername();
@ConfigurationPropertySetter(name = "jdbc.username")
void setUsername(String username);
@ConfigurationPropertyGetter(name = "jdbc.password")
String getPassword();
@ConfigurationPropertySetter(name = "jdbc.password")
void setPassword(String password);
}

View File

@@ -0,0 +1,16 @@
package com.l2jserver.service.game.script;
import com.l2jserver.model.world.capability.Scriptable;
public interface Script<O extends Scriptable> extends Runnable {
/**
* Load this script for <tt>object</tt>
*
* @param object
*/
void load(O object);
void unload();
O getObject();
}

View File

@@ -0,0 +1,7 @@
package com.l2jserver.service.game.script;
import com.l2jserver.service.Service;
public interface ScriptingService extends Service {
}

View File

@@ -0,0 +1,25 @@
package com.l2jserver.service.game.template;
import com.l2jserver.model.id.TemplateID;
import com.l2jserver.model.template.AbstractTemplate;
import com.l2jserver.service.Service;
public interface TemplateService extends Service {
/**
* Get the template assigned with <tt>id</tt>
*
* @param id
* the template id
* @return the template matching the id
*/
AbstractTemplate getTemplate(TemplateID id);
/**
* Recompile the template with id <tt>id</tt>. This can be used to reload
* the template.
*
* @param id
* the template id
*/
void recompile(TemplateID id);
}

View File

@@ -0,0 +1,8 @@
package com.l2jserver.service.game.world;
import com.l2jserver.model.world.AbstractObject;
import com.l2jserver.model.world.event.WorldEvent;
public interface WorldEventDispatcher {
void dispatch(AbstractObject object, WorldEvent event);
}

View File

@@ -0,0 +1,22 @@
package com.l2jserver.service.game.world;
import com.l2jserver.model.world.WorldObject;
import com.l2jserver.service.Service;
public interface WorldService extends Service, Iterable<WorldObject> {
/**
* Register a new {@link WorldObject} to the service.
*
* @param object
* the object
*/
void register(WorldObject object);
/**
* Removes an registered {@link WorldObject} from the service.
*
* @param object
* the object
*/
void unregister(WorldObject object);
}

View File

@@ -0,0 +1,47 @@
package com.l2jserver.service.game.world;
import java.util.Iterator;
import java.util.Set;
import com.l2jserver.model.world.WorldObject;
import com.l2jserver.model.world.filter.WorldFilter;
import com.l2jserver.service.ServiceStartException;
import com.l2jserver.service.ServiceStopException;
public class WorldServiceImpl implements WorldService {
private Set<WorldObject> objects;
@Override
public void start() throws ServiceStartException {
// TODO Auto-generated method stub
}
@Override
public void register(WorldObject object) {
// TODO Auto-generated method stub
}
@Override
public void unregister(WorldObject object) {
// TODO Auto-generated method stub
}
@Override
public Iterator<WorldObject> iterator() {
return objects.iterator();
}
public <T extends WorldObject> Iterator<T> iterator(WorldFilter<T> filter) {
//return objects.iterator();
return null;
}
@Override
public void stop() throws ServiceStopException {
// TODO Auto-generated method stub
}
}

View File

@@ -0,0 +1,19 @@
package com.l2jserver.service.logging;
public class JdkLogger implements Logger {
private final java.util.logging.Logger logger;
public JdkLogger(java.util.logging.Logger logger) {
this.logger = logger;
}
@Override
public void info(String message) {
logger.info(message);
}
@Override
public void info(String message, Exception e) {
logger.info(message);
}
}

View File

@@ -0,0 +1,26 @@
package com.l2jserver.service.logging;
import java.util.logging.LogManager;
import com.l2jserver.service.ServiceStartException;
import com.l2jserver.service.ServiceStopException;
public class JdkLoggingService implements LoggingService {
@Override
public void start() throws ServiceStartException {
// TODO Auto-generated method stub
}
@Override
public Logger getLogger(Class<?> clazz) {
return new JdkLogger(LogManager.getLogManager().getLogger(
clazz.getName()));
}
@Override
public void stop() throws ServiceStopException {
// TODO Auto-generated method stub
}
}

View File

@@ -0,0 +1,7 @@
package com.l2jserver.service.logging;
public interface Logger {
void info(String message);
void info(String message, Exception e);
}

View File

@@ -0,0 +1,7 @@
package com.l2jserver.service.logging;
import com.l2jserver.service.Service;
public interface LoggingService extends Service {
Logger getLogger(Class<?> clazz);
}

View File

@@ -0,0 +1,23 @@
package com.l2jserver.service.network;
import com.google.inject.Inject;
import com.l2jserver.service.configuration.ConfigurationService;
public class NettyNetworkService implements NetworkService {
private final NetworkConfiguration config;
@Inject
public NettyNetworkService(ConfigurationService configService) {
this.config = configService.get(NetworkConfiguration.class);
}
@Override
public void start() {
}
@Override
public void stop() {
}
}

View File

@@ -0,0 +1,29 @@
package com.l2jserver.service.network;
import java.net.InetSocketAddress;
import com.l2jserver.service.configuration.Configuration;
import com.l2jserver.service.configuration.Configuration.ConfigurationName;
import com.l2jserver.service.configuration.Configuration.ConfigurationPrefix;
@ConfigurationName("network")
@ConfigurationPrefix("net")
public interface NetworkConfiguration extends Configuration {
// TODO set default value
/**
* Get the server listen address
*
* @return the listen address
*/
@ConfigurationPropertyGetter(name = "listen", defaultValue = "0.0.0.0:54")
InetSocketAddress getListenAddress();
/**
* Set the server listen address
*
* @param addr
* the listen address
*/
@ConfigurationPropertySetter(name = "listen")
void setListenAddress(InetSocketAddress addr);
}

View File

@@ -0,0 +1,7 @@
package com.l2jserver.service.network;
import com.l2jserver.service.Service;
public interface NetworkService extends Service {
}