You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ba...@apache.org on 2002/06/02 13:53:35 UTC
cvs commit: jakarta-commons-sandbox/simplestore/src/test/org/apache/commons/simplestore TestAll.java TestEnhancer.java
baliuka 2002/06/02 04:53:35
Modified: simplestore/src/java/org/apache/commons/simplestore/persistence/impl
PersistentProxy.java
simplestore/src/java/org/apache/commons/simplestore/tools
Enhancer.java MethodInterceptor.java
simplestore/src/test/org/apache/commons/simplestore
TestAll.java TestEnhancer.java
Added: simplestore/src/java/org/apache/commons/simplestore/tools
Factory.java
Log:
Revision Changes Path
1.39 +3 -3 jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/PersistentProxy.java
Index: PersistentProxy.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/PersistentProxy.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- PersistentProxy.java 25 May 2002 13:48:58 -0000 1.38
+++ PersistentProxy.java 2 Jun 2002 11:53:35 -0000 1.39
@@ -77,7 +77,7 @@
* baliuka@mwm.lt</a>
*@author Gerhard Froehlich <a href="mailto:g-froehlich@gmx.de">
* g-froehlich@gmx.de</a>
- *@version $Id: PersistentProxy.java,v 1.38 2002/05/25 13:48:58 baliuka Exp $
+ *@version $Id: PersistentProxy.java,v 1.39 2002/06/02 11:53:35 baliuka Exp $
*/
public class PersistentProxy
implements MetaObject, org.apache.commons.simplestore.tools.Constants ,
@@ -242,7 +242,6 @@
public Object afterReturn(Object obj,
Method method,
Object[] args,
- Object retValFromBefore,
boolean invokedSuper,
Object retValFromSuper,
Throwable e)
@@ -260,7 +259,7 @@
return invoke(obj,method,args);
}
- public boolean invokeSuper(Object obj,Method method,Object[] args,Object retValFromBefore) throws Throwable{
+ public boolean invokeSuper(Object obj,Method method,Object[] args) throws Throwable{
if( Enhancer.equals(method, HASH_CODE) ||
Enhancer.equals(method,EQUALS) ||
@@ -274,6 +273,7 @@
return null;
}
public Object invoke(Object obj, Method method, Object[] obj2) throws Throwable {
+
synchronized (this) {
if ( Enhancer.equals(method,GET_META_OBJECT) ) {
return this;
1.28 +160 -104 jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/tools/Enhancer.java
Index: Enhancer.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/tools/Enhancer.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- Enhancer.java 17 May 2002 22:20:51 -0000 1.27
+++ Enhancer.java 2 Jun 2002 11:53:35 -0000 1.28
@@ -53,6 +53,9 @@
* <http://www.apache.org/>.
*/
package org.apache.commons.simplestore.tools;
+
+import java.lang.reflect.*;
+
import org.apache.bcel.classfile.JavaClass;
import org.apache.bcel.classfile.Method;
import org.apache.bcel.generic.AASTORE;
@@ -135,7 +138,7 @@
* </pre>
*@author Juozas Baliuka <a href="mailto:baliuka@mwm.lt">
* baliuka@mwm.lt</a>
- *@version $Id: Enhancer.java,v 1.27 2002/05/17 22:20:51 baliuka Exp $
+ *@version $Id: Enhancer.java,v 1.28 2002/06/02 11:53:35 baliuka Exp $
*/
public class Enhancer implements org.apache.bcel.Constants ,
Constants{
@@ -163,33 +166,47 @@
static final String CLASS_SUFIX = "$$EnhancedBySimplestore$$";
static final String CLASS_PREFIX = "org.apache.";
static int index = 0;
+ static java.util.Map factories = new java.util.HashMap();
+
private static int addAfterConstructionRef(ConstantPoolGen cp) {
return cp.addMethodref(
Enhancer.class.getName(),
"handleConstruction",
"(Ljava/lang/Object;[Ljava/lang/Object;)V");
}
+
+ private static int addNewInstanceRef(ConstantPoolGen cp,String name) {
+ return cp.addMethodref(
+ name,
+ "<init>",
+ "(L"+ INTERCEPTOR_CLASS.replace('.','/') +";)V");
+ }
+
+
+
private static int addAfterRef(ConstantPoolGen cp) {
return cp.addInterfaceMethodref(
INTERCEPTOR_CLASS,
"afterReturn",
- "(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;Ljava/lang/Object;ZLjava/lang/Object;Ljava/lang/Throwable;)Ljava/lang/Object;");
+ "(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;ZLjava/lang/Object;Ljava/lang/Throwable;)Ljava/lang/Object;");
}
private static int addInvokeSupperRef(ConstantPoolGen cp) {
return cp.addInterfaceMethodref(
INTERCEPTOR_CLASS,
"invokeSuper",
- "(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;Ljava/lang/Object;)Z");
+ "(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Z");
}
+ /*
private static int addBeforeRef(ConstantPoolGen cp) {
return cp.addInterfaceMethodref(
INTERCEPTOR_CLASS,
"beforeInvoke",
"(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;");
- }
+ }*/
private static java.util.List costructionHandlers = new java.util.Vector();
private static java.util.Map cache = new java.util.WeakHashMap();
/** Creates a new instance of Enchancer */
+
protected Enhancer() {}
public static void setMethodInterceptor(Object enhanced, MethodInterceptor ih)
throws Throwable {
@@ -205,18 +222,9 @@
throw new IllegalAccessError(enhanced.getClass().getName() + ":" + iae.getMessage());
}
}
- public static void addConstructionHandler(ConstructionHandler ch) {
- costructionHandlers.add(ch);
- }
- public static void removeConstructionHandler(ConstructionHandler ch) {
- costructionHandlers.remove(ch);
- }
- public static synchronized void handleConstruction(Object obj, Object args[])
- throws Throwable {
- for (java.util.Iterator i = costructionHandlers.iterator(); i.hasNext();) {
- ((ConstructionHandler) i.next()).afterConstruction(obj, args);
- }
- }
+
+
+
public static Object enhance(
Class cls,
Class interfaces[],
@@ -285,10 +293,22 @@
map.put(key, result);
}
- return result
+
+ Factory factory = (Factory)factories.get(result);
+ if( factory == null ){
+ factory = (Factory)result.getConstructor(
+ new Class[] {
+ Class.forName(MethodInterceptor.class.getName(), true, loader)
+ }).newInstance(new Object[] { null });
+ factories.put(result,factory);
+
+ }
+ return factory.newInstance(ih);
+ /*result
.getConstructor(
new Class[] { Class.forName(MethodInterceptor.class.getName(), true, loader)})
.newInstance(new Object[] { ih });
+ */
}
private static void addConstructors(ClassGen cg, Class superClass)
throws Throwable {
@@ -326,7 +346,8 @@
cg.addMethod(costructor.getMethod());
}
}
- private static void addConstructor(ClassGen cg) {
+ private static void addConstructor(ClassGen cg) throws Throwable {
+
String parentClass = cg.getSuperclassName();
InstructionFactory factory = new InstructionFactory(cg);
ConstantPoolGen cp = cg.getConstantPool(); // cg creates constant pool
@@ -336,6 +357,8 @@
new Type[] { // argument types
new ObjectType(INTERCEPTOR_CLASS)}, null, // arg names
CONSTRUCTOR_NAME, cg.getClassName(), il, cp);
+
+
il.append(new ALOAD(0));
il.append(
factory.createInvoke(
@@ -352,32 +375,39 @@
FIELD_NAME,
new ObjectType(INTERCEPTOR_CLASS),
PUTFIELD));
- Type argTypes[] = new Type[] { new ObjectType(INTERCEPTOR_CLASS)};
- int argArray = createArgArray(il, factory, cp, argTypes);
- il.append(new ASTORE(argArray));
- il.append(new ALOAD(0));
- il.append(
- factory.createFieldAccess(
- cg.getClassName(),
- FIELD_NAME,
- new ObjectType(INTERCEPTOR_CLASS),
- GETFIELD));
- il.append(new ALOAD(0));
- il.append(new ALOAD(argArray));
- il.append(new INVOKESTATIC(addAfterConstructionRef(cp)));
il.append(new RETURN());
cg.addMethod(getMethod(costructor));
+
+
+ il = new InstructionList();
+ MethodGen newInstance = toMethodGen(
+ Factory.class.getMethod("newInstance",
+ new Class[]{ MethodInterceptor.class } ),
+ cg.getClassName(),
+ il,
+ cp
+ );
+ il.append( new NEW(cp.addClass( new ObjectType(cg.getClassName()) )) );
+ il.append( new DUP());
+ il.append( new ALOAD(1) );
+ il.append( new INVOKESPECIAL( addNewInstanceRef(cp, cg.getClassName()) ) ) ;
+ il.append( new ARETURN());
+ cg.addMethod(getMethod(newInstance));
+
}
+
+
private static void addHandlerField(ClassGen cg) {
ConstantPoolGen cp = cg.getConstantPool();
FieldGen fg =
new FieldGen(ACC_PUBLIC, new ObjectType(INTERCEPTOR_CLASS), FIELD_NAME, cp);
cg.addField(fg.getField());
}
+
private static ClassGen getClassGen(
- String class_name,
- Class parentClass,
- Class[] interfaces) {
+ String class_name,
+ Class parentClass,
+ Class[] interfaces) {
ClassGen gen =
new ClassGen(class_name, parentClass.getName(), SOURCE_FILE, ACC_PUBLIC, null);
if (interfaces != null) {
@@ -385,19 +415,20 @@
gen.addInterface(interfaces[i].getName());
}
}
+ gen.addInterface( Factory.class.getName() );
return gen;
}
+
private static JavaClass enhance(
- Class parentClass,
- String class_name,
- Class interfaces[],
- java.util.HashMap methodTable)
- throws Throwable {
+ Class parentClass,
+ String class_name,
+ Class interfaces[],
+ java.util.HashMap methodTable) throws Throwable {
+
ClassGen cg = getClassGen(class_name, parentClass, interfaces);
ConstantPoolGen cp = cg.getConstantPool(); // cg creates constant pool
addHandlerField(cg);
- addConstructors(cg, parentClass);
- int before = addBeforeRef(cp);
+ addConstructor(cg);
int after = addAfterRef(cp);
int invokeSuper = addInvokeSupperRef(cp);
java.util.Set methodSet = new java.util.HashSet();
@@ -417,10 +448,7 @@
|| java.lang.reflect.Modifier.isProtected(mod))) {
methodSet.add(new MethodWrapper(methods[i]));
- /*
- if( DEBUG ){
- System.out.println("added:" + methods[i]);
- }*/
+
}
}
}
@@ -428,23 +456,28 @@
for (java.util.Iterator i = methodSet.iterator(); i.hasNext();) {
java.lang.reflect.Method method = ((MethodWrapper) i.next()).method;
String fieldName = "METHOD_" + (cntr++);
- cg.addMethod(generateMethod(method, fieldName, cg, before, after, invokeSuper));
+ cg.addMethod(generateMethod(method, fieldName, cg, after, invokeSuper));
methodTable.put(fieldName, method);
}
JavaClass jcl = cg.getJavaClass();
return jcl;
}
+
+
private static void addMethodField(String fieldName, ClassGen cg) {
ConstantPoolGen cp = cg.getConstantPool();
FieldGen fg =
new FieldGen(ACC_PUBLIC | ACC_STATIC, METHOD_OBJECT, fieldName, cp);
cg.addField(fg.getField());
}
+
+
private static int createArgArray(
- InstructionList il,
- InstructionFactory factory,
- ConstantPoolGen cp,
- Type[] args) {
+ InstructionList il,
+ InstructionFactory factory,
+ ConstantPoolGen cp,
+ Type[] args) {
+
int argCount = args.length;
if (argCount > 5)
il.append(new BIPUSH((byte) argCount));
@@ -526,18 +559,22 @@
}
return load;
}
+
private static Method getMethod(MethodGen mg) {
mg.stripAttributes(true);
mg.setMaxLocals();
mg.setMaxStack();
return mg.getMethod();
}
+
private static InstructionHandle generateReturnValue(
- InstructionList il,
- InstructionFactory factory,
- ConstantPoolGen cp,
- Type returnType,
- int stack) {
+ InstructionList il,
+ InstructionFactory factory,
+ ConstantPoolGen cp,
+ Type returnType,
+ int stack) {
+
+
if (returnType.equals(Type.VOID)) {
return il.append(new RETURN());
}
@@ -652,7 +689,10 @@
}
throw new java.lang.InternalError();
}
+
+
private static Instruction newWrapper(Type type, ConstantPoolGen cp) {
+
if (type instanceof BasicType) {
if (type.equals(Type.BOOLEAN)) {
return new NEW(cp.addClass(BOOLEAN_OBJECT));
@@ -674,7 +714,9 @@
}
return null;
}
+
private static Instruction initWrapper(Type type, ConstantPoolGen cp) {
+
if (type instanceof BasicType) {
if (type.equals(Type.BOOLEAN)) {
return new INVOKESPECIAL(
@@ -704,7 +746,9 @@
}
return null;
}
+
private static int loadArg(InstructionList il, Type t, int index, int pos) {
+
if (t instanceof BasicType) {
if (t.equals(Type.LONG)) {
il.append(new LLOAD(pos));
@@ -726,14 +770,18 @@
return ++pos;
}
}
+
private static Type[] toType(Class cls[]) {
+
Type tp[] = new Type[cls.length];
for (int i = 0; i < cls.length; i++) {
tp[i] = toType(cls[i]);
}
return tp;
}
+
private static Type toType(Class cls) {
+
if (cls.equals(void.class)) {
return Type.VOID;
}
@@ -761,7 +809,9 @@
return new ObjectType(cls.getName());
throw new java.lang.InternalError(cls.getName());
}
+
private static void invokeSuper(ClassGen cg, MethodGen mg, Type args[]) {
+
ConstantPoolGen cp = cg.getConstantPool();
InstructionList il = mg.getInstructionList();
int pos = 1;
@@ -773,11 +823,13 @@
new INVOKESPECIAL(
cp.addMethodref(cg.getSuperclassName(), mg.getName(), mg.getSignature())));
}
+
private static MethodGen toMethodGen(
- java.lang.reflect.Method mtd,
- String className,
- InstructionList il,
- ConstantPoolGen cp) {
+ java.lang.reflect.Method mtd,
+ String className,
+ InstructionList il,
+ ConstantPoolGen cp) {
+
return new MethodGen(
ACC_PUBLIC,
toType(mtd.getReturnType()),
@@ -788,11 +840,13 @@
il,
cp);
}
+
private static MethodGen toMethodGen(
- java.lang.reflect.Constructor mtd,
- String className,
- InstructionList il,
- ConstantPoolGen cp) {
+ java.lang.reflect.Constructor mtd,
+ String className,
+ InstructionList il,
+ ConstantPoolGen cp) {
+
return new MethodGen(
ACC_PUBLIC,
Type.VOID,
@@ -803,13 +857,13 @@
il,
cp);
}
+
private static Method generateMethod(
- java.lang.reflect.Method method,
- String fieldName,
- ClassGen cg,
- int before,
- int after,
- int invokeSuper) {
+ java.lang.reflect.Method method,
+ String fieldName,
+ ClassGen cg,
+ int after,
+ int invokeSuper) {
InstructionList il = new InstructionList();
InstructionFactory factory = new InstructionFactory(cg);
@@ -820,8 +874,8 @@
int argCount = types.length;
addMethodField(fieldName, cg);
boolean returnsValue = !mg.getReturnType().equals(Type.VOID);
- boolean abstractM =
- java.lang.reflect.Modifier.isAbstract(method.getModifiers());
+ boolean abstractM = Modifier.isAbstract(method.getModifiers());
+
InstructionHandle ehEnd = null;
GOTO gotoHandled = null;
IFEQ ifInvoke = null;
@@ -829,28 +883,14 @@
InstructionHandle ehHandled = null;
InstructionHandle ehStart = null;
InstructionHandle start = il.getStart();
+
+ //GENERATE ARG ARRAY
int loaded = createArgArray(il, factory, cp, mg.getArgumentTypes());
int argArray = loaded;
- int resutFromBefore = ++loaded;
il.append(new ASTORE(argArray));
- // if (!abstractM) { // invoke before
- il.append(new ALOAD(0));
- il.append(
- factory.createFieldAccess(
- cg.getClassName(),
- FIELD_NAME,
- new ObjectType(INTERCEPTOR_CLASS),
- GETFIELD));
- il.append(new ALOAD(0));
- il.append(factory.createGetStatic(cg.getClassName(), fieldName, METHOD_OBJECT));
- il.append(new ALOAD(argArray));
- il.append(new INVOKEINTERFACE(before, 4));
- il.append(new ASTORE(resutFromBefore));
- // } else {
- // il.append(new ACONST_NULL());
- // il.append(new ASTORE(resutFromBefore));
- // }
- //locals
+
+
+ //DEFINE LOCAL VARIABLES
il.append(new ACONST_NULL());
int resultFromSuper = ++loaded;
il.append(new ASTORE(resultFromSuper));
@@ -860,7 +900,9 @@
il.append(new ACONST_NULL());
int error = ++loaded;
il.append(new ASTORE(error));
- if (!abstractM) { //test before invoke super
+
+
+ if (!abstractM) {
il.append(new ALOAD(0)); //this.handler
il.append(
factory.createFieldAccess(
@@ -868,23 +910,28 @@
FIELD_NAME,
new ObjectType(INTERCEPTOR_CLASS),
GETFIELD));
+
+ //GENERATE INVOKE SUPER
il.append(new ALOAD(0)); //this
il.append(factory.createGetStatic(cg.getClassName(), fieldName, METHOD_OBJECT));
il.append(new ALOAD(argArray));
- il.append(new ALOAD(resutFromBefore));
- il.append(new INVOKEINTERFACE(invokeSuper, 5));
+ il.append(new INVOKEINTERFACE(invokeSuper, 4));
+
//test returned true
ifInvoke = new IFEQ(null);
condition = il.append(ifInvoke);
il.append(new ICONST(1));
ehStart = il.append(new ISTORE(superInvoked)); // Ivoked = true
+
Instruction wrapper = newWrapper(mg.getReturnType(), cp);
if (wrapper != null) {
ehStart = il.append(wrapper);
il.append(new DUP());
}
- invokeSuper(cg, mg, types);
+ invokeSuper(cg, mg, types);
+
+
if (wrapper != null) {
il.append(initWrapper(mg.getReturnType(), cp));
}
@@ -899,39 +946,46 @@
}
ehHandled = il.append(new ASTORE(error));
}
- InstructionHandle endif = il.append(new ALOAD(0)); //this
+
+ InstructionHandle endif = il.append(new ALOAD(0)); //this.handler
+
if (!abstractM) {
+
ifInvoke.setTarget(endif);
gotoHandled.setTarget(endif);
}
+
+ //-------------------------------
il.append(
factory.createFieldAccess(
cg.getClassName(),
FIELD_NAME,
new ObjectType(INTERCEPTOR_CLASS),
GETFIELD));
+
+ // INVOKE AFTER RETURN
il.append(new ALOAD(0)); //this
il.append(factory.createGetStatic(cg.getClassName(), fieldName, METHOD_OBJECT));
il.append(new ALOAD(argArray));
- il.append(new ALOAD(resutFromBefore));
il.append(new ILOAD(superInvoked));
il.append(new ALOAD(resultFromSuper));
il.append(new ALOAD(error));
- il.append(new INVOKEINTERFACE(after, 8));
+ il.append(new INVOKEINTERFACE(after, 7));
+
+ //GENERATE RETURN VALUE
InstructionHandle exitMethod =
generateReturnValue(il, factory, cp, mg.getReturnType(), ++loaded);
if (!abstractM) {
mg.addExceptionHandler(ehStart, ehEnd, ehHandled, Type.THROWABLE);
}
+
mg.setMaxStack();
mg.setMaxLocals();
Method result = getMethod(mg);
- /* if (DEBUG) {
- System.err.println(mg.getMethod());
- System.err.println(mg.getMethod().getCode());
- }*/
- return result;
+
+ return result;
}
+
static class MethodWrapper {
java.lang.reflect.Method method;
MethodWrapper(java.lang.reflect.Method method) {
@@ -952,8 +1006,8 @@
}
public static boolean equals(
- java.lang.reflect.Method m1,
- java.lang.reflect.Method m2) {
+ java.lang.reflect.Method m1,
+ java.lang.reflect.Method m2) {
if (m1 == m2) {
@@ -982,4 +1036,6 @@
return false;
}
+
+
}
1.4 +6 -5 jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/tools/MethodInterceptor.java
Index: MethodInterceptor.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/tools/MethodInterceptor.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- MethodInterceptor.java 14 Apr 2002 19:43:45 -0000 1.3
+++ MethodInterceptor.java 2 Jun 2002 11:53:35 -0000 1.4
@@ -103,7 +103,7 @@
*@author Juozas Baliuka <a href="mailto:baliuka@mwm.lt">
* baliuka@mwm.lt</a>
- *@version $Id: MethodInterceptor.java,v 1.3 2002/04/14 19:43:45 baliuka Exp $
+ *@version $Id: MethodInterceptor.java,v 1.4 2002/06/02 11:53:35 baliuka Exp $
*/
public interface MethodInterceptor {
@@ -115,9 +115,10 @@
* @return returned value used as parameter for all
* interceptor methods
*/
- public Object beforeInvoke( Object obj,
+ /* public Object beforeInvoke( Object obj,
java.lang.reflect.Method method,
Object args[] )throws java.lang.Throwable;
+ */
/** Generated code calls this method before invoking super
* @param obj this
@@ -129,8 +130,8 @@
*/
public boolean invokeSuper( Object obj,
java.lang.reflect.Method method,
- Object args[],
- Object retValFromBefore )
+ Object args[]
+ /*,Object retValFromBefore*/ )
throws java.lang.Throwable;
/** this method is invoked after execution
@@ -147,7 +148,7 @@
public Object afterReturn( Object obj,
java.lang.reflect.Method method,
Object args[],
- Object retValFromBefore,
+ /*Object retValFromBefore,*/
boolean invokedSuper,
Object retValFromSuper,
java.lang.Throwable e )
1.1 jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/tools/Factory.java
Index: Factory.java
===================================================================
/*
* Factory.java
*
* Created on �e�tadienis, 2002, Gegu��s 25, 19.40
*/
package org.apache.commons.simplestore.tools;
/**
*
* @author user
*/
public interface Factory{
public Object newInstance( MethodInterceptor ih );
}
1.14 +3 -3 jakarta-commons-sandbox/simplestore/src/test/org/apache/commons/simplestore/TestAll.java
Index: TestAll.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/src/test/org/apache/commons/simplestore/TestAll.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- TestAll.java 20 May 2002 20:49:09 -0000 1.13
+++ TestAll.java 2 Jun 2002 11:53:35 -0000 1.14
@@ -59,7 +59,7 @@
/**
*@author Gerhard Froehlich <a href="mailto:g-froehlich@gmx.de">
* g-froehlich@gmx.de</a>
- *@version $Id: TestAll.java,v 1.13 2002/05/20 20:49:09 baliuka Exp $
+ *@version $Id: TestAll.java,v 1.14 2002/06/02 11:53:35 baliuka Exp $
*/
public class TestAll extends TestCase {
public TestAll(String testName) {
@@ -68,9 +68,9 @@
public static Test suite() {
TestSuite suite = new TestSuite();
- suite.addTest(TestSample.suite());
+ // suite.addTest(TestSample.suite());
suite.addTest(TestEnhancer.suite());
- suite.addTest(TestXmlDbStorage.suite());
+ // suite.addTest(TestXmlDbStorage.suite());
return suite;
}
1.16 +15 -16 jakarta-commons-sandbox/simplestore/src/test/org/apache/commons/simplestore/TestEnhancer.java
Index: TestEnhancer.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/src/test/org/apache/commons/simplestore/TestEnhancer.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- TestEnhancer.java 30 Apr 2002 18:04:35 -0000 1.15
+++ TestEnhancer.java 2 Jun 2002 11:53:35 -0000 1.16
@@ -58,13 +58,12 @@
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-import org.apache.commons.simplestore.tools.Enhancer;
-import org.apache.commons.simplestore.tools.MethodInterceptor;
+import org.apache.commons.simplestore.tools.*;
/**
*@author Juozas Baliuka <a href="mailto:baliuka@mwm.lt">
* baliuka@mwm.lt</a>
- *@version $Id: TestEnhancer.java,v 1.15 2002/04/30 18:04:35 baliuka Exp $
+ *@version $Id: TestEnhancer.java,v 1.16 2002/06/02 11:53:35 baliuka Exp $
*/
public class TestEnhancer extends TestCase {
@@ -88,21 +87,16 @@
MethodInterceptor interceptor =
new MethodInterceptor(){
- public Object beforeInvoke( Object obj,java.lang.reflect.Method method,
- Object args[] )
- throws java.lang.Throwable{
- return null;
- }
public boolean invokeSuper( Object obj,java.lang.reflect.Method method,
- Object args[], Object retValFromBefore )
+ Object args[] )
throws java.lang.Throwable{
return true;
}
public Object afterReturn( Object obj, java.lang.reflect.Method method,
- Object args[], Object retValFromBefore,
+ Object args[],
boolean invokedSuper, Object retValFromSuper,
java.lang.Throwable e )throws java.lang.Throwable{
assertTrue("Pure method " + method,invokedSuper);
@@ -112,11 +106,17 @@
};
java.util.Vector vector = (java.util.Vector)Enhancer.enhance(
- java.util.Vector.class,
- new Class[]{java.util.List.class},interceptor );
- java.util.Vector vector2 = (java.util.Vector)Enhancer.enhance(
- java.util.Vector.class,
- new Class[]{java.util.List.class},interceptor );
+ java.util.Vector.class,
+ new Class[]{java.util.List.class},interceptor );
+
+
+
+ java.util.Vector vector2 = (java.util.Vector)Enhancer.enhance(
+ java.util.Vector.class,
+ new Class[]{java.util.List.class},interceptor );
+
+
+
assertTrue("Cache failed",vector.getClass() == vector2.getClass());
//TODO : Add meanigful asserts
@@ -133,7 +133,6 @@
vector.get(0);
vector.contains(value);
vector.toArray(new Object[]{});
-
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>