1 /***
2 * Redistribution and use of this software and associated documentation
3 * ("Software"), with or without modification, are permitted provided
4 * that the following conditions are met:
5 *
6 * 1. Redistributions of source code must retain copyright
7 * statements and notices. Redistributions must also contain a
8 * copy of this document.
9 *
10 * 2. Redistributions in binary form must reproduce the
11 * above copyright notice, this list of conditions and the
12 * following disclaimer in the documentation and/or other
13 * materials provided with the distribution.
14 *
15 * 3. The name "Exolab" must not be used to endorse or promote
16 * products derived from this Software without prior written
17 * permission of Exoffice Technologies. For written permission,
18 * please contact tma@netspace.net.au.
19 *
20 * 4. Products derived from this Software may not be called "Exolab"
21 * nor may "Exolab" appear in their names without prior written
22 * permission of Exoffice Technologies. Exolab is a registered
23 * trademark of Exoffice Technologies.
24 *
25 * 5. Due credit should be given to the Exolab Project
26 * (http://www.exolab.org/).
27 *
28 * THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
29 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
30 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
31 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
32 * EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
33 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
35 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
39 * OF THE POSSIBILITY OF SUCH DAMAGE.
40 *
41 * Copyright 2001-2004 (C) Exoffice Technologies Inc. All Rights Reserved.
42 *
43 * $Id: MessengerServer.java,v 1.2 2004/02/02 03:49:20 tanderson Exp $
44 */
45 package org.exolab.jmscts.core.service;
46
47 import java.rmi.Naming;
48 import java.rmi.RemoteException;
49 import java.rmi.server.UnicastRemoteObject;
50
51 import javax.jms.JMSException;
52
53 import org.apache.commons.cli.CommandLine;
54 import org.apache.commons.cli.CommandLineParser;
55 import org.apache.commons.cli.Options;
56 import org.apache.commons.cli.PosixParser;
57
58 import org.exolab.jmscts.core.JMSTestRunner;
59 import org.exolab.jmscts.core.MessagePopulator;
60 import org.exolab.jmscts.core.MessageVerifier;
61 import org.exolab.jmscts.core.Messenger;
62
63
64 /***
65 * This class enables messaging operations to be performed in a separate
66 * JVM
67 *
68 * @version $Revision: 1.2 $ $Date: 2004/02/02 03:49:20 $
69 * @author <a href="mailto:tma@netspace.net.au">Tim Anderson</a>
70 */
71 public class MessengerServer extends UnicastRemoteObject implements Messenger {
72
73 /***
74 * The registry port argument
75 */
76 private static final String PORT = "port";
77
78 /***
79 * The name of the server bound in the RMI registry
80 */
81 private String _name = null;
82
83
84 /***
85 * Construct a new instance
86 *
87 * @param port the RMI registry port
88 * @throws Exception for any error
89 */
90 protected MessengerServer(int port) throws Exception {
91 _name = "//localhost:" + port + "/Messenger";
92 Naming.rebind(_name, this);
93 }
94
95 /***
96 * Send messages to a destination
97 *
98 * @param message the type of the message to send
99 * @param destination the name of the destination
100 * @param count the number of messages to send
101 * @param populator the message populator (may be null)
102 * @throws Exception if the populator fails or remote call fails
103 * @throws JMSException if the messages can't be sent
104 */
105 public void send(Class message, String destination, int count,
106 MessagePopulator populator)
107 throws Exception, JMSException {
108 }
109
110 /***
111 * Receive messages from a destination
112 *
113 * @param destination the name of the destination
114 * @param count the expected number of messages to receive
115 * @param timeout the maximum time to wait for each
116 * @param verifier the message verifier (may be null)
117 * @return the actual number of messages received
118 * @throws JMSException if the messages can't be received
119 * @throws RemoteException if the remote call fails
120 */
121 public int receive(String destination, int count, long timeout,
122 MessageVerifier verifier)
123 throws JMSException, RemoteException {
124 return 0;
125 }
126
127 /***
128 * Main line
129 *
130 * @param args command line arguments
131 * @throws Exception for any error
132 */
133 public static void main(String[] args) throws Exception {
134 Options options = new Options();
135 options.addOption(
136 PORT, true, "use port to connect to the compliance test");
137
138 CommandLineParser parser = new PosixParser();
139 CommandLine commands = parser.parse(options, args);
140
141 String port = commands.getOptionValue(
142 PORT, JMSTestRunner.DEFAULT_PORT);
143
144 new MessengerServer(Integer.parseInt(port));
145 }
146
147 }
This page was automatically generated by Maven