felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Chemouil <schemo...@gmail.com>
Subject Re: Creating annotated components programmatically with iPojo API
Date Fri, 09 Nov 2012 15:51:25 GMT
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,


On Fri, Nov 9, 2012 at 9:16 AM, Clement Escoffier
<clement.escoffier@gmail.com> 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 <schemouil@gmail.com> 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: 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

View raw message