KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > proxy > 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.ejb3.proxy;
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 Oberg (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: 57882 $
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 (EJBException JavaDoc e)
97       {
98          throw e;
99       }
100       catch (RemoteException JavaDoc e)
101       {
102          e.printStackTrace();
103          throw new EJBException JavaDoc(e);
104       }
105    }
106
107    /**
108     * Obtain the Class object for the enterprise Bean's home interface.
109     */

110    public Class JavaDoc getHomeInterfaceClass()
111    {
112       return home;
113    }
114
115    /**
116     * Obtain the Class object for the enterprise Bean's remote interface.
117     */

118    public Class JavaDoc getRemoteInterfaceClass()
119    {
120       return remote;
121    }
122
123    /**
124     * Obtain the Class object for the enterprise Bean's primary key class.
125     */

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

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

149    public boolean isStatelessSession()
150    {
151       return statelessSession;
152    }
153 }
154
Popular Tags