Rio Project 4.2 API Documentation



org.rioproject.jsb
Class ServiceElementUtil

java.lang.Object
  extended by org.rioproject.jsb.ServiceElementUtil

public class ServiceElementUtil
extends Object

The ServiceElementUtil class provides static methods to assist in working with a ServiceElement

Author:
Dennis Reedy

Constructor Summary
ServiceElementUtil()
           
 
Method Summary
static ServiceBeanConfig addConfigParameter(ServiceBeanConfig sbc, String key, Integer value)
          Add a name,value pair to the ServiceBeanConfig
static ServiceElement copyServiceElement(ServiceElement sElem)
          Make a copy of the ServiceElement
static ServiceElement create(String serviceName, String implClassName, Iterable<String> interfaceClassNames, Iterable<String> implJars, Iterable<String> downloadJars, String codebase, String... group)
          Create a dynamic ServiceElement
static String formatDiscoverySettings(ServiceBeanConfig sbConfig)
          Format discovery settings
static AssociationDescriptor[] getAssociationDescriptors(ServiceElement elem, AssociationType type)
          Get the AssociationDescriptors from the ServiceElement that match the AssociationType type
static PlatformCapability[] getMatchedPlatformCapabilities(ServiceElement sElem, PlatformCapability[] pCaps)
          Get the PlatformCapability instances that match declared operational requirements
static long getNextID(long[] lArray)
          Get the next instance ID
static WatchDescriptor getWatchDescriptor(ServiceElement sElem, String name)
          Get the WatchDescriptor from an SLA for the given ID
static boolean hasDifferentGroups(ServiceElement sElem1, ServiceElement sElem2)
          Determine if the Discovery groups are different between the two ServiceElement instances
static boolean hasDifferentLocators(ServiceElement sElem1, ServiceElement sElem2)
          Determine if the LookupLocators are different between the two ServiceElement instances
static boolean hasDifferentLoggerConfig(ServiceElement sElem1, ServiceElement sElem2)
          Determine if the LoggerConfig attributes are different between the two ServiceElement instances
static boolean hasDifferentServiceUIs(Entry[] serviceUIs, ServiceElement sElem2, String codebase)
          Determine if there are different ServiceUI declarations in the ServiceElement instance
static boolean hasHTTPCodebase(ServiceElement sElem)
          Determine if the ServiceElement has a HTTP based codebase
static boolean matchesServiceElement(ServiceElement sElem, String name, String[] interfaces, String opStringName)
          Determines if the name, interfaces and opStringName equate to attributes found in the provided ServiceElement
static ServiceBeanInstance prepareInstanceID(ServiceBeanInstance sbi, long id)
          Set the instanceID, optionally making a copy of the ServiceElement
static ServiceElement prepareInstanceID(ServiceElement sElem, boolean copy, long id)
          Set the instanceID, optionally making a copy of the ServiceElement
static ServiceElement prepareInstanceID(ServiceElement sElem, long id)
          Make a copy of the ServiceElement and set the instance ID
static void setCodebase(ServiceElement sElem, String codebase)
          Set the codebase for the ServiceElement
static void setThreadDeadlockDetector(ServiceElement sElem, MBeanServerConnection mbsc)
          Check to see if the ThreadDeadlockMonitor has been declared as an SLA.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceElementUtil

public ServiceElementUtil()
Method Detail

setThreadDeadlockDetector

public static void setThreadDeadlockDetector(ServiceElement sElem,
                                             MBeanServerConnection mbsc)
Check to see if the ThreadDeadlockMonitor has been declared as an SLA. If not, add the default setup for the ThreadDeadlockMonitor

Parameters:
sElem - The ServiceElement to use
mbsc - An optional MBeanServerConnection to set to the ThreadDeadlockDetector
Throws:
IllegalArgumentException - if the ServiceElement parameter is null

getWatchDescriptor

public static WatchDescriptor getWatchDescriptor(ServiceElement sElem,
                                                 String name)
Get the WatchDescriptor from an SLA for the given ID

Parameters:
sElem - The ServiceElement to use
name - The WatchDescriptor name
Returns:
The matching WatchDescriptor or null if not found
Throws:
IllegalArgumentException - if either of the parameters are null

setCodebase

public static void setCodebase(ServiceElement sElem,
                               String codebase)
Set the codebase for the ServiceElement

Parameters:
sElem - The ServiceElement
codebase - The codebase to set
Throws:
IllegalArgumentException - if either of the parameters are null

hasHTTPCodebase

public static boolean hasHTTPCodebase(ServiceElement sElem)
Determine if the ServiceElement has a HTTP based codebase

Parameters:
sElem - The ServiceElement
Returns:
True if the ServiceElement has either a component or export bundle which has a codebase that is HTTP based
Throws:
IllegalArgumentException - if either of the parameters are null

hasDifferentLoggerConfig

public static boolean hasDifferentLoggerConfig(ServiceElement sElem1,
                                               ServiceElement sElem2)
Determine if the LoggerConfig attributes are different between the two ServiceElement instances

Parameters:
sElem1 - ServiceElement to compare
sElem2 - ServiceElement to compare
Returns:
True if there is a difference between the LoggerConfig attributes, false otherwise

hasDifferentServiceUIs

public static boolean hasDifferentServiceUIs(Entry[] serviceUIs,
                                             ServiceElement sElem2,
                                             String codebase)
