forked from I2P_Developers/i2p.i2p
JettyStart: Cleanup, replace Resource with File
This commit is contained in:
@@ -18,6 +18,8 @@ import java.io.IOException;
|
||||
// limitations under the License.
|
||||
// ========================================================================
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
@@ -36,7 +38,6 @@ import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.NetworkConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.component.LifeCycle;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
|
||||
/**
|
||||
@@ -54,6 +55,7 @@ public class JettyStart implements ClientApp {
|
||||
private final ClientAppManager _mgr;
|
||||
private final String[] _args;
|
||||
private final List<LifeCycle> _jettys;
|
||||
// warning, may be null if called from main
|
||||
private final I2PAppContext _context;
|
||||
private volatile ClientAppState _state;
|
||||
private volatile int _port;
|
||||
@@ -82,23 +84,18 @@ public class JettyStart implements ClientApp {
|
||||
public void parseArgs(String[] args) throws Exception {
|
||||
Properties properties=new Properties();
|
||||
XmlConfiguration last=null;
|
||||
Resource r = null;
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
File f = new File(args[i]);
|
||||
if (args[i].toLowerCase().endsWith(".properties")) {
|
||||
InputStream in = null;
|
||||
try {
|
||||
r = Resource.newResource(args[i]);
|
||||
properties.load(r.getInputStream());
|
||||
in = new FileInputStream(f);
|
||||
properties.load(in);
|
||||
} finally {
|
||||
if (r != null) r.close();
|
||||
if (in != null) try { in.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
} else {
|
||||
URL configUrl;
|
||||
try {
|
||||
r = Resource.newResource(args[i]);
|
||||
configUrl = r.getURL();
|
||||
} finally {
|
||||
if (r != null) r.close();
|
||||
}
|
||||
URL configUrl = f.toURI().toURL();
|
||||
XmlConfiguration configuration = new XmlConfiguration(configUrl);
|
||||
if (last!=null)
|
||||
configuration.getIdMap().putAll(last.getIdMap());
|
||||
|
||||
Reference in New Issue
Block a user