org.rhq.core.pc.util
Class ComponentUtil
java.lang.Object
org.rhq.core.pc.util.ComponentUtil
public class ComponentUtil
- extends Object
Some static utilities for use with component objects.
- Author:
- John Mazzitelli
|
Method Summary |
static ResourceComponent |
fetchResourceComponent(int resourceId)
|
static
|
getComponent(int resourceId,
Class<T> facetInterface,
FacetLockType lockType,
long timeout,
boolean daemonThread,
boolean onlyIfStarted)
Gets the given facet interface for the resource identified with the given ID. |
static org.rhq.core.domain.resource.ResourceType |
getResourceType(int resourceId)
Gets the Resource type of the Resource identified with the given ID. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ComponentUtil
public ComponentUtil()
getResourceType
public static org.rhq.core.domain.resource.ResourceType getResourceType(int resourceId)
throws PluginContainerException
- Gets the Resource type of the Resource identified with the given ID. An exception is thrown if it cannot be
determined.
- Parameters:
resourceId - the Resource id
- Returns:
- the Resource's
ResourceType
- Throws:
PluginContainerException - if the Resource is not known
getComponent
public static <T> T getComponent(int resourceId,
Class<T> facetInterface,
FacetLockType lockType,
long timeout,
boolean daemonThread,
boolean onlyIfStarted)
throws PluginContainerException
- Gets the given facet interface for the resource identified with the given ID. If the resource does not have a
valid resource component associated with it or if it does not support the given facet, an exception is thrown. If
the resource component is not yet started and
onlyIfStarted is true, an exception will
be thrown. Under most conditions when the plugin container managers need components, those components must be in
the started state. This method can ensure that the component will only be returned if it is started.
The lockType defines how the caller wants to synchronize access to the facet method calls. If it
is FacetLockType.NONE, the returned object is the component itself and will allow immediate and
concurrent access to the component without synchronization. If it is FacetLockType.READ or
FacetLockType.WRITE, the returned object is actually a proxy to the component that restricts access to
the component's facet methods by synchronizing on the component's read or write lock. You would request
synchronized access to a component if you want to make calls to the facet interface that require that it not run
concurrently with any other component call in any other facet. For example, if you want to update a configuration
via the configuration facet, you would ask for a write lock to prohibit any other facet call from concurrently
being made. This will ensure that the configuration update will not occur at the same time an operation facet
method call was made.
- Parameters:
resourceId - identifies the resource whose facet component interface is to be returnedfacetInterface - the resource component's facet type that is to be returnedlockType - how access to the facet should be synchronizedtimeout - if the method invocation thread has not completed after this many milliseconds, interrupt
it; value must be positivedaemonThread - whether or not the thread used for the invocation should be a daemon threadonlyIfStarted - if true, and the component is not started, an exception is thrown
- Returns:
- the resource's
T component interface
- Throws:
PluginContainerException - if the resource does not have a component or it does not support the given facet
interface or it is not started and onlyIfStarted is
true- See Also:
ResourceContainer.createResourceComponentProxy(Class, FacetLockType, long, boolean, boolean)
fetchResourceComponent
public static ResourceComponent fetchResourceComponent(int resourceId)
Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.