Determine if there are different ServiceUI declarations in the ServiceElement instance

Parameters:
serviceUIs - Array of attributes
sElem2 - ServiceElement to compare
codebase - The codebase to use
Returns:
True if there are differences. false if the same

hasDifferentGroups

public static boolean hasDifferentGroups(ServiceElement sElem1,
                                         ServiceElement sElem2)
Determine if the Discovery groups are different between the two ServiceElement instances

Parameters:
sElem1 - ServiceElement to compare
sElem2 - ServiceElement to compare
Returns:
True if there is a difference between the Discovery groups, false otherwise

hasDifferentLocators

public static boolean hasDifferentLocators(ServiceElement sElem1,
                                           ServiceElement sElem2)
Determine if the LookupLocators are different between the two ServiceElement instances

Parameters:
sElem1 - ServiceElement to compare
sElem2 - ServiceElement to compare
Returns:
True if there is a difference between the LookupLocators, false otherwise

prepareInstanceID

public static ServiceElement prepareInstanceID(ServiceElement sElem,
                                               boolean copy,
                                               long id)
Set the instanceID, optionally making a copy of the ServiceElement

Parameters:
sElem - The ServiceElement to use
copy - If true, make a copy of the ServiceElement before assigning the instanceID
id - The instanceID to assign
Returns:
A ServiceElement with it's instanceID set to the value provided

prepareInstanceID

public static ServiceBeanInstance prepareInstanceID(ServiceBeanInstance sbi,
                                                    long id)
Set the instanceID, optionally making a copy of the ServiceElement

Parameters:
sbi - The ServiceBeanInstance to use
id - The instanceID to assign
Returns:
A ServiceBeanInstance with it's instanceID set to the value provided

prepareInstanceID

public static ServiceElement prepareInstanceID(ServiceElement sElem,
                                               long id)
Make a copy of the ServiceElement and set the instance ID

Parameters:
sElem - ServiceElement to use
id - the id to set
Returns:
A new ServiceElement

getNextID

public static long getNextID(long[] lArray)
Get the next instance ID

Parameters:
lArray - An array of ids
Returns:
The next instanceID

copyServiceElement

public static ServiceElement copyServiceElement(ServiceElement sElem)
Make a copy of the ServiceElement

Parameters:
sElem - The ServiceElement to copy
Returns:
A new ServiceElement

create

public static ServiceElement create(String serviceName,
                                    String implClassName,
                                    Iterable<String> interfaceClassNames,
                                    Iterable<String> implJars,
                                    Iterable<String> downloadJars,
                                    String codebase,
                                    String... group)
                             throws Exception
Create a dynamic ServiceElement

Parameters:
serviceName - The name of the service. Must not be null.
implClassName - The implementation classname. Must not be null.
interfaceClassNames - An iterable collection of interface classnames the service exports, must not be null.
implJars - An iterable collection of jars used to instantiate the service, must not be null.
downloadJars - An iterable collection of jars used as the codebase of the service; for the jars
codebase - The location the resources, both the implementation and codebase jars, can be accessed from
group - Name of the groups to use for discovery & join.
Returns:
A ServiceElement
Throws:
Exception - If the ServiceElement cannot be created.

addConfigParameter

public static ServiceBeanConfig addConfigParameter(ServiceBeanConfig sbc,
                                                   String key,
                                                   Integer value)
Add a name,value pair to the ServiceBeanConfig

Parameters:
sbc - The current ServiceBeanConfig to set
key - The key to set
value - The value for the key
Returns:
A ServiceBeanConfig with the added properties

matchesServiceElement

public static boolean matchesServiceElement(ServiceElement sElem,
                                            String name,
                                            String[] interfaces,
                                            String opStringName)
Determines if the name, interfaces and opStringName equate to attributes found in the provided ServiceElement

Parameters:
sElem - The ServiceElement to test, must not be null
name - The name to check, may be null
interfaces - The ames of the interfaces the service advertises, must not be null
opStringName - The name of the operationalString, may be null
Returns:
If the attributes can be found in the ServiceElement, return true

getMatchedPlatformCapabilities

public static PlatformCapability[] getMatchedPlatformCapabilities(ServiceElement sElem,
                                                                  PlatformCapability[] pCaps)
Get the PlatformCapability instances that match declared operational requirements

Parameters:
sElem - The ServiceElement to use
pCaps - Array of PlatformCapability objects objects
Returns:
Array of matching PlatformCapability objects. If there are no matching PlatformCapability instances, a zero-length array is returned. A new array is allocated each time.

getAssociationDescriptors

public static AssociationDescriptor[] getAssociationDescriptors(ServiceElement elem,
                                                                AssociationType type)
Get the AssociationDescriptors from the ServiceElement that match the AssociationType type

Parameters:
elem - The ServiceElement
type - The AssociationType type
Returns:
An array of AssociationDescriptor instances that match the AssociationType type. If there are no matching AssociationDescriptors, return an empty array. A new array is allocated each time

formatDiscoverySettings

public static String formatDiscoverySettings(ServiceBeanConfig sbConfig)
Format discovery settings

Parameters:
sbConfig - The ServiceElement to use
Returns:
a String with discovery settings formatted

Copyright © Rio Project.

Copyright © 2006-2011 Rio Project. All Rights Reserved.