com.instantbank.component.lettersjobmdb.util
Class MessageSender

java.lang.Object
  |
  +--com.instantbank.component.lettersjobmdb.util.MessageSender

public class MessageSender
extends java.lang.Object

Wraper for the message sending process related to letter jobs.

Author:
InstantBank (Rodrigo Lopez)

Field Summary
private  java.lang.String contextProviderUrl
          Context provider url.
private  Debug debug
          The ubiquitous debugger object
private  java.lang.String initContextFactory
          Name of the initial context factory class.
private  javax.jms.Queue q
          Actual queue
private  javax.jms.QueueConnection qConnection
          Queue connection
private  javax.jms.QueueSender qSender
          Queue sender
private  javax.jms.QueueSession qSession
          Queue session
 
Constructor Summary
MessageSender(java.lang.String server, int port, java.lang.String queue)
          MessageSender constructor.
MessageSender(java.lang.String contextProviderUrl, java.lang.String initContextFactory, java.lang.String queue)
          MessageSender constructor.
 
Method Summary
 javax.jms.Message buildFtpMessage(java.lang.String companyId, java.lang.Long userId, java.lang.String filePath, long jobLogId, long locId1, long locId2)
          Builds a message as expected by the LettersJobFtpMdb.
 javax.jms.Message buildLetterJobMessage(java.lang.String companyId, java.lang.String temporalPath, java.lang.Long userId, java.lang.Long jobId, java.lang.String contextProvider, java.lang.String initContextFactory, java.lang.String maxZipSize)
          Builds a letter job message as expected by the LettersJobMessageEJB.
private  void debugContext(javax.naming.Context ctx)
          Debug method allowing to explore some standard context in the JNDI tree.
 java.lang.String getContextProviderUrl()
          Getter method for contextProviderUrl
 java.lang.String getInitContextFactory()
          Getter method for initContextFactory
private  void init(java.lang.String queue)
          Inits the required entities for sending messages.
 void release()
          Release the message sending resources
 void send(javax.jms.Message msg)
          Sends a message
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

initContextFactory

private java.lang.String initContextFactory
Name of the initial context factory class.

contextProviderUrl

private java.lang.String contextProviderUrl
Context provider url.

qConnection

private javax.jms.QueueConnection qConnection
Queue connection

qSession

private javax.jms.QueueSession qSession
Queue session

qSender

private javax.jms.QueueSender qSender
Queue sender

q

private javax.jms.Queue q
Actual queue

debug

private Debug debug
The ubiquitous debugger object
Constructor Detail

MessageSender

public MessageSender(java.lang.String server,
                     int port,
                     java.lang.String queue)
              throws javax.jms.JMSException
MessageSender constructor. It searches the required initial context factory through JNDI.
Parameters:
server - Server name.
port - Port number
queue - Actual queue where messages will be posted.
Throws:
javax.jms.JMSException - if any trouble arises constructing the sender

MessageSender

public MessageSender(java.lang.String contextProviderUrl,
                     java.lang.String initContextFactory,
                     java.lang.String queue)
              throws javax.jms.JMSException
MessageSender constructor.
Parameters:
contextProviderUrl - Context Provider Url.
initContextFactory - Name of the Initial Context Factory class
queue - Actual queue where messages will be posted.
Throws:
javax.jms.JMSException - if any trouble arises constructing the sender
Method Detail

init

private void init(java.lang.String queue)
           throws javax.jms.JMSException
Inits the required entities for sending messages.
Parameters:
queue - Name of the actual queue where messages are posted.
Throws:
javax.jms.JMSException - If anything goes wrong.

buildLetterJobMessage

public javax.jms.Message buildLetterJobMessage(java.lang.String companyId,
                                               java.lang.String temporalPath,
                                               java.lang.Long userId,
                                               java.lang.Long jobId,
                                               java.lang.String contextProvider,
                                               java.lang.String initContextFactory,
                                               java.lang.String maxZipSize)
                                        throws javax.jms.JMSException
Builds a letter job message as expected by the LettersJobMessageEJB.
Parameters:
companyId - Company Id
temporalPath - Full path of a working (scratch) directory.
userId - User Id
jobId - Job Id
contextProvider - Context Provider Url
initContextFactory - Name of the Initial Context Factory class
maxZipSize - Description of the Parameter
Returns:
Description of the Return Value
Throws:
javax.jms.JMSException - Description of the Exception

buildFtpMessage

public javax.jms.Message buildFtpMessage(java.lang.String companyId,
                                         java.lang.Long userId,
                                         java.lang.String filePath,
                                         long jobLogId,
                                         long locId1,
                                         long locId2)
                                  throws javax.jms.JMSException
Builds a message as expected by the LettersJobFtpMdb.
Parameters:
companyId - Description of the Parameter
userId - Description of the Parameter
filePath - Description of the Parameter
jobLogId - Description of the Parameter
locId1 - Description of the Parameter
locId2 - Description of the Parameter
Returns:
Description of the Return Value
Throws:
javax.jms.JMSException - Description of the Exception

send

public void send(javax.jms.Message msg)
          throws javax.jms.JMSException
Sends a message
Parameters:
msg - Description of the Parameter
Throws:
javax.jms.JMSException - Description of the Exception

release

public void release()
Release the message sending resources

getContextProviderUrl

public java.lang.String getContextProviderUrl()
Getter method for contextProviderUrl
Returns:
The contextProviderUrl value

getInitContextFactory

public java.lang.String getInitContextFactory()
Getter method for initContextFactory
Returns:
The initContextFactory value

debugContext

private void debugContext(javax.naming.Context ctx)
Debug method allowing to explore some standard context in the JNDI tree.
Parameters:
ctx - Description of the Parameter