// Path: rsimulator-core/src/main/java/com/github/bjuvensjo/rsimulator/core/config/CoreModule.java
// public class CoreModule extends AbstractModule {
//     private final Logger log = LoggerFactory.getLogger(CoreModule.class);
//     private static final CacheManager cacheManager = CacheManager.create();
// 
//     @Provides
//     @Named("rsimulator-core-properties")
//     java.util.Properties provideProperties() {
//         java.util.Properties properties = new java.util.Properties();
//         URL resource = getClass().getResource("/rsimulator.properties");
//         if (resource == null) {
//             properties.setProperty("simulatorCache", "false");
//             properties.setProperty("ignoreXmlNamespaces", "false");
//         } else {
//             try (BufferedInputStream bis = new BufferedInputStream(resource.openStream())) {
//                 properties.load(bis);
//             } catch (Exception e) {
//                 log.error("Error reading properties from: {}", resource.getPath(), e);
//             }
//         }
//         return properties;
//     }
// 
//     @Override
//     protected void configure() {
//         MapBinder<String, Handler> map = MapBinder.newMapBinder(binder(), String.class, Handler.class);
//         map.addBinding("json").to(JsonHandler.class);
//         map.addBinding("txt").to(TxtHandler.class);
//         map.addBinding("xml").to(XmlHandler.class);
// 
//         // ***** Interceptors for cache and script *****
//         Arrays.asList("SimulatorCache", "FileUtilsCache", "PropsCache").forEach(name ->
//                 bind(net.sf.ehcache.Cache.class).annotatedWith(Names.named(name)).toInstance(cacheManager.getCache(name)));
// 
// 
//         SimulatorPropertiesInterceptor simulatorPropertiesInterceptor = new SimulatorPropertiesInterceptor();
//         SimulatorCacheInterceptor simulatorCacheInterceptor = new SimulatorCacheInterceptor();
//         SimulatorScriptInterceptor simulatorScriptInterceptor = new SimulatorScriptInterceptor();
//         FileUtilsCacheInterceptor fileUtilsCacheInterceptor = new FileUtilsCacheInterceptor();
//         PropsCacheInterceptor propsCacheInterceptor = new PropsCacheInterceptor();
// 
//         requestInjection(simulatorPropertiesInterceptor);
//         requestInjection(simulatorCacheInterceptor);
//         requestInjection(simulatorScriptInterceptor);
//         requestInjection(fileUtilsCacheInterceptor);
//         requestInjection(propsCacheInterceptor);
// 
//         // Order is significant
//         bindInterceptor(Matchers.subclassesOf(Simulator.class), Matchers.annotatedWith(Properties.class),
//                 simulatorPropertiesInterceptor);
//         bindInterceptor(Matchers.subclassesOf(Simulator.class), Matchers.annotatedWith(Cache.class),
//                 simulatorCacheInterceptor);
//         bindInterceptor(Matchers.subclassesOf(Simulator.class), Matchers.annotatedWith(Script.class),
//                 simulatorScriptInterceptor);
//         bindInterceptor(Matchers.subclassesOf(FileUtils.class), Matchers.annotatedWith(Cache.class),
//                 fileUtilsCacheInterceptor);
//         bindInterceptor(Matchers.subclassesOf(Props.class), Matchers.annotatedWith(Cache.class),
//                 propsCacheInterceptor);
//     }
// }
// 
// Path: rsimulator-socket/src/main/java/com/github/bjuvensjo/rsimulator/socket/config/GlobalConfig.java
// public class GlobalConfig {
//     public static int port;
//     public static String rootPath;
//     public static boolean useRootRelativePath;
// 
//     static {
//         port = System.getProperty(Constants.PORT) != null ? Integer.parseInt(System
//                 .getProperty(Constants.PORT)) : Constants.DEFAULT_PORT;
// 
//         rootPath = System.getProperty(Constants.ROOT_PATH) != null ? System.getProperty(Constants.ROOT_PATH)
//                 : Constants.DEFAULT_ROOT_PATH;
// 
//         useRootRelativePath = System.getProperty(Constants.USE_ROOT_RELATIVE_PATH) != null && "true".equals(System
//                 .getProperty(Constants.USE_ROOT_RELATIVE_PATH));
//     }
// 
//     private GlobalConfig() {
//         // noop
//     }
// }
// 
// Path: rsimulator-socket/src/main/java/com/github/bjuvensjo/rsimulator/socket/config/SocketModule.java
// public class SocketModule extends AbstractModule {
// 
//     /*
//      * (non-Javadoc)
//      *
//      * @see com.google.inject.AbstractModule#configure()
//      */
//     @Override
//     protected void configure() {
//         bind(new TypeLiteral<String>() {
//         }).annotatedWith(Names.named("simulatorContentType")).toInstance("txt");
// 
//         bind(new TypeLiteral<String>() {
//         }).annotatedWith(Names.named("encoding")).toInstance("Cp278");
// 
//         bind(new TypeLiteral<Integer>() {
//         }).annotatedWith(Names.named("headerLength")).toInstance(48);
// 
//         bind(new TypeLiteral<Integer>() {
//         }).annotatedWith(Names.named("headerBodyLengthBeginIndex")).toInstance(4);
// 
//         bind(new TypeLiteral<Integer>() {
//         }).annotatedWith(Names.named("headerBodyLengthEndIndex")).toInstance(8);
//     }
// }


