| | |
| | | package de.uhilger.mediaz; |
| | | |
| | | import com.sun.net.httpserver.HttpServer; |
| | | import de.uhilger.mediaz.api.AblageTestHandler; |
| | | import de.uhilger.mediaz.api.FileHandler; |
| | | import de.uhilger.mediaz.api.StopServerHandler; |
| | | import de.uhilger.mediaz.api.StorageHandler; |
| | | import de.uhilger.mediaz.api.StoreTestHandler; |
| | | import de.uhilger.mediaz.store.FileStorage; |
| | | import de.uhilger.mediaz.entity.Ablageort; |
| | | import java.io.File; |
| | |
| | | public static final String RB_STORE = "store"; |
| | | //public static final String RB_UI_ROOT = "uiroot"; |
| | | public static final String RB_STOP_SERVER = "stopServer"; |
| | | public static final String RB_ABLAGE_TEST = "testAblage"; |
| | | public static final String RB_STORE_TEST = "testStore"; |
| | | //public static final String RB_ABLAGE_TEST = "testAblage"; |
| | | //public static final String RB_STORE_TEST = "testStore"; |
| | | public static final String RB_SLASH = "slash"; |
| | | |
| | | private int port; |
| | |
| | | } |
| | | |
| | | /** |
| | | * Die Endpunkte ('Context'e) einrichten, unter denen die Dienste dieses |
| | | * Die Endpunkte einrichten, unter denen die Dienste dieses |
| | | * Servers erreichbar sein sollen und den Server starten |
| | | * |
| | | * @throws IOException wenn etwas schief geht, finden sich Angaben in diesem |
| | |
| | | server.createContext(ctx + App.getRs(RB_STORE), new StorageHandler()); |
| | | //server.createContext(ctx + App.getRs(RB_UI_ROOT), new FileHandler(uiDir.getAbsolutePath())); |
| | | server.createContext(ctx + App.getRs(RB_STOP_SERVER), new StopServerHandler()); |
| | | server.createContext(ctx + App.getRs(RB_ABLAGE_TEST), new AblageTestHandler()); |
| | | server.createContext(ctx + App.getRs(RB_STORE_TEST), new StoreTestHandler()); |
| | | //server.createContext(ctx + App.getRs(RB_ABLAGE_TEST), new AblageTestHandler()); |
| | | //server.createContext(ctx + App.getRs(RB_STORE_TEST), new StoreTestHandler()); |
| | | server.setExecutor(Executors.newFixedThreadPool(20)); |
| | | server.start(); |
| | | } |
| | |
| | | new FileHandler(new File(ablageort.getOrt()).getAbsolutePath())); |
| | | } |
| | | } |
| | | |
| | | /* |
| | | String conf = App.getInitParameter(App.getRs(App.RB_AP_CONF)); |
| | | File ablageortDir = new File(conf, Ablageort.class.getSimpleName()); |
| | | File[] orte = ablageortDir.listFiles(); |
| | | if (orte != null) { |
| | | for (File ort : orte) { |
| | | Entity elem = store.readFromFile(ort); |
| | | if (elem instanceof Ablageort) { |
| | | Ablageort ablageort = (Ablageort) elem; |
| | | server.createContext(ctx + ablageort.getUrl(), |
| | | new FileHandler(new File(ablageort.getOrt()).getAbsolutePath())); |
| | | } |
| | | } |
| | | } |
| | | */ |
| | | } |
| | | |
| | | } |