You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2008/06/01 09:42:34 UTC
svn commit: r662161 -
/geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/application/DefaultApplicationManager.java
Author: jdillon
Date: Sun Jun 1 00:42:34 2008
New Revision: 662161
URL: http://svn.apache.org/viewvc?rev=662161&view=rev
Log:
Use a real proxy
Modified:
geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/application/DefaultApplicationManager.java
Modified: geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/application/DefaultApplicationManager.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/application/DefaultApplicationManager.java?rev=662161&r1=662160&r2=662161&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/application/DefaultApplicationManager.java (original)
+++ geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/application/DefaultApplicationManager.java Sun Jun 1 00:42:34 2008
@@ -19,7 +19,6 @@
package org.apache.geronimo.gshell.application;
-import org.apache.geronimo.gshell.settings.SettingsManager;
import org.apache.geronimo.gshell.artifact.ArtifactManager;
import org.apache.geronimo.gshell.io.IO;
import org.apache.geronimo.gshell.model.application.Application;
@@ -32,8 +31,8 @@
import org.apache.geronimo.gshell.plexus.GShellPlexusContainer;
import org.apache.geronimo.gshell.plugin.CommandCollector;
import org.apache.geronimo.gshell.plugin.CommandDiscoverer;
+import org.apache.geronimo.gshell.settings.SettingsManager;
import org.apache.geronimo.gshell.shell.Environment;
-import org.apache.geronimo.gshell.shell.ShellInfo;
import org.apache.geronimo.gshell.shell.Shell;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
@@ -56,6 +55,9 @@
import org.slf4j.LoggerFactory;
import java.io.File;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
import java.net.URL;
import java.util.HashSet;
import java.util.LinkedHashSet;
@@ -320,44 +322,21 @@
log.debug("Created shell instance: {}", shell);
- //
- // FIXME: Use a real proxy, so we can add generic interception muck to handle security muck and whatever ?
- // or shall we use an aspect to handle this muck?
- //
-
- Shell proxy = new Shell() {
- public void run(final Object... args) throws Exception {
- shell.run(args);
- }
-
- public ShellInfo getShellInfo() {
- return shell.getShellInfo();
- }
-
- public boolean isInteractive() {
- return shell.isInteractive();
- }
-
- public Environment getEnvironment() {
- return shell.getEnvironment();
- }
-
- public Object execute(String line) throws Exception {
- return shell.execute(line);
- }
-
- public Object execute(String command, Object[] args) throws Exception {
- return shell.execute(command, args);
- }
-
- public Object execute(Object... args) throws Exception {
- return shell.execute(args);
- }
+ InvocationHandler handler = new InvocationHandler()
+ {
+ public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
+ if (method.getDeclaringClass() == Object.class) {
+ return method.invoke(proxy, args);
+ }
- public Object execute(Object[][] commands) throws Exception {
- return shell.execute(commands);
+ // TODO: Add security handling?
+
+ return method.invoke(shell, args);
}
};
+
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ Shell proxy = (Shell) Proxy.newProxyInstance(cl, new Class[] { Shell.class }, handler);
log.debug("Create shell proxy: {}", proxy);