import com.github.bjuvensjo.rsimulator.core.config.CoreModule;
import com.github.bjuvensjo.rsimulator.socket.config.GlobalConfig;
import com.github.bjuvensjo.rsimulator.socket.config.SocketModule;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
package com.github.bjuvensjo.rsimulator.socket;



/**
 * SocketSimulator.
 */
public class SocketSimulator {
    private static final Logger log = LoggerFactory.getLogger(SocketSimulator.class);

    @Inject
    private Manager manager;

    public SocketSimulator() {
// Path: rsimulator-core/src/main/java/com/github/bjuvensjo/rsimulator/core/config/CoreModule.java
// public class CoreModule extends AbstractModule {
//     private final Logger log = LoggerFactory.getLogger(CoreModule.class);
//     private static final CacheManager cacheManager = CacheManager.create();
// 
//     @Provides
//     @Named("rsimulator-core-properties")
//     java.util.Properties provideProperties() {
//         java.util.Properties properties = new java.util.Properties();
//         URL resource = getClass().getResource("/rsimulator.properties");
//         if (resource == null) {
//             properties.setProperty("simulatorCache", "false");
//             properties.setProperty("ignoreXmlNamespaces", "false");
//         } else {
//             try (BufferedInputStream bis = new BufferedInputStream(resource.openStream())) {
//                 properties.load(bis);
//             } catch (Exception e) {
//                 log.error("Error reading properties from: {}", resource.getPath(), e);
//             }
//         }
//         return properties;
//     }
// 
//     @Override
//     protected void configure() {
//         MapBinder<String, Handler> map = MapBinder.newMapBinder(binder(), String.class, Handler.class);
//         map.addBinding("json").to(JsonHandler.class);
//         map.addBinding("txt").to(TxtHandler.class);
//         map.addBinding("xml").to(XmlHandler.class);
// 
//         // ***** Interceptors for cache and script *****
//         Arrays.asList("SimulatorCache", "FileUtilsCache", "PropsCache").forEach(name ->
//                 bind(net.sf.ehcache.Cache.class).annotatedWith(Names.named(name)).toInstance(cacheManager.getCache(name)));
// 
// 
//         SimulatorPropertiesInterceptor simulatorPropertiesInterceptor = new SimulatorPropertiesInterceptor();
//         SimulatorCacheInterceptor simulatorCacheInterceptor = new SimulatorCacheInterceptor();
//         SimulatorScriptInterceptor simulatorScriptInterceptor = new SimulatorScriptInterceptor();
//         FileUtilsCacheInterceptor fileUtilsCacheInterceptor = new FileUtilsCacheInterceptor();
//         PropsCacheInterceptor propsCacheInterceptor = new PropsCacheInterceptor();
// 
//         requestInjection(simulatorPropertiesInterceptor);
//         requestInjection(simulatorCacheInterceptor);
//         requestInjection(simulatorScriptInterceptor);
//         requestInjection(fileUtilsCacheInterceptor);
//         requestInjection(propsCacheInterceptor);
// 
//         // Order is significant
//         bindInterceptor(Matchers.subclassesOf(Simulator.class), Matchers.annotatedWith(Properties.class),
//                 simulatorPropertiesInterceptor);
//         bindInterceptor(Matchers.subclassesOf(Simulator.class), Matchers.annotatedWith(Cache.class),
//                 simulatorCacheInterceptor);
//         bindInterceptor(Matchers.subclassesOf(Simulator.class), Matchers.annotatedWith(Script.class),
//                 simulatorScriptInterceptor);
//         bindInterceptor(Matchers.subclassesOf(FileUtils.class), Matchers.annotatedWith(Cache.class),
//                 fileUtilsCacheInterceptor);
//         bindInterceptor(Matchers.subclassesOf(Props.class), Matchers.annotatedWith(Cache.class),
//                 propsCacheInterceptor);
//     }
// }
// 
// Path: rsimulator-socket/src/main/java/com/github/bjuvensjo/rsimulator/socket/config/GlobalConfig.java
// public class GlobalConfig {
//     public static int port;
//     public static String rootPath;
//     public static boolean useRootRelativePath;
// 
//     static {
//         port = System.getProperty(Constants.PORT) != null ? Integer.parseInt(System
//                 .getProperty(Constants.PORT)) : Constants.DEFAULT_PORT;
// 
//         rootPath = System.getProperty(Constants.ROOT_PATH) != null ? System.getProperty(Constants.ROOT_PATH)
//                 : Constants.DEFAULT_ROOT_PATH;
// 
//         useRootRelativePath = System.getProperty(Constants.USE_ROOT_RELATIVE_PATH) != null && "true".equals(System
//                 .getProperty(Constants.USE_ROOT_RELATIVE_PATH));
//     }
// 
//     private GlobalConfig() {
//         // noop
//     }
// }
// 
// Path: rsimulator-socket/src/main/java/com/github/bjuvensjo/rsimulator/socket/config/SocketModule.java
// public class SocketModule extends AbstractModule {
// 
//     /*
//      * (non-Javadoc)
//      *
//      * @see com.google.inject.AbstractModule#configure()
//      */
//     @Override
//     protected void configure() {
//         bind(new TypeLiteral<String>() {
//         }).annotatedWith(Names.named("simulatorContentType")).toInstance("txt");
// 
//         bind(new TypeLiteral<String>() {
//         }).annotatedWith(Names.named("encoding")).toInstance("Cp278");
// 
//         bind(new TypeLiteral<Integer>() {
//         }).annotatedWith(Names.named("headerLength")).toInstance(48);
// 
//         bind(new TypeLiteral<Integer>() {
//         }).annotatedWith(Names.named("headerBodyLengthBeginIndex")).toInstance(4);
// 
//         bind(new TypeLiteral<Integer>() {
//         }).annotatedWith(Names.named("headerBodyLengthEndIndex")).toInstance(8);
//     }
// }


// Path: rsimulator-socket/src/main/java/com/github/bjuvensjo/rsimulator/socket/SocketSimulator.java
import com.github.bjuvensjo.rsimulator.core.config.CoreModule;
import com.github.bjuvensjo.rsimulator.socket.config.GlobalConfig;
import com.github.bjuvensjo.rsimulator.socket.config.SocketModule;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

package com.github.bjuvensjo.rsimulator.socket;



/**
 * SocketSimulator.
 */
public class SocketSimulator {
    private static final Logger log = LoggerFactory.getLogger(SocketSimulator.class);

    @Inject
    private Manager manager;

    public SocketSimulator() {
        Injector injector = Guice.createInjector(new CoreModule(), new SocketModule());