org.chwf.resources
Class ResourceLocator

java.lang.Object
  |
  +--org.chwf.resources.ResourceLocator

public class ResourceLocator
extends java.lang.Object

A locator for resources. It delegates is calls to the appropriate [@link ResourceFactory}.

Author:
Paul Strack

Constructor Summary
ResourceLocator()
           
 
Method Summary
static java.lang.Object getResource(java.lang.Class type)
          Get a resource from its default factory.
static java.lang.Object getResource(java.lang.Class type, java.lang.String factoryName)
          Get a resource from a named factory.
static boolean hasFactory(java.lang.Class resource)
          True if the resource has a (default) factory.
static boolean hasFactory(java.lang.Class resource, java.lang.String factoryName)
          True if the resource has a factory with the given name.
static boolean isManaged(java.lang.Class resource)
          True if this resource is managed for the default factory.
static boolean isManaged(java.lang.Class resource, java.lang.String factoryName)
          True if this resource is managed for the given named factory.
static boolean isManagementActive()
          True if management is initialized.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceLocator

public ResourceLocator()
Method Detail

hasFactory

public static boolean hasFactory(java.lang.Class resource)
True if the resource has a (default) factory.
Parameters:
resource - The resource class.
Returns:
True if the resource has a factory.

hasFactory

public static boolean hasFactory(java.lang.Class resource,
                                 java.lang.String factoryName)
True if the resource has a factory with the given name.
Parameters:
resource - The resource class.
factoryName - The factory name.
Returns:
True if the resource has a factory with the given name.

isManaged

public static boolean isManaged(java.lang.Class resource)
True if this resource is managed for the default factory.
Parameters:
resource - The resource class.
Returns:
True if this resource is managed by the default factory.

isManaged

public static boolean isManaged(java.lang.Class resource,
                                java.lang.String factoryName)
True if this resource is managed for the given named factory.
Parameters:
resource - The resource class.
factoryName - The factory name.
Returns:
True if this resource is managed for the given named factory.

getResource

public static java.lang.Object getResource(java.lang.Class type)
                                    throws ResourceException,
                                           ResourceInitException
Get a resource from its default factory.
Parameters:
type - The resource type.
Returns:
The resource.
Throws:
ResourceException - If there is no factory for this resource.
ResourceInitException - If the factory cannot be found.

getResource

public static java.lang.Object getResource(java.lang.Class type,
                                           java.lang.String factoryName)
                                    throws ResourceException,
                                           ResourceInitException
Get a resource from a named factory.
Parameters:
type - The resource type.
factoryName - The factory name.
Returns:
The resource.
Throws:
ResourceException - If there is no factory with this name.
ResourceInitException - If the factory cannot be found.

isManagementActive

public static boolean isManagementActive()
True if management is initialized.
Returns:
True if management is initialized.


Copyright © 2002-2004, Paul Strack. All Rights Reserved.