You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by jo...@apache.org on 2005/12/13 21:01:25 UTC

svn commit: r356601 [1/3] - in /webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin: ./ src/main/java/org/apache/ws/jaxme/maven/plugins/ src/schema/ src/site/ src/site/apt/

Author: jochen
Date: Tue Dec 13 12:00:57 2005
New Revision: 356601

URL: http://svn.apache.org/viewcvs?rev=356601&view=rev
Log:
Initial commit

Added:
    webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/pom.xml
    webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/src/main/java/org/apache/ws/jaxme/maven/plugins/JaxMeGoal.java
    webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/src/main/java/org/apache/ws/jaxme/maven/plugins/MavenProjectLogger.java
    webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/src/schema/maven.xsd
    webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/src/site/apt/goals.apt
    webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/src/site/apt/index.apt
    webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/src/site/apt/properties.apt
    webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/src/site/apt/use.apt
    webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/src/site/site.xml

Added: webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/pom.xml
URL: http://svn.apache.org/viewcvs/webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/pom.xml?rev=356601&view=auto
==============================================================================
--- webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/pom.xml (added)
+++ webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/pom.xml Tue Dec 13 12:00:57 2005
@@ -0,0 +1,149 @@
+<?xml version="1.0"?>
+<!--
+
+  Copyright 2005  The Apache Software Foundation
+  
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.ws.jaxme</groupId>
+  <artifactId>maven-jaxme-plugin</artifactId>
+  <packaging>maven-plugin</packaging>
+  <name>Maven JaxMe Plugin</name>
+  <version>1.0-SNAPSHOT</version>
+  <description>
+    This plugin allows running the JaxMe binding compiler on
+    your XML schema files and add the generated sources to
+    your project.
+  </description>
+  <url>http://ws.apache.org/jaxme</url>
+  <issueManagement>
+    <system>jira</system>
+    <url>http://issues.apache.org/jira/browse/JAXME</url>
+  </issueManagement>
+  <inceptionYear>2005</inceptionYear>
+  <mailingLists>
+    <mailingList>
+      <name>JaxMe Developers</name>
+      <subscribe>jaxme-dev-subscribe@ws.apache.org</subscribe>
+      <unsubscribe>jaxme-dev-unsubscribe@ws.apache.org</unsubscribe>
+      <post>jaxme-dev@ws.apache.org</post>
+      <archive>http://mail-archives.apache.org/mod_mbox/ws-jaxme-dev/</archive>
+      <otherArchives>
+        <otherArchive>http://marc.theaimsgroup.com/?l=jaxme-dev</otherArchive>
+      </otherArchives>
+    </mailingList>
+  </mailingLists>
+  <developers>
+    <developer>
+      <name>Jochen Wiedmann</name>
+      <id>jochen</id>
+      <email>jochen.wiedmann@gmail.com</email>
+    </developer>
+  </developers>  
+  <licenses>
+    <license>
+      <name>The Apache Software License, Version 2.0</name>
+      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+      <distribution>repo</distribution>
+    </license>
+  </licenses>
+  <scm>
+    <connection>scm:svn:http://svn.apache.org/repos/asf/webservices/jaxme/trunk/maven-jaxme-plugin/</connection>
+    <developerConnection>scm:svn:https://svn.apache.org/repos/asf/webservices/jaxme/trunk/maven-jaxme-plugin/</developerConnection>
+    <url>http://svn.apache.org/viewcvs.cgi/webservices/jaxme/trunk/maven-jaxme-plugin/</url>
+  </scm>
+  <organization>
+    <name>Apache Software Foundation</name>
+    <url>http://www.apache.org/</url>
+  </organization>
+  <build>
+    <sourceDirectory>src/main/java</sourceDirectory>
+    <resources>
+      <resource>
+        <directory>src/main/resources</directory>
+      </resource>
+    </resources>
+    <testSourceDirectory>src/test/java</testSourceDirectory>
+    <testResources>
+      <testResource>
+        <directory>src/test/resources</directory>
+      </testResource>
+    </testResources>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-eclipse-plugin</artifactId>
+        <configuration>
+          <downloadSources>true</downloadSources>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.ws.jaxme</groupId>
+      <artifactId>jaxme2</artifactId>
+      <version>0.5.1-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-project</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <artifactId>plexus-utils</artifactId>
+      <groupId>plexus</groupId>
+      <version>1.0.3</version>
+    </dependency>
+  </dependencies>
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </reporting>
+  <distributionManagement>
+    <repository>
+      <id>people.apache.org</id>
+      <name>Apache Maven Repository</name>
+      <url>scp://people.apache.org/www/www.apache.org/dist/maven-repository</url>
+    </repository>
+    <snapshotRepository>
+      <id>people.apache.org</id>
+      <name>Apache Maven Snapshot Repository</name>
+      <url>scp://people.apache.org/www/www.apache.org/dist/maven-repository</url>
+    </snapshotRepository>
+    <site>
+      <id>people.apache.org</id>
+      <name>Jochen's home directory on people.apache.org</name>
+      <url>scp://people.apache.org/home/jochen/public_html/jaxme/site/mp</url>
+    </site>
+  </distributionManagement>
+  <repositories>
+    <repository>
+      <id>jochen</id>
+      <name>people.apache.org/~jochen</name>
+      <url>http://people.apache.org/~jochen/jaxme/dist</url>
+    </repository>
+  </repositories>
+</project>

