Author: jochen
Date: Sat Dec 24 13:48:25 2005
New Revision: 358952
URL: http://svn.apache.org/viewcvs?rev=358952&view=rev
Log:
Added the possibility to write Java source files and resource files
to different directories. This is required for use in Maven projects.
Modified:
webservices/jaxme/branches/b0_5/build.xml
webservices/jaxme/branches/b0_5/src/documentation/manual/xjctask.xml
webservices/jaxme/branches/b0_5/src/jaxme/org/apache/ws/jaxme/generator/Generator.java
webservices/jaxme/branches/b0_5/src/jaxme/org/apache/ws/jaxme/generator/Main.java
webservices/jaxme/branches/b0_5/src/jaxme/org/apache/ws/jaxme/generator/XJCTask.java
webservices/jaxme/branches/b0_5/src/jaxme/org/apache/ws/jaxme/generator/impl/GeneratorImpl.java
webservices/jaxme/branches/b0_5/src/js/org/apache/ws/jaxme/js/JavaSourceFactory.java
webservices/jaxme/branches/b0_5/status.xml
Modified: webservices/jaxme/branches/b0_5/build.xml
URL:
http://svn.apache.org/viewcvs/webservices/jaxme/branches/b0_5/build.xml?rev=358952&r1=358951&r2=358952&view=diff
==============================================================================
--- webservices/jaxme/branches/b0_5/build.xml (original)
+++ webservices/jaxme/branches/b0_5/build.xml Sat Dec 24 13:48:25 2005
@@ -14,7 +14,7 @@
* limitations under the License.
-->
<project name="JaxMe" default="all">
- <property name="version" value="0.5.1-dev"/>
+ <property name="version" value="0.5.1-SNAPSHOT"/>
<property name="debug" value="true"/>
<property name="optimize" value="false"/>
Modified: webservices/jaxme/branches/b0_5/src/documentation/manual/xjctask.xml
URL:
http://svn.apache.org/viewcvs/webservices/jaxme/branches/b0_5/src/documentation/manual/xjctask.xml?rev=358952&r1=358951&r2=358952&view=diff
==============================================================================
--- webservices/jaxme/branches/b0_5/src/documentation/manual/xjctask.xml
(original)
+++ webservices/jaxme/branches/b0_5/src/documentation/manual/xjctask.xml Sat
Dec 24 13:48:25 2005
@@ -135,11 +135,23 @@
<entry>No</entry>
</row>
<row>
+ <entry>resourceTarget</entry>
+ <entry>Specifies the target directory for generating resource files.
+ If required, a package structure is created automatically below
+ the resource target directory. For example, if the "target"
attribute
+ has the value "src" and the "package" attribute is "com.acme", then
+ the directory <filename>src/com/acme</filename> will be used.
+ </entry>
+ <entry>JaxMe</entry>
+ <entry>No, defaults to the "target" directory</entry>
+ </row>
+ <row>
<entry>target</entry>
- <entry>Specifies the target directory, where generated sources are
being created
- in a package structure. For example, if the "target" attribute has
the value
- "src" and the "package" attribute is "com.acme", then the directory
- <filename>src/com/acme</filename> will be used.</entry>
+ <entry>Specifies the target directory for generating Java source
files.
+ If required, a package structure is created automatically below
+ the resource target directory. For example, if the "target"
attribute
+ has the value "src" and the "package" attribute is "com.acme", then
+ the directory <filename>src/com/acme</filename> will be
used.</entry>
<entry>JAXB XJC</entry>
<entry>No, defaults to the current directory</entry>
</row>
Modified:
webservices/jaxme/branches/b0_5/src/jaxme/org/apache/ws/jaxme/generator/Generator.java
URL:
http://svn.apache.org/viewcvs/webservices/jaxme/branches/b0_5/src/jaxme/org/apache/ws/jaxme/generator/Generator.java?rev=358952&r1=358951&r2=358952&view=diff
==============================================================================
---
webservices/jaxme/branches/b0_5/src/jaxme/org/apache/ws/jaxme/generator/Generator.java
(original)
+++
webservices/jaxme/branches/b0_5/src/jaxme/org/apache/ws/jaxme/generator/Generator.java
Sat Dec 24 13:48:25 2005
@@ -77,13 +77,25 @@
*/
public SchemaReader getSchemaReader();
- /** <p>Sets the directory where to create files.</p>
+ /** Sets the directory where Java source files are being
+ * created.
*/
public void setTargetDirectory(File pDirectory);
- /** <p>Returns the directory where to create files.</p>
+ /** Returns the directory where Java source files are being
+ * created.
*/
public File getTargetDirectory();
+
+ /** Sets the directory where resource files are being
+ * created. By default, this is the Java source directory.
+ */
+ public void setResourceTargetDirectory(File pDirectory);
+
+ /** Sets the directory where resource files are being
+ * created. By default, this is the Java source directory.
+ */
+ public File getResourceTargetDirectory();
/** <p>Sets whether the generator is using a validating XML
* schema parser. Defaults to false.</p>
Modified:
webservices/jaxme/branches/b0_5/src/jaxme/org/apache/ws/jaxme/generator/Main.java
URL:
http://svn.apache.org/viewcvs/webservices/jaxme/branches/b0_5/src/jaxme/org/apache/ws/jaxme/generator/Main.java?rev=358952&r1=358951&r2=358952&view=diff
==============================================================================
---
webservices/jaxme/branches/b0_5/src/jaxme/org/apache/ws/jaxme/generator/Main.java
(original)
+++
webservices/jaxme/branches/b0_5/src/jaxme/org/apache/ws/jaxme/generator/Main.java
Sat Dec 24 13:48:25 2005
@@ -63,7 +63,10 @@
ps.println(" --option=<name=value> Sets the option <name> to the given
<value>.");
ps.println(" --package=<name> Sets the package of the generated
sources to");
ps.println(" <name>.");
- ps.println(" --target=<dir> Sets the directory where to
generate");
+ ps.println(" --resourceTarget=<dir> Sets the directory where to
generate");
+ ps.println(" resource files. By default, the
same directory");
+ ps.println(" is used for Java sources and
resource files.");
+ ps.println(" --target=<dir> Sets the directory where to
generate Java");
ps.println(" sources. By default the current
directory");
ps.println(" is used.");
ps.println(" --validating Turns the XML parsers validation
on.");
@@ -77,7 +80,7 @@
java.io.File schemaFile = null;
Generator g = new GeneratorImpl();
String schemaReaderClass = JAXBSchemaReader.class.getName();
- String target = null;
+ String target = null, resourceTarget = null;
String logFile = null;
String logLevel = null;
String packageName = null;
@@ -163,6 +166,17 @@
opt = args[++i];
}
target = opt;
+ } else if (arg.equalsIgnoreCase("resourceTarget")) {
+ if (resourceTarget != null) {
+ Usage("The option " + arg + " may be used only once.");
+ }
+ if (opt == null) {
+ if (i == args.length) {
+ Usage("Missing argument for option " + arg);
+ }
+ opt = args[++i];
+ }
+ resourceTarget = opt;
} else if (arg.equalsIgnoreCase("option")) {
if (opt == null) {
if (i == args.length) {
@@ -264,6 +278,9 @@
if (target != null) {
g.setTargetDirectory(new File(target));
+ }
+ if (resourceTarget != null) {
+ g.setResourceTargetDirectory(new File(target));
}
try {
Modified:
webservices/jaxme/branches/b0_5/src/jaxme/org/apache/ws/jaxme/generator/XJCTask.java
URL:
http://svn.apache.org/viewcvs/webservices/jaxme/branches/b0_5/src/jaxme/org/apache/ws/jaxme/generator/XJCTask.java?rev=358952&r1=358951&r2=358952&view=diff
==============================================================================
---
webservices/jaxme/branches/b0_5/src/jaxme/org/apache/ws/jaxme/generator/XJCTask.java
(original)
+++
webservices/jaxme/branches/b0_5/src/jaxme/org/apache/ws/jaxme/generator/XJCTask.java
Sat Dec 24 13:48:25 2005
@@ -83,12 +83,19 @@
* </tr>
* <tr>
* <td>target</td>
- * <td>Specifies the target directory, where generated sources are being
created. A package
+ * <td>Specifies the target directory for generated Java source files. A
package
* structure will be created below that directory. For example, with
target="src" and
* package="org.acme", you will have files being created in
"src/org/acme".</td>
* <td>No, defaults to the current directory</td>
* </tr>
* <tr>
+ * <td>resourceTarget</td>
+ * <td>Specifies the target directory for generated resource files. A
package
+ * structure will be created below that directory. For example, with
target="src" and
+ * package="org.acme", you will have files being created in
"src/org/acme".</td>
+ * <td>No, defaults to the "target" directory</td>
+ * </tr>
+ * <tr>
* <td>readonly</td>
* <td>Generated Java source files are in read-only mode, if true is
specified</td>
* <td>No, defaults to false</td>
@@ -316,7 +323,7 @@
}
}
- private File binding, schema, target;
+ private File binding, schema, target, resourceTarget;
private String packageName;
private boolean readOnly, extension, removeOldOutput, force, isValidating;
private boolean isSettingLoggerFactory = true;
@@ -423,7 +430,6 @@
return isValidating;
}
-
/** <p>Setting this option to true forces the up-to-date check to fail.
* This option is mainly useful while working on the JaxMe generator.
* For JaxMe users, which only change schema files, this option isn't of much
@@ -574,22 +580,42 @@
log("The 'stackSize' attribute is ignored by the JaxMe ant task.",
Project.MSG_WARN);
}
- /** <p>Returns the target directory, where generated sources are being
created. A package
+ /** Returns the target directory for generating Java source files. A package
* structure will be created below that directory. For example, with
target="src" and
- * package="org.acme", you will have files being created in
"src/org/acme".</p>
+ * package="org.acme", you will have files being created in "src/org/acme".
*/
public File getTarget() {
return target;
}
- /** <p>Sets the target directory, where generated sources are being created.
A package
+ /** Sets the target directory for generating Java source files. A package
* structure will be created below that directory. For example, with
target="src" and
- * package="org.acme", you will have files being created in
"src/org/acme".</p>
+ * package="org.acme", you will have files being created in "src/org/acme".
*/
public void setTarget(File pTarget) {
target = pTarget;
}
+ /** Returns the target directory for generating resource files. A package
+ * structure will be created below that directory. For example, with
target="src"
+ * and package="org.acme", you will have files being created in
"src/org/acme".
+ * By default, the same directory is being used for Java source files and
+ * resource files.
+ */
+ public File getResourceTarget() {
+ return resourceTarget;
+ }
+
+ /** Sets the target directory for generating resource files. A package
+ * structure will be created below that directory. For example, with
target="src"
+ * and package="org.acme", you will have files being created in
"src/org/acme".
+ * By default, the same directory is being used for Java source files and
+ * resource files.
+ */
+ public void setResourceTarget(File pTarget) {
+ resourceTarget = pTarget;
+ }
+
/** <p>Multiple schema files may be compiled in one or more nested
<schema>
* elements. The element syntax is equivalent to a nested <fileset>.
* Use of a nested <schema> element is mutually exclusive with the use
@@ -973,6 +999,7 @@
generator.setSchemaReader(reader);
reader.setGenerator(generator);
generator.setTargetDirectory(getTarget());
+ generator.setResourceTargetDirectory(getResourceTarget());
ClassType[] mySgFactoryChains = getSGFactoryChains();
if (mySgFactoryChains.length > 0) {
Modified:
webservices/jaxme/branches/b0_5/src/jaxme/org/apache/ws/jaxme/generator/impl/GeneratorImpl.java
URL:
http://svn.apache.org/viewcvs/webservices/jaxme/branches/b0_5/src/jaxme/org/apache/ws/jaxme/generator/impl/GeneratorImpl.java?rev=358952&r1=358951&r2=358952&view=diff
==============================================================================
---
webservices/jaxme/branches/b0_5/src/jaxme/org/apache/ws/jaxme/generator/impl/GeneratorImpl.java
(original)
+++
webservices/jaxme/branches/b0_5/src/jaxme/org/apache/ws/jaxme/generator/impl/GeneratorImpl.java
Sat Dec 24 13:48:25 2005
@@ -12,7 +12,6 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-
*/
package org.apache.ws.jaxme.generator.impl;
@@ -36,155 +35,166 @@
/** <p>The Generator is reading an input schema. The schema is
* converted into a DOM tree. Finally one or more source
* writers are executed.
- *
- * @author <a href="mailto:[EMAIL PROTECTED]">Jochen Wiedmann</a>
*/
public class GeneratorImpl implements Generator {
- private static final Logger log =
LoggerAccess.getLogger(GeneratorImpl.class);
- private SchemaReader schemaReader;
- private java.io.File targetDirectory;
- private Map properties = new HashMap();
- private int nextKey;
- private boolean isValidating, isForcingOverwrite, isSettingReadOnly;
- private EntityResolver entityResolver;
-
- /** <p>Sets the [EMAIL PROTECTED] EntityResolver} being used to import
external
- * schemata.</p>
- */
- public void setEntityResolver(EntityResolver pEntityResolver) {
- entityResolver = pEntityResolver;
- }
-
- /** <p>Returns the [EMAIL PROTECTED] EntityResolver} being used to import
external
- * schemata.</p>
- */
- public EntityResolver getEntityResolver() {
- return entityResolver;
- }
-
- /** <p>Returns whether the generator is forcing an overwrite of files.</p>
- */
- public boolean isForcingOverwrite() {
- return isForcingOverwrite;
- }
-
- /** <p>Sets whether the generator is forcing an overwrite of files.</p>
- */
- public void setForcingOverwrite(boolean pIsForcingOverwrite) {
- isForcingOverwrite = pIsForcingOverwrite;
- }
-
- /** <p>Returns whether the generator will create files in read-only mode.</p>
- */
- public boolean isSettingReadOnly() {
- return isSettingReadOnly;
- }
-
- /** <p>Sets whether the generator will create files in read-only mode.</p>
- */
- public void setSettingReadOnly(boolean pIsSettingReadOnly) {
- isSettingReadOnly = pIsSettingReadOnly;
- }
-
- public boolean isValidating() {
- return isValidating;
- }
-
- public void setValidating(boolean pIsValidating) {
- isValidating = pIsValidating;
- }
-
- /** Creates a new GeneratorImpl */
- public GeneratorImpl() {
- }
-
- /** <p>Sets the SchemaReader.</p>
- */
- public void setSchemaReader(SchemaReader pReader) {
- schemaReader = pReader;
- }
-
- /** <p>Returns the SchemaReader.</p>
- */
- public SchemaReader getSchemaReader() {
- return schemaReader;
- }
-
- public void setTargetDirectory(File pDirectory) {
- targetDirectory = pDirectory;
- }
-
- public File getTargetDirectory() {
- return targetDirectory;
- }
-
- public SchemaSG generate(InputSource pSource) throws Exception {
- SchemaReader sr = getSchemaReader();
- sr.setGenerator(this);
-
- SchemaSG s = sr.parse(pSource);
- s.generate();
- File targetDir = getTargetDirectory();
- JavaSourceFactory jsf = s.getJavaSourceFactory();
- for (Iterator iter = jsf.getJavaSources(); iter.hasNext(); ) {
- ((JavaSource) iter.next()).setForcingFullyQualifiedName(true);
- }
- s.getJavaSourceFactory().write(targetDir);
-
- return s;
- }
-
-
- /** <p>Opens the given file, calls the specified SchemaReaders
- * () method and SourceWriters write() method.</p>
- */
- public SchemaSG generate(File pFile) throws Exception {
- final String mName = "generate(File)";
- log.finer(mName, "->", pFile);
- String path = pFile.getAbsolutePath();
- if (!pFile.exists()) {
- throw new java.io.FileNotFoundException("File does not exist: " + path);
- }
- if (!pFile.isFile()) {
- throw new java.io.FileNotFoundException("Not a file: " + path);
- }
-
- InputSource isource = new InputSource(new FileInputStream(pFile));
- isource.setSystemId(pFile.toURL().toString());
- SchemaSG s = generate(isource);
- log.finer(mName, "<-", s);
- return s;
- }
-
- /** <p>Opens the given URL, calls the specified SchemaReaders
- * () method and SourceWriters write() method.</p>
- */
- public SchemaSG generate(java.net.URL pURL) throws Exception {
- final String mName = "generate(URL)";
- log.entering(mName, pURL);
- java.net.URLConnection conn = pURL.openConnection();
-
- InputSource isource = new InputSource(conn.getInputStream());
- isource.setSystemId(pURL.toString());
- SchemaSG s = generate(isource);
- log.exiting(mName, s);
- return s;
- }
-
- public String getProperty(String pName) {
- return (String) properties.get(pName);
- }
-
- public String getProperty(String pName, String pDefault) {
- String result = (String) properties.get(pName);
- return (result == null) ? pDefault : result;
- }
-
- public void setProperty(String pName, String pValue) {
- properties.put(pName, pValue);
- }
-
- public String getKey() {
- return Integer.toString(nextKey++);
- }
+ private static final Logger log =
LoggerAccess.getLogger(GeneratorImpl.class);
+ private SchemaReader schemaReader;
+ private java.io.File targetDirectory;
+ private java.io.File resourceTargetDirectory;
+ private Map properties = new HashMap();
+ private int nextKey;
+ private boolean isValidating, isForcingOverwrite, isSettingReadOnly;
+ private EntityResolver entityResolver;
+
+ /** <p>Sets the [EMAIL PROTECTED] EntityResolver} being used to import
external
+ * schemata.</p>
+ */
+ public void setEntityResolver(EntityResolver pEntityResolver) {
+ entityResolver = pEntityResolver;
+ }
+
+ /** <p>Returns the [EMAIL PROTECTED] EntityResolver} being used to
import external
+ * schemata.</p>
+ */
+ public EntityResolver getEntityResolver() {
+ return entityResolver;
+ }
+
+ /** <p>Returns whether the generator is forcing an overwrite of
files.</p>
+ */
+ public boolean isForcingOverwrite() {
+ return isForcingOverwrite;
+ }
+
+ /** <p>Sets whether the generator is forcing an overwrite of files.</p>
+ */
+ public void setForcingOverwrite(boolean pIsForcingOverwrite) {
+ isForcingOverwrite = pIsForcingOverwrite;
+ }
+
+ /** <p>Returns whether the generator will create files in read-only
mode.</p>
+ */
+ public boolean isSettingReadOnly() {
+ return isSettingReadOnly;
+ }
+
+ /** <p>Sets whether the generator will create files in read-only
mode.</p>
+ */
+ public void setSettingReadOnly(boolean pIsSettingReadOnly) {
+ isSettingReadOnly = pIsSettingReadOnly;
+ }
+
+ public boolean isValidating() {
+ return isValidating;
+ }
+
+ public void setValidating(boolean pIsValidating) {
+ isValidating = pIsValidating;
+ }
+
+ /** Creates a new GeneratorImpl */
+ public GeneratorImpl() {
+ }
+
+ /** <p>Sets the SchemaReader.</p>
+ */
+ public void setSchemaReader(SchemaReader pReader) {
+ schemaReader = pReader;
+ }
+
+ /** <p>Returns the SchemaReader.</p>
+ */
+ public SchemaReader getSchemaReader() {
+ return schemaReader;
+ }
+
+ public void setTargetDirectory(File pDirectory) {
+ targetDirectory = pDirectory;
+ }
+
+ public File getTargetDirectory() {
+ return targetDirectory;
+ }
+
+ public void setResourceTargetDirectory(File pDirectory) {
+ resourceTargetDirectory = pDirectory;
+ }
+
+ public File getResourceTargetDirectory() {
+ return resourceTargetDirectory;
+ }
+
+ public SchemaSG generate(InputSource pSource) throws Exception {
+ SchemaReader sr = getSchemaReader();
+ sr.setGenerator(this);
+
+ SchemaSG s = sr.parse(pSource);
+ s.generate();
+ File targetDir = getTargetDirectory();
+ File resourceTargetDir = getResourceTargetDirectory();
+ if (resourceTargetDir == null) {
+ resourceTargetDir = targetDir;
+ }
+ JavaSourceFactory jsf = s.getJavaSourceFactory();
+ for (Iterator iter = jsf.getJavaSources(); iter.hasNext(); ) {
+ ((JavaSource)
iter.next()).setForcingFullyQualifiedName(true);
+ }
+ s.getJavaSourceFactory().write(targetDir, resourceTargetDir);
+
+ return s;
+ }
+
+
+ /** <p>Opens the given file, calls the specified SchemaReaders
+ * () method and SourceWriters write() method.</p>
+ */
+ public SchemaSG generate(File pFile) throws Exception {
+ final String mName = "generate(File)";
+ log.finer(mName, "->", pFile);
+ String path = pFile.getAbsolutePath();
+ if (!pFile.exists()) {
+ throw new java.io.FileNotFoundException("File does not
exist: " + path);
+ }
+ if (!pFile.isFile()) {
+ throw new java.io.FileNotFoundException("Not a file: "
+ path);
+ }
+
+ InputSource isource = new InputSource(new
FileInputStream(pFile));
+ isource.setSystemId(pFile.toURL().toString());
+ SchemaSG s = generate(isource);
+ log.finer(mName, "<-", s);
+ return s;
+ }
+
+ /** <p>Opens the given URL, calls the specified SchemaReaders
+ * () method and SourceWriters write() method.</p>
+ */
+ public SchemaSG generate(java.net.URL pURL) throws Exception {
+ final String mName = "generate(URL)";
+ log.entering(mName, pURL);
+ java.net.URLConnection conn = pURL.openConnection();
+
+ InputSource isource = new InputSource(conn.getInputStream());
+ isource.setSystemId(pURL.toString());
+ SchemaSG s = generate(isource);
+ log.exiting(mName, s);
+ return s;
+ }
+
+ public String getProperty(String pName) {
+ return (String) properties.get(pName);
+ }
+
+ public String getProperty(String pName, String pDefault) {
+ String result = (String) properties.get(pName);
+ return (result == null) ? pDefault : result;
+ }
+
+ public void setProperty(String pName, String pValue) {
+ properties.put(pName, pValue);
+ }
+
+ public String getKey() {
+ return Integer.toString(nextKey++);
+ }
}
Modified:
webservices/jaxme/branches/b0_5/src/js/org/apache/ws/jaxme/js/JavaSourceFactory.java
URL:
http://svn.apache.org/viewcvs/webservices/jaxme/branches/b0_5/src/js/org/apache/ws/jaxme/js/JavaSourceFactory.java?rev=358952&r1=358951&r2=358952&view=diff
==============================================================================
---
webservices/jaxme/branches/b0_5/src/js/org/apache/ws/jaxme/js/JavaSourceFactory.java
(original)
+++
webservices/jaxme/branches/b0_5/src/js/org/apache/ws/jaxme/js/JavaSourceFactory.java
Sat Dec 24 13:48:25 2005
@@ -66,61 +66,61 @@
* @version $Id$
*/
public class JavaSourceFactory implements JavaSourceResolver {
- private Logger logger = LoggerAccess.getLogger(JavaSourceFactory.class);
- private boolean overwriteForced;
- private boolean settingReadOnly;
+ private Logger logger = LoggerAccess.getLogger(JavaSourceFactory.class);
+ private boolean overwriteForced;
+ private boolean settingReadOnly;
private Map sources = new HashMap();
- private List files = new ArrayList();
+ private List files = new ArrayList();
- /** <p>Sets the [EMAIL PROTECTED] Logger} to use.</p>
- */
- public void setLogger(Logger pLogger) {
- logger = pLogger;
- }
-
- /** <p>Returns the [EMAIL PROTECTED] Logger}.</p>
- */
- public Logger getLogger() {
- return logger;
- }
-
- /** <p>Sets whether the generated files are created in read-only mode.</p>
- */
- public void setSettingReadOnly(boolean pSettingReadOnly) {
- settingReadOnly = pSettingReadOnly;
- }
-
- /** <p>Returns whether the generated files are created in read-only mode.</p>
- */
- public boolean isSettingReadOnly() {
- return settingReadOnly;
- }
-
- /** <p>By default the JavaSourceFactory will only overwrite existing
- * files only, if they have different content. If the overwriteForced
property is
- * set to true, existing files will always be overwritten.</p>
- * @see #isOverwriteForced()
- */
- public void setOverwriteForced(boolean pOverwriteForced) {
- overwriteForced = pOverwriteForced;
- }
-
- /** <p>By default the JavaSourceFactory will only overwrite existing
- * files, if they have different content. If the overwriteForced property is
- * set to true, existing files will always be overwritten.</p>
- * @see #setOverwriteForced(boolean)
- */
- public boolean isOverwriteForced() {
- return overwriteForced;
- }
+ /** <p>Sets the [EMAIL PROTECTED] Logger} to use.</p>
+ */
+ public void setLogger(Logger pLogger) {
+ logger = pLogger;
+ }
+ /** <p>Returns the [EMAIL PROTECTED] Logger}.</p>
+ */
+ public Logger getLogger() {
+ return logger;
+ }
+
+ /** <p>Sets whether the generated files are created in read-only
mode.</p>
+ */
+ public void setSettingReadOnly(boolean pSettingReadOnly) {
+ settingReadOnly = pSettingReadOnly;
+ }
+
+ /** <p>Returns whether the generated files are created in read-only
mode.</p>
+ */
+ public boolean isSettingReadOnly() {
+ return settingReadOnly;
+ }
+
+ /** <p>By default the JavaSourceFactory will only overwrite existing
+ * files only, if they have different content. If the overwriteForced
property is
+ * set to true, existing files will always be overwritten.</p>
+ * @see #isOverwriteForced()
+ */
+ public void setOverwriteForced(boolean pOverwriteForced) {
+ overwriteForced = pOverwriteForced;
+ }
+
+ /** <p>By default the JavaSourceFactory will only overwrite existing
+ * files, if they have different content. If the overwriteForced
property is
+ * set to true, existing files will always be overwritten.</p>
+ * @see #setOverwriteForced(boolean)
+ */
+ public boolean isOverwriteForced() {
+ return overwriteForced;
+ }
+
/** <p>Creates a new instance of JavaSource with the given
* name and default protection.</p>
*/
public JavaSource newJavaSource(JavaQName pName) {
return newJavaSource(pName, JavaSource.DEFAULT_PROTECTION);
}
-
+
/** <p>Creates a new instance of JavaSource with the given
* name and protection.</p>
*/
@@ -132,7 +132,7 @@
sources.put(pName, result);
return result;
}
-
+
/** <p>Creates a new instance of JavaSource with the given
* name and protection. Shortcut for
* <code>newJavaSource(pName,
JavaSource.Protection.valueOf(pProtection))</code>.</p>
@@ -140,67 +140,67 @@
public JavaSource newJavaSource(JavaQName pName, String pProtection) {
return newJavaSource(pName,
JavaSource.Protection.valueOf(pProtection));
}
-
- /** <p>Returns an iterator to the generated classes.</p>
- */
- public Iterator getJavaSources() {
- return sources.values().iterator();
- }
-
- /** <p>Returns an iterator to the generated text files.</p>
- */
- public Iterator getTextFiles() {
- return files.iterator();
- }
-
- /** <p>Returns the generated class with the given name or null, if
- * no such class has been generated.</p>
- */
- public JavaSource getJavaSource(JavaQName pName) {
- return (JavaSource) sources.get(pName);
- }
-
- /** <p>Returns the text file with the given name or null, if no such
- * text file has been generated.</p>
- */
- public TextFile getTextFile(String pPackageName, String pFileName) {
- for (Iterator iter = files.iterator(); iter.hasNext(); ) {
- TextFile textFile = (TextFile) iter.next();
- if (textFile.getPackageName().equals(pPackageName) &&
textFile.getFileName().equals(pFileName)) {
- return textFile;
- }
- }
- return null;
- }
-
- /** <p>Given a package name and a base directory, returns the package
- * directory.</p>
- *
- * @param pBaseDir The base directory, where to create sources;
- * may be null (current directory).
- * @return Package directory; null is a valid value and indicates
- * the current directory.
- */
- public File getPackageDirectory(File pBaseDir, String pPackageName) {
- if (pPackageName != null) {
- for (StringTokenizer st = new StringTokenizer(pPackageName,
".");
- st.hasMoreTokens(); ) {
- String dir = st.nextToken();
- pBaseDir = new File(pBaseDir, dir);
- }
- }
- return pBaseDir;
- }
-
- /** <p>Given a fully qualified name, returns the name of the
- * corresponding Java file.</p>
- */
- public File getSourceFile(File pBaseDir, JavaQName pQName) {
- if (pQName == null) {
- throw new NullPointerException("The class name must not be
null.");
- }
- File packageDirectory = getPackageDirectory(pBaseDir,
pQName.getPackageName());
- String name = pQName.getClassName();
+
+ /** <p>Returns an iterator to the generated classes.</p>
+ */
+ public Iterator getJavaSources() {
+ return sources.values().iterator();
+ }
+
+ /** <p>Returns an iterator to the generated text files.</p>
+ */
+ public Iterator getTextFiles() {
+ return files.iterator();
+ }
+
+ /** <p>Returns the generated class with the given name or null, if
+ * no such class has been generated.</p>
+ */
+ public JavaSource getJavaSource(JavaQName pName) {
+ return (JavaSource) sources.get(pName);
+ }
+
+ /** <p>Returns the text file with the given name or null, if no such
+ * text file has been generated.</p>
+ */
+ public TextFile getTextFile(String pPackageName, String pFileName) {
+ for (Iterator iter = files.iterator(); iter.hasNext(); ) {
+ TextFile textFile = (TextFile) iter.next();
+ if (textFile.getPackageName().equals(pPackageName) &&
textFile.getFileName().equals(pFileName)) {
+ return textFile;
+ }
+ }
+ return null;
+ }
+
+ /** <p>Given a package name and a base directory, returns the package
+ * directory.</p>
+ *
+ * @param pBaseDir The base directory, where to create sources;
+ * may be null (current directory).
+ * @return Package directory; null is a valid value and indicates
+ * the current directory.
+ */
+ public File getPackageDirectory(File pBaseDir, String pPackageName) {
+ if (pPackageName != null) {
+ for (StringTokenizer st = new
StringTokenizer(pPackageName, ".");
+ st.hasMoreTokens(); ) {
+ String dir = st.nextToken();
+ pBaseDir = new File(pBaseDir, dir);
+ }
+ }
+ return pBaseDir;
+ }
+
+ /** <p>Given a fully qualified name, returns the name of the
+ * corresponding Java file.</p>
+ */
+ public File getSourceFile(File pBaseDir, JavaQName pQName) {
+ if (pQName == null) {
+ throw new NullPointerException("The class name must not
be null.");
+ }
+ File packageDirectory = getPackageDirectory(pBaseDir,
pQName.getPackageName());
+ String name = pQName.getClassName();
int offset = name.indexOf('.');
if (offset != -1) {
throw new IllegalArgumentException("Source files must
not be generated for inner classes: " + name);
@@ -210,8 +210,8 @@
throw new IllegalArgumentException("Source files must
not be generated for inner classes: " + name);
}
return new File(packageDirectory, name + ".java");
- }
-
+ }
+
/** <p>Returns a location the given package, relative to the given
* base directory. For example, if you have the base
* directory <code>c:\temp</code> and the package
@@ -231,169 +231,178 @@
}
return pBaseDir;
}
-
- /** <p>Returns a location for storing the JavaSource class, relative
- * to the given base directory. For example, if you have the base
- * directory <code>c:\temp</code> and the class <code>Sample</code>
- * in package <code>com.mycompany.demo</code>, this would yield
- * new File("c:\temp\com\mycompany\demo\Sample.java").</p>
- *
- * @param pBaseDir The base directory or null for the current directory.
- * @param pJs The JavaSource being stored.
- */
- public File getLocation(File pBaseDir, JavaSource pJs) {
+
+ /** <p>Returns a location for storing the JavaSource class, relative
+ * to the given base directory. For example, if you have the base
+ * directory <code>c:\temp</code> and the class <code>Sample</code>
+ * in package <code>com.mycompany.demo</code>, this would yield
+ * new File("c:\temp\com\mycompany\demo\Sample.java").</p>
+ *
+ * @param pBaseDir The base directory or null for the current directory.
+ * @param pJs The JavaSource being stored.
+ */
+ public File getLocation(File pBaseDir, JavaSource pJs) {
if (pJs.isInnerClass()) {
throw new IllegalArgumentException("Inner classes have
no assigned location in the file system.");
}
- return new File(getLocation(pBaseDir, pJs.getPackageName()),
- pJs.getClassName() + ".java");
- }
-
- /** <p>Returns a location for storing the TextFile, relative
- * to the given base directory. For example, if you have the base
- * directory <code>c:\temp</code> and the class <code>Sample</code>
- * in package <code>com.mycompany.demo</code>, this would yield
- * new File("c:\temp\com\mycompany\demo\Sample.java").</p>
- *
- * @param pBaseDir The base directory or null for the current directory.
- * @param pTextFile The text file being created.
- */
- public File getLocation(File pBaseDir, TextFile pTextFile) {
- return new File(getLocation(pBaseDir, pTextFile.getPackageName()),
pTextFile.getFileName());
- }
-
-
- /** <p>Verifies whether the given Java source and the contents of the
- * given file are identical.</p>
- */
- protected boolean isSameFile(JavaSource pJs, File pFile) throws IOException {
- StringWriter sw = new StringWriter();
- pJs.write(sw);
- sw.close();
- return isSameFile(sw.toString(), pFile);
- }
-
- /** <p>Verifies whether the given string and the contents of the given
- * file are identical.</p>
- */
- protected boolean isSameFile(String pContents, File pFile) throws
IOException {
- Reader r = new FileReader(pFile);
- StringWriter sw = new StringWriter();
- char[] buffer = new char[4096];
- for (;;) {
- int len = r.read(buffer);
- if (len == -1) {
- break;
- } else if (len > 0) {
- sw.write(buffer, 0, len);
- }
- }
- return isSameFile(pContents, sw.toString());
- }
-
- /** <p>Verifies whether the given strings are identical.</p>
- */
- protected boolean isSameFile(String pContents1, String pContents2) {
- return pContents1.equals(pContents2);
- }
-
- /** <p>Actually creates a file with the given name.</p>
- */
- protected void writeFile(File pFile, JavaSource pJs) throws IOException {
- final String mName = "writeFile(File,JavaSource)";
- File p = pFile.getParentFile();
- if (p != null && !p.exists()) {
- getLogger().fine(mName, "Creating directory " + p);
- p.mkdirs();
- }
-
- if (isOverwriteForced() || !pFile.exists() || !isSameFile(pJs, pFile))
{
- getLogger().fine(mName, "Creating " + pFile);
- Writer w = new BufferedWriter(new FileWriter(pFile), 4096);
- pJs.write(w);
- w.close();
- if (isSettingReadOnly()) {
- pFile.setReadOnly();
- }
- } else {
- getLogger().fine(mName, "Uptodate: " + pFile);
- }
- }
-
- /** <p>Actually creates a file with the given name.</p>
- */
- protected void writeFile(File pFile, String pContents) throws IOException {
- final String mName = "writeFile(File,String)";
- File p = pFile.getParentFile();
- if (p != null && !p.exists()) {
- getLogger().fine(mName, "Creating directory " + p);
- p.mkdirs();
- }
-
- if (isOverwriteForced() || !pFile.exists() || !isSameFile(pContents,
pFile)) {
- getLogger().fine(mName, "Creating " + pFile);
- Writer w = new BufferedWriter(new FileWriter(pFile), 4096);
- w.write(pContents);
- w.close();
- if (isSettingReadOnly()) {
- pFile.setReadOnly();
- }
- } else {
- getLogger().fine(mName, "Uptodate: " + pFile);
- }
- }
-
- /** <p>Writes the given JavaSource class to the file system,
- * relative to the given base directory.</p>
- * @param pBaseDir The base directory or null for the current directory.
- * @param pJs The JavaSource being stored.
- * @see JavaSource#write(Writer)
- */
- public void write(File pBaseDir, JavaSource pJs) throws IOException {
- writeFile(getLocation(pBaseDir, pJs), pJs);
- }
-
- /** <p>Writes the given text file to the file system, relative to the
- * given base directory.</p>
- * @param pBaseDir The base directory or null for the current directory.
- * @param pFile The text file being stored.
- * @see JavaSource#write(Writer)
- */
- public void write(File pBaseDir, TextFile pFile) throws IOException {
- writeFile(getLocation(pBaseDir, pFile), pFile.getContents());
- }
-
- /** <p>Writes all JavaSource classes to the FileSystem, relative to the
- * given base directory.</p>
- * @param pBaseDir The base directory or null for the current directory.
- */
- public void write(File pBaseDir) throws IOException {
- for (Iterator iter = getJavaSources(); iter.hasNext(); ) {
- write(pBaseDir, (JavaSource) iter.next());
- }
- for (Iterator iter = getTextFiles(); iter.hasNext(); ) {
- write(pBaseDir, (TextFile) iter.next());
- }
- }
-
- /** <p>Creates a new text file.</p>
- */
- public TextFile newTextFile(String pPackageName, String pFileName) {
- for (Iterator iter = files.iterator(); iter.hasNext(); ) {
- TextFile f = (TextFile) iter.next();
- if (f.getPackageName().equals(pPackageName) &&
f.getFileName().equals(pFileName)) {
- throw new IllegalStateException("A file named " + pFileName + " in
package " + pPackageName + " already exists.");
- }
- }
- for (Iterator iter = sources.keySet().iterator(); iter.hasNext(); ) {
- JavaQName qName = (JavaQName) iter.next();
- if (qName.getPackageName().equals(pPackageName) &&
(qName.getClassName() + ".java").equals(pFileName)) {
- throw new IllegalStateException("A Java source file names " +
pFileName + " in package " + pPackageName + " already exists.");
- }
- }
+ return new File(getLocation(pBaseDir, pJs.getPackageName()),
+ pJs.getClassName() + ".java");
+ }
+
+ /** <p>Returns a location for storing the TextFile, relative
+ * to the given base directory. For example, if you have the base
+ * directory <code>c:\temp</code> and the class <code>Sample</code>
+ * in package <code>com.mycompany.demo</code>, this would yield
+ * new File("c:\temp\com\mycompany\demo\Sample.java").</p>
+ *
+ * @param pBaseDir The base directory or null for the current directory.
+ * @param pTextFile The text file being created.
+ */
+ public File getLocation(File pBaseDir, TextFile pTextFile) {
+ return new File(getLocation(pBaseDir,
pTextFile.getPackageName()), pTextFile.getFileName());
+ }
+
+
+ /** <p>Verifies whether the given Java source and the contents of the
+ * given file are identical.</p>
+ */
+ protected boolean isSameFile(JavaSource pJs, File pFile) throws
IOException {
+ StringWriter sw = new StringWriter();
+ pJs.write(sw);
+ sw.close();
+ return isSameFile(sw.toString(), pFile);
+ }
+
+ /** <p>Verifies whether the given string and the contents of the given
+ * file are identical.</p>
+ */
+ protected boolean isSameFile(String pContents, File pFile) throws
IOException {
+ Reader r = new FileReader(pFile);
+ StringWriter sw = new StringWriter();
+ char[] buffer = new char[4096];
+ for (;;) {
+ int len = r.read(buffer);
+ if (len == -1) {
+ break;
+ } else if (len > 0) {
+ sw.write(buffer, 0, len);
+ }
+ }
+ return isSameFile(pContents, sw.toString());
+ }
+
+ /** <p>Verifies whether the given strings are identical.</p>
+ */
+ protected boolean isSameFile(String pContents1, String pContents2) {
+ return pContents1.equals(pContents2);
+ }
+
+ /** <p>Actually creates a file with the given name.</p>
+ */
+ protected void writeFile(File pFile, JavaSource pJs) throws IOException
{
+ final String mName = "writeFile(File,JavaSource)";
+ File p = pFile.getParentFile();
+ if (p != null && !p.exists()) {
+ getLogger().fine(mName, "Creating directory " + p);
+ p.mkdirs();
+ }
+
+ if (isOverwriteForced() || !pFile.exists() ||
!isSameFile(pJs, pFile)) {
+ getLogger().fine(mName, "Creating " + pFile);
+ Writer w = new BufferedWriter(new FileWriter(pFile),
4096);
+ pJs.write(w);
+ w.close();
+ if (isSettingReadOnly()) {
+ pFile.setReadOnly();
+ }
+ } else {
+ getLogger().fine(mName, "Uptodate: " + pFile);
+ }
+ }
+
+ /** <p>Actually creates a file with the given name.</p>
+ */
+ protected void writeFile(File pFile, String pContents) throws
IOException {
+ final String mName = "writeFile(File,String)";
+ File p = pFile.getParentFile();
+ if (p != null && !p.exists()) {
+ getLogger().fine(mName, "Creating directory " + p);
+ p.mkdirs();
+ }
+
+ if (isOverwriteForced() || !pFile.exists() ||
!isSameFile(pContents, pFile)) {
+ getLogger().fine(mName, "Creating " + pFile);
+ Writer w = new BufferedWriter(new FileWriter(pFile),
4096);
+ w.write(pContents);
+ w.close();
+ if (isSettingReadOnly()) {
+ pFile.setReadOnly();
+ }
+ } else {
+ getLogger().fine(mName, "Uptodate: " + pFile);
+ }
+ }
+
+ /** <p>Writes the given JavaSource class to the file system,
+ * relative to the given base directory.</p>
+ * @param pBaseDir The base directory or null for the current directory.
+ * @param pJs The JavaSource being stored.
+ * @see JavaSource#write(Writer)
+ */
+ public void write(File pBaseDir, JavaSource pJs) throws IOException {
+ writeFile(getLocation(pBaseDir, pJs), pJs);
+ }
+
+ /** <p>Writes the given text file to the file system, relative to the
+ * given base directory.</p>
+ * @param pBaseDir The base directory or null for the current directory.
+ * @param pFile The text file being stored.
+ * @see JavaSource#write(Writer)
+ */
+ public void write(File pBaseDir, TextFile pFile) throws IOException {
+ writeFile(getLocation(pBaseDir, pFile), pFile.getContents());
+ }
+
+ /** Writes all Source files to the FileSystem, relative to the
+ * given base directory.
+ * @param pBaseDir The base directory or null for the current directory.
+ */
+ public void write(File pBaseDir) throws IOException {
+ write(pBaseDir, pBaseDir);
+ }
- TextFile result = new TextFileImpl(pPackageName, pFileName);
- files.add(result);
- return result;
- }
+ /** Writes all Source files to the file system, relative to the
+ * respective base directory.
+ * @param pJavaSourceDir The base directory for Java source files.
+ * @param pResourceDir The base directory for resource files.
+ */
+ public void write(File pJavaSourceDir, File pResourceDir) throws
IOException {
+ for (Iterator iter = getJavaSources(); iter.hasNext(); ) {
+ write(pJavaSourceDir, (JavaSource) iter.next());
+ }
+ for (Iterator iter = getTextFiles(); iter.hasNext(); ) {
+ write(pResourceDir, (TextFile) iter.next());
+ }
+ }
+
+ /** <p>Creates a new text file.</p>
+ */
+ public TextFile newTextFile(String pPackageName, String pFileName) {
+ for (Iterator iter = files.iterator(); iter.hasNext(); ) {
+ TextFile f = (TextFile) iter.next();
+ if (f.getPackageName().equals(pPackageName) &&
f.getFileName().equals(pFileName)) {
+ throw new IllegalStateException("A file named "
+ pFileName + " in package " + pPackageName + " already exists.");
+ }
+ }
+ for (Iterator iter = sources.keySet().iterator();
iter.hasNext(); ) {
+ JavaQName qName = (JavaQName) iter.next();
+ if (qName.getPackageName().equals(pPackageName) &&
(qName.getClassName() + ".java").equals(pFileName)) {
+ throw new IllegalStateException("A Java source
file names " + pFileName + " in package " + pPackageName + " already exists.");
+ }
+ }
+
+ TextFile result = new TextFileImpl(pPackageName, pFileName);
+ files.add(result);
+ return result;
+ }
}
Modified: webservices/jaxme/branches/b0_5/status.xml
URL:
http://svn.apache.org/viewcvs/webservices/jaxme/branches/b0_5/status.xml?rev=358952&r1=358951&r2=358952&view=diff
==============================================================================
--- webservices/jaxme/branches/b0_5/status.xml (original)
+++ webservices/jaxme/branches/b0_5/status.xml Sat Dec 24 13:48:25 2005
@@ -30,7 +30,7 @@
</todo>
<changes>
- <release version="0.5.1-dev" date="Not yet published">
+ <release version="0.5.1-SNAPSHOT" date="Not yet published">
<action dev="JW" type="enhancement" context="js">
Added several methods for modifying and querying the
methods signature.
@@ -65,6 +65,13 @@
<action dev="JW" type="fix" context="js">
Added the BeanSchemaWriter, which converts a Java bean
into an XML schema.
+ </action>
+ <action dev="JW" type="enhancement" context="generator">
+ The separation between "Java source files" and "resource
+ files" is now supported. This is typically required by
+ projects, which are following the Maven directory layout.
+ The XJC Ant task and the Main frontent both have a new
+ option "resourceTarget".
</action>
</release>
<release version="0.5" date="2005-Aug-08">
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]