KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > jms > server > container > Client


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.jms.server.container;
8
9 import org.jboss.aop.joinpoint.Invocation;
10 import org.jboss.aop.joinpoint.MethodInvocation;
11 import org.jboss.aop.metadata.SimpleMetaData;
12 import org.jboss.jms.destination.JBossDestination;
13 import org.jboss.jms.server.BrowserEndpointFactory;
14 import org.jboss.jms.server.DeliveryEndpointFactory;
15 import org.jboss.jms.server.MessageBroker;
16 import org.jboss.util.id.GUID;
17
18 /**
19  * The serverside representation of the client
20  *
21  * @author <a HREF="mailto:adrian@jboss.org>Adrian Brock</a>
22  * @version $Revision: 1.4 $
23  */

24 public class Client
25 {
26    // Constants -----------------------------------------------------
27

28    // Attributes ----------------------------------------------------
29

30    /** The Message broker */
31    private MessageBroker broker;
32
33    // Static --------------------------------------------------------
34

35    public static Client getClient(Invocation invocation)
36    {
37       return (Client) invocation.getMetaData("JMS", "Client");
38    }
39
40    // Constructors --------------------------------------------------
41

42    public Client(MessageBroker broker)
43    {
44       this.broker = broker;
45    }
46
47    // Public --------------------------------------------------------
48

49    public SimpleMetaData createSession(MethodInvocation invocation)
50    {
51       return getMetaData();
52    }
53
54    public SimpleMetaData createBrowser(MethodInvocation invocation)
55    {
56       SimpleMetaData result = getMetaData();
57       
58       JBossDestination destination = (JBossDestination) invocation.getArguments()[0];
59       String JavaDoc selector = (String JavaDoc) invocation.getArguments()[1];
60       BrowserEndpointFactory endpointFactory = broker.getBrowserEndpointFactory(destination, selector);
61       result.addMetaData("JMS", "BrowserEndpointFactory", endpointFactory);
62       return result;
63    }
64
65    public SimpleMetaData createConsumer(MethodInvocation invocation)
66    {
67       return getMetaData();
68    }
69
70    public SimpleMetaData createProducer(MethodInvocation invocation)
71    {
72       SimpleMetaData result = getMetaData();
73       
74       JBossDestination destination = (JBossDestination) invocation.getArguments()[0];
75       DeliveryEndpointFactory endpointFactory = broker.getDeliveryEndpointFactory(destination);
76       result.addMetaData("JMS", "DeliveryEndpointFactory", endpointFactory);
77       return result;
78    }
79
80    public SimpleMetaData getMetaData()
81    {
82       SimpleMetaData result = new SimpleMetaData();
83       result.addMetaData("JMS", "Client", this);
84       result.addMetaData("JMS", "OID", GUID.asString());
85       return result;
86    }
87
88    // Protected ------------------------------------------------------
89

90    // Package Private ------------------------------------------------
91

92    // Private --------------------------------------------------------
93

94    // Inner Classes --------------------------------------------------
95

96 }
97
Popular Tags