AR System Java Plug-in API

com.bmc.arsys.pluginsvr.plugins
Class ARPluginContext

java.lang.Object
  extended by com.bmc.arsys.pluginsvr.plugins.ARPluginContext
All Implemented Interfaces:
com.bmc.arsys.api.ARNativeAuthenticationInfo

public class ARPluginContext
extends Object
implements com.bmc.arsys.api.ARNativeAuthenticationInfo

Provides the contextual information for each plugin call. Provides access to login information for the call that led to this plugin call. Also provides access to common plugin server functionality that plugins will need, like access to configuration info for a given plugin, logging methods to log into the plugin server log etc. This class can also be used to create a ARServerUser that can be used to make api calls as the user who triggered this api call.


Field Summary
static int AR_INTERNAL_REQ_CONFIG
          Used as eventId in ARPlugin.onEvent(ARPluginContext, int) to indicate that ar.cfg has serverInfo changed.
static int PLUGIN_LOG_LEVEL_ERROR
          Logging level for warning messages.
static int PLUGIN_LOG_LEVEL_FATAL
          Logging level for fatal messages
static int PLUGIN_LOG_LEVEL_INFO
          Logging level for informational messages.
static int PLUGIN_LOG_LEVEL_WARNING
          Logging level for warning messages.
 
Constructor Summary
ARPluginContext()
          Default Constructor
ARPluginContext(String user, String guid, String authString)
          Constructor
ARPluginContext(String user, String guid, String authString, String[] args, ARPluginInfo info)
          Constructor
 
Method Summary
 String getARConfigEntry(String key)
          If the server configuration file was loaded from a path relative to the install path specified in the command line argument, this call will return values for tags configured in the ar.conf or ar.cfg file.
 String getAuthString()
          Returns the authentication string for this user session
 String[] getCmdLineArgs()
          Returns the command line arguments that the plugin server was started with.
 String getConfigItem(ARPluginInfo id, String key)
          If ARPluginInfo == null, get the supported value of a configuration item for plugin server element in the pluginsvr_config.xml file.
 String getConfigItem(String key)
          Get the value of a configuration item for this plug-in from the <userDefined> element in the pluginsvr_config.xml file.
 ARPluginInfo getPluginInfo()
          Return the identification information about the plugin in the current context
 Map<Object,Object> getPluginInstanceLocalInfo()
          Set a map of plug-in instance stateful information that plug-in would want to keep.
 String getRemoteHostCharSet()
          The remote host character set for current request.
 String getUser()
          Returns the user name for the api call that resulted in this plugin call.
 String getUserSessionGuid()
          Returns the session specific guid for this user session, that can be used for authentication purposes along with the user name to make AR API calls to the AR Server in the midst of a plugin call.
 boolean isPluginsvrStarted()
          Check if current instance of java plug-in server is started and ready to take rpc calls
 void logMessage(ARPluginInfo info, int level, String message)
          Given the identification of the plugin, the level and message to log, log all relevant info into the plugin log file, depending on the log level configuration of the plugin server.
 void logMessage(int level, String message)
          Given the level and message to log, log all relevant info including current plugin info, into the plugin log file, depending on the log level configuration of the plugin server.
 void setConfigItem(ARPluginInfo id, String key, String value)
          Set the value of a configuration item for the identified plug-in from the <userDefined> element in the pluginsvr_config.xml file.
 void setConfigItem(String key, String value)
          Set the value of a configuration item for this plug-in from the <userDefined> element in the pluginsvr_config.xml file.
 void setPluginInstanceLocalInfo(Map<Object,Object> pluginInstanceLocalInfo)
          Set the plug-in instance local info back to plug-in server, so that next call to this same plug-in instance will contain them, no matter what thread calling this instance.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PLUGIN_LOG_LEVEL_INFO

public static final int PLUGIN_LOG_LEVEL_INFO
Logging level for informational messages.

See Also:
Constant Field Values

PLUGIN_LOG_LEVEL_WARNING

