org.rhq.core.pc.inventory
Class ResourceContainer

java.lang.Object
  extended by org.rhq.core.pc.inventory.ResourceContainer
All Implemented Interfaces:
Serializable

public class ResourceContainer
extends Object
implements Serializable

This object holds information relative to the running state of a ResourceComponent in the Plugin Container. It is serializable for persistence to the Plugin Container's storage mechanisms.

Author:
Greg Hinkle, John Mazzitelli, Ian Springer
See Also:
Serialized Form

Nested Class Summary
static class ResourceContainer.ResourceComponentState
           
static class ResourceContainer.SynchronizationState
           
 
Constructor Summary
ResourceContainer(org.rhq.core.domain.resource.Resource resource, ClassLoader resourceClassLoader)
           
 
Method Summary
 void addDriftDefinition(org.rhq.core.domain.drift.DriftDefinition d)
           
 boolean containsDriftDefinition(org.rhq.core.domain.drift.DriftDefinition d)
           
<T> T
createResourceComponentProxy(Class<T> facetInterface, FacetLockType lockType, long timeout, boolean daemonThread, boolean onlyIfStarted)
          Creates a proxy to this container's resource component, essentially returning the component exposed as the given facet interface.
 org.rhq.core.domain.measurement.Availability getAvailability()
          Returns the currently known availability of the resource.
 Collection<org.rhq.core.domain.drift.DriftDefinition> getDriftDefinitions()
           
 Set<org.rhq.core.domain.content.transfer.ResourcePackageDetails> getInstalledPackages()
           
 Set<org.rhq.core.domain.measurement.MeasurementScheduleRequest> getMeasurementSchedule()
           
 Lock getReadFacetLock()
          If a piece of code wants to make a call into a plugin component's facet, and that call doesn't need to write or modify any data within the component or the managed resource itself, that code should obtain the returned read lock.
 org.rhq.core.domain.resource.Resource getResource()
           
 ClassLoader getResourceClassLoader()
           
 ResourceComponent getResourceComponent()
           
 ResourceContainer.ResourceComponentState getResourceComponentState()
           
 ResourceContext getResourceContext()
           
 ResourceContainer.SynchronizationState getSynchronizationState()
           
 Lock getWriteFacetLock()
          If a piece of code wants to make a call into a plugin component's facet, and that call may need to write or modify data within the component or the managed resource itself, that code should obtain the returned write lock.
static void initialize()
          Initialize the ResourceContainer's internals, such as its thread pools.
 void removeDriftDefinition(org.rhq.core.domain.drift.DriftDefinition d)
           
 void setInstalledPackages(Set<org.rhq.core.domain.content.transfer.ResourcePackageDetails> installedPackages)
           
 void setMeasurementSchedule(Set<org.rhq.core.domain.measurement.MeasurementScheduleRequest> measurementSchedule)
           
 void setResourceClassLoader(ClassLoader resourceClassLoader)
          Sets the classloader that should be used by the resource when its component interfaces are being invoked.
 void setResourceComponent(ResourceComponent resourceComponent)
           
 void setResourceComponentState(ResourceContainer.ResourceComponentState state)
           
 void setResourceContext(ResourceContext resourceContext)
           
 void setSynchronizationState(ResourceContainer.SynchronizationState synchronizationState)
           
static void shutdown()
          Shuts down ResourceContainer's internals, such as its thread pools.
 String toString()
           
 org.rhq.core.domain.measurement.Availability updateAvailability(org.rhq.core.domain.measurement.AvailabilityType availabilityType)
           
 boolean updateMeasurementSchedule(Set<org.rhq.core.domain.measurement.MeasurementScheduleRequest> measurementScheduleUpdate)
          Updates the measurementSchedule with the modifications made in the measurementScheduleUpdate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResourceContainer

public ResourceContainer(org.rhq.core.domain.resource.Resource resource,
                         ClassLoader resourceClassLoader)
Method Detail

initialize

public static void initialize()
Initialize the ResourceContainer's internals, such as its thread pools.


shutdown

public static void shutdown()
Shuts down ResourceContainer's internals, such as its thread pools.


updateAvailability

public org.rhq.core.domain.measurement.Availability updateAvailability(org.rhq.core.domain.measurement.AvailabilityType availabilityType)

getResource

public org.rhq.core.domain.resource.Resource getResource()

getAvailability

