KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > ejb > EJBMetaDataImpl


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.ejb;
30
31 import com.caucho.util.CharBuffer;
32
33 import javax.ejb.EJBHome JavaDoc;
34 import javax.ejb.EJBMetaData JavaDoc;
35 import java.io.Serializable JavaDoc;
36
37 public class EJBMetaDataImpl implements EJBMetaData JavaDoc, Serializable JavaDoc {
38   // ejb/0230
39
private EJBHome JavaDoc home;
40   
41   private Class JavaDoc homeInterfaceClass;
42   private Class JavaDoc remoteInterfaceClass;
43   private Class JavaDoc primaryKeyClass;
44
45   private boolean isSession;
46   private boolean isStatelessSession;
47
48   /**
49    * Null constructor for serialization.
50    */

51   public EJBMetaDataImpl()
52   {
53   }
54
55   /**
56    * Create a new meta data.
57    */

58   EJBMetaDataImpl(EJBHome JavaDoc home,
59                   Class JavaDoc homeInterfaceClass,
60                   Class JavaDoc remoteInterfaceClass,
61                   Class JavaDoc primaryKeyClass)
62   {
63     this.home = home;
64     this.homeInterfaceClass = homeInterfaceClass;
65     this.remoteInterfaceClass = remoteInterfaceClass;
66     this.primaryKeyClass = primaryKeyClass;
67   }
68
69   public EJBHome JavaDoc getEJBHome()
70   {
71     return this.home;
72   }
73
74   public void setEJBHome(EJBHome JavaDoc home)
75   {
76     this.home = home;
77   }
78
79   public Class JavaDoc getHomeInterfaceClass()
80   {
81     return this.homeInterfaceClass;
82   }
83
84   public Class JavaDoc getRemoteInterfaceClass()
85   {
86     return this.remoteInterfaceClass;
87   }
88
89   public Class JavaDoc getPrimaryKeyClass()
90   {
91     return this.primaryKeyClass;
92   }
93
94   void setSession(boolean isSession)
95   {
96     this.isSession = isSession;
97   }
98
99   public boolean isSession()
100   {
101     return this.isSession;
102   }
103
104   void setStatelessSession(boolean isStatelessSession)
105   {
106     this.isStatelessSession = isStatelessSession;
107   }
108
109   public boolean isStatelessSession()
110   {
111     return this.isStatelessSession;
112   }
113
114   public String JavaDoc toString()
115   {
116     CharBuffer cb = new CharBuffer();
117
118     cb.append("MetaData[");
119     if (isSession() && isStatelessSession())
120       cb.append("stateless-session");
121     else if (isSession())
122       cb.append("session");
123     else
124       cb.append("entity");
125
126     if (homeInterfaceClass != null)
127       cb.append(" home:" + homeInterfaceClass.getName());
128     if (remoteInterfaceClass != null)
129       cb.append(" remote:" + remoteInterfaceClass.getName());
130     if (primaryKeyClass != null)
131       cb.append(" key:" + primaryKeyClass.getName());
132
133     cb.append("]");
134
135     return cb.toString();
136   }
137 }
138
Popular Tags