public static final int PLUGIN_LOG_LEVEL_WARNING
Logging level for warning messages.

See Also:
Constant Field Values

PLUGIN_LOG_LEVEL_ERROR

public static final int PLUGIN_LOG_LEVEL_ERROR
Logging level for warning messages.

See Also:
Constant Field Values

PLUGIN_LOG_LEVEL_FATAL

public static final int PLUGIN_LOG_LEVEL_FATAL
Logging level for fatal messages

See Also:
Constant Field Values

AR_INTERNAL_REQ_CONFIG

public static final int AR_INTERNAL_REQ_CONFIG
Used as eventId in ARPlugin.onEvent(ARPluginContext, int) to indicate that ar.cfg has serverInfo changed. User can call getConfigItem(ARPluginInfo, String) to get the value of the given key from ar.cfg.

See Also:
Constant Field Values
Constructor Detail

ARPluginContext

public ARPluginContext(String user,
                       String guid,
                       String authString)
Constructor

Parameters:
user - the user's name
guid - the user's GUID
authString - the user's authentication string

ARPluginContext

public ARPluginContext(String user,
                       String guid,
                       String authString,
                       String[] args,
                       ARPluginInfo info)
Constructor

Parameters:
user - the user's name
guid - the user's GUID
authString - the user's authentication string
args - the arguments the Plug-in Server was started with
info - the ARPluginInfo instance the for this plug-in

ARPluginContext

public ARPluginContext()
Default Constructor

Method Detail

getCmdLineArgs

public String[] getCmdLineArgs()
Returns the command line arguments that the plugin server was started with. Plugins can use this information. One value of interest would be the -i argument, which is typically the AR Server install folder. This can be used to get access to the configuration file.

Returns:
the command line arguments

getPluginInfo

public ARPluginInfo getPluginInfo()
Return the identification information about the plugin in the current context

Returns:
ARPluginInfo for the current plugin in the context

getUser

public String getUser()
Returns the user name for the api call that resulted in this plugin call. Useful for use in api calls in the midst of a plugin call if plugins wish to do so.

Specified by:
getUser in interface com.bmc.arsys.api.ARNativeAuthenticationInfo
Returns:
User name for the AR User that triggered this plugin call.

getUserSessionGuid

public String getUserSessionGuid()
Returns the session specific guid for this user session, that can be used for authentication purposes along with the user name to make AR API calls to the AR Server in the midst of a plugin call.

Specified by:
getUserSessionGuid in interface com.bmc.arsys.api.ARNativeAuthenticationInfo
Returns:
An authentication string equivalent to a password that can be used to make AR API calls as the user returned by getUser(). This password is valid only for the length of the calling api call. This cant be saved and reused later.

logMessage

public void logMessage(ARPluginInfo info,
                       int level,
                       String message)
Given the identification of the plugin, the level and message to log, log all relevant info into the plugin log file, depending on the log level configuration of the plugin server.

Parameters:
info - ARPluginInfo about the plugin
level - PLUGIN_LOG_LEVEL_INFO, PLUGIN_LOG_LEVEL_WARNING, PLUGIN_LOG_LEVEL_ERROR or PLUGIN_LOG_LEVEL_FATAL
message - message to log

logMessage

public void logMessage(int level,
                       String message)
Given the level and message to log, log all relevant info including current plugin info, into the plugin log file, depending on the log level configuration of the plugin server.

Parameters:
level - PLUGIN_LOG_LEVEL_INFO, PLUGIN_LOG_LEVEL_WARNING, PLUGIN_LOG_LEVEL_ERROR or PLUGIN_LOG_LEVEL_FATAL
message - message to log

getAuthString

public String getAuthString()
Returns the authentication string for this user session

Specified by:
getAuthString in interface com.bmc.arsys.api.ARNativeAuthenticationInfo
Returns:
the authentication string

getConfigItem

public String getConfigItem(ARPluginInfo id,
                            String key)