@Nullable
public org.rhq.core.domain.measurement.Availability getAvailability()
Returns the currently known availability of the resource. This will return null if this resource is new and we do not yet know what its availability is.

Returns:
resource's availability or null if it is not known

getReadFacetLock

public Lock getReadFacetLock()
If a piece of code wants to make a call into a plugin component's facet, and that call doesn't need to write or modify any data within the component or the managed resource itself, that code should obtain the returned read lock.

Returns:
lock that provides read-only access into all facets of this container's component.

getWriteFacetLock

public Lock getWriteFacetLock()
If a piece of code wants to make a call into a plugin component's facet, and that call may need to write or modify data within the component or the managed resource itself, that code should obtain the returned write lock.

Returns:
lock that provides read-write access into all facets of this container's component.

getInstalledPackages

public Set<org.rhq.core.domain.content.transfer.ResourcePackageDetails> getInstalledPackages()

setInstalledPackages

public void setInstalledPackages(Set<org.rhq.core.domain.content.transfer.ResourcePackageDetails> installedPackages)

getResourceComponent

public ResourceComponent getResourceComponent()

setResourceComponent

public void setResourceComponent(ResourceComponent resourceComponent)

getResourceContext

public ResourceContext getResourceContext()

setResourceContext

public void setResourceContext(ResourceContext resourceContext)

getMeasurementSchedule

public Set<org.rhq.core.domain.measurement.MeasurementScheduleRequest> getMeasurementSchedule()

setMeasurementSchedule

public void setMeasurementSchedule(Set<org.rhq.core.domain.measurement.MeasurementScheduleRequest> measurementSchedule)

updateMeasurementSchedule

public boolean updateMeasurementSchedule(Set<org.rhq.core.domain.measurement.MeasurementScheduleRequest> measurementScheduleUpdate)
Updates the measurementSchedule with the modifications made in the measurementScheduleUpdate.

Parameters:
measurementScheduleUpdate - the updates to the current measurementSchedule
Returns:
true if the schedule was updated successfully, false otherwise

getDriftDefinitions

public Collection<org.rhq.core.domain.drift.DriftDefinition> getDriftDefinitions()

containsDriftDefinition

public boolean containsDriftDefinition(org.rhq.core.domain.drift.DriftDefinition d)

addDriftDefinition

public void addDriftDefinition(org.rhq.core.domain.drift.DriftDefinition d)

removeDriftDefinition

public void removeDriftDefinition(org.rhq.core.domain.drift.DriftDefinition d)

getResourceComponentState

public ResourceContainer.ResourceComponentState getResourceComponentState()

setResourceComponentState

public void setResourceComponentState(ResourceContainer.ResourceComponentState state)

getSynchronizationState

public ResourceContainer.SynchronizationState getSynchronizationState()

setSynchronizationState

public void setSynchronizationState(ResourceContainer.SynchronizationState synchronizationState)

getResourceClassLoader

public ClassLoader getResourceClassLoader()

setResourceClassLoader

public void setResourceClassLoader(ClassLoader resourceClassLoader)
Sets the classloader that should be used by the resource when its component interfaces are being invoked. In most (but not all) cases, this is the plugin classloader of the plugin that defined the resource.

Parameters:
resourceClassLoader - the resource's context classloader

toString

public String toString()
Overrides:
toString in class Object

createResourceComponentProxy

public <T> T createResourceComponentProxy(Class<T> facetInterface,
                                          FacetLockType lockType,
                                          long timeout,
                                          boolean daemonThread,
                                          boolean onlyIfStarted)
                               throws PluginContainerException
Creates a proxy to this container's resource component, essentially returning the component exposed as the given facet interface. This proxy will ensure that calls to the component's interface are synchronized with the given lock type. If lockType is FacetLockType.NONE and there is no timeout, then the resource's actual component instance is returned as-is (i.e. it will not be wrapped in a proxy - which means this returns the same as getResourceComponent()).

Parameters:
facetInterface - the interface that the component implements and will expose via the proxy
lockType - the type of lock to use when synchronizing access; must not be null
timeout - if the method invocation thread has not completed after this many milliseconds, interrupt it; value must be positive
daemonThread - whether or not the thread used for the invocation should be a daemon thread
onlyIfStarted - if true, and the component is not started, an exception is thrown
Returns:
a proxy that wraps the given component and exposes the given facet interface; will never be null
Throws:
PluginContainerException - if the component does not exist or does not implement the interface


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.