All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.install.products.WSRData

java.lang.Object
   |
   +----com.sun.install.products.WSRData

public class WSRData
extends Object
implements Serializable, ResourceResolver
This class encapsulates the notion of a wizard being "Web Start Ready". If an installer includes one of these objects as part of the WizardState, it can then be optionally extracted at runtime for use by other programs, without having to run the installer itself. For example, suppose you have WSR data in a hierarchical directory structure located at /net/syrinx/export/a/WSR. Then, you could include this information by including these lines in your builder:
 WSRData w = new WSRData("/net/syrinx/export/a/WSR");
 addCollection(w.getCollection());
 getWizardState().setData("install.wsrData", w);
 

Then, at runtime, you can retrieve this information to stdout by running the wizard like this:

 $ java wizard -get wsr
 

You can also optionally write out the same file structure to your disk by running the wizard like this:

 $ java wizard -get "wsr,/tmp/out"
 

(yes, you need to include the comma (",") above). This will write the contents of the WSRData into the /tmp/out directory. The directory will be created if it does not exist.

NOTE: Using this class assumes you are also using InstallCommandLineTask as an initialization task, as that is the task that does the command-line parsing for -get. If your builder subclasses from com.sun.install.products.InstallArchiveWriter, then you are most likely using InstallCommandLineTask and should not need to do anything. However, if you are subclassing from com.sun.wizards.builder.ArchiveWriter, you might need to add the InstallCommandLineTask as an initialization task by doing this:

 WizardState wizardState = getWizardState();
 Sequence wizardInitSequence = wizardState.getSequence("wizardStateInitialization");
 if (wizardInitSequence == null)
   wizardInitSequence = new Sequence();
 wizardInitSequence.addTask(new InstallCommandLineTask());
 wizardState.addSequence("wizardStateInitialization", wizardInitSequence);
 


Variable Index

 o SECTION
The wizard state section to place the data into, and retrieve from at runtime

Constructor Index

 o WSRData(String)
Create a WSRData structure and point it at the information.

Method Index

 o copyFile(DataInput, DataOutput, long)
A utility method to copy one stream into another.
 o getCollection()
Convenience method for reporting all the required entries for the WSR data.
 o getList(String)
Returns a list of the WSR data files, prefixed by a string
 o print(PrintWriter, WizardState)
Prints out contents of the WSR data structure, including all files and their contents, in XML-style markup.
 o resolveResource(String, String, byte[])
Method to fulfill the ResourceResolver interface.
 o setPath(String)
Resets the object with a new path.
 o writeTo(String, WizardState)
Writes out the WSR data files into the directory specified by path.

Variables

 o SECTION
 public static final String SECTION
The wizard state section to place the data into, and retrieve from at runtime

Constructors

 o WSRData
 public WSRData(String path)
Create a WSRData structure and point it at the information. The information will be read in when you create the object.

Parameters:
path - The path to the directory containing the hierarchical WSR data.

Methods

 o setPath
 public void setPath(String path)
Resets the object with a new path. The files are read out of the directory specified.

Parameters:
path - The path to the directory containing the hierarchical WSR data.
 o resolveResource
 public ResourceInputStream resolveResource(String type,
                                            String name,
                                            byte extData[])
Method to fulfill the ResourceResolver interface. This is so the object can serve up the WSR data files itself for inclusing into the wizard. Users of this object should not call this method directly.

Parameters:
type - The section to go into, should be SECTION.
name - The name of the object. Should be the same name as was reported in getCollection().
extData - Extra data for each entry. Should be null.
 o getCollection
 public ResourceCollection getCollection()
Convenience method for reporting all the required entries for the WSR data. Each file in the path specified in the constructor is represented in the ResourceCollection returned by this method, and this is passed into the ResourceCollection indicating that this object will resolve the WSR files (since it knows the path to them).

Returns:
The collection representing the WSR data files in this object.
 o getList
 public Vector getList(String offset)
Returns a list of the WSR data files, prefixed by a string

Parameters:
offset - The prefix (directory) for each file returned in the Vector.
Returns:
The list of files representing this WSR data structure, each prefixed by the supplied offset.
 o writeTo
 public void writeTo(String path,
                     WizardState state) throws IOException
Writes out the WSR data files into the directory specified by path. The contents of each file come from the preconfigured section in the wizard state passed in.

Parameters:
path - The path to write the objects to. This should be a directory name. If it does not exist, it is created.
state - The runtime wizard state containing the contents of each file.
Throws: IOException
if there is a problem writing to the disk.
 o print
 public void print(PrintWriter out,
                   WizardState state)
Prints out contents of the WSR data structure, including all files and their contents, in XML-style markup. Here is an example:
 
   
 CD_NAME=Solaris Software Companion CD
 CD_INSTALLER=installer -warp Verify,Summary
 CD_VOLID=s8_software_companion
   
   
 companioncd
   
   
     
 testfilecontentsline1
 testfilecontentsline2
     
   
 

This would correspond to a file structure looking like this:

   WSR
    |
    +-- cd.info
    +-- cd.name
    +-- test
          |
          +-- testfilecontentsline1
          +-- testfilecontentsline2
 

The output can be parsed recursively to re-build structures for other applications reading this data.

Parameters:
out - Where to output, normally new PrintWriter(System.out).
state - The runtime wizard state to get file contents from.
 o copyFile
 public static final void copyFile(DataInput in,
                                   DataOutput out,
                                   long length) throws IOException
A utility method to copy one stream into another.

Parameters:
in - The source stream.
out - The destination stream.
length - How much data to copy from the source vector. If this is greather than or equal to than the length of the source stream, then the entire stream will be read.
Throws: IOException
if there is a problem copying the streams.

All Packages  Class Hierarchy  This Package  Previous  Next  Index