If ARPluginInfo == null, get the supported value of a configuration item for plugin server element in the pluginsvr_config.xml file. Only certain supported value will be available for plugins to get from here. If ARPluginInfo != null, get the value of a configuration item for the identified plug-in from the <userDefined> element in the pluginsvr_config.xml file. The plug-in server loads the values from the configuration file when it starts and saves them to the file when it exits.

Parameters:
id - ARPluginInfo plug-in identification. null indicate the key is for pluginsvr configured key.
key - String name of the element in <userDefined> if id is set. Or tag under directly
Returns:
Value of the element named in key from the plug-in server configuration file. Null if not found.
See Also:
setConfigItem(com.bmc.arsys.pluginsvr.plugins.ARPluginInfo, java.lang.String, java.lang.String)

setConfigItem

public void setConfigItem(ARPluginInfo id,
                          String key,
                          String value)
Set the value of a configuration item for the identified plug-in from the <userDefined> element in the pluginsvr_config.xml file. The plug-in server loads the values from the configuration file when it starts and saves them to the file when it exits. Given a plugin identifier, fetch the configuration value for the given key for that plugin. The value is looked up in the plugin server configuration file.

Parameters:
id - ARPluginInfo plug-in identification
key - String name of the element in <userDefined>
value - String value value for the element named in key in the plug-in server configuration file.
See Also:
getConfigItem(com.bmc.arsys.pluginsvr.plugins.ARPluginInfo, java.lang.String)

getConfigItem

public String getConfigItem(String key)
Get the value of a configuration item for this plug-in from the <userDefined> element in the pluginsvr_config.xml file. The plug-in server loads the values from the configuration file when it starts and saves them to the file when it exits.

Parameters:
key - String name of the element in <userDefined>
Returns:
Value of the element named in key from the plug-in server configuration file. Null if not found.
See Also:
setConfigItem(com.bmc.arsys.pluginsvr.plugins.ARPluginInfo, java.lang.String, java.lang.String)

setConfigItem

public void setConfigItem(String key,
                          String value)
Set the value of a configuration item for this plug-in from the <userDefined> element in the pluginsvr_config.xml file. The plug-in server loads the values from the configuration file when it starts and saves them to the file when it exits. Given a plugin identifier, fetch the configuration value for the given key for that plugin. The value is looked up in the plugin server configuration file.

Parameters:
key - String name of the element in <userDefined>
value - String value for the element named in key in the plug-in server configuration file.
See Also:
getConfigItem(com.bmc.arsys.pluginsvr.plugins.ARPluginInfo, java.lang.String)

getARConfigEntry

public String getARConfigEntry(String key)
If the server configuration file was loaded from a path relative to the install path specified in the command line argument, this call will return values for tags configured in the ar.conf or ar.cfg file. Note that the keys should just be the tag, without any : or whitespaces at the end or beginning.

Parameters:
key - an AR configuration tag
Returns:
String value for the configuration tag specified in key

getRemoteHostCharSet

public String getRemoteHostCharSet()
The remote host character set for current request. This value is not available in plugin's static method init() or ARPluggable.initialize(ARPluginContext) methods.

Returns:
String value for the remote host character set name

getPluginInstanceLocalInfo

public Map<Object,Object> getPluginInstanceLocalInfo()
Set a map of plug-in instance stateful information that plug-in would want to keep. Such as if any info that plug-in would want to put in thread local. Since plug-in server might not use the same thread to call the same plug-in instance, those stateful info should be keep by plug-in server for next call

Returns:

setPluginInstanceLocalInfo

public void setPluginInstanceLocalInfo(Map<Object,Object> pluginInstanceLocalInfo)
Set the plug-in instance local info back to plug-in server, so that next call to this same plug-in instance will contain them, no matter what thread calling this instance.

Parameters:
pluginInstanceLocalInfo -

isPluginsvrStarted

public boolean isPluginsvrStarted()
Check if current instance of java plug-in server is started and ready to take rpc calls

Returns:

AR System Java Plug-in API

© Copyright 2014 BMC Software, Inc.