.
+ *
+ * l2jserver2 is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * l2jserver2 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with l2jserver2. If not, see .
+ */
+package com.l2jserver.service.core.vfs;
+
+import java.nio.file.Path;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.Inject;
+import com.l2jserver.service.AbstractService;
+import com.l2jserver.service.ServiceStartException;
+import com.l2jserver.service.ServiceStopException;
+import com.l2jserver.service.configuration.ConfigurationService;
+
+import de.schlichtherle.truezip.fs.FsSyncException;
+import de.schlichtherle.truezip.nio.file.TPath;
+
+/**
+ * Implementation of {@link VFSService} using default Java7 APIs.
+ *
+ * @author Rogiel
+ */
+public class TrueZipVFSService extends AbstractService implements VFSService {
+ /**
+ * The logger
+ */
+ private final Logger log = LoggerFactory.getLogger(this.getClass());
+
+ /**
+ * The Java 7 vfs configuration
+ */
+ private final TrueZipVFSConfiguration config;
+
+ /**
+ * The root {@link Path} of the server data
+ */
+ private TPath root;
+ /**
+ * The root for the "data" folder
+ */
+ private TPath dataRoot;
+
+ /**
+ * Configuration interface for {@link TrueZipVFSService}.
+ *
+ * @author Rogiel
+ */
+ public interface TrueZipVFSConfiguration extends VFSConfiguration {
+ }
+
+ /**
+ * @param configService
+ * the configuration service
+ */
+ @Inject
+ protected TrueZipVFSService(final ConfigurationService configService) {
+ this.config = configService.get(TrueZipVFSConfiguration.class);
+ }
+
+ @Override
+ protected void doStart() throws ServiceStartException {
+ root = new TPath(config.getRoot().toAbsolutePath());
+ log.debug("Root path is {}", root);
+
+ dataRoot = root.resolve(config.getDataPath());
+ log.debug("Data root path is {}", root);
+ }
+
+ @Override
+ public Path resolve(String path) {
+ log.debug("Resolving file {}", path);
+ return root.resolve(path);
+ }
+
+ @Override
+ public Path resolveDataFile(String path) {
+ log.debug("Resolving data file {}", path);
+ return dataRoot.resolve(path);
+ }
+
+ @Override
+ protected void doStop() throws ServiceStopException {
+ try {
+ root.getFileSystem().close();
+ } catch (FsSyncException e) {
+ throw new ServiceStopException(e);
+ } finally {
+ root = null;
+ dataRoot = null;
+ }
+ }
+}
diff --git a/l2jserver2-common/src/main/java/com/l2jserver/service/core/vfs/VFSService.java b/l2jserver2-common/src/main/java/com/l2jserver/service/core/vfs/VFSService.java
index 80c6e29fe..bfb5bcca6 100644
--- a/l2jserver2-common/src/main/java/com/l2jserver/service/core/vfs/VFSService.java
+++ b/l2jserver2-common/src/main/java/com/l2jserver/service/core/vfs/VFSService.java
@@ -52,12 +52,27 @@ public interface VFSService extends Service {
@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.
*
- * Please note that event if the file DOES NOT exists a valid object will be
+ * Please note that even if the file DOES NOT exists a valid object will be
* returned.
*
* @param path
@@ -65,4 +80,17 @@ public interface VFSService extends Service {
* @return the resolved file. Will return null if could not resolve.
*/
Path resolve(String path);
+
+ /**
+ * Resolves an file inside the data storage file system. If the file cannot
+ * be resolved, null will be returned.
+ *
+ * Please note that, differently from {@link #resolve(String)}, if the file
+ * does not exists, null is returned.
+ *
+ * @param path
+ * the file path as an string
+ * @return the resolved file. Will return null if could not resolve.
+ */
+ Path resolveDataFile(String path);
}
diff --git a/l2jserver2-gameserver/config/config.xml b/l2jserver2-gameserver/config/config.xml
index f2fc211c6..731d4d22b 100644
--- a/l2jserver2-gameserver/config/config.xml
+++ b/l2jserver2-gameserver/config/config.xml
@@ -73,7 +73,11 @@
sure on the usage of any parameter, read the "Configuration" section in wiki
article about VFSService. -->
+
+
+
+ ./data