From ed702f7ab0178ed92311c0ff2b71e0d138eace8a Mon Sep 17 00:00:00 2001 From: Rogiel Date: Tue, 13 Sep 2011 00:22:16 -0300 Subject: [PATCH] Server code and files reorganization --- config/database.properties | 26 +++ config/template.properties | 15 ++ config/vfs.properties | 14 ++ dist/config/database.properties | 31 +++- dist/config/template.properties | 12 ++ dist/config/vfs.properties | 11 ++ .../com/l2jserver/model/dao/CharacterDAO.java | 2 +- .../model/dao/CharacterFriendDAO.java | 2 +- .../l2jserver/model/dao/ChatMessageDAO.java | 2 +- .../java/com/l2jserver/model/dao/ClanDAO.java | 2 +- .../java/com/l2jserver/model/dao/ItemDAO.java | 2 +- .../java/com/l2jserver/model/dao/NPCDAO.java | 2 +- .../java/com/l2jserver/model/dao/PetDAO.java | 2 +- .../l2jserver/model/world/AbstractObject.java | 2 +- .../com/l2jserver/model/world/Player.java | 2 +- .../core/vfs/Java7VFSConfiguration.java | 25 --- .../service/core/vfs/Java7VFSService.java | 8 + .../service/core/vfs/VFSConfiguration.java | 45 ------ .../service/core/vfs/VFSService.java | 25 +++ .../database/DatabaseConfiguration.java | 31 ---- .../service/database/DatabaseService.java | 12 ++ .../database/JDBCDatabaseConfiguration.java | 115 -------------- .../service/database/JDBCDatabaseService.java | 149 +++++++++++++++--- .../game/template/TemplateException.java | 37 ----- .../game/template/XMLTemplateService.java | 12 ++ .../XMLTemplateServiceConfiguration.java | 31 ---- .../service/network/NetworkConfiguration.java | 48 ------ .../service/network/NetworkService.java | 30 ++++ 28 files changed, 326 insertions(+), 369 deletions(-) delete mode 100644 src/main/java/com/l2jserver/service/core/vfs/Java7VFSConfiguration.java delete mode 100644 src/main/java/com/l2jserver/service/core/vfs/VFSConfiguration.java delete mode 100644 src/main/java/com/l2jserver/service/database/DatabaseConfiguration.java delete mode 100644 src/main/java/com/l2jserver/service/database/JDBCDatabaseConfiguration.java delete mode 100644 src/main/java/com/l2jserver/service/game/template/TemplateException.java delete mode 100644 src/main/java/com/l2jserver/service/game/template/XMLTemplateServiceConfiguration.java delete mode 100644 src/main/java/com/l2jserver/service/network/NetworkConfiguration.java diff --git a/config/database.properties b/config/database.properties index 591ab9f9a..84f8d02f1 100644 --- a/config/database.properties +++ b/config/database.properties @@ -1,4 +1,30 @@ +# --------------------------------------------------------------------------- +# JDBCDatabaseService configuration +# --------------------------------------------------------------------------- +# Parameters in this file are used by JDBCDatabaseService. +# If you are not sure on the usage of any parameter, read the "Configuration" +# section in wiki article about "JDBCDatabaseService". +# https://github.com/l2jserver2/ +# --------------------------------------------------------------------------- +# NOTE: this is the development configuration file. Always remember to add +# new parameters to "dist/config" files too! +# --------------------------------------------------------------------------- + +# This defines the connection URL used by JDBC to connect to the database. +# Default: jdbc:mysql://localhost/l2jserver2 jdbc.url = jdbc:mysql://localhost/l2jserver2 + +# The driver used to connect to the database. Please note that the driver +# library must be available in the JVM classpath. +# Default: com.mysql.jdbc.Driver in MySQL binary distribution or +# org.h2.Driver in H2 binary distribution jdbc.driver = com.mysql.jdbc.Driver + +# The username used to login into the database. +# NOTE: Try not use "root" in production servers! +# Default: l2j jdbc.username = l2j + +# The password used to login into the database. +# Default: changeme jdbc.password = changeme \ No newline at end of file diff --git a/config/template.properties b/config/template.properties index b431db32e..e90d854b6 100644 --- a/config/template.properties +++ b/config/template.properties @@ -1 +1,16 @@ +# --------------------------------------------------------------------------- +# XMLTemplateService configuration +# --------------------------------------------------------------------------- +# Parameters in this file are used by XMLTemplateService. +# If you are not sure on the usage of any parameter, read the "Configuration" +# section in wiki article about "XMLTemplateService". +# https://github.com/l2jserver2/ +# --------------------------------------------------------------------------- +# NOTE: this is the development configuration file. Always remember to add +# new parameters to "dist/config" files too! +# --------------------------------------------------------------------------- + +# The directory in which templates are located. All template files must be +# in .xml # file format. Must be relative to 'vfs.root' (vfs.properties) +# Default: data/templates template.directory = data/templates \ No newline at end of file diff --git a/config/vfs.properties b/config/vfs.properties index 2f6df2fab..2512df5d6 100644 --- a/config/vfs.properties +++ b/config/vfs.properties @@ -1 +1,15 @@ +# --------------------------------------------------------------------------- +# Java7VFSService configuration +# --------------------------------------------------------------------------- +# Parameters in this file are used by Java7VFSService. +# If you are not sure on the usage of any parameter, read the "Configuration" +# section in wiki article about "Java7VFSService". +# https://github.com/l2jserver2/ +# --------------------------------------------------------------------------- +# NOTE: this is the development configuration file. Always remember to add +# new parameters to "dist/config" files too! +# --------------------------------------------------------------------------- + +# The root of the VFS, any file placed in "/" will go to specified path. +# Defaul: (will inherit from terminal working directory, if any) vfs.root = \ No newline at end of file diff --git a/dist/config/database.properties b/dist/config/database.properties index 6bacfe2f5..232669a63 100644 --- a/dist/config/database.properties +++ b/dist/config/database.properties @@ -1,4 +1,27 @@ -jdbc.mysql.url = jdbc:mysql://localhost/l2jserver2 -jdbc.mysql.driver = com.mysql.jdbc.Driver -jdbc.mysql.username = l2j -jdbc.mysql.password = changeme \ No newline at end of file +# --------------------------------------------------------------------------- +# JDBCDatabaseService configuration +# --------------------------------------------------------------------------- +# Parameters in this file are used by JDBCDatabaseService. +# If you are not sure on the usage of any parameter, read the "Configuration" +# section in wiki article about "JDBCDatabaseService". +# https://github.com/l2jserver2/ +# --------------------------------------------------------------------------- + +# This defines the connection URL used by JDBC to connect to the database. +# Default: jdbc:mysql://localhost/l2jserver2 +jdbc.url = jdbc:mysql://localhost/l2jserver2 + +# The driver used to connect to the database. Please note that the driver +# library must be available in the JVM classpath. +# Default: com.mysql.jdbc.Driver in MySQL binary distribution or +# org.h2.Driver in H2 binary distribution +jdbc.driver = com.mysql.jdbc.Driver + +# The username used to login into the database. +# NOTE: Try not use "root" in production servers! +# Default: +jdbc.username = l2j + +# The password used to login into the database. +# Default: +jdbc.password = changeme \ No newline at end of file diff --git a/dist/config/template.properties b/dist/config/template.properties index b431db32e..c1d5e0e48 100644 --- a/dist/config/template.properties +++ b/dist/config/template.properties @@ -1 +1,13 @@ +# --------------------------------------------------------------------------- +# XMLTemplateService configuration +# --------------------------------------------------------------------------- +# Parameters in this file are used by XMLTemplateService. +# If you are not sure on the usage of any parameter, read the "Configuration" +# section in wiki article about "XMLTemplateService". +# https://github.com/l2jserver2/ +# --------------------------------------------------------------------------- + +# The directory in which templates are located. All template files must be +# in .xml # file format. Must be relative to 'vfs.root' (vfs.properties) +# Default: data/templates template.directory = data/templates \ No newline at end of file diff --git a/dist/config/vfs.properties b/dist/config/vfs.properties index 2f6df2fab..7d96566d5 100644 --- a/dist/config/vfs.properties +++ b/dist/config/vfs.properties @@ -1 +1,12 @@ +# --------------------------------------------------------------------------- +# Java7VFSService configuration +# --------------------------------------------------------------------------- +# Parameters in this file are used by Java7VFSService. +# If you are not sure on the usage of any parameter, read the "Configuration" +# section in wiki article about "Java7VFSService". +# https://github.com/l2jserver2/ +# --------------------------------------------------------------------------- + +# The root of the VFS, any file placed in "/" will go to specified path. +# Defaul: (will inherit from terminal working directory, if any) vfs.root = \ No newline at end of file diff --git a/src/main/java/com/l2jserver/model/dao/CharacterDAO.java b/src/main/java/com/l2jserver/model/dao/CharacterDAO.java index 4f3c61de0..b4f91f465 100644 --- a/src/main/java/com/l2jserver/model/dao/CharacterDAO.java +++ b/src/main/java/com/l2jserver/model/dao/CharacterDAO.java @@ -29,7 +29,7 @@ import com.l2jserver.service.database.DataAccessObject; * The {@link CharacterDAO} is can load and save {@link Character character * instances} . * - * @author Rogiel + * @author Rogiel */ public interface CharacterDAO extends DataAccessObject, Cacheable { diff --git a/src/main/java/com/l2jserver/model/dao/CharacterFriendDAO.java b/src/main/java/com/l2jserver/model/dao/CharacterFriendDAO.java index bf578ed13..19740fd6c 100644 --- a/src/main/java/com/l2jserver/model/dao/CharacterFriendDAO.java +++ b/src/main/java/com/l2jserver/model/dao/CharacterFriendDAO.java @@ -28,7 +28,7 @@ import com.l2jserver.service.database.DataAccessObject; * The {@link CharacterFriendDAO} is can load and save * {@link CharacterFriendList character friend list}. * - * @author Rogiel + * @author Rogiel */ public interface CharacterFriendDAO extends DataAccessObject, Cacheable { diff --git a/src/main/java/com/l2jserver/model/dao/ChatMessageDAO.java b/src/main/java/com/l2jserver/model/dao/ChatMessageDAO.java index 7570034c2..a4e614517 100644 --- a/src/main/java/com/l2jserver/model/dao/ChatMessageDAO.java +++ b/src/main/java/com/l2jserver/model/dao/ChatMessageDAO.java @@ -25,7 +25,7 @@ import com.l2jserver.service.database.DataAccessObject; * The {@link ChatMessageDAO} is can load and save {@link ChatMessage chat * messages}. * - * @author Rogiel + * @author Rogiel */ public interface ChatMessageDAO extends DataAccessObject, Cacheable { diff --git a/src/main/java/com/l2jserver/model/dao/ClanDAO.java b/src/main/java/com/l2jserver/model/dao/ClanDAO.java index e27f69acc..43fa7ee4c 100644 --- a/src/main/java/com/l2jserver/model/dao/ClanDAO.java +++ b/src/main/java/com/l2jserver/model/dao/ClanDAO.java @@ -24,7 +24,7 @@ import com.l2jserver.service.database.DataAccessObject; /** * The {@link ClanDAO} is can load and save {@link Clan clan instances}. * - * @author Rogiel + * @author Rogiel */ public interface ClanDAO extends DataAccessObject, Cacheable { } diff --git a/src/main/java/com/l2jserver/model/dao/ItemDAO.java b/src/main/java/com/l2jserver/model/dao/ItemDAO.java index e0e7c18b3..b39a58f4f 100644 --- a/src/main/java/com/l2jserver/model/dao/ItemDAO.java +++ b/src/main/java/com/l2jserver/model/dao/ItemDAO.java @@ -26,7 +26,7 @@ import com.l2jserver.service.database.DataAccessObject; * The {@link ItemDAO} is can load and save {@link Character character * instances} . * - * @author Rogiel + * @author Rogiel */ public interface ItemDAO extends DataAccessObject, Cacheable { /** diff --git a/src/main/java/com/l2jserver/model/dao/NPCDAO.java b/src/main/java/com/l2jserver/model/dao/NPCDAO.java index 39cd04e3b..2245e966a 100644 --- a/src/main/java/com/l2jserver/model/dao/NPCDAO.java +++ b/src/main/java/com/l2jserver/model/dao/NPCDAO.java @@ -28,7 +28,7 @@ import com.l2jserver.service.database.DataAccessObject; /** * The {@link NPCDAO} is can load and save {@link NPC NPC instances}. * - * @author Rogiel + * @author Rogiel */ public interface NPCDAO extends DataAccessObject, Cacheable { /** diff --git a/src/main/java/com/l2jserver/model/dao/PetDAO.java b/src/main/java/com/l2jserver/model/dao/PetDAO.java index d6a94d813..9c6b481e7 100644 --- a/src/main/java/com/l2jserver/model/dao/PetDAO.java +++ b/src/main/java/com/l2jserver/model/dao/PetDAO.java @@ -24,7 +24,7 @@ import com.l2jserver.service.database.DataAccessObject; /** * The {@link PetDAO} is can load and save {@link Pet pet instances}. * - * @author Rogiel + * @author Rogiel */ public interface PetDAO extends DataAccessObject, Cacheable { } diff --git a/src/main/java/com/l2jserver/model/world/AbstractObject.java b/src/main/java/com/l2jserver/model/world/AbstractObject.java index 08368349f..525389b3e 100644 --- a/src/main/java/com/l2jserver/model/world/AbstractObject.java +++ b/src/main/java/com/l2jserver/model/world/AbstractObject.java @@ -22,7 +22,7 @@ import com.l2jserver.model.id.ObjectID; /** * This is an abstract object representing all the world objects in Lineage II. * - * @author Rogiel + * @author Rogiel */ public abstract class AbstractObject extends AbstractModel> implements WorldObject { diff --git a/src/main/java/com/l2jserver/model/world/Player.java b/src/main/java/com/l2jserver/model/world/Player.java index 5bd9d9eb5..7a9308d11 100644 --- a/src/main/java/com/l2jserver/model/world/Player.java +++ b/src/main/java/com/l2jserver/model/world/Player.java @@ -22,7 +22,7 @@ import com.l2jserver.model.id.template.ActorTemplateID; * {@link Player} is any object that can be controlled by the player. The most * common implementation is {@link L2Character}. * - * @author Rogiel + * @author Rogiel */ public abstract class Player extends Actor { public Player(ActorTemplateID templateID) { diff --git a/src/main/java/com/l2jserver/service/core/vfs/Java7VFSConfiguration.java b/src/main/java/com/l2jserver/service/core/vfs/Java7VFSConfiguration.java deleted file mode 100644 index 82345af0a..000000000 --- a/src/main/java/com/l2jserver/service/core/vfs/Java7VFSConfiguration.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * This file is part of l2jserver . - * - * l2jserver 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. - * - * l2jserver 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 l2jserver. If not, see . - */ -package com.l2jserver.service.core.vfs; - -/** - * Configuration interface for {@link Java7VFSService}. - * - * @author Rogiel - */ -public interface Java7VFSConfiguration extends VFSConfiguration { -} diff --git a/src/main/java/com/l2jserver/service/core/vfs/Java7VFSService.java b/src/main/java/com/l2jserver/service/core/vfs/Java7VFSService.java index b844f1ac7..12b5ec3ae 100644 --- a/src/main/java/com/l2jserver/service/core/vfs/Java7VFSService.java +++ b/src/main/java/com/l2jserver/service/core/vfs/Java7VFSService.java @@ -54,6 +54,14 @@ public class Java7VFSService extends AbstractService implements VFSService { */ private Path root; + /** + * Configuration interface for {@link Java7VFSService}. + * + * @author Rogiel + */ + public interface Java7VFSConfiguration extends VFSConfiguration { + } + @Inject protected Java7VFSService(final ConfigurationService configService) { this.config = configService.get(Java7VFSConfiguration.class); diff --git a/src/main/java/com/l2jserver/service/core/vfs/VFSConfiguration.java b/src/main/java/com/l2jserver/service/core/vfs/VFSConfiguration.java deleted file mode 100644 index a22f0fabc..000000000 --- a/src/main/java/com/l2jserver/service/core/vfs/VFSConfiguration.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This file is part of l2jserver . - * - * l2jserver 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. - * - * l2jserver 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 l2jserver. If not, see . - */ -package com.l2jserver.service.core.vfs; - -import java.net.URI; -import java.nio.file.Path; - -import com.l2jserver.service.configuration.Configuration; -import com.l2jserver.service.configuration.Configuration.ConfigurationName; - -/** - * VFS service configuration - * - * @author Rogiel - * @see Configuration - */ -@ConfigurationName("vfs") -public interface VFSConfiguration extends Configuration { - /** - * @return the VFS root {@link URI} - */ - @ConfigurationPropertyGetter(name = "vfs.root", defaultValue = "") - Path getRoot(); - - /** - * @param root - * the new VFS root {@link URI} - */ - @ConfigurationPropertySetter(name = "vfs.root") - void setRoot(Path root); -} diff --git a/src/main/java/com/l2jserver/service/core/vfs/VFSService.java b/src/main/java/com/l2jserver/service/core/vfs/VFSService.java index 86ba08379..52f1994bb 100644 --- a/src/main/java/com/l2jserver/service/core/vfs/VFSService.java +++ b/src/main/java/com/l2jserver/service/core/vfs/VFSService.java @@ -16,9 +16,12 @@ */ package com.l2jserver.service.core.vfs; +import java.net.URI; import java.nio.file.Path; import com.l2jserver.service.Service; +import com.l2jserver.service.configuration.Configuration; +import com.l2jserver.service.configuration.Configuration.ConfigurationName; /** * The VFS service is responsible for creating a Virtual File System that is @@ -27,6 +30,28 @@ import com.l2jserver.service.Service; * @author Rogiel */ public interface VFSService extends Service { + /** + * VFS service configuration + * + * @author Rogiel + * @see Configuration + */ + @ConfigurationName("vfs") + public interface VFSConfiguration extends Configuration { + /** + * @return the VFS root {@link URI} + */ + @ConfigurationPropertyGetter(name = "vfs.root", defaultValue = "") + Path getRoot(); + + /** + * @param root + * the new VFS root {@link URI} + */ + @ConfigurationPropertySetter(name = "vfs.root") + void setRoot(Path root); + } + /** * Resolves an file. If the file cannot be resolved, null will be returned. *

