KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfox > ejb > EJBObjectId


1 /* JFox, the OpenSource J2EE Application Server
2  *
3  * Distributable under GNU LGPL license by gun.org
4  * more details please visit http://www.huihoo.org/jfox
5  */

6 package org.jfox.ejb;
7
8 import org.jfox.ioc.connector.ObjectId;
9 import org.jfox.ioc.util.ObjectUUID;
10
11 /**
12  * ObjectId 用来保证 Container 中的 ejb object 的唯一性
13  *
14  * @author <a HREF="mailto:young_yy@hotmail.com">Young Yang</a>
15  */

16
17 public class EJBObjectId extends ObjectId {
18
19     private String JavaDoc ejbName;
20     private String JavaDoc remoteInterf;
21     private String JavaDoc homeInterf;
22
23     private boolean isHome;
24
25     public EJBObjectId(String JavaDoc ejbName, String JavaDoc homeInterf, String JavaDoc remoteInterf, ObjectUUID hash, boolean isHome) {
26         super(hash);
27         this.ejbName = ejbName;
28         this.homeInterf = homeInterf;
29         this.remoteInterf = remoteInterf;
30         this.isHome = isHome;
31     }
32
33     public String JavaDoc toString() {
34         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
35         if(isHome) {
36             sb.append(homeInterf);
37         }
38         else {
39             sb.append(remoteInterf);
40         }
41         sb.append("@").append(uuid);
42         return sb.toString();
43     }
44
45     /**
46      * @return 这个 ejb 的 name ,作为 ejb container 中的 key
47      */

48     public String JavaDoc getRemoteInterfaceName() {
49         return remoteInterf;
50     }
51
52     public String JavaDoc getHomeInterfName() {
53         return homeInterf;
54     }
55
56     public boolean isHome() {
57         return isHome;
58     }
59
60     public String JavaDoc getEjbName() {
61         return ejbName;
62     }
63
64     public int hashCode() {
65         return uuid.hashCode();
66     }
67
68     /**
69      * @return 完整的 Object ID, name@hashCode
70      */

71     public String JavaDoc getStringObjectId() {
72         return this.toString();
73     }
74
75     public ObjectUUID getObjectUUID() {
76         return uuid;
77     }
78
79     public byte[] getAddress() {
80         return uuid.getVMID().getAddress();
81     }
82
83     /**
84      * is this ObjectId's VM in
85      *
86      * @return boolean
87      */

88     public boolean isCurrentVM() {
89         return uuid.getVMID().isCurrentVM();
90     }
91
92     public boolean equals(Object JavaDoc obj) {
93         if(!(obj instanceof EJBObjectId)) return false;
94         return ((EJBObjectId) obj).getStringObjectId().equals(this.getStringObjectId());
95     }
96
97 /*
98   public String getIdentity(){
99     return identity;
100   }
101 */

102
103 }
104
Popular Tags