Added: webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/src/main/java/org/apache/ws/jaxme/maven/plugins/JaxMeGoal.java
URL: http://svn.apache.org/viewcvs/webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/src/main/java/org/apache/ws/jaxme/maven/plugins/JaxMeGoal.java?rev=356601&view=auto
==============================================================================
--- webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/src/main/java/org/apache/ws/jaxme/maven/plugins/JaxMeGoal.java (added)
+++ webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/src/main/java/org/apache/ws/jaxme/maven/plugins/JaxMeGoal.java Tue Dec 13 12:00:57 2005
@@ -0,0 +1,442 @@
+/*
+ * Copyright 2005  The Apache Software Foundation
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.maven.plugins;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.maven.model.Resource;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.apache.ws.jaxme.generator.Generator;
+import org.apache.ws.jaxme.generator.SchemaReader;
+import org.apache.ws.jaxme.generator.impl.GeneratorImpl;
+import org.apache.ws.jaxme.generator.sg.SGFactoryChain;
+import org.apache.ws.jaxme.generator.sg.impl.JAXBSchemaReader;
+import org.apache.ws.jaxme.generator.sg.impl.JaxMeSchemaReader;
+import org.apache.ws.jaxme.logging.Logger;
+import org.apache.ws.jaxme.logging.LoggerAccess;
+import org.apache.ws.jaxme.logging.LoggerFactory;
+import org.codehaus.plexus.util.DirectoryScanner;
+
+
+/** This is the "jaxme:jaxme" goal. It runs the source
+ * generator.
+ * @goal jaxme
+ * @phase generate-sources
+ * @description Runs the JaxMe binding compiler
+ * and generates the source files.
+ * @requiresDependencyResolution test
+ */
+public class JaxMeGoal extends AbstractMojo {
+	/** This property specifies a set of files, which
+	 * are referenced from within the XML schema files,
+	 * but aren't processed as XML schema files for
+	 * themselves. Specifying files in the "depends" set
+	 * allows to include them into the uptodate check.
+	 */
+	private String[] depends;
+
+	/** Setting this property to true enables JaxMe's extension
+	 * mode. Several vendor extensions are available, including
+	 * some extensions, which are originally specified by the
+	 * JAXB reference implementation.
+	 * @parameter expression="false"
+	 */
+	private boolean extension;
+
+	/** Setting this property to suppresses the builtin
+	 * uptodate check.
+	 * @parameter expression="false"
+	 */
+	private boolean force;
+
+	/** Sets the Java package name.
+	 * @parameter
+	 */
+	private String packageName;
+
+	/** This property specifies a set of files, which are
+	 * being produced by the source generator. Any element
+	 * in the set may contain wildcards.
+	 * The set of produced files is used for checking,
+	 * whether the generated files are uptodate. If that is
+	 * the case, then the generator will omit recreating
+	 * them. If the uptodate check fails, or if the "force"
+	 * property is turned on, then the source generator
+	 * will actually be invoked. In that case, the set of
+	 * produces files will also be used for removing old
+	 * files, if the "removeOldOutput" feature is turned
+	 * on.
+	 */
+	private String[] produces;
+
+	/** The Maven project.
+	 * @parameter expression="${project}"
+	 */
+	private MavenProject project;
+
+	/** The properties being set on the generator.
+	 * @parameter
+	 */
+	private Map properties;
+
+	/** Setting this property to true will make the generated
+	 * files read-only.
+	 * @parameter expression="false"
+	 */
+	private boolean readOnly;
+
+	/** If this property is set to true, and one or more
+	 * produces "produces" elements are specified, then the plugin
+	 * will remove all files matching the "produces" elements
+	 * before running the source generator.
+	 * @parameter expression="false"
+	 */
+	private boolean removingOldOutput;
+
+	/** Sets the schema reader being used. The default
+	 * schema reader is an instance of {@link JAXBSchemaReader}.
+	 * The default changes, if "extension" is set to true,
+	 * in which case the {@link JaxMeSchemaReader} is being
+	 * used.
+	 * @parameter expression="org.apache.ws.jaxme.generator.sg.impl.JAXBSchemaReader"
+	 */
+	private String schemaReader;
+	
+	/** The set of schemas being compiled. Schema names may
+	 * include wildcards.
+	 * @parameter
+	 */
+	private String[] schemas;
+
+	/** The set of factory chains, which are being added to the
+	 * generator. Factory chains are modifying the generators
+	 * behaviour. A good example is the
+	 * <code>org.apache.ws.jaxme.pm.generator.jdbc.JaxMeJdbcSG</code>.
+	 */
+	private String[] sgFactoryChain;
+
+	/** The target directory for source files. Defaults to
+	 * @parameter expression="${project.build.directory}/jaxme/java"
+	 */
+	private String srcTarget;
+
+	/** The target directory for resource files. Defaults to
+	 * @parameter expression="${project.build.directory}/jaxme/resources"
+	 */
+	private String resourceTarget;
+
+	/** Setting this property to true advices the plugin to use
+	 * a validating XML parser for reading the schema files.
+	 * By default, validation is disabled.
+	 * @parameter expression="false"
+	 */
+	private boolean validating;
+
+	protected String[] getDepends() {
+		return depends;
+	}
+
+	protected boolean isExtension() {
+		return extension;
+	}
+
+
+	protected boolean isForce() {
+		return force;
+	}
+
+	protected String getPackageName() {
+		return packageName;
+	}
+
+	protected String[] getProduces() {
+		return produces;
+	}
+
+	protected MavenProject getProject() {
+		return project;
+	}
+
+	protected Map getProperties() {
+		return properties;
+	}
+
+	protected boolean isReadOnly() {
+		return readOnly;
+	}
+
+	protected boolean isRemovingOldOutput() {
+		return removingOldOutput;
+	}
+
+	protected String getSchemaReader() {
+		return schemaReader;
+	}
+
+	protected String[] getSgFactoryChain() {
+		return sgFactoryChain;
+	}
+
+	protected String getSrcTarget() {
+		return srcTarget;
+	}
+
+	protected String getResourceTarget() {
+		return resourceTarget;
+	}
+
+	protected boolean isValidating() {
+		return validating;
+	}
+
+	private File[] getProducedFiles() {
+		return getFiles(getProduces());
+	}
+
+	private File[] getFiles(String[] pSpec) {
+		if (pSpec == null  ||  pSpec.length == 0) {
+			return new File[0];
+		}
+		DirectoryScanner ds = new DirectoryScanner();
+		final File baseDir = getProject().getBasedir();
+		ds.setBasedir(baseDir);
+		ds.setIncludes(pSpec);
+		ds.scan();
+		String[] files = ds.getIncludedFiles();
+		File[] result = new File[files.length];
+		for (int i = 0;  i < result.length;  i++) {
+			result[i] = new File(baseDir, files[i]);
+		}
+		return result;
+	}
+
+	private File[] getSchemaFiles() {
+		if (schemas == null  ||  schemas.length == 0) {
+			schemas = new String[]{"src/jaxme/*.xsd"};
+		}
+		File[] schemaFiles = getFiles(schemas);
+		if (schemaFiles.length == 0) {
+			StringBuffer sb = new StringBuffer();
+			sb.append("Schema specification returns no result: ");
+			for (int i = 0;  i < schemas.length;  i++) {
+				if (i > 0) {
+					sb.append(",");
+				}
+				sb.append(schemas[i]);
+			}
+			getLog().warn(sb);
+		}
+		return schemaFiles;
+	}
+
+	private File[] getDependencies() {
+		return getFiles(getDepends());
+	}
+
+	private boolean isUptodate(File[] pSchemaFiles, File[] pDependencies, File[] pProducedFiles) {
+		if (isForce()) {
+			getLog().debug("Force flag set, disabling uptodate check.");
+			return false;
+		}
+		if (pProducedFiles.length == 0) {
+			getLog().debug("No produced files found, disabling uptodate check.");
+			return false;
+		}
+		File minProducedFile = null;
+		long minProducedTime = 0;
+		for (int i = 0;  i < pProducedFiles.length;  i++) {
+			File f = pProducedFiles[i];
+			long l = f.lastModified();
+			if (l == 0) {
+				getLog().debug("Produced file " + f + " has unknown timestamp, disabling uptodate check.");
+				return false;
+			}
+			if (minProducedTime == 0  ||  minProducedTime > l) {
+				minProducedTime = l;
+				minProducedFile = f;
+			}
+		}
+
+		final File[] deps = new File[pSchemaFiles.length + pDependencies.length];
+		System.arraycopy(pSchemaFiles, 0, deps, 0, pSchemaFiles.length);
+		System.arraycopy(pDependencies, 0, deps, pSchemaFiles.length, pDependencies.length);
+		long maxDepTime = 0;
+		File maxDepFile = null;
+		for (int i = 0;  i < deps.length;  i++) {
+			File f = deps[i];
+			long l = f.lastModified();
+			if (l == 0) {
+				getLog().debug("Dependency file " + f + " has unknown timestamp, disabling uptodate check.");
+				return false;
+			}
+			if (maxDepTime == 0  ||  maxDepTime < l) {
+				maxDepTime = l;
+				maxDepFile = f;
+			}
+		}
+
+		if (maxDepTime >= minProducedTime) {
+			getLog().debug("Dependency file " + maxDepFile + " is more recent than produced file " + minProducedFile);
+			return true;
+		} else {
+			getLog().debug("All produced files are uptodate.");
+			return false;
+		}
+	}
+
+	private void removeOldOutput(File[] pProducedFiles) throws MojoExecutionException {
+		if (isRemovingOldOutput()) {
+			for (int i = 0;  i < pProducedFiles.length;  i++) {
+				File f = pProducedFiles[i];
+				if (f.isFile()  &&  !f.delete()) {
+					throw new MojoExecutionException("Unable to delete file: " + f.getAbsolutePath());
+				}
+			}
+		}
+	}
+
+	private Class getSgFactoryChainClass(String pClass) throws MojoFailureException {
+		Class c;
+		try {
+			c = Class.forName(pClass);
+		} catch (ClassNotFoundException e) {
+			throw new MojoFailureException("The factory chain class " + pClass + " was not found.");
+		}
+		if (!SGFactoryChain.class.isAssignableFrom(c)) {
+			throw new MojoFailureException("The factory chain class " + c.getName()
+					+ " is not implementing " + SGFactoryChain.class);
+		}
+		return c;
+	}
+
+	private SchemaReader getSchemaReaderInstance() throws MojoFailureException, MojoExecutionException {
+		String s = getSchemaReader();
+		final SchemaReader result;
+		if (s == null  ||  s.length() == 0) {
+			if (isExtension()) {
+				result = new JaxMeSchemaReader();
+			} else {
+				result = new JAXBSchemaReader();
+			}
+		} else {
+			Class c;
+			try {
+				c = Class.forName(s);
+			} catch (ClassNotFoundException e) {
+				throw new MojoFailureException("The schema reader class " + s + " was not found.");
+			}
+			Object o;
+			try {
+				o = c.newInstance();
+			} catch (InstantiationException e) {
+				throw new MojoExecutionException("Failed to instantiate schema reader class " + c.getName(), e);
+			} catch (IllegalAccessException e) {
+				throw new MojoExecutionException("Illegal access to schema reader class " + c.getName(), e);
+			}
+			try {
+				result = (SchemaReader) o;
+			} catch (ClassCastException e) {
+				throw new MojoFailureException("The configured schema reader class " + c.getName()
+						+ " is not implementing " + SchemaReader.class.getName());
+			}
+		}
+
+		String[] chains = getSgFactoryChain();
+		if (chains != null) {
+			for (int i = 0;  i < chains.length;  i++) {
+				Class c = getSgFactoryChainClass(chains[i]);
+				result.addSGFactoryChain(c);
+			}
+		}
+
+		return result;
+	}
+
+	private File getSrcTargetDirectory() {
+		return getTargetDir(getSrcTarget());
+	}
+
+	private File getTargetDir(String pDir) {
+		File f = new File(pDir);
+		if (!f.isAbsolute()) {
+			f = new File(getProject().getBasedir(), getSrcTarget());
+		}
+		return f;
+	}
+
+	private File getResourceTargetDirectory() {
+		return getTargetDir(getResourceTarget());
+	}
+
+	public void execute() throws MojoExecutionException, MojoFailureException {
+		LoggerFactory lf = LoggerAccess.getLoggerFactory();
+		try {
+			LoggerAccess.setLoggerFactory(new LoggerFactory(){
+				public Logger getLogger(String pName) {
+					return new MavenProjectLogger(getLog(), pName);
+				}
+			});
+			final File[] schemaFiles = getSchemaFiles();
+			if (schemaFiles.length == 0) {
+				return;
+			}
+			final File[] producedFiles = getProducedFiles();
+			final File[] dependencies = getDependencies();
+			final boolean uptodate = isUptodate(schemaFiles, dependencies, producedFiles);
+			if (uptodate) {
+				getLog().info("Generated files are uptodate.");
+				return;
+			}
+	
+			removeOldOutput(producedFiles);
+	
+			for (int i = 0;  i < schemaFiles.length;  i++) {
+				Generator g = new GeneratorImpl();
+				final SchemaReader reader = getSchemaReaderInstance();
+				g.setSchemaReader(reader);
+				g.setForcingOverwrite(isForce());
+				g.setSettingReadOnly(isReadOnly());
+				g.setTargetDirectory(getSrcTargetDirectory());
+				g.setResourceTargetDirectory(getResourceTargetDirectory());
+				g.setValidating(isValidating());
+				Map props = getProperties();
+				if (props != null) {
+					for (Iterator iter = props.entrySet().iterator();  iter.hasNext();  ) {
+						Map.Entry entry = (Map.Entry) iter.next();
+						g.setProperty((String) entry.getKey(), (String) entry.getValue());
+					}
+				}
+				try {
+					g.generate(schemaFiles[i]);
+				} catch (Exception e) {
+					throw new MojoExecutionException(e.getMessage(), e);
+				}
+			}
+	
+			getProject().addCompileSourceRoot(getSrcTarget());
+			Resource resource = new Resource();
+			resource.setDirectory(getResourceTarget());
+			getProject().addResource(resource);
+		} finally {
+			LoggerAccess.setLoggerFactory(lf);
+		}
+	}
+}

