org.jboss.shotoku.tools
Class CacheTools

java.lang.Object
  extended by org.jboss.shotoku.tools.CacheTools

public class CacheTools
extends java.lang.Object

Utility, helper functions used internally.

Author:
Adam Warski

Field Summary
static java.lang.String DEFAULT_CACHE_MONITOR_MBEAN
          Name of the default RenewableCacheMonitorServiceMBean mbean.
static java.lang.String DEFAULT_RENEWABLE_CACHE_MBEAN
          Name of the default RenewableCacheServiceMBean mbean.
static java.lang.String GENERATED_FQN_BASE
          The first part of automatically generated fqn-s for cache item nodes.
 
Constructor Summary
CacheTools()
           
 
Method Summary
static int getNextId()
           
static java.lang.Object getService(java.lang.String mbeanName, java.lang.Class<?> c)
          Gets a reference to an mbean with the given name.
static boolean isEmpty(java.lang.String s)
          Checks if the given string is empty (null or "").
static boolean objectsEqual(java.lang.Object obj1, java.lang.Object obj2)
          Checks if two objects are equal - either both null, or their equals method returns true.
static java.lang.String toString(java.lang.Object o)
          Converts the given object to a String in a null-safe way.
static java.lang.String toStringNotNull(java.lang.Object o)
          Converts the given object to a String in a null-safe way.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GENERATED_FQN_BASE

public static final java.lang.String GENERATED_FQN_BASE
The first part of automatically generated fqn-s for cache item nodes.

See Also:
Constant Field Values

DEFAULT_RENEWABLE_CACHE_MBEAN

public static final java.lang.String DEFAULT_RENEWABLE_CACHE_MBEAN
Name of the default RenewableCacheServiceMBean mbean.

See Also:
Constant Field Values

DEFAULT_CACHE_MONITOR_MBEAN

public static final java.lang.String DEFAULT_CACHE_MONITOR_MBEAN
Name of the default RenewableCacheMonitorServiceMBean mbean.

See Also:
Constant Field Values
Constructor Detail

CacheTools

public CacheTools()
Method Detail

getService

public static java.lang.Object getService(java.lang.String mbeanName,
                                          java.lang.Class<?> c)
                                   throws javax.management.MalformedObjectNameException
Gets a reference to an mbean with the given name.

Parameters:
mbeanName - Name of the mbean to get.
c - Class of the mbean to get.
Returns:
A reference to the mbean.
Throws:
javax.management.MalformedObjectNameException

isEmpty

public static boolean isEmpty(java.lang.String s)
Checks if the given string is empty (null or "").

Parameters:
s - String to check.
Returns:
True iff the given string is null or equal to "".

toString

public static java.lang.String toString(java.lang.Object o)
Converts the given object to a String in a null-safe way.

Parameters:
o - Object to convert.
Returns:
Result of o.toString() or null if o is null.

toStringNotNull

public static java.lang.String toStringNotNull(java.lang.Object o)
Converts the given object to a String in a null-safe way. Never returns a null.

Parameters:
o - Object to convert.
Returns:
Result of o.toString() or an emptys tring if o is null.

objectsEqual

public static boolean objectsEqual(java.lang.Object obj1,
                                   java.lang.Object obj2)
Checks if two objects are equal - either both null, or their equals method returns true.

Parameters:
obj1 - First object to compare.
obj2 - Second object to compare.
Returns:
True iff both objects are equal to null or if their equals method returns true.

getNextId

public static int getNextId()
Returns:
Gets a unique integer id.