Hi Clement,

Thanks for your answer.

I knew about "regular" factories.  I did solve my problem that way in
the mean time. That's the indeed the most natural solution but I was
hoping for a solution that doesn't involve exposing the factory as a
public service, since I want only "my code" to be allowed to create
new instances. I was hoping for a solution in iPojo for this :).
Is there any way to achieve this, as in getting the factory
programmatically for an already annotated components from a separate
bundle without exposing it as an OSGi service? :-)

Thanks for your help,

Simon



On Fri, Nov 9, 2012 at 9:16 AM, Clement Escoffier
<[email protected]> wrote:
> Hi,
>
> Unfortunately, when you're using the API and the PrimitiveComponentType it 
> creates an empty component type that you need to describe by yourself. If 
> your class is already using annotations, you just have to use the published 
> Factory. Each (public) component type is accessible using a Factory service. 
> By default the service.pid is the class name of the class (except if the 
> 'name' is configured).
>
> You will find details on 
> http://felix.apache.org/site/how-to-use-ipojo-factories.html.
>
> Regards,
>
> Clement
>
> On 8 nov. 2012, at 18:04, Simon Chemouil <[email protected]> wrote:
>
>> Hi,
>>
>> I'm trying to define iPojo components programmatically using the API,
>> and have the component class use iPojo annotations (I am trying to
>> bridge another extension mechanism so I can keep using iPojo semantics
>> there).
>>
>> I'm defining my component this way:
>>
>> PrimitiveComponentType type = new PrimitiveComponentType()
>> .setBundleContext(origContext)
>> .setClassName(componentClassName).setImmediate(true);
>>
>>
>> type.start();
>> try {
>>         ComponentInstance instance = type.createInstance();
>>         return ((InstanceManager) instance).getPojoObject();
>> } catch (...) { }
>>
>>
>> However so far annotations are ignored. I know they're class
>> retention, but I think the manipulator should be able to see them in
>> the bytecode anyway.
>> For instance I don't use .addDependency(), a field annotated with
>> @Requires will not get injected. I'm also interested in getting this
>> to work with custom handlers processing custom annotations!
>>
>> Is there any way to get this working? Pointers will be much appreciated!
>>
>> Thanks,
>>
>> --
>> Simon
>>
>> ---------------------------------------------------------------------
>> 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]

Reply via email to