1 /***
2 * Copyright 2003-2010 Terracotta, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18 package net.sf.ehcache.distribution;
19
20 import java.rmi.Naming;
21 import java.rmi.RemoteException;
22 import java.rmi.registry.LocateRegistry;
23 import java.rmi.server.UnicastRemoteObject;
24
25
26 /***
27 * Enables manual playing around with RMI ports.
28 * @author Greg Luck
29 */
30 public class RMIPortUsage extends UnicastRemoteObject {
31
32 private static RMIPortUsage rmi;
33
34 /***
35 *
36 * @param port
37 * @throws RemoteException
38 */
39 protected RMIPortUsage(int port) throws RemoteException {
40 super(port);
41 }
42
43 /***
44 *
45 * @param args
46 * @throws Exception
47 */
48 public static void main(String[] args) throws Exception {
49 int port = 10001;
50 String service = "rmi://127.0.0.1" + ':' + port + '/' +
51 "test";
52 rmi = new RMIPortUsage(port);
53 LocateRegistry.createRegistry(port);
54
55
56
57 Naming.rebind(service, rmi);
58
59
60
61
62
63 Thread.sleep(100000);
64
65 }
66
67 }
68
69