Methods Summary |
---|
public void | emailLostPassword(java.lang.String username)
System.out.println("<In EmailSystemBean.emailLostPassword business method");
//Pretend we are looking up password and email, and place a message on the queue
String password = "xyz";
String email = "xyz@lalala.com";
sendMessage(email, "Password Reminder", "Your password is " + password);
System.out.println("Exiting EmailSystemBean.emailLostPassword business method>");
|
public java.lang.Object | myBeanInterceptor(javax.interceptor.InvocationContext ctx)
if (ctx.getMethod().getName().equals("emailLostPassword"))
{
System.out.println("*** EmailSystemBean.myBeanInterceptor - username: " + ctx.getParameters()[0]);
}
return ctx.proceed();
|
public void | noop()
System.out.println("<In EmailSystemBean.noop business method");
System.out.println("Exiting EmailSystemBean.noop business method>");
|
public void | noop2()
System.out.println("<In EmailSystemBean.noop2 business method");
System.out.println("Exiting EmailSystemBean.noop2 business method>");
|
public void | sendBookingCancellationMessage(long orderId)
System.out.println("<In EmailSystemBean.sendBookingCancellationMessage business method");
//Pretend we are looking email, and place a message on the queue
String email = "xyz@lalala.com";
sendMessage(email, "Booking Confirmed!", "Your order " + orderId + "is confirmed!");
System.out.println("Exiting EmailSystemBean.sendBookingCancellationMessage business method>");
|
public void | sendBookingConfirmationMessage(long orderId)
System.out.println("<In EmailSystemBean.sendBookingConfirmationMessage business method");
//Pretend we are looking email, and place a message on the queue
String email = "xyz@lalala.com";
sendMessage(email, "Booking Confirmed!", "Your order " + orderId + "is confirmed!");
System.out.println("Exiting EmailSystemBean.sendBookingConfirmationMessage business method>");
|
private void | sendMessage(java.lang.String email, java.lang.String subject, java.lang.String body)
QueueConnection cnn = null;
QueueSession session = null;
try
{
QueueSender sender = null;
InitialContext ctx = new InitialContext();
Queue queue = (Queue) ctx.lookup("queue/tutorial/email");
QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
cnn = factory.createQueueConnection();
session = cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
TextMessage msg = session.createTextMessage(
"<mail>" +
"<to>" + email + "</to>" +
"<to>" + subject + "</to>" +
"<msg>" + body +"</msg>" +
"</mail>");
sender = session.createSender(queue);
sender.send(msg);
System.out.println("Message sent successfully to remote queue.");
}
catch(Exception e)
{
throw new RuntimeException(e);
}
finally
{
try
{
session.close();
cnn.close();
}
catch (JMSException e)
{
throw new RuntimeException(e);
}
}
|