Why not use HM 1.1 now and let us know if you come across any bugs? That's what the beta is for.
-----Original Message----- From: David J. M. Karlsen [mailto:[EMAIL PROTECTED] Sent: Thursday, May 26, 2005 5:29 PM To: hivemind-dev@jakarta.apache.org Subject: Re: ClassFabUtils.getInstanceClass David J. M. Karlsen wrote: > Hi list! > >>> >>> I'm trying to make an interceptor the same way as HM's >>> LoggingInterceptorFactory, but I have some problems with the >>> following code: >>> >>> private void createInfrastructure(InterceptorStack stack, ClassFab >>> classFab){ >>> Class topClass = ClassFabUtils.getInstanceClass(stack.peek(), >>> stack.getServiceInterface()); >>> classFab.addField("_delegate", topClass); >>> classFab.addConstructor(new Class[]{ topClass }, null, >>> "{_delegate = >>> $1;}"); >>> } >>> >>> >>> the debugger tells me topClass is: Class ($PooledProxy_1040f7af339_32) >>> which is the pooled instance of my real underlying class. >>> >>> The function fails at line two, with this message: >>> >>> Unable to process content of element construct/service: Unable to >>> lookup >>> $PooledProxy_1040f7af339_32: $PooledProxy_1040f7af339_32 >>> (DefaultErrorHandler.java:37) >>> >>> I guess that this is beacuse topClass is no real class - but a dynamic >>> one - but the same should be true for the LoggingInterceptor - so I >>> cannot understand why this is a problem for my class ?? >>> >> > I posted a mail earlier with the same problem - and Knut's response: > > " > > The problem is a class loader issue. You're creating your own > ClassFactory instance, which in turn uses its own Javassist ClassPool, > which can't find the PooledProxy class HiveMind created using its own > ClassPool. You'll have to use HiveMind's ClassFactory. > > For this you should define a setFactory(ClassFactory) method on your > interceptor factory and then add a line like this to the <construct> > of your interceptor factory service: > > <set-service property="factory" service-id="hivemind.ClassFactory"/> > > " > > fixed the problem. > > But I've fallen into a new one - on some methods I get this: > > " > Unable to create class $Interceptor_1041511b5ba_38: (class: > $Interceptor_1041511b5ba_38, method: defaultIntValueOf signature: > (Ljava/lang/String;Ljava/lang/Object;I)I) Expecting to find > object/array on stack > " > > which I posted on the same mail thread. A good old reply-to-myself: I din't check for the correct return types (it failed on returning primitives). Now I check signature.getResulttype() and change the bodybuilder accordingly. If javassist dini't have the bug the code could be the same for all return types - I'm looking forward to HM 1.1! :-) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]