How to get the plugin configuration in parent resource ?

Ian Springer ian.springer at redhat.com
Wed Dec 22 03:49:27 UTC 2010


There's no API provided for a ResourceComponent to obtain its parent 
ResourceComponent's plugin configuration. However, there is the 
ResourceContext.getParentResourceComponent() API, so if a 
ResourceComponent wanted to provide child ResourceComponents access to 
its plugin config it could implement:

public ResourceContext getResourceContext();
// then child ResourceComponents could do 
((FooComponent)getParentResourceComponent()).getResourceContext().getPluginConfiguration()

or

public Configuration getPluginConfiguration();
// then child ResourceComponents could do 
((FooComponent)getParentResourceComponent()).getPluginConfiguration()

or it could just provide access to certain plugin configuration 
properties, e.g.:

public File getInstallPath();

On 12/21/2010 08:28 PM, Lin Gao wrote:
> Hi, gurus:
>
>     I am fresher on RHQ plug-ins, I am writing a RHQ plug-in, and have a question on the plugin configuration:
>
> My rhq-plugins.xml:
>
> <plugin name="HttpCheck" displayName="Http Server Checker" ...>
>    <server name="Http Server Checker" discovery="HttpCheckServerDiscoveryComponent" class="HttpCheckResourceComponent">
>       <server name="HttpServer-Host" supportsManualAdd="true" discovery="HttpHostDiscoveryComponent" class="HttpHostResourceComponent">
>           <plugin-configuration>
>               <c:simple-property name="host" ... />
>               <c:simple-property name="port" type="integer" ... />
>           </plugin-configuration>
>
>           <service name="HttpServer-Path" supportsManualAdd="true" discovery="HttpPathDiscoveryComponent" class="HttpPathResourceComponent">
>              <plugin-configuration>
>                  <c:simple-property name="path" ... />
>              </plugin-configuration>
>           </service>
>       </server>
>    </server>
> </plugin>
>
>
> The idea of this plugin is to check the specified path of one http server whether it is available.
>
> In the
> HttpPathResourceComponent.start(ResourceContext _context){
>      Configuration config = context.getPluginConfiguration();
>      String path = config.getSimpleValue("path", "/");   // Here get the path configuration
>
>      //TODO:  How to get the host and port here ??
>      //TODO:  What is the best practice to get the plugin configuration in parent resource ??
>
> }
>
>
> --
> Best Regards
> Lin Gao
>
> _______________________________________________
> rhq-devel mailing list
> rhq-devel at lists.fedorahosted.org
> https://fedorahosted.org/mailman/listinfo/rhq-devel


-- 
Ian Springer
Principal Software Developer
JBoss Operations Network
Red Hat
ian.springer at redhat.com



More information about the rhq-devel mailing list