KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jdo > spi > persistence > support > ejb > ejbc > CMP11TemplateFormatter


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24
25
26 /*
27  * CMP11TemplateFormatter.java
28  *
29  * Created on February 25, 2004
30  */

31
32 package com.sun.jdo.spi.persistence.support.ejb.ejbc;
33
34 import java.io.*;
35
36 import java.text.MessageFormat JavaDoc;
37 import java.util.HashMap JavaDoc;
38 import java.util.Properties JavaDoc;
39 import java.util.StringTokenizer JavaDoc;
40
41 import com.sun.jdo.spi.persistence.utility.generator.JavaClassWriterHelper;
42
43 /*
44  * This is the helper class for JDO specific generation of
45  * a concrete bean implementation for CMP 1.1 beans.
46  * Because both CMP20TemplateFormatter and this class extend
47  * CMPTemplateFormatter, and all references are static, properties
48  * in this class must differ in names. This is why they have 1_1
49  * or 11 in them.
50  *
51  * @author Marina Vatkina
52  */

53 class CMP11TemplateFormatter extends CMPTemplateFormatter {
54
55     private final static String JavaDoc templateFile =
56         "com/sun/jdo/spi/persistence/support/ejb/ejbc/CMP11Templates.properties"; // NOI18N
57

58     // Strings for CMP 1.1 code generation:
59
public final static String JavaDoc one_oneVariables_ = "one_oneVariables"; // NOI18N
60
public final static String JavaDoc ejbQuerySetIgnoreCache_ = "ejbQuerySetIgnoreCache"; //NOI18N
61

62     // Inner helper Class strings.
63
public final static String JavaDoc helper11Interface_
64                       = "com.sun.jdo.spi.persistence.support.sqlstore.ejb.JDOEJB11Helper"; // NOI18N
65
public final static String JavaDoc helper11Impl_
66                       = "com.sun.jdo.spi.persistence.support.ejb.cmp.JDOEJB11HelperImpl"; // NOI18N
67

68     // CMP1.1 properties
69
public final static String JavaDoc ejbCreate1_1_ = "ejbCreate1_1"; // NOI18N
70
public final static String JavaDoc ejbCreateUnknownPK1_1_ = "ejbCreateUnknownPK1_1"; // NOI18N
71
public final static String JavaDoc ejbPostCreate1_1_ = "ejbPostCreate1_1"; // NOI18N
72
public final static String JavaDoc ejbRemove1_1_ = "ejbRemove1_1"; // NOI18N
73
public final static String JavaDoc storeFields1_1_ = "jdoStoreFields"; // NOI18N
74
public final static String JavaDoc loadFields1_1_ = "jdoLoadFields"; // NOI18N
75
public final static String JavaDoc setEntityContext1_1_ = "setEntityContext1_1"; // NOI18N
76
public final static String JavaDoc internalMethods1_1_ = "internalMethods1_1"; // NOI18N
77
public final static String JavaDoc helperMethods1_1_ = "helperMethods1_1"; // NOI18N
78
public final static String JavaDoc load1_1_ = "load1_1"; // NOI18N
79
public final static String JavaDoc store1_1_ = "store1_1"; // NOI18N
80
public final static String JavaDoc assertPKStore1_1_ = "assertPKStore1_1"; // NOI18N
81
public final static String JavaDoc pkstore1_1_ = "pkstore1_1"; // NOI18N
82
public final static String JavaDoc pkstringstore1_1_ = "pkstringstore1_1"; // NOI18N
83
public final static String JavaDoc pkcopystore1_1_ = "pkcopystore1_1"; // NOI18N
84
public final static String JavaDoc copyload1_1_ = "copyload1_1"; // NOI18N
85
public final static String JavaDoc copystore1_1_ = "copystore1_1"; // NOI18N
86
public final static String JavaDoc arrayload1_1_ = "arrayload1_1"; // NOI18N
87
public final static String JavaDoc arraystore1_1_ = "arraystore1_1"; // NOI18N
88
public final static String JavaDoc loadSerializable1_1_ = "loadSerializable1_1"; // NOI18N
89
public final static String JavaDoc storeSerializable1_1_ = "storeSerializable1_1"; // NOI18N
90

91     // property key for the CVS keyword substitution
92
public final static String JavaDoc signature1_1_ = "signature1_1"; //NOI18N
93

94     // finder/selector methods
95
public static MessageFormat JavaDoc querysetignorecacheformatter = null; // statement to set the ignoreCache flag for a JDOQL query
96

97     // CMP1.1 formatter
98
public static MessageFormat JavaDoc c11formatter = null; // ejbCreate1_1
99
public static MessageFormat JavaDoc c11unpkformatter = null; // ejbCreateUnknownPK1_1
100
public static MessageFormat JavaDoc postc11formatter = null; // ejbPostCreate1_1
101
public static MessageFormat JavaDoc l11formatter = null; // CMP field load for 1.1
102
public static MessageFormat JavaDoc s11formatter = null; // CMP field store for 1.1
103
public static MessageFormat JavaDoc l11copyformatter = null; // Mutable CMP field load for 1.1
104
public static MessageFormat JavaDoc s11copyformatter = null; // Mutable CMP field store for 1.1
105
public static MessageFormat JavaDoc l11arrayformatter = null; // byte[] CMP field load for 1.1
106
public static MessageFormat JavaDoc s11arrayformatter = null; // byte[] CMP field store for 1.1
107
public static MessageFormat JavaDoc assertpks11formatter = null; // assert not null PK CMP field store for 1.1
108
public static MessageFormat JavaDoc pks11formatter = null; // PK CMP field store for 1.1
109
public static MessageFormat JavaDoc pkstring11formatter = null; // String CMP field store for 1.1
110
public static MessageFormat JavaDoc pkcopy11formatter = null; // Mutable CMP field store for 1.1
111
public static MessageFormat JavaDoc l11Serializableformatter = null; // serializable CMP field load for 1.1
112
public static MessageFormat JavaDoc s11Serializableformatter = null; // serializable CMP field store for 1.1
113

114     // standard 1.1 templates for the corresponding keys, so that a template "xxxTemplate"
115
// corresponds to a "xxx" key.
116
public static String JavaDoc one_oneVariablesTemplate = null;
117     public static String JavaDoc ejbRemove1_1Template = null;
118     public static String JavaDoc signature1_1Template = null;
119
120     private static boolean is11HelpersLoaded = false;
121
122     /**
123      * Constructs a new <code>CMP11TemplateFormatter</code> instance.
124      */

125     CMP11TemplateFormatter() {
126     }
127
128     /**
129      * Initializes templates for code generation.
130      */

131     static synchronized void initHelpers() throws IOException {
132         if (is11HelpersLoaded == false) {
133             loadProperties(helpers, templateFile);
134             init11Formatters();
135             init11Templates();
136
137             is11HelpersLoaded = true;
138
139         }
140     }
141
142     /**
143      * Initializes MessageFormats for code generation.
144      */

145     private static void init11Formatters() {
146         // 1.1 finder methods
147
querysetignorecacheformatter = new MessageFormat JavaDoc(helpers.getProperty(ejbQuerySetIgnoreCache_));
148
149         // CMP1.1 formatters
150
c11formatter = new MessageFormat JavaDoc(helpers.getProperty(ejbCreate1_1_));
151         c11unpkformatter = new MessageFormat JavaDoc(helpers.getProperty(ejbCreateUnknownPK1_1_));
152         postc11formatter = new MessageFormat JavaDoc(helpers.getProperty(ejbPostCreate1_1_));
153         l11formatter = new MessageFormat JavaDoc(helpers.getProperty(load1_1_));
154         s11formatter = new MessageFormat JavaDoc(helpers.getProperty(store1_1_));
155         assertpks11formatter = new MessageFormat JavaDoc(helpers.getProperty(assertPKStore1_1_));
156         pks11formatter = new MessageFormat JavaDoc(helpers.getProperty(pkstore1_1_));
157         pkstring11formatter = new MessageFormat JavaDoc(helpers.getProperty(pkstringstore1_1_));
158         pkcopy11formatter = new MessageFormat JavaDoc(helpers.getProperty(pkcopystore1_1_));
159         l11copyformatter = new MessageFormat JavaDoc(helpers.getProperty(copyload1_1_));
160         s11copyformatter = new MessageFormat JavaDoc(helpers.getProperty(copystore1_1_));
161         l11arrayformatter = new MessageFormat JavaDoc(helpers.getProperty(arrayload1_1_));
162         s11arrayformatter = new MessageFormat JavaDoc(helpers.getProperty(arraystore1_1_));
163         l11Serializableformatter = new MessageFormat JavaDoc(helpers.getProperty(loadSerializable1_1_));
164         s11Serializableformatter = new MessageFormat JavaDoc(helpers.getProperty(storeSerializable1_1_));
165     }
166
167     /**
168      * Initializes standard templates for code generation.
169      */

170     private static void init11Templates() {
171         one_oneVariablesTemplate = helpers.getProperty(one_oneVariables_);
172         ejbRemove1_1Template = helpers.getProperty(ejbRemove1_1_);
173         signature1_1Template = helpers.getProperty(signature1_1_);
174     }
175 }
176
Popular Tags