jpos.config.simple
Class SimpleRegPopulator

java.lang.Object
  |
  +--jpos.config.simple.AbstractRegPopulator
        |
        +--jpos.config.simple.SimpleRegPopulator
All Implemented Interfaces:
JposRegPopulator

public class SimpleRegPopulator
extends AbstractRegPopulator

Simple implementation of the JposRegPopulator loading and saving from a serialized set of entries NOTE: this class must define a public no-argument ctor so that it may be created via reflection when its defined in the jpos.properties as the jpos.config.regPopulatorClass

Since:
1.2 (NY 2K 99 meeting)
Author:
E. Michael Maximilien (maxim@us.ibm.com)
See Also:
JposPropertiesConst.JPOS_REG_POPULATOR_CLASS_PROP_NAME

Field Summary
static java.lang.String DEFAULT_JPOS_SER_FILE_NAME
          The default serialized JposEntry file name
static java.lang.String SIMPLE_REG_POPULATOR_NAME_STRING
          The default name for the SimpleRegPopulator
static java.lang.String TEMP_SER_FILE_NAME
          A tempory file name used for temporary storage
 
Fields inherited from class jpos.config.simple.AbstractRegPopulator
lastLoadException
 
Constructor Summary
SimpleRegPopulator()
          Default ctor
SimpleRegPopulator(java.lang.String s)
          1-arg ctor that takes the unique ID string
 
Method Summary
protected  java.io.ObjectInputStream findSerOIS()
           
protected  java.io.ObjectInputStream findSerOISInClasspath(java.util.Vector jarZipFilesVector)
          Finds the first serialized JposEntry file in directory of each classpath NOTE:Decorated the FileInputStream with a BufferedInputStream to improve load time...
protected  java.io.ObjectInputStream findSerOISInJar(java.util.Vector jarFilesVector)
          Finds the first serialized JposEntry file in the JAR files
 java.lang.String getClassName()
           
 java.net.URL getEntriesURL()
           
 java.lang.String getName()
           
 void load()
          Tell the populator to load the entries
 void load(java.lang.String fileName)
          Loads the entries specified in the fileName
protected  java.util.Enumeration readJposEntries()
           
protected  java.util.Enumeration readJposEntries(java.io.InputStream is)
          Searches the current class path for the serialized file and un-serializes the JposEntry objects
 void save(java.util.Enumeration entries)
          Tell the populator to save the current entries
 void save(java.util.Enumeration entries, java.lang.String fileName)
          Tell the populator to save the current entries in the file specified
protected  void saveJposEntries(java.util.Enumeration entries)
           
protected  void saveJposEntries(java.util.Enumeration entries, java.io.OutputStream os)
          Save the JposEntry object to the OutputStream as serialized objects
protected  void saveSerFile(java.util.Enumeration entries)
          Tries to save the entries in the file where they were loaded
protected  void saveSerInZipFile(java.util.Enumeration entries)
          Tries to save the entries as a ZipEntry in the ZipFile
 
Methods inherited from class jpos.config.simple.AbstractRegPopulator
createURLFromFile, createURLFromFile, findFileInClasspath, findFileInJarZipFiles, getEntries, getJposEntries, getLastLoadException, getPopulatorFileIS, getPopulatorFileName, getPopulatorFileOS, getPopulatorFileURL, getUniqueId, isComposite, isPopulatorFileDefined, setUniqueId, toString
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_JPOS_SER_FILE_NAME

public static final java.lang.String DEFAULT_JPOS_SER_FILE_NAME
The default serialized JposEntry file name
Since:
1.2 (NY 2K meeting)

TEMP_SER_FILE_NAME

public static final java.lang.String TEMP_SER_FILE_NAME
A tempory file name used for temporary storage
Since:
1.2 (NY 2K meeting)

SIMPLE_REG_POPULATOR_NAME_STRING

public static final java.lang.String SIMPLE_REG_POPULATOR_NAME_STRING
The default name for the SimpleRegPopulator
Since:
1.3 (Washington DC 2001 meeting)
Constructor Detail

SimpleRegPopulator

public SimpleRegPopulator()
Default ctor
Since:
1.2 (NY 2K meeting)

SimpleRegPopulator

public SimpleRegPopulator(java.lang.String s)
1-arg ctor that takes the unique ID string
Parameters:
s - the unique ID string
Since:
1.3 (Washington DC 2001 meeting)
Method Detail

getClassName

public java.lang.String getClassName()
Returns:
the fully qualified class name implementing the JposRegPopulator interface
Since:
1.3 (Washington DC 2001 meeting)

save

public void save(java.util.Enumeration entries)
          throws java.lang.Exception
