1 /* 2 * The contents of this file are subject to the terms 3 * of the Common Development and Distribution License 4 * (the License). You may not use this file except in 5 * compliance with the License. 6 * 7 * You can obtain a copy of the license at 8 * https://glassfish.dev.java.net/public/CDDLv1.0.html or 9 * glassfish/bootstrap/legal/CDDLv1.0.txt. 10 * See the License for the specific language governing 11 * permissions and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL 14 * Header Notice in each file and include the License file 15 * at glassfish/bootstrap/legal/CDDLv1.0.txt. 16 * If applicable, add the following below the CDDL Header, 17 * with the fields enclosed by brackets [] replaced by 18 * you own identifying information: 19 * "Portions Copyrighted [year] [name of copyright owner]" 20 * 21 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 22 */ 23 24 25 package javax.jms; 26 27 /** A <CODE>ServerSession</CODE> object is an application server object that 28 * is used by a server to associate a thread with a JMS session (optional). 29 * 30 * <P>A <CODE>ServerSession</CODE> implements two methods: 31 * 32 * <UL> 33 * <LI><CODE>getSession</CODE> - returns the <CODE>ServerSession</CODE>'s 34 * JMS session. 35 * <LI><CODE>start</CODE> - starts the execution of the 36 * <CODE>ServerSession</CODE> 37 * thread and results in the execution of the JMS session's 38 * <CODE>run</CODE> method. 39 * </UL> 40 * 41 * <P>A <CODE>ConnectionConsumer</CODE> implemented by a JMS provider uses a 42 * <CODE>ServerSession</CODE> to process one or more messages that have 43 * arrived. It does this by getting a <CODE>ServerSession</CODE> from the 44 * <CODE>ConnectionConsumer</CODE>'s <CODE>ServerSessionPool</CODE>; getting 45 * the <CODE>ServerSession</CODE>'s JMS session; loading it with the messages; 46 * and then starting the <CODE>ServerSession</CODE>. 47 * 48 * <P>In most cases the <CODE>ServerSession</CODE> will register some object 49 * it provides as the <CODE>ServerSession</CODE>'s thread run object. The 50 * <CODE>ServerSession</CODE>'s <CODE>start</CODE> method will call the 51 * thread's <CODE>start</CODE> method, which will start the new thread, and 52 * from it, call the <CODE>run</CODE> method of the 53 * <CODE>ServerSession</CODE>'s run object. This object will do some 54 * housekeeping and then call the <CODE>Session</CODE>'s <CODE>run</CODE> 55 * method. When <CODE>run</CODE> returns, the <CODE>ServerSession</CODE>'s run 56 * object can return the <CODE>ServerSession</CODE> to the 57 * <CODE>ServerSessionPool</CODE>, and the cycle starts again. 58 * 59 * <P>Note that the JMS API does not architect how the 60 * <CODE>ConnectionConsumer</CODE> loads the <CODE>Session</CODE> with 61 * messages. Since both the <CODE>ConnectionConsumer</CODE> and 62 * <CODE>Session</CODE> are implemented by the same JMS provider, they can 63 * accomplish the load using a private mechanism. 64 * 65 * @version 1.0 - 9 March 1998 66 * @author Mark Hapner 67 * @author Rich Burridge 68 * 69 * @see javax.jms.ServerSessionPool 70 * @see javax.jms.ConnectionConsumer 71 */ 72 73 public interface ServerSession { 74 75 /** Return the <CODE>ServerSession</CODE>'s <CODE>Session</CODE>. This must 76 * be a <CODE>Session</CODE> created by the same <CODE>Connection</CODE> 77 * that will be dispatching messages to it. The provider will assign one or 78 * more messages to the <CODE>Session</CODE> 79 * and then call <CODE>start</CODE> on the <CODE>ServerSession</CODE>. 80 * 81 * @return the server session's session 82 * 83 * @exception JMSException if the JMS provider fails to get the associated 84 * session for this <CODE>ServerSession</CODE> due 85 * to some internal error. 86 **/ 87 88 Session 89 getSession() throws JMSException; 90 91 92 /** Cause the <CODE>Session</CODE>'s <CODE>run</CODE> method to be called 93 * to process messages that were just assigned to it. 94 * 95 * @exception JMSException if the JMS provider fails to start the server 96 * session to process messages due to some internal 97 * error. 98 */ 99 100 void 101 start() throws JMSException; 102 } 103