You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Donald Whytock <dw...@gmail.com> on 2011/08/17 17:07:25 UTC

Felix interfering with method overrides?

Hi all...

I've been having a problem with method overrides in Felix.
Generalized scenario:

Two bundles: BundleA and BundleB.

BundleB's ActivatorB extends BundleA's ActivatorA.  ActivatorB does
not define a start() method.

BundleB's ServiceImplB extends BundleA's ServiceImplA.

ActivatorA is abstract and has an abstract method getServiceImpl(),
which returns a ServiceImplA.  ActivatorB implements this method,
returning an instance of ServiceImplB.

ServiceImplA is abstract and has a non-abstract method showStatus().
ServiceImplB overrides showStatus().

BundleA is resolved and does not have a Bundle-Activator.  BundleB is
resolved and has ActivatorB as a Bundle-Activator.

When BundleB is started, ActivatorA.start() instantiates and starts an
extension of ServiceTracker, myServiceTracker.
myServiceTracker.addingReference() calls getServiceImpl() for a
ServiceImpA and calls showStatus() on it.

If ServiceImplB.showStatus() calls super.showStatus(),
ServiceImplB.showStatus() is called.  If ServiceImplB.showStatus()
does not call super.showStatus(), ServiceImplA.showStatus() is called.

I don't believe this is normal Java behavior.  I believe in a
command-line-JVM situation, ServiceImplB.showStatus() would always be
called, whether or not it called super.showStatus().  So is this an
idiosyncracy of classloaders in Felix?

Don

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Felix interfering with method overrides?

Posted by "Richard S. Hall" <he...@ungoverned.org>.
On 8/17/11 13:14, Donald Whytock wrote:
> Unable to reproduce the problem today.  Maybe all that time I was just
> short by a refresh.
>
> Thanks anyway for the help...

No problem...I thought it sounded too odd to be that simple... :-)

-> richard

>
> Don
>
> On Wed, Aug 17, 2011 at 11:41 AM, Donald Whytock<dw...@gmail.com>  wrote:
>>>> When BundleB is started, ActivatorA.start() instantiates and starts an
>>>> extension of ServiceTracker, myServiceTracker.
>>>> myServiceTracker.addingReference() calls getServiceImpl() for a
>>>> ServiceImpA and calls showStatus() on it.
>>>>
>>>> If ServiceImplB.showStatus() calls super.showStatus(),
>>>> ServiceImplB.showStatus() is called.  If ServiceImplB.showStatus()
>>>> does not call super.showStatus(), ServiceImplA.showStatus() is called.
>>> Are you saying that invoking ServiceImplB.showStatus() bypasses the code in
>>> ServiceImplB.showStatus() and directly goes to ServiceImplA.showStatus()?
>> Yes. Code in the ServiceTracker launched by ActivatorA does
>> serviceImpl = getServiceImpl(); getServiceImpl() is abstract, and
>> implemented by ActivatorB to return a ServiceImplB.  If
>> serviceImpl.showStatus() is called, ServiceImplA.showStatus() is run,
>> unless ServiceImplB.showStatus() calls super.showStatus().
>>
>>>> I don't believe this is normal Java behavior.  I believe in a
>>>> command-line-JVM situation, ServiceImplB.showStatus() would always be
>>>> called, whether or not it called super.showStatus().  So is this an
>>>> idiosyncracy of classloaders in Felix?
>>> I doubt it. I would imagine something else is going on. If you want to email
>>> me a simple working example, I can take a look at it.
>> Not sure I have an example I'd call simple, but I'll see what I can
>> do. :)  Thanks...
>>
>> Don
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Felix interfering with method overrides?

Posted by Donald Whytock <dw...@gmail.com>.
Unable to reproduce the problem today.  Maybe all that time I was just
short by a refresh.

Thanks anyway for the help...

Don