Tell the populator to save the current entries
Overrides:
save in class AbstractRegPopulator
Parameters:
entries - an enumeration of JposEntry objects
Throws:
java.lang.Exception - if any error occurs while saving
Since:
1.2 (NY 2K meeting)

save

public void save(java.util.Enumeration entries,
                 java.lang.String fileName)
          throws java.lang.Exception
Tell the populator to save the current entries in the file specified
Overrides:
save in class AbstractRegPopulator
Parameters:
entries - an enumeration of JposEntry objects
fileName - the file name to save entries
Throws:
java.lang.Exception - if any error occurs while saving
Since:
1.3 (SF 2K meeting)

load

public void load()
Tell the populator to load the entries
Overrides:
load in class AbstractRegPopulator
Since:
1.2 (NY 2K meeting)

load

public void load(java.lang.String fileName)
Loads the entries specified in the fileName
Overrides:
load in class AbstractRegPopulator
Parameters:
fileName - the entries file name
Since:
1.3 (SF 2K meeting)

getEntriesURL

public java.net.URL getEntriesURL()
Overrides:
getEntriesURL in class AbstractRegPopulator
Returns:
the URL pointing to the entries file loaded or saved
Since:
1.2 (NY 2K meeting)

getName

public java.lang.String getName()
Overrides:
getName in class AbstractRegPopulator
Returns:
the name of this populator. This should be a short descriptive name
Since:
1.3 (Washington DC 2001 meeting)

saveSerInZipFile

protected void saveSerInZipFile(java.util.Enumeration entries)
                         throws java.lang.Exception
Tries to save the entries as a ZipEntry in the ZipFile
Parameters:
entries - an Enumeration of JposEntry objects NOTE: if the the serialized entries is in a Sip/JAR file then if must be an entry in the "root" of the Sip/JAR file... Also when saving in a Zip/JAR file could get an error because the Zip/JAR file is being used by a process in Win32 environment
Throws:
java.lang.Exception - if any problems occurs while saving
Since:
1.2 (NY 2K meeting)

saveSerFile

protected void saveSerFile(java.util.Enumeration entries)
                    throws java.lang.Exception
Tries to save the entries in the file where they were loaded
Parameters:
entries - an Enumeration of JposEntry objects
Throws:
java.lang.Exception - if any problems occurs while saving
Since:
1.2 (NY 2K meeting)

saveJposEntries

protected void saveJposEntries(java.util.Enumeration entries,
                               java.io.OutputStream os)
                        throws java.lang.Exception
Save the JposEntry object to the OutputStream as serialized objects
Parameters:
entries - an enumeration of JposEntry objects
os - the OuputStream to save to
Throws:
java.lang.Exception - if any error occurs while saving
Since:
1.2 (NY 2K meeting)

findSerOIS

protected java.io.ObjectInputStream findSerOIS()
Returns:
an ObjectInputStream of the first serFileName found. The algorithm is: 1) Goes through the CLASSPATH and get the first serialized file name in the paths in order 2) If no simple ser file is found then looks in the JAR files in order
Since:
1.2 (NY 2K meeting)

findSerOISInClasspath

protected java.io.ObjectInputStream findSerOISInClasspath(java.util.Vector jarZipFilesVector)
Finds the first serialized JposEntry file in directory of each classpath NOTE:Decorated the FileInputStream with a BufferedInputStream to improve load time...
Parameters:
jarZipFilesVector - a vector of JAR/Zip file names
Since:
1.2 (NY 2K meeting)

findSerOISInJar

protected java.io.ObjectInputStream findSerOISInJar(java.util.Vector jarFilesVector)
Finds the first serialized JposEntry file in the JAR files
Parameters:
jarFilesVector - a vector of JAR/Zip file names
Since:
1.2 (NY 2K meeting)

readJposEntries

protected java.util.Enumeration readJposEntries(java.io.InputStream is)
Searches the current class path for the serialized file and un-serializes the JposEntry objects
Parameters:
is - the InputStream from which to read the serialized entries from
Returns:
an Enumeration of JposEntry objects un-serializes from the file specified
Since:
1.2 (NY 2K meeting)

readJposEntries

protected java.util.Enumeration readJposEntries()
Returns:
an Enumeration of JposEntry objects
Since:
1.2 (NY 2K meeting)

saveJposEntries

protected void saveJposEntries(java.util.Enumeration entries)
                        throws java.lang.Exception
Parameters:
entries - an enumeration of JposEntry objects
Throws:
java.lang.Exception - if any error occurs while saving
Since:
1.2 (NY 2K meeting)


This API and code belongs to the JavaPOS committee please see LISCENCE file for details