blob: 2e74f5c8b62b8615079a1bcb020a21e78d046b8a [file] [log] [blame]
/*
* Copyright (c) 2017, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package com.sun.s1peqe.nonacc.simple.ejb;
import jakarta.ejb.MessageDrivenBean;
import jakarta.ejb.MessageDrivenContext;
import javax.naming.*;
import jakarta.jms.*;
public class SimpleMessageBean implements MessageDrivenBean,
MessageListener {
private transient MessageDrivenContext mdc = null;
private Context context;
public SimpleMessageBean() {
System.out.println("In SimpleMessageBean.SimpleMessageBean()");
}
public void setMessageDrivenContext(MessageDrivenContext mdc) {
System.out.println("In "
+ "SimpleMessageBean.setMessageDrivenContext()");
this.mdc = mdc;
}
public void ejbCreate() {
System.out.println("In SimpleMessageBean.ejbCreate()");
}
public void onMessage(Message inMessage) {
TextMessage msg = null;
try {
if (inMessage instanceof TextMessage) {
msg = (TextMessage) inMessage;
System.out.println("MESSAGE BEAN: Message received: "
+ msg.getText());
} else {
System.out.println("Message of wrong type: "
+ inMessage.getClass().getName());
}
} catch (JMSException e) {
e.printStackTrace();
} catch (Throwable te) {
te.printStackTrace();
}
} // onMessage
public void ejbRemove() {
System.out.println("In SimpleMessageBean.remove()");
}
} // class