KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > proxy > ejb > EJBMetaDataImpl


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.proxy.ejb;
23
24 import java.io.Serializable JavaDoc;
25 import java.rmi.RemoteException JavaDoc;
26
27 import javax.ejb.HomeHandle JavaDoc;
28 import javax.ejb.EJBMetaData JavaDoc;
29 import javax.ejb.EJBHome JavaDoc;
30 import javax.ejb.EJBException JavaDoc;
31
32 /**
33  * An implementation of the EJBMetaData interface which allows a
34  * client to obtain the enterprise Bean's meta-data information.
35  *
36  * @author Rickard Öberg (rickard.oberg@telkel.com)
37  * @author <a HREF="mailto:marc.fleury@telkel.com">Marc Fleury</a>
38  * @author <a HREF="mailto:jason@planet57.com">Jason Dillon</a>
39  * @version $Revision: 37459 $
40  */

41 public class EJBMetaDataImpl
42       implements EJBMetaData JavaDoc, Serializable JavaDoc
43 {
44    /** Serial Version Identifier. @since 1.1 */
45    private static final long serialVersionUID = -3698855455664391097L;
46
47    // Attributes ----------------------------------------------------
48
private final Class JavaDoc remote;
49    private final Class JavaDoc home;
50    private final Class JavaDoc pkClass;
51
52    private final boolean session;
53    private final boolean statelessSession;
54    private final HomeHandle JavaDoc homeHandle;
55
56    // Constructors --------------------------------------------------
57

58    /**
59     * Construct an <tt>EJBMetaDataImpl</tt>.
60     * this should only be accessible from the factory.
61     */

62    public EJBMetaDataImpl(final Class JavaDoc remote,
63          final Class JavaDoc home,
64          final Class JavaDoc pkClass,
65          final boolean session,
66          final boolean statelessSession,
67          final HomeHandle JavaDoc homeHandle)
68    {
69       this.remote = remote;
70       this.home = home;
71       this.pkClass = pkClass;
72       this.session = session;
73       this.statelessSession = statelessSession;
74       this.homeHandle = homeHandle;
75    }
76
77    // Constructors --------------------------------------------------
78

79    // EJBMetaData ---------------------------------------------------
80

81
82    // EJBMetaData ---------------------------------------------------
83

84    /**
85     * Obtain the home interface of the enterprise Bean.
86     *
87     * @throws EJBException Failed to get EJBHome object.
88     */

89
90    public EJBHome JavaDoc getEJBHome()
91    {
92       try
93       {
94          return homeHandle.getEJBHome();
95       }
96       catch (RemoteException JavaDoc e)
97       {
98          e.printStackTrace();
99          throw new EJBException JavaDoc(e);
100       }
101    }
102
103    /**
104     * Obtain the Class object for the enterprise Bean's home interface.
105     */

106    public Class JavaDoc getHomeInterfaceClass()
107    {
108       return home;
109    }
110
111    /**
112     * Obtain the Class object for the enterprise Bean's remote interface.
113     */

114    public Class JavaDoc getRemoteInterfaceClass()
115    {
116       return remote;
117    }
118
119    /**
120     * Obtain the Class object for the enterprise Bean's primary key class.
121     */

122    public Class JavaDoc getPrimaryKeyClass()
123    {
124       if (session == true)
125          throw new RuntimeException JavaDoc("A session bean does not have a primary key class");
126
127       return pkClass;
128    }
129
130    /**
131     * Test if the enterprise Bean's type is "session".
132     *
133     * @return True if the type of the enterprise Bean is session bean.
134     */

135    public boolean isSession()
136    {
137       return session;
138    }
139
140    /**
141     * Test if the enterprise Bean's type is "stateless session".
142     *
143     * @return True if the type of the enterprise Bean is stateless session.
144     */

145    public boolean isStatelessSession()
146    {
147       return statelessSession;
148    }
149 }
150
Popular Tags