Hi,

I'm quite sure this works like you want:



public class FilterAPITest2 extends ARFilterAPIPlugin {
        ...
        ...
        private static String username = null;
        
        public static void init(ARPluginContext context){
                context.logMessage(pluginInfo,
ARPluginContext.PLUGIN_LOG_LEVEL_DEBUG, "getConfigItem()");
                username = context.getConfigItem("username");
    }
        ...
        ...
}

--
J

2012/1/24 Axton <axton.gr...@gmail.com>:
> The ARFilterAPIPluggable Interface implements or inherits the following 
> methods:
>
> filterAPICall
> initialize
> onEvent
> terminate
>
> I am trying to find the best way to initialize plugins where I have
> both static fields and instance fields in the classes that make up the
> plugin.  I can easily use the initialize method to set the instance
> fields because initialize is called for each thread the plugin servers
> starts.  This does not work so well with the static fields because all
> the different threads step on each other trying to write to the static
> fields.  The static fields are good for things like reading a
> properties file into a Properties object (no need to read/store it 10
> times).  If I implement Runnable on the plugin class and add a log
> line to the initialize method:
>
> context.logMessage(context.getPluginInfo(),
> com.bmc.arsys.pluginsvr.plugins.ARPluginContext.PLUGIN_LOG_LEVEL_INFO,
> "initialize called - " + Thread.currentThread().getName());
>
> The logs show that initialize is called for every thread (10 in this case):
>
> 2012-01-24 14:20:51,516 [pool-2-thread-6  ] INFO
> com.bmc.arsys.pluginsvr.plugins.ARPluginContext - <PLUGIN>initialize
> called - pool-2-thread-6
> 2012-01-24 14:20:51,515 [pool-2-thread-5  ] INFO
> com.bmc.arsys.pluginsvr.plugins.ARPluginContext - <PLUGIN>initialize
> called - pool-2-thread-5
> 2012-01-24 14:20:51,536 [pool-2-thread-10 ] INFO
> com.bmc.arsys.pluginsvr.plugins.ARPluginContext - <PLUGIN>initialize
> called - pool-2-thread-10
> 2012-01-24 14:20:51,538 [pool-2-thread-8  ] INFO
> com.bmc.arsys.pluginsvr.plugins.ARPluginContext - <PLUGIN>initialize
> called - pool-2-thread-8
> 2012-01-24 14:20:51,557 [pool-2-thread-4  ] INFO
> com.bmc.arsys.pluginsvr.plugins.ARPluginContext - <PLUGIN>initialize
> called - pool-2-thread-4
> 2012-01-24 14:20:51,560 [pool-2-thread-3  ] INFO
> com.bmc.arsys.pluginsvr.plugins.ARPluginContext - <PLUGIN>initialize
> called - pool-2-thread-3
> 2012-01-24 14:20:51,562 [pool-2-thread-2  ] INFO
> com.bmc.arsys.pluginsvr.plugins.ARPluginContext - <PLUGIN>initialize
> called - pool-2-thread-2
> 2012-01-24 14:20:51,565 [pool-2-thread-7  ] INFO
> com.bmc.arsys.pluginsvr.plugins.ARPluginContext - <PLUGIN>initialize
> called - pool-2-thread-7
> 2012-01-24 14:20:51,568 [pool-2-thread-1  ] INFO
> com.bmc.arsys.pluginsvr.plugins.ARPluginContext - <PLUGIN>initialize
> called - pool-2-thread-1
> 2012-01-24 14:20:51,571 [pool-2-thread-9  ] INFO
> com.bmc.arsys.pluginsvr.plugins.ARPluginContext - <PLUGIN>initialize
> called - pool-2-thread-9
>
>
> I can use the thread name to isolate these types of tasks to a single
> thread, but there are no guarantees this will work with the next
> release of ARS:
>
> if (Thread.currentThread().getName().endsWith("thread-1"))
>
>
> Is there a better way to achieve this?
>
> The C based plugin framework provides functions to address this need:
> * ARPluginCreateInstance
> * ARPluginDeleteInstance
> ARPluginEvent
> ARPluginIdentify
> * ARPluginInitialization
> ARPluginSetProperties
> * ARPluginTermination
>
> But these seem to be missing from the Java implementation.
>
> Thanks,
> Axton Grams
>
> _______________________________________________________________________________
> UNSUBSCRIBE or access ARSlist Archives at www.arslist.org
> attend wwrug12 www.wwrug12.com ARSList: "Where the Answers Are"

_______________________________________________________________________________
UNSUBSCRIBE or access ARSlist Archives at www.arslist.org
attend wwrug12 www.wwrug12.com ARSList: "Where the Answers Are"

Reply via email to