org.objectweb.jonas_ws.wsgen
Class JarManager

java.lang.Object
  extended byorg.objectweb.jonas_ws.wsgen.JarManager
Direct Known Subclasses:
EarManager, WarManager

public class JarManager
extends java.lang.Object

Manage a jar file.


Field Summary
protected  java.util.Hashtable jarEntries
           
protected  java.lang.String jarFileName
           
protected  java.util.jar.JarOutputStream jos
           
protected static org.objectweb.util.monolog.api.Logger logger
          The logger to use
protected  java.io.File tempJar
           
protected  java.util.Enumeration tjEntries
           
 
Constructor Summary
JarManager(java.lang.String jarFilename)
          Build a new instance of a JarManager.
 
Method Summary
 void addDir(java.io.File dir)
          Add all Files contained in a directory in the current jar file.
 void addDir(java.lang.String base, java.io.File dir)
          Add all Files contained in a directory in the current jar file at the specified entryName location.
 void addFile(java.lang.String entryName, java.io.File file)
          Add a new File in the current jar file.
 void close()
           
protected static java.lang.String getSAXMsg(java.lang.String fileName, org.xml.sax.SAXParseException exception, java.lang.String msg)
          build a message from SAX Exception in a consistent style, consistent with emacs compile mode (same as grep, cc, javac, etc).
protected  boolean isNewFile()
          Return true if a new jar file has been created.
protected  void open()
          Open the output stream on the jar file and create a save of the jar.
protected  void save()
          add all jar entries in the jar file.
protected  void writeEntry(java.util.zip.ZipEntry ze, java.io.InputStream is)
          write a new entry in the jar output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jarFileName

protected java.lang.String jarFileName

jos

protected java.util.jar.JarOutputStream jos

tempJar

protected java.io.File tempJar

tjEntries

protected java.util.Enumeration tjEntries

jarEntries

protected java.util.Hashtable jarEntries

logger

protected static org.objectweb.util.monolog.api.Logger logger
The logger to use

Constructor Detail

JarManager

public JarManager(java.lang.String jarFilename)
           throws WsGenException
Build a new instance of a JarManager. Create the file if it doesn't exists.

Parameters:
jarFilename - the name of the jar file that we want to manage.
Throws:
WsGenException - if the war file doesn't exist.
Method Detail

addDir

public void addDir(java.io.File dir)
            throws WsGenException
Add all Files contained in a directory in the current jar file. This adding keep the same file structure (directory & subdir)

Parameters:
dir - the directory to add
Throws:
WsGenException

addDir

public void addDir(java.lang.String base,
                   java.io.File dir)
            throws WsGenException
Add all Files contained in a directory in the current jar file at the specified entryName location. This adding keep the same file structure (directory & subdir)

Parameters:
base - where to put directory files in the jar
dir - the directory to add
Throws:
WsGenException

addFile

public void addFile(java.lang.String entryName,
                    java.io.File file)
             throws WsGenException
Add a new File in the current jar file.

Parameters:
entryName - where to put the file in the jar
file - the file to add
Throws:
WsGenException

getSAXMsg

protected static java.lang.String getSAXMsg(java.lang.String fileName,
                                            org.xml.sax.SAXParseException exception,
                                            java.lang.String msg)
build a message from SAX Exception in a consistent style, consistent with emacs compile mode (same as grep, cc, javac, etc).

Parameters:
fileName - name of the file
exception - the SAX exception
msg - the string message
Returns:
a message which is in a consistent style

isNewFile

protected boolean isNewFile()
Return true if a new jar file has been created.

Returns:
true if a new jar file has been created.

writeEntry

protected void writeEntry(java.util.zip.ZipEntry ze,
                          java.io.InputStream is)
                   throws WsGenException
write a new entry in the jar output stream.

Parameters:
ze - the zip entry to add.
is - the input stream to write.
Throws:
WsGenException

open

protected void open()
             throws WsGenException
Open the output stream on the jar file and create a save of the jar.

Throws:
WsGenException

save

protected void save()
             throws WsGenException
add all jar entries in the jar file.

Throws:
WsGenException

close

public void close()
           throws WsGenException
Throws:
WsGenException