Hi,
On 29 janvier 2015 at 15:21:00, Thiago Souza ([email protected]) wrote: Hi! Thanks for the tips! I ended up creating a custom handler for this. Now, what I need to do is to generate some metadata to bundle's manifest. Is it possible using the visitor? If not, I'll have to solve this in runtime. No the visitor does not let you do such kind of enhancement.The visitor lets you write the iPOJO metadata you want (well, they are stored in the manifest, so maybe it’s enough for you). Cheers, Clement Thanks! On Mon Jan 26 2015 at 3:40:06 AM clement escoffier [via Apache Felix] < [email protected]> wrote: > Hi, > > On 25 janvier 2015 at 22:45:46, Thiago Souza ([hidden email] > <http:///user/SendEmail.jtp?type=node&node=5011275&i=0>) wrote: > Hi! > > I could implement a prototype that generates metadata in the component > descriptor. > > Now I can create an iPojo that requires component factories with these > metadata. But I'm not being able to find a way to access the pojo > instance > itself given a factory, is it possible? > You use the Factory to create a ComponentInstance, then you have two ways: > > 1) The best way is to retrieve a service exposed by the freshly created > instance. You can use the ‘instance.name’ property to select the service. > That way, you manager ‘invalid’ instance (instances that depends on > unavailable services), as the service won’t be exposed in this case. > > try { > ServiceReference[] refs = > > context.getServiceReferences(YourServiceInterface.class.getName(), > "(instance.name=" + instance.getInstanceName() +")"); > if (refs != null) { > Foo your_object = (Foo) context.getService(refs[0]); > } > } catch (InvalidSyntaxException e) { > // Should not happen > } > 2) You can use the following snippet: > > if (instance.getState() == ComponentInstance.VALID) { > ImplementationClass object = > (ImplementationClass) ((InstanceManager) instance).getPojoObject(); > } else { > System.out.println("Cannot get an implementation object from an invalid > instance"); > } > > First it requires a cast to InstanceManager. InstanceManager is the > implementation class behind @Component. As iPOJO supports her type of > entities, you need to be sure you are using @Component before casting > (others are Handler, Composite…). Once you have the instance manager you > can call the ‘getPojoObject’ to retrieve the pojo instance. If none exist, > one is created. > > > Cheers, > > Clement > > > > > Regards > > On Sun, Jan 25, 2015, 14:15 clement escoffier [via Apache Felix] < > [hidden email] <http:///user/SendEmail.jtp?type=node&node=5011275&i=1>> > wrote: > > > Hi, > > > > Unfortunately stereotypes do not support ‘parameter’ right now, but you > > can use ‘visitors’ which are small classes rewriting the annotation. > > Here is something similar to what you try to do: > > > https://github.com/wisdom-framework/wisdom/blob/master/core/wisdom-ipojo-module/src/main/java/org/wisdom/ipojo/module/WisdomServiceVisitor.java > > > > > > Cheers, > > > > Clement > > On 25 janvier 2015 at 16:42:50, Thiago Souza ([hidden email] > > <http:///user/SendEmail.jtp?type=node&node=5011272&i=0>) wrote: > > > > Hi all, > > > > I'm trying to create a custom handler with a @Stereotype annotation > (named > > > > @Namespace) with the following use case: > > > > @Namespace("a-namespace") > > public class ANamespaceComponent { > > } > > > > The ANamespaceComponent would also inherit > @Component(name="a-namespace") > > > > and @Instantiate with additional processing. > > > > Unfortunatelly I'm not being able to understand, from the > documentation, > > what artifacts (and how) should be created. > > > > Any help appreciated! > > > > Thanks! > > > > > > > > > > > > -- > > View this message in context: > > > http://apache-felix.18485.x6.nabble.com/ipojo-Help-wih-Stereotype-and-custom-handler-tp5011271.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=5011272&i=1> > > For additional commands, e-mail: [hidden email] > > <http:///user/SendEmail.jtp?type=node&node=5011272&i=2> > > > > > > > > ------------------------------ > > If you reply to this email, your message will be added to the > discussion > > below: > > > > > http://apache-felix.18485.x6.nabble.com/ipojo-Help-wih-Stereotype-and-custom-handler-tp5011271p5011272.html > > > > To unsubscribe from [ipojo] Help wih @Stereotype and custom handler, > click > > here > > < > > > . > > NAML > > < > http://apache-felix.18485.x6.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.x6.nabble.com/ipojo-Help-wih-Stereotype-and-custom-handler-tp5011271p5011274.html > > > Sent from the Apache Felix - Users mailing list archive at Nabble.com. > > If you reply to this email, your message will be added to the discussion > below: > > http://apache-felix.18485.x6.nabble.com/ipojo-Help-wih-Stereotype-and-custom-handler-tp5011271p5011275.html > > To unsubscribe from [ipojo] Help wih @Stereotype and custom handler, click > here > <http://apache-felix.18485.x6.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5011271&code=dGNvc3Rhc291emFAZ21haWwuY29tfDUwMTEyNzF8LTEyNzI0NjQ3MjU=> > > . > NAML > <http://apache-felix.18485.x6.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.x6.nabble.com/ipojo-Help-wih-Stereotype-and-custom-handler-tp5011271p5011303.html Sent from the Apache Felix - Users mailing list archive at Nabble.com.

