public void initialize() throws SmooksConfigurationException, JMSException {
Context context = null;
boolean initialized = false;
if(beanId == null) {
throw new SmooksConfigurationException("Mandatory 'beanId' property not defined.");
}
if(jmsProperties.getDestinationName() == null) {
throw new SmooksConfigurationException("Mandatory 'destinationName' property not defined.");
}
try
{
if(correlationIdPattern != null) {
correlationIdTemplate = new FreeMarkerTemplate(correlationIdPattern);
}
Properties jndiContextProperties = jndiProperties.toProperties();
if(jndiContextProperties.isEmpty()) {
context = new InitialContext();
} else {
context = new InitialContext(jndiContextProperties);
}
destination = (Destination) context.lookup( jmsProperties.getDestinationName() );
msgProducer = createMessageProducer( destination, context );
setMessageProducerProperties( );
initialized = true;
}
catch (NamingException e)
{
final String errorMsg = "NamingException while trying to lookup [" + jmsProperties.getDestinationName() + "]";
logger.error( errorMsg, e );
throw new SmooksConfigurationException( errorMsg, e );
} finally {
if ( context != null )
{
try { context.close(); } catch (NamingException e) { logger.debug( "NamingException while trying to close initial Context"); }
}