Added: webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/src/main/java/org/apache/ws/jaxme/maven/plugins/MavenProjectLogger.java
URL: http://svn.apache.org/viewcvs/webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/src/main/java/org/apache/ws/jaxme/maven/plugins/MavenProjectLogger.java?rev=356601&view=auto
==============================================================================
--- webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/src/main/java/org/apache/ws/jaxme/maven/plugins/MavenProjectLogger.java (added)
+++ webservices/jaxme/trunk/ws-jaxme/maven-jaxme-plugin/src/main/java/org/apache/ws/jaxme/maven/plugins/MavenProjectLogger.java Tue Dec 13 12:00:57 2005
@@ -0,0 +1,162 @@
+/*
+ * Copyright 2005  The Apache Software Foundation
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.maven.plugins;
+
+import org.apache.maven.plugin.logging.Log;
+import org.apache.ws.jaxme.logging.Logger;
+
+
+/** A Logger implementation, which uses the Maven
+ * projects logger.
+ */
+class MavenProjectLogger implements Logger {
+	private final Log log;
+	private final String name;
+
+	MavenProjectLogger(Log pLog, String pName) {
+		log = pLog;
+		name = pName;
+	}
+
+	private String asName(String pName) {
+		return name + "." + pName;
+	}
+
+	private String asString(Object[] pArgs) {
+		StringBuffer sb = new StringBuffer();
+		if (pArgs != null) {
+			for (int i = 0;  i < pArgs.length;  i++) {
+				if (i > 0) {
+					sb.append(", ");
+				}
+				sb.append(pArgs[i]);
+			}
+		}
+		return sb.toString();
+	}
+
+	public void entering(String pName, Object[] pArgs) {
+		entering(pName, asString(pArgs));
+	}
+
+	public void entering(String pName) {
+		entering(pName, "");
+	}
+
+	public void entering(String pName, Object pArg) {
+		log.debug(asName(pName) + " -> " + pArg);
+	}
+
+	public void exiting(String pName, Object[] pArgs) {
+		exiting(pName, asString(pArgs));
+	}
+
+	public void exiting(String pName) {
+		exiting(pName, "");
+	}
+
+	public void exiting(String pName, Object pArg) {
+		log.debug(asName(pName) + " <- " + pArg);
+	}
+
+	public void throwing(String pName, Throwable pError) {
+		log.error(asName(pName), pError);
+	}
+
+	public boolean isFinestEnabled() { return true; }
+
+	public void finest(String pName, String pArg, Object[] pArgs) {
+		finest(pName, pArg + ", " + asString(pArgs));
+	}
+
+	public void finest(String pName, String pArg) {
+		log.debug(asName(pName) + ": " + pArg);
+	}
+
+	public void finest(String pName, String pArg1, Object pArg2) {
+		finest(pName, pArg1 + ", " + pArg2);
+	}
+
+	public void finer(String pName, String pArg, Object[] pArgs) {
+		finer(pName, pArg + ", " + asString(pArgs));
+	}
+
+	public boolean isFinerEnabled() { return true; }
+
+	public void finer(String pName, String pArg) {
+		log.debug(asName(pName) + ": " + pArg);
+	}
+
+	public void finer(String pName, String pArg1, Object pArg2) {
+		finer(pName, pArg1 + ", " + pArg2);
+	}
+
+	public boolean isFineEnabled() { return true; }
+
+	public void fine(String pName, String pArg, Object[] pArgs) {
+		fine(pName, pArg + ", " + asString(pArgs));
+	}
+
+	public void fine(String pName, String pArg) {
+		log.debug(asName(pName) + ": " + pArg);
+	}
+
+	public void fine(String pName, String pArg1, Object pArg2) {
+		fine(pName, pArg1 + ", " + pArg2);
+	}
+
+	public boolean isInfoEnabled() { return true; }
+
+	public void info(String pName, String pArg, Object[] pArgs) {
+		info(pName, pArg + ", " + asString(pArgs));
+	}
+
+	public void info(String pName, String pArg) {
+		log.info(asName(pName) + ": " + pArg);
+	}
+
+	public void info(String pName, String pArg1, Object pArg2) {
+		info(pName, pArg1 + ", " + pArg2);
+	}
+
+	public boolean isWarnEnabled() { return true; }
+
+	public void warn(String pName, String pArg, Object[] pArgs) {
+		warn(pName, pArg + ", " + asString(pArgs));
+	}
+
+	public void warn(String pName, String pArg) {
+		log.warn(pName + ": " + pArg);
+	}
+
+	public void warn(String pName, String pArg1, Object pArg2) {
+		warn(pName, pArg1 + ", " + pArg2);
+	}
+
+	public boolean isErrorEnabled() { return true; }
+
+	public void error(String pName, String pArg, Object[] pArgs) {
+		error(pName, pArg + ", " + asString(pArgs));
+	}
+
+	public void error(String pName, String pArg) {
+		log.error(asName(pName) + ": " + pArg);
+	}
+
+	public void error(String pName, String pArg1, Object pArg2) {
+		error(pName, pArg1 + ", " + pArg2);
+	}
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org