KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_ejb > genic > VcParam


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999-2004 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: VcParam.java,v 1.5 2004/09/21 14:28:46 joaninh Exp $
23  * --------------------------------------------------------------------------
24  */

25
26
27 package org.objectweb.jonas_ejb.genic;
28
29 import org.objectweb.jonas_ejb.deployment.api.BeanDesc;
30 import org.objectweb.jonas_ejb.lib.JavaType;
31 import org.objectweb.jonas_ejb.lib.JormType;
32
33 /**
34  * This class is the "Velocity context" for a parameter of a finder/select method for CMP2 only,
35  * used in the Velocity Templates.
36  * @author Helene Joanin : Initial developer
37  */

38 public class VcParam {
39
40     /**
41      * Type's name of the parameter
42      */

43     private String JavaDoc mTypeName = null;
44
45     /**
46      * JORM type's name of the parameter
47      */

48     private String JavaDoc mJormTypeName = null;
49
50     /**
51      * true if the parameter is a local bean
52      */

53     private boolean mIsEjbLocal = false;
54     /**
55      * In case the parameter is a local bean, name of this local bean
56      */

57     private String JavaDoc mEjbName = null;
58
59     /**
60      * VcParam Constructor
61      * @param type parameter class
62      * @param dd bean descriptor
63      */

64     VcParam(Class JavaDoc type, BeanDesc dd) {
65         mTypeName = JavaType.getName(type);
66         mJormTypeName = JormType.getPTypeDef(type, false);
67         mIsEjbLocal = javax.ejb.EJBLocalObject JavaDoc.class.isAssignableFrom(type);
68         if (mIsEjbLocal) {
69             BeanDesc bdp = dd.getDeploymentDesc().getBeanDescWithLocalInterface(mTypeName);
70             if (bdp == null) {
71                 throw new Error JavaDoc("VcParam: Cannot get the BeanDesc associated to the interface local '" + mTypeName + "'");
72             }
73             mEjbName = bdp.getEjbName();
74         }
75     }
76
77     /**
78      * @return Returns the type's name of the parameter
79      */

80     public String JavaDoc getTypeName() {
81         return mTypeName;
82     }
83
84     /**
85      * @return Returns the JORM type's name of the parameter
86      */

87     public String JavaDoc getJormType() {
88         return mJormTypeName;
89     }
90
91     /**
92      * @return Returns true if the parameter is a local bean
93      */

94     public boolean isEjbLocal() {
95         return mIsEjbLocal;
96     }
97
98     /**
99      * @return If the parameter is a local bean, returns the name of this local bean
100      */

101     public String JavaDoc getEjbName() {
102         if (!isEjbLocal()) {
103             throw new Error JavaDoc("VcParam.getEjbName(): No BeanDesc associated to the param '"
104                             + mTypeName + "'");
105         }
106         return mEjbName;
107     }
108
109 }
110
111
Popular Tags