| Nils Diewald | 40996d8 | 2015-02-26 22:23:52 +0000 | [diff] [blame] | 1 | package de.ids_mannheim.korap.server; |
| Nils Diewald | 32030a6 | 2014-09-03 20:16:50 +0000 | [diff] [blame] | 2 | |
| Nils Diewald | f04e100 | 2014-09-24 22:52:59 +0000 | [diff] [blame] | 3 | import java.util.*; |
| 4 | import java.io.*; |
| Marc Kupietz | fb6f4d4 | 2015-03-06 12:17:09 +0100 | [diff] [blame] | 5 | import java.net.URL; |
| Nils Diewald | f04e100 | 2014-09-24 22:52:59 +0000 | [diff] [blame] | 6 | |
| Nils Diewald | 32030a6 | 2014-09-03 20:16:50 +0000 | [diff] [blame] | 7 | import org.glassfish.grizzly.http.server.HttpServer; |
| 8 | import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; |
| 9 | import org.glassfish.jersey.server.ResourceConfig; |
| 10 | |
| Nils Diewald | f6b351c | 2014-09-04 21:34:05 +0000 | [diff] [blame] | 11 | import org.slf4j.Logger; |
| 12 | import org.slf4j.LoggerFactory; |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 13 | import java.util.logging.LogManager; |
| 14 | import org.slf4j.bridge.SLF4JBridgeHandler; |
| Nils Diewald | f6b351c | 2014-09-04 21:34:05 +0000 | [diff] [blame] | 15 | |
| Nils Diewald | 32030a6 | 2014-09-03 20:16:50 +0000 | [diff] [blame] | 16 | import java.net.URI; |
| Nils Diewald | f04e100 | 2014-09-24 22:52:59 +0000 | [diff] [blame] | 17 | import java.beans.PropertyVetoException; |
| Nils Diewald | 32030a6 | 2014-09-03 20:16:50 +0000 | [diff] [blame] | 18 | |
| Nils Diewald | a14ecd6 | 2015-02-26 21:00:20 +0000 | [diff] [blame] | 19 | import de.ids_mannheim.korap.KrillIndex; |
| Nils Diewald | f6b351c | 2014-09-04 21:34:05 +0000 | [diff] [blame] | 20 | import org.apache.lucene.store.MMapDirectory; |
| 21 | |
| Nils Diewald | f04e100 | 2014-09-24 22:52:59 +0000 | [diff] [blame] | 22 | import com.mchange.v2.c3p0.*; |
| Nils Diewald | f6b351c | 2014-09-04 21:34:05 +0000 | [diff] [blame] | 23 | |
| Nils Diewald | 32030a6 | 2014-09-03 20:16:50 +0000 | [diff] [blame] | 24 | /** |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 25 | * Standalone REST-Service for the Krill node. |
| 26 | * Reads a property file at <tt>krill.properties</tt>. |
| 27 | * Defaults to port <tt>9876</tt> if no information is given, |
| 28 | * and an unprotected in-memory SQLite database for collections. |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 29 | * |
| Nils Diewald | c99ed5b | 2015-01-21 22:08:53 +0000 | [diff] [blame] | 30 | * @author diewald |
| Nils Diewald | 32030a6 | 2014-09-03 20:16:50 +0000 | [diff] [blame] | 31 | */ |
| Nils Diewald | 40996d8 | 2015-02-26 22:23:52 +0000 | [diff] [blame] | 32 | public class Node { |
| Nils Diewald | 32030a6 | 2014-09-03 20:16:50 +0000 | [diff] [blame] | 33 | |
| 34 | // Base URI the Grizzly HTTP server will listen on |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 35 | public static String BASE_URI = "http://localhost:9876/"; |
| 36 | private static String propFile = "krill.properties"; |
| 37 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 38 | |
| Nils Diewald | f6b351c | 2014-09-04 21:34:05 +0000 | [diff] [blame] | 39 | // Logger |
| Nils Diewald | 40996d8 | 2015-02-26 22:23:52 +0000 | [diff] [blame] | 40 | private final static Logger log = LoggerFactory.getLogger(Node.class); |
| Nils Diewald | f6b351c | 2014-09-04 21:34:05 +0000 | [diff] [blame] | 41 | |
| 42 | // Index |
| Nils Diewald | a14ecd6 | 2015-02-26 21:00:20 +0000 | [diff] [blame] | 43 | private static KrillIndex index; |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 44 | |
| 45 | // Database |
| Nils Diewald | f04e100 | 2014-09-24 22:52:59 +0000 | [diff] [blame] | 46 | private static ComboPooledDataSource cpds; |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 47 | private static String path = null; |
| 48 | private static String name = "unknown"; |
| Nils Diewald | f04e100 | 2014-09-24 22:52:59 +0000 | [diff] [blame] | 49 | private static String dbUser, dbPwd; |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 50 | private static String dbClass = "org.sqlite.JDBC"; |
| 51 | private static String dbURL = "jdbc:sqlite:"; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 52 | |
| 53 | |
| Nils Diewald | 7cbcfe9 | 2014-09-22 22:01:51 +0000 | [diff] [blame] | 54 | /* |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 55 | * Todo: Close cdps.close() on shutdown. |
| Nils Diewald | 7cbcfe9 | 2014-09-22 22:01:51 +0000 | [diff] [blame] | 56 | * see: https://10.0.10.12/trac/korap/browser/KorAP-modules/KorAP-REST/src/main/java/de/ids_mannheim/korap/web/Application.java |
| 57 | * https://10.0.10.12/trac/korap/browser/KorAP-modules/KorAP-REST/src/main/java/de/ids_mannheim/korap/web/ShutdownHook.java |
| 58 | */ |
| 59 | |
| Nils Diewald | 32030a6 | 2014-09-03 20:16:50 +0000 | [diff] [blame] | 60 | /** |
| Nils Diewald | bbd39a5 | 2015-02-23 19:56:57 +0000 | [diff] [blame] | 61 | * Starts Grizzly HTTP server exposing JAX-RS |
| 62 | * resources defined in this application. |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 63 | * This will load a <tt>krill.properties</tt> property file. |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 64 | * |
| Nils Diewald | 32030a6 | 2014-09-03 20:16:50 +0000 | [diff] [blame] | 65 | * @return Grizzly HTTP server. |
| 66 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 67 | public static HttpServer startServer () { |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 68 | _loadResourceProperties(); |
| Nils Diewald | f04e100 | 2014-09-24 22:52:59 +0000 | [diff] [blame] | 69 | |
| Nils Diewald | 32030a6 | 2014-09-03 20:16:50 +0000 | [diff] [blame] | 70 | // create a resource config that scans for JAX-RS resources and providers |
| 71 | // in de.ids_mannheim.korap.server package |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 72 | final ResourceConfig rc = new ResourceConfig() |
| margaretha | b097bac | 2015-04-15 11:37:02 +0200 | [diff] [blame] | 73 | .packages("de.ids_mannheim.korap.server"); |
| Nils Diewald | 32030a6 | 2014-09-03 20:16:50 +0000 | [diff] [blame] | 74 | |
| 75 | // create and start a new instance of grizzly http server |
| 76 | // exposing the Jersey application at BASE_URI |
| margaretha | b097bac | 2015-04-15 11:37:02 +0200 | [diff] [blame] | 77 | return GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), |
| 78 | rc); |
| Nils Diewald | ff6f766 | 2014-09-21 15:08:52 +0000 | [diff] [blame] | 79 | }; |
| 80 | |
| margaretha | b097bac | 2015-04-15 11:37:02 +0200 | [diff] [blame] | 81 | |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 82 | /** |
| 83 | * Starts Grizzly HTTP server exposing JAX-RS |
| 84 | * resources defined in this application. |
| 85 | * Mainly used for testing. |
| 86 | * |
| margaretha | b097bac | 2015-04-15 11:37:02 +0200 | [diff] [blame] | 87 | * @param nodeName |
| 88 | * The name of the node. |
| 89 | * @param indexPath |
| 90 | * The path of the Lucene index. |
| 91 | * |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 92 | * @return Grizzly {@link HttpServer} server. |
| 93 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 94 | public static HttpServer startServer (String nodeName, String indexPath) { |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 95 | LogManager.getLogManager().reset(); |
| 96 | SLF4JBridgeHandler.install(); |
| Nils Diewald | ff6f766 | 2014-09-21 15:08:52 +0000 | [diff] [blame] | 97 | |
| 98 | // create a resource config that scans for JAX-RS resources and providers |
| 99 | // in de.ids_mannheim.korap.server package |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 100 | final ResourceConfig rc = new ResourceConfig() |
| 101 | .packages("de.ids_mannheim.korap.server"); |
| Nils Diewald | ff6f766 | 2014-09-21 15:08:52 +0000 | [diff] [blame] | 102 | |
| Nils Diewald | c99ed5b | 2015-01-21 22:08:53 +0000 | [diff] [blame] | 103 | name = nodeName; |
| 104 | path = indexPath; |
| Nils Diewald | ff6f766 | 2014-09-21 15:08:52 +0000 | [diff] [blame] | 105 | |
| 106 | // create and start a new instance of grizzly http server |
| 107 | // exposing the Jersey application at BASE_URI |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 108 | return GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), |
| 109 | rc); |
| Nils Diewald | ff6f766 | 2014-09-21 15:08:52 +0000 | [diff] [blame] | 110 | }; |
| 111 | |
| Nils Diewald | 32030a6 | 2014-09-03 20:16:50 +0000 | [diff] [blame] | 112 | |
| 113 | /** |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 114 | * Runner method for Krill node. |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 115 | * |
| margaretha | b097bac | 2015-04-15 11:37:02 +0200 | [diff] [blame] | 116 | * @param args |
| 117 | * No special arguments required. |
| Nils Diewald | 32030a6 | 2014-09-03 20:16:50 +0000 | [diff] [blame] | 118 | * @throws IOException |
| 119 | */ |
| Nils Diewald | bbd39a5 | 2015-02-23 19:56:57 +0000 | [diff] [blame] | 120 | public static void main (String[] args) throws IOException { |
| Nils Diewald | 979b2fe | 2014-09-29 16:21:41 +0000 | [diff] [blame] | 121 | |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 122 | // WADL available at BASE_URI + application.wadl |
| 123 | // Start the server with krill properties or given defaults |
| Nils Diewald | 32030a6 | 2014-09-03 20:16:50 +0000 | [diff] [blame] | 124 | final HttpServer server = startServer(); |
| Nils Diewald | 2f44c63 | 2014-09-29 19:46:55 +0000 | [diff] [blame] | 125 | |
| Nils Diewald | c99ed5b | 2015-01-21 22:08:53 +0000 | [diff] [blame] | 126 | // Establish shutdown hook |
| margaretha | b097bac | 2015-04-15 11:37:02 +0200 | [diff] [blame] | 127 | Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 128 | |
| margaretha | b097bac | 2015-04-15 11:37:02 +0200 | [diff] [blame] | 129 | @Override |
| 130 | public void run () { |
| 131 | log.info("Stop Server"); |
| 132 | server.stop(); |
| 133 | if (cpds != null) |
| 134 | cpds.close(); |
| 135 | }; |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 136 | |
| margaretha | b097bac | 2015-04-15 11:37:02 +0200 | [diff] [blame] | 137 | }, "shutdownHook")); |
| Nils Diewald | 2f44c63 | 2014-09-29 19:46:55 +0000 | [diff] [blame] | 138 | |
| Nils Diewald | c99ed5b | 2015-01-21 22:08:53 +0000 | [diff] [blame] | 139 | // Start server |
| 140 | try { |
| 141 | server.start(); |
| 142 | log.info("You may kill me gently with Ctrl+C"); |
| 143 | Thread.currentThread().join(); |
| 144 | } |
| 145 | catch (Exception e) { |
| 146 | log.error("Unable to start server: {}", e.getLocalizedMessage()); |
| 147 | }; |
| Nils Diewald | f6b351c | 2014-09-04 21:34:05 +0000 | [diff] [blame] | 148 | }; |
| Nils Diewald | 32030a6 | 2014-09-03 20:16:50 +0000 | [diff] [blame] | 149 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 150 | |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 151 | /** |
| 152 | * Get the name of the node. |
| 153 | * The name is unique in the cluster and should be persistent. |
| margaretha | b097bac | 2015-04-15 11:37:02 +0200 | [diff] [blame] | 154 | * |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 155 | * @return The unique name of the node. |
| 156 | */ |
| Nils Diewald | ff6f766 | 2014-09-21 15:08:52 +0000 | [diff] [blame] | 157 | public static String getName () { |
| Nils Diewald | c99ed5b | 2015-01-21 22:08:53 +0000 | [diff] [blame] | 158 | return name; |
| Nils Diewald | ff6f766 | 2014-09-21 15:08:52 +0000 | [diff] [blame] | 159 | }; |
| 160 | |
| Nils Diewald | 979b2fe | 2014-09-29 16:21:41 +0000 | [diff] [blame] | 161 | |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 162 | /** |
| 163 | * Get the URI (incl. port) the node is listening on. |
| margaretha | b097bac | 2015-04-15 11:37:02 +0200 | [diff] [blame] | 164 | * |
| 165 | * @return The URI the node is listening on. |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 166 | */ |
| Nils Diewald | f04e100 | 2014-09-24 22:52:59 +0000 | [diff] [blame] | 167 | public static String getListener () { |
| Nils Diewald | c99ed5b | 2015-01-21 22:08:53 +0000 | [diff] [blame] | 168 | return BASE_URI; |
| Nils Diewald | f04e100 | 2014-09-24 22:52:59 +0000 | [diff] [blame] | 169 | }; |
| 170 | |
| Nils Diewald | 979b2fe | 2014-09-29 16:21:41 +0000 | [diff] [blame] | 171 | |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 172 | /** |
| 173 | * Shut down the database pool. |
| 174 | */ |
| 175 | public static void closeDBPool () { |
| 176 | if (cpds != null) |
| 177 | cpds.close(); |
| 178 | }; |
| 179 | |
| 180 | |
| 181 | /** |
| 182 | * Get the associated database pool |
| 183 | * for match collection. |
| margaretha | b097bac | 2015-04-15 11:37:02 +0200 | [diff] [blame] | 184 | * |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 185 | * @return The CPDS {@link ComboPooledDataSource} object. |
| 186 | */ |
| Nils Diewald | f04e100 | 2014-09-24 22:52:59 +0000 | [diff] [blame] | 187 | public static ComboPooledDataSource getDBPool () { |
| Nils Diewald | 979b2fe | 2014-09-29 16:21:41 +0000 | [diff] [blame] | 188 | |
| Nils Diewald | c99ed5b | 2015-01-21 22:08:53 +0000 | [diff] [blame] | 189 | // Pool already initiated |
| 190 | if (cpds != null) |
| 191 | return cpds; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 192 | |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 193 | // Initiate pool |
| Nils Diewald | c99ed5b | 2015-01-21 22:08:53 +0000 | [diff] [blame] | 194 | try { |
| Nils Diewald | f04e100 | 2014-09-24 22:52:59 +0000 | [diff] [blame] | 195 | |
| Nils Diewald | c99ed5b | 2015-01-21 22:08:53 +0000 | [diff] [blame] | 196 | // Parameters are defined in the property file |
| 197 | cpds = new ComboPooledDataSource(); |
| 198 | cpds.setDriverClass(dbClass); |
| 199 | cpds.setJdbcUrl(dbURL); |
| 200 | if (dbUser != null) |
| 201 | cpds.setUser(dbUser); |
| 202 | if (dbPwd != null) |
| 203 | cpds.setPassword(dbPwd); |
| 204 | cpds.setMaxStatements(100); |
| 205 | return cpds; |
| 206 | } |
| 207 | catch (PropertyVetoException e) { |
| 208 | log.error(e.getLocalizedMessage()); |
| 209 | }; |
| 210 | return null; |
| Nils Diewald | f04e100 | 2014-09-24 22:52:59 +0000 | [diff] [blame] | 211 | }; |
| 212 | |
| 213 | |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 214 | /** |
| 215 | * Get the associuated {@link KrillIndex}. |
| margaretha | b097bac | 2015-04-15 11:37:02 +0200 | [diff] [blame] | 216 | * |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 217 | * @return The associated {@link KrillIndex}. |
| 218 | */ |
| Nils Diewald | a14ecd6 | 2015-02-26 21:00:20 +0000 | [diff] [blame] | 219 | public static KrillIndex getIndex () { |
| Nils Diewald | 979b2fe | 2014-09-29 16:21:41 +0000 | [diff] [blame] | 220 | |
| Nils Diewald | c99ed5b | 2015-01-21 22:08:53 +0000 | [diff] [blame] | 221 | // Index already instantiated |
| 222 | if (index != null) |
| 223 | return index; |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 224 | |
| 225 | try { |
| Nils Diewald | 979b2fe | 2014-09-29 16:21:41 +0000 | [diff] [blame] | 226 | |
| Nils Diewald | c99ed5b | 2015-01-21 22:08:53 +0000 | [diff] [blame] | 227 | // Get a temporary index |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 228 | if (path == null) { |
| 229 | |
| Nils Diewald | c99ed5b | 2015-01-21 22:08:53 +0000 | [diff] [blame] | 230 | // Temporary index |
| Nils Diewald | a14ecd6 | 2015-02-26 21:00:20 +0000 | [diff] [blame] | 231 | index = new KrillIndex(); |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 232 | } |
| Nils Diewald | f6b351c | 2014-09-04 21:34:05 +0000 | [diff] [blame] | 233 | |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 234 | // Get a MMap directory index |
| Nils Diewald | c99ed5b | 2015-01-21 22:08:53 +0000 | [diff] [blame] | 235 | else { |
| 236 | File file = new File(path); |
| Nils Diewald | ff6f766 | 2014-09-21 15:08:52 +0000 | [diff] [blame] | 237 | |
| Nils Diewald | c99ed5b | 2015-01-21 22:08:53 +0000 | [diff] [blame] | 238 | log.info("Loading index from {}", path); |
| 239 | if (!file.exists()) { |
| 240 | log.error("Index not found at {}", path); |
| 241 | return null; |
| 242 | }; |
| Nils Diewald | ff6f766 | 2014-09-21 15:08:52 +0000 | [diff] [blame] | 243 | |
| Nils Diewald | c99ed5b | 2015-01-21 22:08:53 +0000 | [diff] [blame] | 244 | // Set real index |
| Nils Diewald | a14ecd6 | 2015-02-26 21:00:20 +0000 | [diff] [blame] | 245 | index = new KrillIndex(new MMapDirectory(file)); |
| Nils Diewald | c99ed5b | 2015-01-21 22:08:53 +0000 | [diff] [blame] | 246 | }; |
| 247 | return index; |
| 248 | } |
| 249 | catch (IOException e) { |
| 250 | log.error("Index not loadable at {}: {}", path, e.getMessage()); |
| 251 | }; |
| 252 | return null; |
| Nils Diewald | f6b351c | 2014-09-04 21:34:05 +0000 | [diff] [blame] | 253 | }; |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 254 | |
| 255 | |
| 256 | // Load properties from file |
| 257 | private static Properties _loadProperties (String propFile) { |
| 258 | try { |
| 259 | InputStream file = new FileInputStream(propFile); |
| 260 | Properties prop = new Properties(); |
| 261 | prop.load(file); |
| 262 | |
| 263 | // Node properties |
| 264 | path = prop.getProperty("krill.indexDir", path); |
| 265 | name = prop.getProperty("krill.server.name", name); |
| 266 | BASE_URI = prop.getProperty("krill.server.baseURI", BASE_URI); |
| 267 | |
| 268 | // Database properties |
| 269 | dbUser = prop.getProperty("krill.db.user", dbUser); |
| 270 | dbPwd = prop.getProperty("krill.db.pwd", dbPwd); |
| 271 | dbClass = prop.getProperty("krill.db.class", dbClass); |
| 272 | dbURL = prop.getProperty("krill.db.jdbcURL", dbURL); |
| 273 | return prop; |
| 274 | } |
| 275 | catch (IOException e) { |
| 276 | log.error(e.getLocalizedMessage()); |
| 277 | }; |
| 278 | return null; |
| 279 | }; |
| 280 | |
| 281 | |
| 282 | // Load properties from resource file |
| 283 | private static Properties _loadResourceProperties () { |
| 284 | |
| 285 | // Load configuration |
| 286 | URL resUrl = Node.class.getClassLoader().getResource(propFile); |
| 287 | if (resUrl == null) { |
| margaretha | b097bac | 2015-04-15 11:37:02 +0200 | [diff] [blame] | 288 | log.error( |
| 289 | "Cannot find {}. Please create it using \"{}.info\" as template.", |
| 290 | propFile, propFile); |
| Marc Kupietz | a61d2ba | 2015-03-20 16:30:26 +0100 | [diff] [blame] | 291 | return null; |
| 292 | }; |
| 293 | |
| 294 | return _loadProperties(resUrl.getFile()); |
| 295 | }; |
| Nils Diewald | f6b351c | 2014-09-04 21:34:05 +0000 | [diff] [blame] | 296 | }; |