On Wed, Aug 17, 2011 at 11:41 AM, Donald Whytock <dw...@gmail.com> wrote:
>>> When BundleB is started, ActivatorA.start() instantiates and starts an
>>> extension of ServiceTracker, myServiceTracker.
>>> myServiceTracker.addingReference() calls getServiceImpl() for a
>>> ServiceImpA and calls showStatus() on it.
>>>
>>> If ServiceImplB.showStatus() calls super.showStatus(),
>>> ServiceImplB.showStatus() is called.  If ServiceImplB.showStatus()
>>> does not call super.showStatus(), ServiceImplA.showStatus() is called.
>>
>> Are you saying that invoking ServiceImplB.showStatus() bypasses the code in
>> ServiceImplB.showStatus() and directly goes to ServiceImplA.showStatus()?
>
> Yes. Code in the ServiceTracker launched by ActivatorA does
> serviceImpl = getServiceImpl(); getServiceImpl() is abstract, and
> implemented by ActivatorB to return a ServiceImplB.  If
> serviceImpl.showStatus() is called, ServiceImplA.showStatus() is run,
> unless ServiceImplB.showStatus() calls super.showStatus().
>
>>
>>>
>>> I don't believe this is normal Java behavior.  I believe in a
>>> command-line-JVM situation, ServiceImplB.showStatus() would always be
>>> called, whether or not it called super.showStatus().  So is this an
>>> idiosyncracy of classloaders in Felix?
>>
>> I doubt it. I would imagine something else is going on. If you want to email
>> me a simple working example, I can take a look at it.
>
> Not sure I have an example I'd call simple, but I'll see what I can
> do. :)  Thanks...
>
> Don
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Felix interfering with method overrides?

Posted by Donald Whytock <dw...@gmail.com>.
>> When BundleB is started, ActivatorA.start() instantiates and starts an
>> extension of ServiceTracker, myServiceTracker.
>> myServiceTracker.addingReference() calls getServiceImpl() for a
>> ServiceImpA and calls showStatus() on it.
>>
>> If ServiceImplB.showStatus() calls super.showStatus(),
>> ServiceImplB.showStatus() is called.  If ServiceImplB.showStatus()
>> does not call super.showStatus(), ServiceImplA.showStatus() is called.
>
> Are you saying that invoking ServiceImplB.showStatus() bypasses the code in
> ServiceImplB.showStatus() and directly goes to ServiceImplA.showStatus()?

Yes. Code in the ServiceTracker launched by ActivatorA does
serviceImpl = getServiceImpl(); getServiceImpl() is abstract, and
implemented by ActivatorB to return a ServiceImplB.  If
serviceImpl.showStatus() is called, ServiceImplA.showStatus() is run,
unless ServiceImplB.showStatus() calls super.showStatus().

>
>>
>> I don't believe this is normal Java behavior.  I believe in a
>> command-line-JVM situation, ServiceImplB.showStatus() would always be
>> called, whether or not it called super.showStatus().  So is this an
>> idiosyncracy of classloaders in Felix?
>
> I doubt it. I would imagine something else is going on. If you want to email
> me a simple working example, I can take a look at it.

Not sure I have an example I'd call simple, but I'll see what I can
do. :)  Thanks...

Don

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Felix interfering with method overrides?

Posted by "Richard S. Hall" <he...@ungoverned.org>.
On 8/17/11 11:07, Donald Whytock wrote:
> Hi all...
>
> I've been having a problem with method overrides in Felix.
> Generalized scenario:
>
> Two bundles: BundleA and BundleB.
>
> BundleB's ActivatorB extends BundleA's ActivatorA.  ActivatorB does
> not define a start() method.
>
> BundleB's ServiceImplB extends BundleA's ServiceImplA.
>
> ActivatorA is abstract and has an abstract method getServiceImpl(),
> which returns a ServiceImplA.  ActivatorB implements this method,
> returning an instance of ServiceImplB.
>
> ServiceImplA is abstract and has a non-abstract method showStatus().
> ServiceImplB overrides showStatus().
>
> BundleA is resolved and does not have a Bundle-Activator.  BundleB is
> resolved and has ActivatorB as a Bundle-Activator.
>
> When BundleB is started, ActivatorA.start() instantiates and starts an
> extension of ServiceTracker, myServiceTracker.
> myServiceTracker.addingReference() calls getServiceImpl() for a
> ServiceImpA and calls showStatus() on it.
>
> If ServiceImplB.showStatus() calls super.showStatus(),
> ServiceImplB.showStatus() is called.  If ServiceImplB.showStatus()
> does not call super.showStatus(), ServiceImplA.showStatus() is called.

Are you saying that invoking ServiceImplB.showStatus() bypasses the code 
in ServiceImplB.showStatus() and directly goes to ServiceImplA.showStatus()?

>
> I don't believe this is normal Java behavior.  I believe in a
> command-line-JVM situation, ServiceImplB.showStatus() would always be
> called, whether or not it called super.showStatus().  So is this an
> idiosyncracy of classloaders in Felix?

I doubt it. I would imagine something else is going on. If you want to 
email me a simple working example, I can take a look at it.

-> richard

>
> Don
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org