Typically, you would have the PlugIn store an object in the Servlet scope under a known name, and then other objects could retrieve the information form there. So, the PlugIn does provide the service itself, it's a loader for the service provider.

HTH, Ted.

Andy Engle wrote:
Hi all,

I am wondering if there is a clean(er) way to get PlugIn configuration
information out of struts-config.xml.  I have written a PlugIn that
gets this information, but it seems somewhat convoluted.  First I get
all the PlugInConfigs, then I loop through that array of PlugInConfig
objects until I find the one that matches the current PlugIn I'm
working with.  Next, I set that value as my PlugIn index and get the
properties from there.  While this works, it seems like I am getting it
almost "by hook or by crook", and I'm wondering if there is a more
elegant way to do it.  I'm not sure I like the use of the "for" loop;
it seems there should be a way to just directly access the PlugIn's
config info right away.  The code snippet I'm using is below.

Thanks for any advice!


Andy


---

Here's that code snippet:

// Get all the PlugIn configs, for every plugin
PlugInConfig allPluginConfigs[] = config.findPlugInConfigs();

// This goes through all the Plugin configs and looks for the
// plugin config for this class.
for(int i = 0; i < allPluginConfigs.length; i++) {
if(allPluginConfigs[i].getClassName().equals("com.andyengle.struts.app.WhateverPlugin"))
{
pluginConfigIndex = i;
break;
}
}


// Get the properties for this PlugIn and shlep them into a map.
thisConfigMap = allPluginConfigs[pluginConfigIndex].getProperties();

// Finally, access the config information that was set in struts-config
String value1 = (String) thisConfigMap.get("val1_str");
String value2 = (String) thisConfigMap.get("val2_str");


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]





--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to