Hi Steve.
I added the following three lines to the code suggested in your reply:
Class dummy =
this.getClass().getClassLoader().loadClass("de.jb.compo.MyComponent");
loggerInst.debug(dummy.getName());
loggerInst.debug("isInterface(): " + dummy.isInterface());
The output:
#1st time
here : 23361497
there: 2730814
de.jb.compo.MyComponent
isInterface(): true
(...)
#2nd time
here : 23361497
there: 2730814
de.jb.compo.MyComponent
isInterface(): true
(...)
Stephen McConnell schrieb am 12.01.2004:
>Joerg Buchberger wrote:
>
>> Hi there.
>>
>> Using Sun-JDK-1.4.1_03(WinNT4SP6a), Phoenix-4.0.3,
>> ServiceManager.lookup(MyComponent.ROLE):
>>
>> The ServiceManager always returns a $Proxy<number> type object, which causes
>a
>> ClassCastException when I try to cast to my components service interface:
>> MyComponent mytest = (MyComponent) ServiceManager.lookup(MyComponent.ROLE);
>>
>> When getting a needed component with ServiceManager, am I supposed to use
>> reflection to get at my services interface/impl(?!), or should the returned
>> object be castable as I tried above?
>> Actually, reflection even tells me that MyComponent-interface is implemented
>by
>> the returned mytest.
>>
>> ?! I'm somehow lost here.
>> Does anyone see or can anyone guess the mistake?
>
>What happens if you do the following in your test:
>
> Object test = serviceManagerInst.lookup( MyComponent.ROLE );
> loggerInst.debug(
> "here : " + System.identityHashCode( MyComponent.class ) );
> loggerInst.debug(
> "there: " + System.identityHashCode( test.getClass() ) );
>
>Steve.
>
>--
>
>|------------------------------------------------|
>| Magic by Merlin |
>| Production by Avalon |
>| |
>| http://avalon.apache.org/merlin |
>| http://dpml.net/merlin/distributions/latest |
>|------------------------------------------------|
>
>---------------------------------------------------------------------
>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]