Source Code Cross Referenced for CompileTool172.java in  » 6.0-JDK-Modules » j2me » com » sun » j2mews » sg » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » j2me » com.sun.j2mews.sg 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  
003:         *
004:         * Copyright  1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006:         * 
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License version
009:         * 2 only, as published by the Free Software Foundation.
010:         * 
011:         * This program is distributed in the hope that it will be useful, but
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014:         * General Public License version 2 for more details (a copy is
015:         * included at /legal/license.txt).
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * version 2 along with this work; if not, write to the Free Software
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA
021:         * 
022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023:         * Clara, CA 95054 or visit www.sun.com if you need additional
024:         * information or have any questions.
025:         */
026:
027:        package com.sun.j2mews.sg;
028:
029:        import java.io.*;
030:        import java.util.*;
031:        import com.sun.xml.rpc.tools.wscompile.CompileTool;
032:        import com.sun.xml.rpc.processor.model.*;
033:        import com.sun.xml.rpc.processor.util.*;
034:        import com.sun.xml.rpc.processor.*;
035:        import com.sun.xml.rpc.processor.util.GeneratedFileInfo;
036:        import com.sun.xml.rpc.tools.wscompile.ActionConstants;
037:        import com.sun.xml.rpc.util.localization.*;
038:
039:        /**
040:         * We extend the JAX-RPC SI's CompileTool class and replace their
041:         * generators with ours where needed.
042:         *
043:         */
044:        public class CompileTool172 extends CompileTool {
045:            protected StringBuffer errorMessages = new StringBuffer();
046:            protected String cldcVersion = "1.0";
047:            protected boolean expandArguments = true;
048:            protected LocalizableMessageFactory messageFactory172;
049:            protected boolean doCompilation = true;
050:            protected RemoteInterfaceGenerator rig;
051:            protected StubGenerator sg;
052:
053:            private Map originalTypes;
054:
055:            public CompileTool172(OutputStream out, String program) {
056:                super (out, program);
057:                originalTypes = new HashMap();
058:                messageFactory172 = new LocalizableMessageFactory(
059:                        "com.sun.j2mews.sg.wscompile172");
060:
061:                installReplacementActions();
062:            }
063:
064:            protected void installReplacementActions() {
065:                rig = new RemoteInterfaceGenerator();
066:                replaceAction(
067:                        ActionConstants.ACTION_REMOTE_INTERFACE_GENERATOR, rig);
068:
069:                sg = new StubGenerator();
070:                sg.setOriginalTypes(originalTypes);
071:                replaceAction(ActionConstants.ACTION_STUB_GENERATOR, sg);
072:
073:                // And tell these processors to do nothing
074:                NullProcessorAction nullProcessor = new NullProcessorAction();
075:                replaceAction(
076:                        ActionConstants.ACTION_ENUMERATION_ENCODER_GENERATOR,
077:                        nullProcessor);
078:                replaceAction(
079:                        ActionConstants.ACTION_INTERFACE_SERIALIZER_GENERATOR,
080:                        nullProcessor);
081:                replaceAction(
082:                        ActionConstants.ACTION_SOAP_OBJECT_SERIALIZER_GENERATOR,
083:                        nullProcessor);
084:                replaceAction(
085:                        ActionConstants.ACTION_SOAP_OBJECT_BUILDER_GENERATOR,
086:                        nullProcessor);
087:                replaceAction(
088:                        ActionConstants.ACTION_LITERAL_OBJECT_SERIALIZER_GENERATOR,
089:                        nullProcessor);
090:                replaceAction(
091:                        ActionConstants.ACTION_SOAP_FAULT_SERIALIZER_GENERATOR,
092:                        nullProcessor);
093:                replaceAction(
094:                        ActionConstants.ACTION_FAULT_EXCEPTION_BUILDER_GENERATOR,
095:                        nullProcessor);
096:                replaceAction(
097:                        ActionConstants.ACTION_SERIALIZER_REGISTRY_GENERATOR,
098:                        nullProcessor);
099:                replaceAction(ActionConstants.ACTION_SERVICE_GENERATOR,
100:                        nullProcessor);
101:                replaceAction(
102:                        ActionConstants.ACTION_SERVICE_INTERFACE_GENERATOR,
103:                        nullProcessor);
104:            }
105:
106:            /**
107:             * For example,
108:             *    replaceAction(ActionConstants.ACTION_STUB_GENERATOR, new StubGenerator());
109:             */
110:            public void replaceAction(String name, ProcessorAction pa) {
111:                actions.put(name, pa);
112:            }
113:
114:            /**
115:             * Add a few parameters/features specific to JSR-172.
116:             * Remove a few parameters/features that don't apply.
117:             * Always make sure the wsi feature is on.
118:             */
119:            protected boolean parseArguments(String[] args) {
120:                boolean hasFeatures = false;
121:                boolean optimize = false;
122:                boolean showCldc1_0Info = false;
123:                boolean hasKeep = false;
124:                for (int i = 0; i < args.length; ++i) {
125:                    String arg = args[i].intern();
126:                    if (arg == "-cldc1.0") {
127:                        cldcVersion = "1.0";
128:                    } else if (arg == "-cldc1.1") {
129:                        cldcVersion = "1.1";
130:                    } else if (arg == "-cldc1.0info") {
131:                        showCldc1_0Info = true;
132:                    } else if (arg == "-define" || arg == "-gen:server"
133:                            || arg == "-gen:both") {
134:                        // The server side only features are not supported here.
135:                        onError(get172Message("wscompile172.noServiceSide"));
136:                        return false;
137:                    } else if (args[i].startsWith("-f:")
138:                            || args[i].startsWith("-features:")) {
139:                        hasFeatures = true;
140:                        boolean hasWSIFeatureSet = false;
141:                        String featureString = args[i].substring(args[i]
142:                                .startsWith("-f:") ? 3 : 10);
143:                        StringTokenizer tokenizer = new StringTokenizer(
144:                                featureString, ",");
145:                        String unprocessedFeatures = null;
146:                        while (tokenizer.hasMoreTokens()) {
147:                            String feature = tokenizer.nextToken().trim()
148:                                    .intern();
149:                            if (feature == "rpcliteral") {
150:                                onError(get172Message(
151:                                        "wscompile172.featureNotSupported",
152:                                        "rpcliteral"));
153:                                return false;
154:                            } else if (feature == "wsi") {
155:                                hasWSIFeatureSet = true;
156:                            } else if (feature == "donotunwrap") {
157:                                expandArguments = false;
158:                                continue;
159:                            }
160:                            if (unprocessedFeatures == null)
161:                                unprocessedFeatures = "-f:";
162:                            else
163:                                unprocessedFeatures += ",";
164:                            unprocessedFeatures += feature;
165:                        }
166:                        if (!hasWSIFeatureSet) {
167:                            if (unprocessedFeatures == null)
168:                                unprocessedFeatures = "-f:";
169:                            unprocessedFeatures += ",wsi";
170:                            hasWSIFeatureSet = true;
171:                        }
172:                        if (unprocessedFeatures != null)
173:                            args[i] = unprocessedFeatures;
174:                        continue;
175:                    } else if (arg == "-O") {
176:                        optimize = true;
177:                        continue;
178:                    } else if (arg == "-keep") {
179:                        hasKeep = true;
180:                        continue;
181:                    } else {
182:                        // Skip the resetting of the argument.
183:                        continue;
184:                    }
185:                    args[i] = "";
186:                }
187:                if (!hasFeatures) {
188:                    String[] newArgs = new String[args.length + 1];
189:                    System.arraycopy(args, 0, newArgs, 0, args.length);
190:                    newArgs[args.length] = "-f:wsi";
191:                    args = newArgs;
192:                }
193:                if (!hasKeep) {
194:                    String[] newArgs = new String[args.length + 1];
195:                    System.arraycopy(args, 0, newArgs, 0, args.length);
196:                    newArgs[args.length] = "-keep";
197:                    args = newArgs;
198:                }
199:                if (cldcVersion.equals("1.0"))
200:                    properties.setProperty(
201:                            StubGenerator.FLOAT_DOUBLE_TO_STRING, "true");
202:                else
203:                    properties.setProperty(
204:                            StubGenerator.FLOAT_DOUBLE_TO_STRING, "false");
205:                if (showCldc1_0Info)
206:                    properties.setProperty(StubGenerator.SHOW_ALL_CLDC1_0_INFO,
207:                            "true");
208:                else
209:                    properties.setProperty(StubGenerator.SHOW_ALL_CLDC1_0_INFO,
210:                            "false");
211:                if (expandArguments)
212:                    properties.setProperty(StubGenerator.EXPAND_ARGUMENTS,
213:                            "true");
214:                else
215:                    properties.setProperty(StubGenerator.EXPAND_ARGUMENTS,
216:                            "false");
217:                if (optimize)
218:                    properties.setProperty(StubGenerator.OPTIMIZE, "true");
219:                else
220:                    properties.setProperty(StubGenerator.OPTIMIZE, "false");
221:
222:                return super .parseArguments(args);
223:            }
224:
225:            public Localizable getVersion() {
226:                return get172Message("wscompile172.version", super .getVersion());
227:            }
228:
229:            protected void compileGeneratedClasses() {
230:                if (doCompilation) {
231:                    super .compileGeneratedClasses();
232:                } else {
233:                    // Do nothing, so as to skip the compilation step.
234:                }
235:            }
236:
237:            protected void registerProcessorActions(Processor processor) {
238:                rig.setLocalizer(localizer);
239:                rig.setEnvironment(environment);
240:                sg.setLocalizer(localizer);
241:                sg.setEnvironment(environment);
242:                if (cldcVersion.equals("1.0")) {
243:                    MakeCldc1_0 coercer = new MakeCldc1_0(originalTypes);
244:                    coercer.setEnvironment(environment);
245:                    processor.add(coercer);
246:                }
247:                super .registerProcessorActions(processor);
248:            }
249:
250:            public Map getOriginalTypes() {
251:                return originalTypes;
252:            }
253:
254:            public Iterator getGeneratedFiles() {
255:                return environment.getGeneratedFiles();
256:            }
257:
258:            public Model getCompileToolModel() {
259:                return (Model) processor.getModel();
260:            }
261:
262:            public Object getCompileToolEnvironment() {
263:                return environment;
264:            }
265:
266:            public void onError(Localizable msg) {
267:                String text = localizer.localize(msg);
268:                errorMessages.append(text);
269:                errorMessages.append("\n");
270:                super .onError(msg);
271:            }
272:
273:            public String getErrorMessages() {
274:                return errorMessages.toString();
275:            }
276:
277:            protected Localizable get172Message(String key) {
278:                return messageFactory172.getMessage(key);
279:            }
280:
281:            protected Localizable get172Message(String key, String arg) {
282:                return messageFactory172.getMessage(key, new Object[] { arg });
283:            }
284:
285:            protected Localizable get172Message(String key, Localizable l) {
286:                return messageFactory172.getMessage(key, new Object[] { l });
287:            }
288:
289:            protected Localizable get172Message(String key, Object[] args) {
290:                return messageFactory172.getMessage(key, args);
291:            }
292:
293:            protected void usage() {
294:                report(get172Message("wscompile172.usage", program));
295:            }
296:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.