diff --git a/src/main/java/com/l2jserver/service/database/DatabaseConfiguration.java b/src/main/java/com/l2jserver/service/database/DatabaseConfiguration.java deleted file mode 100644 index 4e0730ff7..000000000 --- a/src/main/java/com/l2jserver/service/database/DatabaseConfiguration.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * This file is part of l2jserver . - * - * l2jserver 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. - * - * l2jserver 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 l2jserver. If not, see . - */ -package com.l2jserver.service.database; - -import com.l2jserver.service.configuration.Configuration; -import com.l2jserver.service.configuration.Configuration.ConfigurationName; - -/** - * Database service configuration - * - * @author Rogiel - * @see Configuration - */ -@ConfigurationName("database") -public interface DatabaseConfiguration extends Configuration { - -} diff --git a/src/main/java/com/l2jserver/service/database/DatabaseService.java b/src/main/java/com/l2jserver/service/database/DatabaseService.java index 0d749d071..b6666f42f 100644 --- a/src/main/java/com/l2jserver/service/database/DatabaseService.java +++ b/src/main/java/com/l2jserver/service/database/DatabaseService.java @@ -19,6 +19,8 @@ package com.l2jserver.service.database; import com.l2jserver.model.Model; import com.l2jserver.model.id.ID; import com.l2jserver.service.Service; +import com.l2jserver.service.configuration.Configuration; +import com.l2jserver.service.configuration.Configuration.ConfigurationName; /** * This service provides access to an database implementation. Each @@ -36,6 +38,16 @@ import com.l2jserver.service.Service; * @author Rogiel */ public interface DatabaseService extends Service { + /** + * Database service configuration + * + * @author Rogiel + * @see Configuration + */ + @ConfigurationName("database") + public interface DatabaseConfiguration extends Configuration { + } + , I extends ID> DataAccessObject getDAO( Class model); } diff --git a/src/main/java/com/l2jserver/service/database/JDBCDatabaseConfiguration.java b/src/main/java/com/l2jserver/service/database/JDBCDatabaseConfiguration.java deleted file mode 100644 index e5ebdcd98..000000000 --- a/src/main/java/com/l2jserver/service/database/JDBCDatabaseConfiguration.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * This file is part of l2jserver . - * - * l2jserver 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. - * - * l2jserver 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 l2jserver. If not, see . - */ -package com.l2jserver.service.database; - -/** - * Configuration interface for {@link JDBCDatabaseService}. - * - * @author Rogiel - */ -public interface JDBCDatabaseConfiguration extends DatabaseConfiguration { - /** - * @return the jdbc url - */ - @ConfigurationPropertyGetter(name = "jdbc.url", defaultValue = "jdbc:mysql://localhost/l2jserver2") - String getJdbcUrl(); - - /** - * @param jdbcUrl - * the new jdbc url - */ - @ConfigurationPropertySetter(name = "jdbc.url") - void setJdbcUrl(String jdbcUrl); - - /** - * @return the jdbc driver class - */ - @ConfigurationPropertyGetter(name = "jdbc.driver", defaultValue = "com.jdbc.jdbc.Driver") - String getDriver(); - - /** - * @param driver - * the new jdbc driver - */ - @ConfigurationPropertySetter(name = "jdbc.driver") - void setDriver(Class driver); - - /** - * @return the jdbc database username - */ - @ConfigurationPropertyGetter(name = "jdbc.username", defaultValue = "l2j") - String getUsername(); - - /** - * @param username - * the jdbc database username - */ - @ConfigurationPropertySetter(name = "jdbc.username") - void setUsername(String username); - - /** - * @return the jdbc database password - */ - @ConfigurationPropertyGetter(name = "jdbc.password", defaultValue = "changeme") - String getPassword(); - - /** - * @param password - * the jdbc database password - */ - @ConfigurationPropertySetter(name = "jdbc.password") - void setPassword(String password); - - /** - * @return the maximum number of active connections - */ - @ConfigurationPropertyGetter(name = "jdbc.active.max", defaultValue = "20") - int getMaxActiveConnections(); - - /** - * @param password - * the maximum number of active connections - */ - @ConfigurationPropertySetter(name = "jdbc.active.max") - void setMaxActiveConnections(int password); - - /** - * @return the maximum number of idle connections - */ - @ConfigurationPropertyGetter(name = "jdbc.idle.max", defaultValue = "20") - int getMaxIdleConnections(); - - /** - * @param password - * the maximum number of idle connections - */ - @ConfigurationPropertySetter(name = "jdbc.idle.max") - void setMaxIdleConnections(int password); - - /** - * @return the minimum number of idle connections - */ - @ConfigurationPropertyGetter(name = "jdbc.idle.min", defaultValue = "5") - int getMinIdleConnections(); - - /** - * @param password - * the minimum number of idle connections - */ - @ConfigurationPropertySetter(name = "jdbc.idle.min") - void setMinIdleConnections(int password); -} diff --git a/src/main/java/com/l2jserver/service/database/JDBCDatabaseService.java b/src/main/java/com/l2jserver/service/database/JDBCDatabaseService.java index d3ccf5520..987063937 100644 --- a/src/main/java/com/l2jserver/service/database/JDBCDatabaseService.java +++ b/src/main/java/com/l2jserver/service/database/JDBCDatabaseService.java @@ -145,6 +145,104 @@ public class JDBCDatabaseService extends AbstractService implements */ private ScheduledAsyncFuture autoSaveFuture; + /** + * Configuration interface for {@link JDBCDatabaseService}. + * + * @author Rogiel + */ + public interface JDBCDatabaseConfiguration extends DatabaseConfiguration { + /** + * @return the jdbc url + */ + @ConfigurationPropertyGetter(name = "jdbc.url", defaultValue = "jdbc:mysql://localhost/l2jserver2") + String getJdbcUrl(); + + /** + * @param jdbcUrl + * the new jdbc url + */ + @ConfigurationPropertySetter(name = "jdbc.url") + void setJdbcUrl(String jdbcUrl); + + /** + * @return the jdbc driver class + */ + @ConfigurationPropertyGetter(name = "jdbc.driver", defaultValue = "com.jdbc.jdbc.Driver") + String getDriver(); + + /** + * @param driver + * the new jdbc driver + */ + @ConfigurationPropertySetter(name = "jdbc.driver") + void setDriver(Class driver); + + /** + * @return the jdbc database username + */ + @ConfigurationPropertyGetter(name = "jdbc.username", defaultValue = "l2j") + String getUsername(); + + /** + * @param username + * the jdbc database username + */ + @ConfigurationPropertySetter(name = "jdbc.username") + void setUsername(String username); + + /** + * @return the jdbc database password + */ + @ConfigurationPropertyGetter(name = "jdbc.password", defaultValue = "changeme") + String getPassword(); + + /** + * @param password + * the jdbc database password + */ + @ConfigurationPropertySetter(name = "jdbc.password") + void setPassword(String password); + + /** + * @return the maximum number of active connections + */ + @ConfigurationPropertyGetter(name = "jdbc.active.max", defaultValue = "20") + int getMaxActiveConnections(); + + /** + * @param password + * the maximum number of active connections + */ + @ConfigurationPropertySetter(name = "jdbc.active.max") + void setMaxActiveConnections(int password); + + /** + * @return the maximum number of idle connections + */ + @ConfigurationPropertyGetter(name = "jdbc.idle.max", defaultValue = "20") + int getMaxIdleConnections(); + + /** + * @param password + * the maximum number of idle connections + */ + @ConfigurationPropertySetter(name = "jdbc.idle.max") + void setMaxIdleConnections(int password); + + /** + * @return the minimum number of idle connections + */ + @ConfigurationPropertyGetter(name = "jdbc.idle.min", defaultValue = "5") + int getMinIdleConnections(); + + /** + * @param password + * the minimum number of idle connections + */ + @ConfigurationPropertySetter(name = "jdbc.idle.min") + void setMinIdleConnections(int password); + } + @Inject public JDBCDatabaseService(ConfigurationService configService, Injector injector, CacheService cacheService, @@ -331,7 +429,7 @@ public class JDBCDatabaseService extends AbstractService implements */ private final Logger log = LoggerFactory .getLogger(InsertUpdateQuery.class); - + private final Iterator iterator; /** @@ -358,24 +456,25 @@ public class JDBCDatabaseService extends AbstractService implements @Override public Integer query(Connection conn) throws SQLException { Preconditions.checkNotNull(conn, "conn"); - + log.debug("Starting INSERT/UPDATE query execution"); - + int rows = 0; while (iterator.hasNext()) { final T object = iterator.next(); final String queryString = query(); - + log.debug("Preparing statement for {}: {}", object, queryString); final PreparedStatement st = conn.prepareStatement(queryString, Statement.RETURN_GENERATED_KEYS); - + log.debug("Parametizing statement {} with {}", st, object); this.parametize(st, object); - + log.debug("Sending query to database for {}", object); rows += st.executeUpdate(); - log.debug("Query inserted or updated {} rows for {}", rows, object); + log.debug("Query inserted or updated {} rows for {}", rows, + object); // update object desire --it has been realized if (object instanceof Model && rows > 0) { @@ -386,10 +485,12 @@ public class JDBCDatabaseService extends AbstractService implements if (mapper == null) continue; final ResultSet rs = st.getGeneratedKeys(); - log.debug("Mapping generated keys with {} using {}", mapper, rs); + log.debug("Mapping generated keys with {} using {}", + mapper, rs); while (rs.next()) { final ID generatedID = mapper.map(rs); - log.debug("Generated ID for {} is {}", object, generatedID); + log.debug("Generated ID for {} is {}", object, + generatedID); ((Model>) object).setID(generatedID); mapper.map(rs); } @@ -444,23 +545,23 @@ public class JDBCDatabaseService extends AbstractService implements */ private final Logger log = LoggerFactory .getLogger(SelectListQuery.class); - + @Override public List query(Connection conn) throws SQLException { Preconditions.checkNotNull(conn, "conn"); - + log.debug("Starting SELECT List query execution"); - + final String queryString = query(); log.debug("Preparing statement with {}", queryString); final PreparedStatement st = conn.prepareStatement(query()); - + log.debug("Parametizing statement {}", st); parametize(st); - + log.debug("Sending query to database for {}", st); st.execute(); - + final List list = CollectionFactory.newList(); final ResultSet rs = st.getResultSet(); final Mapper mapper = mapper(); @@ -526,23 +627,23 @@ public class JDBCDatabaseService extends AbstractService implements */ private final Logger log = LoggerFactory .getLogger(SelectSingleQuery.class); - + @Override public T query(Connection conn) throws SQLException { Preconditions.checkNotNull(conn, "conn"); - + log.debug("Starting SELECT single query execution"); - + final String queryString = query(); log.debug("Preparing statement with {}", queryString); final PreparedStatement st = conn.prepareStatement(query()); - + log.debug("Parametizing statement {}", st); parametize(st); - + log.debug("Sending query to database for {}", st); st.execute(); - + final ResultSet rs = st.getResultSet(); final Mapper mapper = mapper(); log.debug("Database returned {}", rs); @@ -630,7 +731,7 @@ public class JDBCDatabaseService extends AbstractService implements */ private final Logger log = LoggerFactory .getLogger(SelectSingleQuery.class); - + /** * The database service instance */ @@ -655,12 +756,12 @@ public class JDBCDatabaseService extends AbstractService implements log.debug("Mapping row {} ID with {}", rs, idMapper); final I id = idMapper.map(rs); Preconditions.checkNotNull(id, "id"); - + log.debug("ID={}, locating cached object", id); if (database.hasCachedObject(id)) return (T) database.getCachedObject(id); - + log.debug("Cached object not found, creating..."); final T object = map(id, rs); diff --git a/src/main/java/com/l2jserver/service/game/template/TemplateException.java b/src/main/java/com/l2jserver/service/game/template/TemplateException.java deleted file mode 100644 index c2b473dff..000000000 --- a/src/main/java/com/l2jserver/service/game/template/TemplateException.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This file is part of l2jserver . - * - * l2jserver 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. - * - * l2jserver 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 l2jserver. If not, see . - */ -package com.l2jserver.service.game.template; - -public class TemplateException extends RuntimeException { - private static final long serialVersionUID = 1L; - - public TemplateException() { - super(); - } - - public TemplateException(String message, Throwable cause) { - super(message, cause); - } - - public TemplateException(String message) { - super(message); - } - - public TemplateException(Throwable cause) { - super(cause); - } -} diff --git a/src/main/java/com/l2jserver/service/game/template/XMLTemplateService.java b/src/main/java/com/l2jserver/service/game/template/XMLTemplateService.java index b634fd13a..cce233c98 100644 --- a/src/main/java/com/l2jserver/service/game/template/XMLTemplateService.java +++ b/src/main/java/com/l2jserver/service/game/template/XMLTemplateService.java @@ -18,6 +18,7 @@ package com.l2jserver.service.game.template; import java.io.IOException; import java.io.InputStream; +import java.net.URI; import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; @@ -52,6 +53,8 @@ import com.l2jserver.service.ServiceStartException; import com.l2jserver.service.ServiceStopException; import com.l2jserver.service.cache.Cache; import com.l2jserver.service.cache.CacheService; +import com.l2jserver.service.configuration.Configuration; +import com.l2jserver.service.configuration.Configuration.ConfigurationName; import com.l2jserver.service.configuration.ConfigurationService; import com.l2jserver.service.core.LoggingService; import com.l2jserver.service.core.vfs.VFSService; @@ -82,6 +85,15 @@ public class XMLTemplateService extends AbstractService implements @SuppressWarnings("rawtypes") private Cache templates; + + @ConfigurationName("template") + public interface XMLTemplateServiceConfiguration extends Configuration { + @ConfigurationPropertyGetter(name = "template.directory", defaultValue = "data/templates") + URI getTemplateDirectory(); + + @ConfigurationPropertySetter(name = "template.directory") + void setTemplateDirectory(URI file); + } @Inject public XMLTemplateService(final VFSService vfsService, diff --git a/src/main/java/com/l2jserver/service/game/template/XMLTemplateServiceConfiguration.java b/src/main/java/com/l2jserver/service/game/template/XMLTemplateServiceConfiguration.java deleted file mode 100644 index d784a67f2..000000000 --- a/src/main/java/com/l2jserver/service/game/template/XMLTemplateServiceConfiguration.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * This file is part of l2jserver . - * - * l2jserver 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. - * - * l2jserver 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 l2jserver. If not, see . - */ -package com.l2jserver.service.game.template; - -import java.net.URI; - -import com.l2jserver.service.configuration.Configuration; -import com.l2jserver.service.configuration.Configuration.ConfigurationName; - -@ConfigurationName("template") -public interface XMLTemplateServiceConfiguration extends Configuration { - @ConfigurationPropertyGetter(name = "template.directory", defaultValue = "data/templates") - URI getTemplateDirectory(); - - @ConfigurationPropertySetter(name = "template.directory") - void setTemplateDirectory(URI file); -} diff --git a/src/main/java/com/l2jserver/service/network/NetworkConfiguration.java b/src/main/java/com/l2jserver/service/network/NetworkConfiguration.java deleted file mode 100644 index 053a6ebbb..000000000 --- a/src/main/java/com/l2jserver/service/network/NetworkConfiguration.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This file is part of l2jserver . - * - * l2jserver 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. - * - * l2jserver 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 l2jserver. If not, see . - */ -package com.l2jserver.service.network; - -import java.net.InetSocketAddress; - -import com.l2jserver.service.configuration.Configuration; -import com.l2jserver.service.configuration.Configuration.ConfigurationName; - -/** - * The network {@link Configuration} - * - * @author Rogiel - */ -@ConfigurationName("network") -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:7777") - InetSocketAddress getListenAddress(); - - /** - * Set the server listen address - * - * @param addr - * the listen address - */ - @ConfigurationPropertySetter(name = "listen") - void setListenAddress(InetSocketAddress addr); -} diff --git a/src/main/java/com/l2jserver/service/network/NetworkService.java b/src/main/java/com/l2jserver/service/network/NetworkService.java index e70829eca..514690ae5 100644 --- a/src/main/java/com/l2jserver/service/network/NetworkService.java +++ b/src/main/java/com/l2jserver/service/network/NetworkService.java @@ -16,6 +16,8 @@ */ package com.l2jserver.service.network; +import java.net.InetSocketAddress; + import com.l2jserver.game.net.Lineage2Client; import com.l2jserver.game.net.Lineage2Session; import com.l2jserver.game.net.packet.ClientPacket; @@ -23,6 +25,8 @@ import com.l2jserver.game.net.packet.ServerPacket; import com.l2jserver.model.id.object.CharacterID; import com.l2jserver.model.world.L2Character; import com.l2jserver.service.Service; +import com.l2jserver.service.configuration.Configuration; +import com.l2jserver.service.configuration.Configuration.ConfigurationName; /** * The network service is responsible for communicating the server with the game @@ -61,6 +65,32 @@ import com.l2jserver.service.Service; * @author Rogiel */ public interface NetworkService extends Service { + /** + * The network {@link Configuration} + * + * @author Rogiel + */ + @ConfigurationName("network") + public interface NetworkConfiguration extends Configuration { + /** + * Get the server listen address + * + * @return the listen address + */ + @ConfigurationPropertyGetter(name = "listen", defaultValue = "0.0.0.0:7777") + InetSocketAddress getListenAddress(); + + /** + * Set the server listen address + * + * @param addr + * the listen address + */ + @ConfigurationPropertySetter(name = "listen") + void setListenAddress(InetSocketAddress addr); + } + + /** * Registers a new client *