View Javadoc

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   *
29   * @author Greg Luck
30   */
31  public class RMIPortUsage extends UnicastRemoteObject {
32  
33      private static RMIPortUsage rmi;
34  
35      /***
36       * @param port
37       * @throws RemoteException
38       */
39      protected RMIPortUsage(int port) throws RemoteException {
40          super(port);
41      }
42  
43      /***
44       * @param args
45       * @throws Exception
46       */
47      public static void main(String[] args) throws Exception {
48          int port = 10001;
49          String service = "rmi://127.0.0.1" + ':' + port + '/' +
50                  "test";
51          rmi = new RMIPortUsage(port);
52          LocateRegistry.createRegistry(port);
53  
54          //Ports being listend to: 
55          //Sep 26 21:29:52 Greg-Lucks-Laptop Firewall[57]: java is listening from ::ffff:0.0.0.0:10001 uid = 501 proto=6
56          Naming.rebind(service, rmi);
57  
58  
59          //Ports being listened to:
60          //Sep 26 21:29:52 Greg-Lucks-Laptop Firewall[57]: java is listening from ::ffff:0.0.0.0:10001 uid = 501 proto=6
61          //Sep 26 21:30:36 Greg-Lucks-Laptop Firewall[57]: java is listening from ::ffff:127.0.0.1:57915 uid = 501 proto=6
62          Thread.sleep(100000);
63  
64      }
65  
66  }
67  
68