Skip to content

Commit

Permalink
Gets rid of command cache
Browse files Browse the repository at this point in the history
vsalaman committed Sep 26, 2012
1 parent 794dbb5 commit 5915576
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions jpos/src/main/java/org/jpos/q2/CLICommandInterface.java
Original file line number Diff line number Diff line change
@@ -9,13 +9,11 @@
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.WeakHashMap;

public class CLICommandInterface
{
CLIContext ctx;
List<String> prefixes = new ArrayList<String>();
WeakHashMap<String, Object> commandCache = new WeakHashMap<String, Object>(100);

public List<String> getPrefixes()
{
@@ -88,23 +86,8 @@ else if (cmd instanceof CLICommand)

private Object getCommand(String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException
{
Object cmd = commandCache.get(className);
if (cmd == null)
{
Class<?> clazz = getClazz(className);
final Object o = clazz.newInstance();
if (o instanceof Command || o instanceof CLICommand)
{
commandCache.put(className, o);
cmd = o;
}
}
return cmd;
}

private Class<?> getClazz(String className) throws ClassNotFoundException
{
return Thread.currentThread().getContextClassLoader().loadClass(className);
final ClassLoader cl = Thread.currentThread().getContextClassLoader();
return cl.loadClass(className).newInstance();
}

private String[] parseCommand(String line) throws IOException

0 comments on commit 5915576

Please sign in to comment.