01: /*
02: * @(#)ResourceAllocationException.java 1.4 01/02/16
03: *
04: * Copyright 1997-1999 Sun Microsystems, Inc. All Rights Reserved.
05: *
06: * This software is the proprietary information of Sun Microsystems, Inc.
07: * Use is subject to license terms.
08: *
09: */
10:
11: package javax.jms;
12:
13: /** A <CODE>ServerSession</CODE> object is an application server object that
14: * is used by a server to associate a thread with a JMS session (optional).
15: *
16: * <P>A <CODE>ServerSession</CODE> implements two methods:
17: *
18: * <UL>
19: * <LI><CODE>getSession</CODE> - returns the <CODE>ServerSession</CODE>'s
20: * JMS session.
21: * <LI><CODE>start</CODE> - starts the execution of the
22: * <CODE>ServerSession</CODE>
23: * thread and results in the execution of the JMS session's
24: * <CODE>run</CODE> method.
25: * </UL>
26: *
27: * <P>A <CODE>ConnectionConsumer</CODE> implemented by a JMS provider uses a
28: * <CODE>ServerSession</CODE> to process one or more messages that have
29: * arrived. It does this by getting a <CODE>ServerSession</CODE> from the
30: * <CODE>ConnectionConsumer</CODE>'s <CODE>ServerSessionPool</CODE>; getting
31: * the <CODE>ServerSession</CODE>'s JMS session; loading it with the messages;
32: * and then starting the <CODE>ServerSession</CODE>.
33: *
34: * <P>In most cases the <CODE>ServerSession</CODE> will register some object
35: * it provides as the <CODE>ServerSession</CODE>'s thread run object. The
36: * <CODE>ServerSession</CODE>'s <CODE>start</CODE> method will call the
37: * thread's <CODE>start</CODE> method, which will start the new thread, and
38: * from it, call the <CODE>run</CODE> method of the
39: * <CODE>ServerSession</CODE>'s run object. This object will do some
40: * housekeeping and then call the <CODE>Session</CODE>'s <CODE>run</CODE>
41: * method. When <CODE>run</CODE> returns, the <CODE>ServerSession</CODE>'s run
42: * object can return the <CODE>ServerSession</CODE> to the
43: * <CODE>ServerSessionPool</CODE>, and the cycle starts again.
44: *
45: * <P>Note that the JMS API does not architect how the
46: * <CODE>ConnectionConsumer</CODE> loads the <CODE>Session</CODE> with
47: * messages. Since both the <CODE>ConnectionConsumer</CODE> and
48: * <CODE>Session</CODE> are implemented by the same JMS provider, they can
49: * accomplish the load using a private mechanism.
50: *
51: * @version 1.0 - 9 March 1998
52: * @author Mark Hapner
53: * @author Rich Burridge
54: *
55: * @see javax.jms.ServerSessionPool
56: * @see javax.jms.ConnectionConsumer
57: */
58:
59: public interface ServerSession {
60:
61: /** Return the <CODE>ServerSession</CODE>'s <CODE>Session</CODE>. This must
62: * be a <CODE>Session</CODE> created by the same <CODE>Connection</CODE>
63: * that will be dispatching messages to it. The provider will assign one or
64: * more messages to the <CODE>Session</CODE>
65: * and then call <CODE>start</CODE> on the <CODE>ServerSession</CODE>.
66: *
67: * @return the server session's session
68: *
69: * @exception JMSException if the JMS provider fails to get the associated
70: * session for this <CODE>ServerSession</CODE> due
71: * to some internal error.
72: **/
73:
74: Session getSession() throws JMSException;
75:
76: /** Cause the <CODE>Session</CODE>'s <CODE>run</CODE> method to be called
77: * to process messages that were just assigned to it.
78: *
79: * @exception JMSException if the JMS provider fails to start the server
80: * session to process messages due to some internal
81: * error.
82: */
83:
84: void start() throws JMSException;
85: }
|