KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > kilim > model > RtExternalValue


1 /**
2  * Copyright (C) 2002 Kelua SA
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19 package org.objectweb.kilim.model;
20
21 import java.util.Stack JavaDoc;
22
23 import org.objectweb.kilim.KilimException;
24
25 /**
26  * RtExternalValues are specific sources referencing external system entities i.e. entities not described by Kilim descriptors.
27  * RtExternalValues can be seen as special properties referencing objects without descriptors and runtime objects.
28  * Remark : Next Kilim implementation should define this class as an extension of ComponentProperty.
29  * @author horn
30  */

31 public class RtExternalValue extends RtComponentSource {
32     private String JavaDoc name;
33     private Object JavaDoc value;
34         
35     /**
36      * The public constructor for external values (i.e. objects without kilim descriptor).
37      * @param aName : the name of the external value
38      * @param aValue : the object reference.
39      */

40     public RtExternalValue(String JavaDoc aName, Object JavaDoc aValue) {
41         super(null, null);
42         name = aName;
43         value = aValue;
44     }
45     
46     /**
47      * @see org.objectweb.kilim.model.ComponentElement#getLocalName()
48      */

49     public String JavaDoc getLocalName() {
50         return name;
51     }
52     
53     /**
54      * @see org.objectweb.kilim.model.RuntimeSource#getValue()
55      */

56     public Object JavaDoc getValue() throws KilimException {
57         Object JavaDoc resultValue = null;
58         if (mappingContext != null) {
59             mappingContext.getCallStack().push(this);
60         }
61         mapper.enterContext(mappingContext);
62         resultValue = mapper.getExternalValue(value, mappingContext);
63
64         if (mappingContext != null) {
65             mappingContext.getCallStack().pop();
66         }
67         mapper.leaveContext(mappingContext);
68         return resultValue;
69     }
70                             
71     /**
72      * @see org.objectweb.kilim.model.RuntimeSource#isEventSource()
73      */

74     public boolean isEventSource() {
75         return false;
76     }
77     
78     /**
79      * @see org.objectweb.kilim.model.RuntimeSource#getEventSource()
80      */

81     public Object JavaDoc getEventSourceValue() throws KilimException {
82         throw new KilimException("attempt to get the event source of element ");
83     }
84     
85     /**
86      * @see org.objectweb.kilim.model.RuntimeSource#setEventSource(Object)
87      */

88     public void setEventSourceValue(Object JavaDoc aSource) throws KilimException {
89         throw new KilimException("attempt to set the event source to a element ");
90     }
91     
92     /**
93      * @see org.objectweb.kilim.model.RuntimeSource#checkValue()
94      */

95     public boolean hasValue() throws KilimException {
96         return true;
97     }
98     
99     /**
100      * @see org.objectweb.kilim.model.RuntimeSource#checkValue(Stack)
101      */

102     public boolean checkValue(Stack JavaDoc exclude) throws KilimException {
103         return true;
104     }
105 }
Popular Tags