- 4.3.1.8.1 Synopsis
- 4.3.1.8.2 getBooleanProperty(String, String)
- 4.3.1.8.3 getServiceInstance(Class<T>)
- 4.3.1.8.4 getServiceInstance(Class<T>, ClassLoader)
- 4.3.1.8.5 getServiceInstance(Class<T>, String)
- 4.3.1.8.6 getServiceInstance(Class<T>, String, ClassLoader)
- 4.3.1.8.7 getServiceInstances(Class<T>, ClassLoader, StringBuffer)
- 4.3.1.8.8 getSessionFactory(Map)
- 4.3.1.8.9 getSessionFactory(Map, ClassLoader)
- 4.3.1.8.10 getStringProperty(String, String)
- 4.3.1.8.11 newDbug()
ClusterJHelper provides helper methods to bridge between the API and the implementation.
public class ClusterJHelper {
// Public Constructorspublic ClusterJHelper();
// Public Static Methodspublic static boolean getBooleanProperty(String propertyName,
String def);public static T getServiceInstance(Class<T> cls);
public static T getServiceInstance(Class<T> cls,
ClassLoader loader);public static T getServiceInstance(Class<T> cls,
String implementationClassName);public static T getServiceInstance(Class<T> cls,
String implementationClassName,
ClassLoader loader);public static List<T> getServiceInstances(Class<T> cls,
ClassLoader loader,
StringBuffer errorMessages);public static SessionFactory getSessionFactory(Map props);
public static SessionFactory getSessionFactory(Map props,
ClassLoader loader);public static String getStringProperty(String propertyName,
String def);public static Dbug newDbug();
}
Methods inherited from
java.lang.Object:
equals
, getClass
, hashCode
, notify
, notifyAll
, toString
, wait
public static boolean getBooleanProperty(String propertyName,
String def);
Get the named boolean property from either the environment or system properties. If the property is not 'true' then return false.
Table 4.5 getBooleanProperty(String, String)
Parameter | Description |
---|---|
propertyName | the name of the property |
def | the default if the property is not set |
return | the system property if it is set via -D or the system environment |
public static T getServiceInstance(Class<T> cls);
Locate a service implementation by services lookup of the context class loader.
Table 4.6 getServiceInstance(Class<T>)
Parameter | Description |
---|---|
cls | the class of the factory |
return | the service instance |
public static T getServiceInstance(Class<T> cls,
ClassLoader loader);
Locate a service implementation for a service by services lookup of a specific class loader. The first service instance found is returned.
Table 4.7 getServiceInstance(Class<T>, ClassLoader)
Parameter | Description |
---|---|
cls | the class of the factory |
loader | the class loader for the factory implementation |
return | the service instance |
public static T getServiceInstance(Class<T> cls,
String implementationClassName);
Locate a service implementation for a service. If the implementation name is not null, use it instead of looking up. If the implementation class is not loadable or does not implement the interface, throw an exception. Use the ClusterJHelper class loader to find the service.
Table 4.8 getServiceInstance(Class<T>, String)
Parameter | Description |
---|---|
cls | |
implementationClassName | |
return | the implementation instance for a service |
public static T getServiceInstance(Class<T> cls,
String implementationClassName,
ClassLoader loader);
Locate a service implementation for a service. If the implementation name is not null, use it instead of looking up. If the implementation class is not loadable or does not implement the interface, throw an exception.
Table 4.9 getServiceInstance(Class<T>, String, ClassLoader)
Parameter | Description |
---|---|
cls | |
implementationClassName | name of implementation class to load |
loader | the ClassLoader to use to find the service |
return | the implementation instance for a service |
public static List<T> getServiceInstances(Class<T> cls,
ClassLoader loader,
StringBuffer errorMessages);
Locate all service implementations by services lookup of a specific class loader. Implementations in the services file are instantiated and returned. Failed instantiations are remembered in the errorMessages buffer.
Table 4.10 getServiceInstances(Class<T>, ClassLoader, StringBuffer)
Parameter | Description |
---|---|
cls | the class of the factory |
loader | the class loader for the factory implementation |
errorMessages | a buffer used to hold the error messages |
return | the service instance |
public static SessionFactory getSessionFactory(Map props);
Locate a SessionFactory implementation by services lookup. The class loader used is the thread's context class loader.
Table 4.11 getSessionFactory(Map)
Parameter | Description |
---|---|
props | properties of the session factory |
return | the session factory |
Exceptions
-
ClusterFatalUserException
if the connection to the cluster cannot be made
public static SessionFactory getSessionFactory(Map props,
ClassLoader loader);
Locate a SessionFactory implementation by services lookup of a specific class loader. The properties are a Map that might contain implementation-specific properties plus standard properties.
Table 4.12 getSessionFactory(Map, ClassLoader)
Parameter | Description |
---|---|
props | the properties for the factory |
loader | the class loader for the factory implementation |
return | the session factory |
Exceptions
-
ClusterFatalUserException
if the connection to the cluster cannot be made
public static String getStringProperty(String propertyName,
String def);
Get the named String property from either the environment or system properties.
Table 4.13 getStringProperty(String, String)
Parameter | Description |
---|---|
propertyName | the name of the property |
def | the default if the property is not set |
return | the system property if it is set via -D or the system environment |