2 * Copyright (C) 2016 Roland Haeder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation, either version 3 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
14 * You should have received a copy of the GNU Affero General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.addressbook.beans.resendlink;
19 import java.io.Serializable;
20 import java.text.MessageFormat;
21 import javax.ejb.Stateless;
22 import javax.jms.JMSException;
23 import javax.jms.Message;
24 import javax.jms.ObjectMessage;
25 import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
26 import org.mxchange.addressbook.mailer.model.delivery.AddressbookMailer;
27 import org.mxchange.addressbook.mailer.model.delivery.DeliverableAddressbookEmail;
30 * A session-based EJB for resending confirmation links
32 * @author Roland Haeder<roland@mxchange.org>
34 @Stateless (name = "resendLink", description = "A bean resending confirmation links")
35 public class AddressbookResendLinkSessionBean extends BaseAddressbookDatabaseBean implements ResendLinkSessionBeanRemote {
40 private static final long serialVersionUID = 75_638_176_619_024L;
45 private final DeliverableAddressbookEmail mailer;
50 public AddressbookResendLinkSessionBean () {
51 // Init mailer instance
52 this.mailer = new AddressbookMailer();
56 public void onMessage (final Message message) {
58 this.getLoggerBeanLocal().logTrace(MessageFormat.format("onMessage: message={0} - CALLED!", message)); //NOI18N
59 // The parameter should be valid
60 if (null == message) {
62 throw new NullPointerException("message is null"); //NOI18N
63 } else if (!(message instanceof ObjectMessage)) {
64 // Not implementing right interface
65 throw new IllegalArgumentException(MessageFormat.format("message={0} does not implemented ObjectMessage", message)); //NOI18N
69 ObjectMessage objectMessage = (ObjectMessage) message;
72 Serializable serializable;
75 // Get object from message
76 serializable = objectMessage.getObject();
77 } catch (final JMSException ex) {
78 // Log it and don't continue any further
79 this.getLoggerBeanLocal().logException(ex);
84 this.getLoggerBeanLocal().logDebug(MessageFormat.format("onMessage: serializable={0}", serializable)); //NOI18N
87 this.getLoggerBeanLocal().logTrace("onMessage - EXIT!"); //NOI18N