org.rhq.core.pc.inventory
Class InventoryFile

java.lang.Object
  extended by org.rhq.core.pc.inventory.InventoryFile

public class InventoryFile
extends Object

Provides methods to read and write inventory data to a file.

Author:
John Mazzitelli

Constructor Summary
InventoryFile(File inventoryFile)
          Constructor for InventoryFile that will read and write inventory data to the given file.
 
Method Summary
 File getInventoryFile()
           
 org.rhq.core.domain.resource.Resource getPlatform()
          Returns the platform resource found in the inventory file.
 Map<String,ResourceContainer> getResourceContainers()
          Returns the map of resource containers (keyed on their UUIDs) found in the inventory file.
 void loadInventory()
          Reads in the inventory found in the file.
 void storeInventory(org.rhq.core.domain.resource.Resource platformResource, Map<String,ResourceContainer> containers)
          Given a platform and map of resource containers (keyed on UUID strings), this persists that inventory to the inventory file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InventoryFile

public InventoryFile(File inventoryFile)
Constructor for InventoryFile that will read and write inventory data to the given file.

Parameters:
inventoryFile - the path to the inventory.dat file
Method Detail

getInventoryFile

public File getInventoryFile()

getPlatform

public org.rhq.core.domain.resource.Resource getPlatform()
Returns the platform resource found in the inventory file.

This will return null if the file has not yet been loaded, initially written to or if an error occurred that did not allow the inventory file to be fully loaded successfully.

Returns:
platform resource in inventory file

getResourceContainers

public Map<String,ResourceContainer> getResourceContainers()
Returns the map of resource containers (keyed on their UUIDs) found in the inventory file.

This will return null if the file has not yet been loaded, initially written to or if an error occurred that did not allow the inventory file to be fully loaded successfully.

Returns:
platform resource in inventory file

loadInventory

public void loadInventory()
                   throws PluginContainerException
Reads in the inventory found in the file. Once this returns, getPlatform() and getResourceContainers() will return non-null objects as found in the file.

Throws:
PluginContainerException - if some error occurred that did not allow this method to fully load the inventory

storeInventory

public void storeInventory(org.rhq.core.domain.resource.Resource platformResource,
                           Map<String,ResourceContainer> containers)
                    throws IOException
Given a platform and map of resource containers (keyed on UUID strings), this persists that inventory to the inventory file. This object's platform and resource containers will be set to those passed to this method.

Parameters:
platformResource -
containers -
Throws:
IOException


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