mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 16:35:45 +01:00
improve SubCommandHandler
This commit is contained in:
@@ -38,6 +38,7 @@ package sonia.scm.cli.cmd;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.ConfigurationException;
|
||||
import sonia.scm.util.IOUtil;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
@@ -47,6 +48,9 @@ import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -59,7 +63,7 @@ public class SubCommandHandler
|
||||
|
||||
/** Field description */
|
||||
public static final String RESOURCE_SERVICES =
|
||||
"/META-INF/services/".concat(SubCommand.class.getName());
|
||||
"META-INF/services/".concat(SubCommand.class.getName());
|
||||
|
||||
/** Field description */
|
||||
private static volatile SubCommandHandler instance;
|
||||
@@ -122,17 +126,16 @@ public class SubCommandHandler
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param url
|
||||
*/
|
||||
private void loadSubCommands()
|
||||
private void loadSubCommand(URL url)
|
||||
{
|
||||
BufferedReader reader = null;
|
||||
|
||||
try
|
||||
{
|
||||
reader = new BufferedReader(
|
||||
new InputStreamReader(
|
||||
SubCommandOptionHandler.class.getResourceAsStream(
|
||||
RESOURCE_SERVICES)));
|
||||
reader = new BufferedReader(new InputStreamReader(url.openStream()));
|
||||
|
||||
String line = reader.readLine();
|
||||
|
||||
@@ -152,6 +155,31 @@ public class SubCommandHandler
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*/
|
||||
private void loadSubCommands()
|
||||
{
|
||||
try
|
||||
{
|
||||
Enumeration<URL> enm =
|
||||
SubCommandHandler.class.getClassLoader().getResources(
|
||||
RESOURCE_SERVICES);
|
||||
|
||||
while (enm.hasMoreElements())
|
||||
{
|
||||
URL url = enm.nextElement();
|
||||
|
||||
loadSubCommand(url);
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
throw new ConfigurationException("could not load SubComamnds", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user