Skip to content

Commit

Permalink
Merge pull request jpos#16 from vsalaman/cci001
Browse files Browse the repository at this point in the history
Gets rid of command cache
  • Loading branch information
ar committed Sep 26, 2012
2 parents 794dbb5 + 5915576 commit 58ad0a8
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
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 58ad0a8

Please sign in to comment.