com.instantbank.component.lettersjobmdb.ejb
Class LettersJobMessageEJB

java.lang.Object
  |
  +--com.instantbank.component.lettersjobmdb.ejb.LettersJobMessageEJB
All Implemented Interfaces:
javax.ejb.EnterpriseBean, javax.ejb.MessageDrivenBean, javax.jms.MessageListener, java.io.Serializable

public class LettersJobMessageEJB
extends java.lang.Object
implements javax.ejb.MessageDrivenBean, javax.jms.MessageListener

Message Driven bean that process letter jobs. A message is a "reference" to a letter job.

Author:
InstantBank (Rodrigo Lopez)
See Also:
Serialized Form

Inner Class Summary
(package private)  class LettersJobMessageEJB.SequencedFileName
          Auxiliary class that generates names of files with a sequencing criterium.
 
Field Summary
private  Debug debug
          The ubiquitous debugger object.
private  java.lang.String jobName
          Name of the job
private  long templateCode
          Code of the template bound to the letter job.
 
Constructor Summary
LettersJobMessageEJB()
           
 
Method Summary
private  void addLetter(java.util.zip.ZipOutputStream zout, java.io.ByteArrayOutputStream letter, int i, java.lang.String ext)
          Adds a letter as a new entry in a zip structure.
 void ejbCreate()
          Initializes the debugger.
 void ejbRemove()
          This method has void body for Mesage Driven Beans.
 void onMessage(javax.jms.Message jobMsg)
          Process one letter job.
private  java.lang.String serializeSqlExec(java.util.ArrayList[] execSet)
          Transforms the result of execution of the sql statement bound to a job into a String of row values separated by a non printable ROW_SEPARATOR character and values in a row separated by a VALUE_SEPARATOR non printable character.
 void setMessageDrivenContext(javax.ejb.MessageDrivenContext mdc)
          Nothing interesting here.
private  java.lang.String writeZipFile(java.util.zip.ZipOutputStream zout, java.io.File workDir, java.lang.String zipname, java.io.ByteArrayOutputStream zipbytes)
          Writes a zip structure to a file.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

templateCode

private long templateCode
Code of the template bound to the letter job.

jobName

private java.lang.String jobName
Name of the job

debug

private Debug debug
The ubiquitous debugger object.
Constructor Detail

LettersJobMessageEJB

public LettersJobMessageEJB()
Method Detail

ejbRemove

public void ejbRemove()
               throws javax.ejb.EJBException
This method has void body for Mesage Driven Beans.
Specified by:
ejbRemove in interface javax.ejb.MessageDrivenBean
Throws:
javax.ejb.EJBException - Description of the Exception

setMessageDrivenContext

public void setMessageDrivenContext(javax.ejb.MessageDrivenContext mdc)
                             throws javax.ejb.EJBException
Nothing interesting here.
Specified by:
setMessageDrivenContext in interface javax.ejb.MessageDrivenBean
Parameters:
mdc - The new messageDrivenContext value
Throws:
javax.ejb.EJBException - Description of the Exception

ejbCreate

public void ejbCreate()
Initializes the debugger.

onMessage

public void onMessage(javax.jms.Message jobMsg)
Process one letter job. Only MapMessages are processed and are expected to contain: Log information is recorded in the LETT_JOB_LOG table.
Specified by:
onMessage in interface javax.jms.MessageListener
Parameters:
jobMsg - Description of the Parameter

addLetter

private void addLetter(java.util.zip.ZipOutputStream zout,
                       java.io.ByteArrayOutputStream letter,
                       int i,
                       java.lang.String ext)
                throws java.lang.Exception
Adds a letter as a new entry in a zip structure.
Parameters:
zout - The zip structure (in main memory).
letter - The letter to be added (in main memory)
i - A sequence number bound to the letter.
ext - The extension appended to the zip entry name.
Throws:
java.lang.Exception - Description of the Exception

writeZipFile

private java.lang.String writeZipFile(java.util.zip.ZipOutputStream zout,
                                      java.io.File workDir,
                                      java.lang.String zipname,
                                      java.io.ByteArrayOutputStream zipbytes)
                               throws java.lang.Exception
Writes a zip structure to a file.
Parameters:
zout - OutputStream through wich the zip structure has been created.
workDir - Directory where the file will be created.
zipname - Name of the file to be created.
zipbytes - The zip structure to be written.
Returns:
The full path of the written file.
Throws:
java.lang.Exception - Description of the Exception

serializeSqlExec

private java.lang.String serializeSqlExec(java.util.ArrayList[] execSet)
Transforms the result of execution of the sql statement bound to a job into a String of row values separated by a non printable ROW_SEPARATOR character and values in a row separated by a VALUE_SEPARATOR non printable character.
Parameters:
execSet - The result as calculated by LetterTemplate.executeSQL().
Returns:
The custom "serialization" of execSet.