pier 2004/05/04 10:47:08
Modified: src/kernel/org/apache/cocoon/kernel ProxyWire.java
Log:
Adapting ProxyWire to new Component interface.
Fixed bug preventing the proxy instance to be configured with the correct
interfaces.
Revision Changes Path
1.6 +8 -22
cocoon-2.2/src/kernel/org/apache/cocoon/kernel/ProxyWire.java
Index: ProxyWire.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/kernel/org/apache/cocoon/kernel/ProxyWire.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ProxyWire.java 3 May 2004 20:43:40 -0000 1.5
+++ ProxyWire.java 4 May 2004 17:47:08 -0000 1.6
@@ -18,7 +18,6 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
-import java.net.URL;
import org.apache.cocoon.kernel.composition.Component;
import org.apache.cocoon.kernel.composition.Composer;
@@ -66,9 +65,6 @@
/** <p>The [EMAIL PROTECTED] Wire#dispose()} method used for
interception.</p> */
private static Method dispose = null;
- /** <p>The [EMAIL PROTECTED] Wire#resolve(URL)} method used for
interception.</p> */
- private static Method resolve = null;
-
/** <p>A static flag indicating whether this class was initialized.</p>
*/
private static boolean initialized = false;
@@ -80,9 +76,6 @@
/* <p>The [EMAIL PROTECTED] Compser} to which the instance should be
released.</p> */
private Composer composer = null;
- /* <p>The [EMAIL PROTECTED] Resolver} for the wire.</p> */
- private Resolver resolver = null;
-
/* <p>The [EMAIL PROTECTED] Wire} instance generated with proxies.</p> */
private Wire wire = null;
@@ -102,12 +95,15 @@
* disposal of proxied component instances will occur.
* @param role an interface [EMAIL PROTECTED] Class} to which the [EMAIL
PROTECTED] Wire}
* returned by [EMAIL PROTECTED] #getWire()} <b>must</b> be
castable to.
- * @param resolver The [EMAIL PROTECTED] Resolver} providing resolution.
+ * @param w The [EMAIL PROTECTED] Wirings} instance associated with the
block instance
+ * where the proxied component is deployed.
+ * @param r The [EMAIL PROTECTED] Resolver} providing resolution in the
context of the
+ * block instance requesting the component instance.
* @throws WiringException if an error occurred acquiring the original
* object or creating the [EMAIL PROTECTED]
Wire}.
* @throws NullPointerException if any of the parameters were
<b>null</b>.
*/
- public ProxyWire(Composer composer, Class role, Resolver resolver)
+ public ProxyWire(Composer composer, Class role, Wirings w, Resolver r)
throws WiringException {
ProxyWire.initialize();
@@ -145,21 +141,17 @@
try {
/* Create the proxy instance */
- Class i[] = instance.getClass().getInterfaces();
- Class c[] = new Class[i.length + 1];
- for (int x = 0; x < i.length; x++) c[x + 1] = i[x];
- c[0] = Wire.class;
+ Class c[] = new Class[] { Wire.class, role };
this.wire = (Wire)Proxy.newProxyInstance(loader, c, this);
/* Contextualize the instance with the wire */
if (instance instanceof Component) {
- ((Component)instance).contextualize(this.wire);
+ ((Component)instance).contextualize(this.wire, null, r);
}
- /* Record the original composer, resolver, and instance */
+ /* Record the original composer and instance */
this.composer = composer;
this.instance = instance;
- this.resolver = resolver;
} catch (Throwable t) {
/* Something bad happened releasing, release the instance */
composer.release(instance);
@@ -218,11 +210,6 @@
/* If it's simply the wiring status they require, that they will get
*/
if (this.check(method, wired)) return(new
Boolean(this.isConnected()));
- /* Intercept lookup on the proxied Wire */
- if (this.check(method, resolve)) {
- return(method.invoke(this.resolver, arguments));
- }
-
/* Invoke the method on the remote instance */
if (this.instance != null) {
return(method.invoke(this.instance, arguments));
@@ -309,7 +296,6 @@
ProxyWire.dispose = Wire.class.getDeclaredMethod("dispose",
parameters);
ProxyWire.finalize =
Object.class.getDeclaredMethod("finalize", parameters);
parameters = new Class[] { String.class };
- ProxyWire.resolve = Wire.class.getDeclaredMethod("resolve",
parameters);
} catch (NoSuchMethodException exception) {
/* If the methods were not found, then we're in BIG troubles
*/
String message = "Unable to locate interceptable methods in
the \""