KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > ubik > rmi > server > RmiUtils


1 /*
2  * RmiUtils.java
3  *
4  * Created on June 30, 2005, 7:54 PM
5  */

6
7 package org.sapia.ubik.rmi.server;
8
9 import java.lang.reflect.Proxy JavaDoc;
10
11 import org.sapia.ubik.rmi.Consts;
12
13 /**
14  *
15  * @author yduchesne
16  */

17 public class RmiUtils {
18   
19   public static final String JavaDoc CODE_BASE = System.getProperty("java.rmi.server.codebase");
20   
21   public static final boolean MARSHALLING = (System.getProperty(Consts.MARSHALLING) != null) &&
22     System.getProperty(Consts.MARSHALLING).equals("true");
23   
24   public static final boolean CODE_DOWNLOAD = (System.getProperty(Consts.ALLOW_CODE_DOWNLOAD) != null) &&
25     System.getProperty(Consts.ALLOW_CODE_DOWNLOAD).equals("true");
26   
27   /**
28    * @return <code>true</code> if the given object is a stub (an instance of
29    * the <code>Stub</code> interface).
30    *
31    * @see Stub
32    */

33   public static boolean isStub(Object JavaDoc o){
34     return o instanceof Stub;
35   }
36
37   /**
38    * @return the <code>StubInvocationHandler</code> corresponding to the given
39    * stub, or <code>null</code> if no such stub exists.
40    */

41   public static StubInvocationHandler getInvocationHandlerFor(Object JavaDoc stub){
42     if(stub instanceof Stub && Proxy.isProxyClass(stub.getClass())){
43       return (StubInvocationHandler)Proxy.getInvocationHandler(stub);
44     }
45     return null;
46   }
47   
48 }
49
Popular Tags