blob: 1fd5cad04db07df0a470f44d183e5fea69cfb7dc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.core;
import com.google.inject.Module;
import com.yahoo.jdisc.application.ContainerBuilder;
import com.yahoo.jdisc.application.OsgiFramework;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
/**
* @author simon
*/
public class Main {
static OsgiFramework newOsgiFramework() {
String cachePath = System.getProperty("jdisc.cache.path");
if (cachePath == null) {
throw new IllegalStateException("System property 'jdisc.cache.path' not set.");
}
FelixParams params = new FelixParams()
.setCachePath(cachePath)
.setLoggerEnabled(Boolean.valueOf(System.getProperty("jdisc.logger.enabled", "true")));
for (String str : ContainerBuilder.safeStringSplit(System.getProperty("jdisc.export.packages"), ",")) {
params.exportPackage(str);
}
return new FelixFramework(params);
}
static Iterable<Module> newConfigModule() {
String configFile = System.getProperty("jdisc.config.file");
if (configFile == null) {
return Collections.emptyList();
}
Module configModule;
try {
configModule = ApplicationConfigModule.newInstanceFromFile(configFile);
} catch (IOException e) {
throw new IllegalStateException("Exception thrown while reading config file '" + configFile + "'.", e);
}
return Arrays.asList(configModule);
}
}
|