You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Leos Kunc <le...@acision.com> on 2010/08/19 16:46:10 UTC

mutliple version with IPOJO

Hi. I'm new in OSGI and IPOJO and last days I've spent looking for solution of 
the following problem. I need to implement two versions of same class running 
in simultaneously. I've created same class in two bundles and exported 
interface as service by annotations:

@Provides
@Component
@Instantiate
public class Impl implements TestServiceIface {
	
	@Override
	public void printString(String arg0) {
		System.out.println(arg0 + "impl1");
	}

}

Problem is that if I do the same for both bundles, service is exported twice 
for the bundle that is started first. So in the end I have one bundle which 
exports the service twice and one bundle that exports no service and therefor 
second implementation is not accessible at all.
  Is there any way in IPOJO to export two versions of same class?

best regards

Leos Kunc


This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.



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


Re: mutliple version with IPOJO

Posted by "Richard S. Hall" <he...@ungoverned.org>.
  On 8/19/10 12:57, Clement Escoffier wrote:
> On 19.08.2010, at 17:43, Richard S. Hall wrote:
>
>> Are you saying you have two bundles containing two component classes with the same name and iPOJO ends up using the same component class to create both instances?
> Yes, that's normal in this case. Indeed, no factory name, so iPOJO use the class name to identify the factory.
>
> So, to fix the issue, just set the factory as private with
> @Component(public_factory=false)

I assume another fix is to assign a unique factory name, correct?

-> richard

> Regards,
>
> Clement
>
>
>> ->  richard
>>
>> On 8/19/10 10:46, Leos Kunc wrote:
>>> Hi. I'm new in OSGI and IPOJO and last days I've spent looking for solution of
>>> the following problem. I need to implement two versions of same class running
>>> in simultaneously. I've created same class in two bundles and exported
>>> interface as service by annotations:
>>>
>>> @Provides
>>> @Component
>>> @Instantiate
>>> public class Impl implements TestServiceIface {
>>> 	
>>> 	@Override
>>> 	public void printString(String arg0) {
>>> 		System.out.println(arg0 + "impl1");
>>> 	}
>>>
>>> }
>>>
>>> Problem is that if I do the same for both bundles, service is exported twice
>>> for the bundle that is started first. So in the end I have one bundle which
>>> exports the service twice and one bundle that exports no service and therefor
>>> second implementation is not accessible at all.
>>>    Is there any way in IPOJO to export two versions of same class?
>>>
>>> best regards
>>>
>>> Leos Kunc
>>>
>>>
>>> This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>

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


Re: mutliple version with IPOJO

Posted by Clement Escoffier <cl...@gmail.com>.
On 19.08.2010, at 17:43, Richard S. Hall wrote:

> Are you saying you have two bundles containing two component classes with the same name and iPOJO ends up using the same component class to create both instances?

Yes, that's normal in this case. Indeed, no factory name, so iPOJO use the class name to identify the factory.

So, to fix the issue, just set the factory as private with
@Component(public_factory=false)

Regards,

Clement


> 
> -> richard
> 
> On 8/19/10 10:46, Leos Kunc wrote:
>> Hi. I'm new in OSGI and IPOJO and last days I've spent looking for solution of
>> the following problem. I need to implement two versions of same class running
>> in simultaneously. I've created same class in two bundles and exported
>> interface as service by annotations:
>> 
>> @Provides
>> @Component
>> @Instantiate
>> public class Impl implements TestServiceIface {
>> 	
>> 	@Override
>> 	public void printString(String arg0) {
>> 		System.out.println(arg0 + "impl1");
>> 	}
>> 
>> }
>> 
>> Problem is that if I do the same for both bundles, service is exported twice
>> for the bundle that is started first. So in the end I have one bundle which
>> exports the service twice and one bundle that exports no service and therefor
>> second implementation is not accessible at all.
>>   Is there any way in IPOJO to export two versions of same class?
>> 
>> best regards
>> 
>> Leos Kunc
>> 
>> 
>> This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> 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: mutliple version with IPOJO

Posted by "Richard S. Hall" <he...@ungoverned.org>.
  Are you saying you have two bundles containing two component classes 
with the same name and iPOJO ends up using the same component class to 
create both instances?

-> richard

On 8/19/10 10:46, Leos Kunc wrote:
> Hi. I'm new in OSGI and IPOJO and last days I've spent looking for solution of
> the following problem. I need to implement two versions of same class running
> in simultaneously. I've created same class in two bundles and exported
> interface as service by annotations:
>
> @Provides
> @Component
> @Instantiate
> public class Impl implements TestServiceIface {
> 	
> 	@Override
> 	public void printString(String arg0) {
> 		System.out.println(arg0 + "impl1");
> 	}
>
> }
>
> Problem is that if I do the same for both bundles, service is exported twice
> for the bundle that is started first. So in the end I have one bundle which
> exports the service twice and one bundle that exports no service and therefor
> second implementation is not accessible at all.
>    Is there any way in IPOJO to export two versions of same class?
>
> best regards
>
> Leos Kunc
>
>
> This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.
>
>
>
> ---------------------------------------------------------------------
> 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