-
1. Re: Can I pass values from parent to child , If child is Manually discovered ? ? ?
lkrejci Jun 17, 2013 4:40 AM (in response to arun2arunraj)The child component has access to the parent component so you can access the parent from the child. See for example here: https://community.jboss.org/message/802880#802880.
-
2. Re: Can I pass values from parent to child , If child is Manually discovered ? ? ?
arun2arunraj Jun 17, 2013 5:20 AM (in response to lkrejci)Dude, I have followed this only. This is working for auto discovered child. But the code is not working for manually imported or discovered childs.
In the child discovery,
public class ChildDiscovery implements ResourceDiscoveryComponent<ParentComponent>, ManualAddFacet { public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context) throws InvalidPluginConfigurationException, Exception { return Collections.emptySet();//For not auto discovered. } public DiscoveredResourceDetails discoverResource(Configuration pluginConfig, ResourceDiscoveryContext context) throws InvalidPluginConfigurationException { //Collect and return the child resource }
In the Child Component,
public class ChildComponent implements ResourceComponent<ParentComponent>, MeasurementFacet { public void start(Resource Context<ParentComponent> Context) { this.Context = Context; } public int dataFromParent() { return Context.getParentComponent().getParentFunction(); } }
This is what I have coded. But the child is not getting the parent values. Is this a correct way of accessing the parent class via manual import option.
Regards,
ArunRaj
-
3. Re: Can I pass values from parent to child , If child is Manually discovered ? ? ?
lkrejci Jun 17, 2013 5:22 AM (in response to arun2arunraj)1 of 1 people found this helpfulWhat is not working in that scenario?
does Context.getParentComponent() return null? Or does the getParentFunction() not return data you need?
-
4. Re: Can I pass values from parent to child , If child is Manually discovered ? ? ?
arun2arunraj Jun 17, 2013 5:50 AM (in response to lkrejci)Problem 1 : getParentComponent() returns two objects for each import....
eg:
when I have tried to do read the object hashvalue i got the following result.
Demo NINE : org.rhq.plugins.demo.ParentComponent@51f46b95 ( System.out.println("Demo NINE : "+Context.getParentComponent())
Demo NINE : org.rhq.plugins.demo.ParentComponent@51f46b95
Problem 2 : getParentFunction() is not returning data.
-
5. Re: Can I pass values from parent to child , If child is Manually discovered ? ? ?
arun2arunraj Jun 17, 2013 6:12 AM (in response to arun2arunraj)Hi Lukas,
I have found the reason for Problem 1:
Reason :
Plugin Lifecycle played a main roll here. Problem is with the method invokation. The Method invoking order 1) Start() 2) Stop 3) Start(). I dont know Why stop is called for , after the start method. In the stop method, I am initializing the object as null. Again, The ChildComponent is calling start() method. That is why I am getting two objects.
Regards,
ArunRaj
-
6. Re: Can I pass values from parent to child , If child is Manually discovered ? ? ?
arun2arunraj Jun 17, 2013 10:38 AM (in response to arun2arunraj)Hi Lukas,
Solved the problem. I have commited a mistakes in my code like mismatching metric properties and Mismatching method initialization. Now Its working. Thank you so much guys for your support.
Regards,
ArunRaj