You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by fabiolf <fa...@gmail.com> on 2012/09/06 03:36:51 UTC

Modifying an iPOJO composite instance in runtime

Hello,

I have a conceptual question about the use of composites in iPOJO. Suppose I
create a CompositeComponentType with two instances inside it and then create
an instance of this CompositeComponentType called A.

Then, somehow, there is a need to add a third instance or swap one of the
two interior instances of A for a third one without having to dispose A and
then recreate it. Would that be possible?

Delving into iPOJO's code, it looks like CompositeComponentType is just a
"template" of a component. The real deal happens later when we use its
metadata to create a Factory and then create an instance from it, right? So,
I wonder if it could be possible to modify the structure of this composite
instance when it is already created.

Thanks,
Fabio



--
View this message in context: http://apache-felix.18485.n6.nabble.com/Modifying-an-iPOJO-composite-instance-in-runtime-tp4999210.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

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


Re: Modifying an iPOJO composite instance in runtime

Posted by fabiolf <fa...@gmail.com>.
Hi Clement,

I had already checked that link, but there are only examples about how to
create components, composites, using properties, services and dependencies.
The only paragraph dealing with changing the composition on the fly is the
one related to the Introspection API. But I couldn't figure out how to do
it based only on that paragraph. Could you provide one simple example? You
can use the scenario below:

PrimitiveComponentType prov = createAProvider(); // Create a primitive
type PrimitiveComponentType cons = createAConsumer(); // Create
another primitive type
       CompositeComponentType type = new CompositeComponentType()
           .setBundleContext(context)
           .setComponentTypeName("comp1")
           .addInstance(new Instance(prov.getFactory().getName())) //
Create an instance in the composite           .addInstance(new
Instance(cons.getFactory().getName()));

       ComponentInstance ci = type.createInstance();


Suppose I have another Provider:

PrimitiveComponentType aprov = createAnotherProvider(); // Create
another primitive type


How could I modify the component instance *ci *on the fly to make it use *
aprov *instead of *prov*?

Thanks!
Fabio

On Mon, Sep 10, 2012 at 7:04 AM, clement escoffier [via Apache Felix] <
ml-node+s18485n4999266h62@n6.nabble.com> wrote:

> Hi,
>
> You can using the iPOJO API (
> http://felix.apache.org/site/apache-felix-ipojo-api.html) to modify the
> composition on the fly.
>
> Regards,
>
> Clement
>
>
>
> On 6 sept. 2012, at 03:36, fabiolf <[hidden email]<http://user/SendEmail.jtp?type=node&node=4999266&i=0>>
> wrote:
>
> > Hello,
> >
> > I have a conceptual question about the use of composites in iPOJO.
> Suppose I
> > create a CompositeComponentType with two instances inside it and then
> create
> > an instance of this CompositeComponentType called A.
> >
> > Then, somehow, there is a need to add a third instance or swap one of
> the
> > two interior instances of A for a third one without having to dispose A
> and
> > then recreate it. Would that be possible?
> >
> > Delving into iPOJO's code, it looks like CompositeComponentType is just
> a
> > "template" of a component. The real deal happens later when we use its
> > metadata to create a Factory and then create an instance from it, right?
> So,
> > I wonder if it could be possible to modify the structure of this
> composite
> > instance when it is already created.
> >
> > Thanks,
> > Fabio
> >
> >
> >
> > --
> > View this message in context:
> http://apache-felix.18485.n6.nabble.com/Modifying-an-iPOJO-composite-instance-in-runtime-tp4999210.html
> > Sent from the Apache Felix - Users mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=4999266&i=1>
> > For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=4999266&i=2>
> >
>
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://apache-felix.18485.n6.nabble.com/Modifying-an-iPOJO-composite-instance-in-runtime-tp4999210p4999266.html
>  To unsubscribe from Modifying an iPOJO composite instance in runtime, click
> here<http://apache-felix.18485.n6.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4999210&code=ZmFiaW8ubC5mb25zZWNhQGdtYWlsLmNvbXw0OTk5MjEwfDE5NjM1NDUwODE=>
> .
> NAML<http://apache-felix.18485.n6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://apache-felix.18485.n6.nabble.com/Modifying-an-iPOJO-composite-instance-in-runtime-tp4999210p4999269.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

Re: Modifying an iPOJO composite instance in runtime

Posted by Clement Escoffier <cl...@gmail.com>.
Hi,

You can using the iPOJO API (http://felix.apache.org/site/apache-felix-ipojo-api.html) to modify the composition on the fly.

Regards,

Clement



On 6 sept. 2012, at 03:36, fabiolf <fa...@gmail.com> wrote:

> Hello,
> 
> I have a conceptual question about the use of composites in iPOJO. Suppose I
> create a CompositeComponentType with two instances inside it and then create
> an instance of this CompositeComponentType called A.
> 
> Then, somehow, there is a need to add a third instance or swap one of the
> two interior instances of A for a third one without having to dispose A and
> then recreate it. Would that be possible?
> 
> Delving into iPOJO's code, it looks like CompositeComponentType is just a
> "template" of a component. The real deal happens later when we use its
> metadata to create a Factory and then create an instance from it, right? So,
> I wonder if it could be possible to modify the structure of this composite
> instance when it is already created.
> 
> Thanks,
> Fabio
> 
> 
> 
> --
> View this message in context: http://apache-felix.18485.n6.nabble.com/Modifying-an-iPOJO-composite-instance-in-runtime-tp4999210.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>