KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > pss > generator > jdo > lib > StorageTypeMapping


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA & USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library 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 library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Christophe Demarey.
23 Contributor(s): ________________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.pss.generator.jdo.lib;
28
29 // Package dependencies
30
/** To access AST. */
31 import org.objectweb.openccm.ast.api.StorageTypeStateMemberDecl;
32 /** To access Java AST. */
33 import org.objectweb.openccm.generator.java.ast.api.*;
34 import org.objectweb.openccm.generator.java.ast.lib.*;
35 /** Others. */
36 import org.objectweb.openccm.generator.translator.idl2java.api.PSDL_JavaTranslator;
37 import org.objectweb.openccm.pss.generator.common.api.PSDL2JavaGenerator;
38
39
40
41 /**
42  * This class generates Storage Type JDO Mapping.
43  *
44  * @author <a HREF="mailto:Christophe.Demarey@lifl.fr">Christophe Demarey</a>
45  *
46  * @version 0.1
47  */

48
49 public class StorageTypeMapping
50      extends org.objectweb.openccm.pss.generator.common.lib.StorageTypeMapping
51 {
52
53     // ==================================================================
54
//
55
// Internal states.
56
//
57
// ==================================================================
58

59     // ==================================================================
60
//
61
// Constructors.
62
//
63
// ==================================================================
64

65     /**
66      * The default constructor.
67      */

68
69     public StorageTypeMapping()
70     {
71         super();
72     }
73
74     // ==================================================================
75
//
76
// Internal methods.
77
//
78
// ==================================================================
79

80     /**
81      * Add methods of javax.jdo.InstanceCallbacks interface to this storage type.
82      *
83      * @param generator - The PSDL to Java generator.
84      * @param clazz - The abstract storage type mapping class.
85      **/

86     protected void
87     addInstanceCallbacks( PSDL2JavaGenerator generator,
88                           ClassObject clazz )
89     {
90         java.util.List JavaDoc to_codec = null,
91                        to_ior = null,
92                        to_class = null;
93         java.util.Iterator JavaDoc it = null;
94         StorageTypeStateMemberDecl state = null;
95         String JavaDoc mapping_type = null;
96         MethodObject method = null;
97         PSDL_JavaTranslator translator = null;
98
99         translator = generator.getTranslator();
100
101         clazz.addImplementedObject("javax.jdo.InstanceCallbacks");
102
103         // Compute marshalled states
104
to_codec = getStatesToCodec(generator);
105         to_ior = getStatesToIOR(generator);
106         to_class = getStatesToClass(generator);
107
108         // Add the jdoPostLoad method
109
method = new MethodObjectImpl();
110         method.addComment("javax.jdo.InstanceCallbacks jdoPostLoad method.");
111         method.setName("jdoPostLoad");
112         method.setReturnType("void");
113         method.getImpl().setMacro("ST_JDO_POST_LOAD_METHOD");
114         method.getImpl().addContextValue("to_codec", to_codec);
115         method.getImpl().addContextValue("to_ior", to_ior);
116         method.getImpl().addContextValue("to_class", to_class);
117         method.getImpl().addContextValue("translator", translator);
118         clazz.addMethod(method);
119
120         // Add the jdoPreStore method
121
method = new MethodObjectImpl();
122         method.addComment("javax.jdo.InstanceCallbacks jdoPreStore method.");
123         method.setName("jdoPreStore");
124         method.setReturnType("void");
125         method.getImpl().setMacro("ST_JDO_PRE_STORE_METHOD");
126         method.getImpl().addContextValue("to_codec", to_codec);
127         method.getImpl().addContextValue("to_ior", to_ior);
128         method.getImpl().addContextValue("to_class", to_class);
129         method.getImpl().addContextValue("translator", translator);
130         clazz.addMethod(method);
131
132         // Add the jdoPreClear method
133
method = new MethodObjectImpl();
134         method.addComment("javax.jdo.InstanceCallbacks jdoPreClear method.");
135         method.setName("jdoPreClear");
136         method.setReturnType("void");
137         clazz.addMethod(method);
138
139         // Add the jdoPreDelete method
140
method = new MethodObjectImpl();
141         method.addComment("javax.jdo.InstanceCallbacks jdoPreDelete method.");
142         method.setName("jdoPreDelete");
143         method.getImpl().setMacro("ST_JDO_PRE_DELETE_METHOD");
144         method.getImpl().addContextValue("to_class", to_class);
145         method.getImpl().addContextValue("translator", translator);
146         method.setReturnType("void");
147         clazz.addMethod(method);
148     }
149
150     /**
151      * Get The base class for JDO Storage Type Mapping.
152      *
153      * @return The base class name.
154      */

155     protected String JavaDoc
156     getStorageTypeBaseClass()
157     {
158         return "org.objectweb.openccm.pss.runtime.jdo.lib.StorageObjectBase";
159     }
160
161     // ==================================================================
162
//
163
// Public methods.
164
//
165
// ==================================================================
166

167 }
168
Popular Tags