You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2009/12/03 23:27:02 UTC
svn commit: r886957 [2/5] - in /cxf/trunk:
api/src/test/java/org/apache/cxf/databinding/
distribution/src/main/release/samples/wsdl_first/src/main/java/com/example/customerservice/client/
distribution/src/main/release/samples/wsdl_first/src/main/java/c...
Modified: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/BindingFileHelper.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/BindingFileHelper.java?rev=886957&r1=886956&r2=886957&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/BindingFileHelper.java (original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/BindingFileHelper.java Thu Dec 3 22:26:58 2009
@@ -1,114 +1,114 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.cxf.maven_plugin;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.net.URI;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.logging.Log;
-
-public final class BindingFileHelper {
- static final String LOCATION_ATTR_NAME = "wsdlLocation";
-
- private BindingFileHelper() {
- }
-
- static Document readDocument(InputStream is) throws Exception {
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- DocumentBuilder db = dbf.newDocumentBuilder();
- Document doc = db.parse(is);
- doc.getDocumentElement().normalize();
- return doc;
- }
-
- /**
- * Reads bindingFile from given stream, sets the attribute wsdlLocation on the top element bindings to the
- * given wsdlLocation and writes the resulting binding file to outBindingFile
- *
- * @param bindingFileStream
- * @param wsdlLocation
- * @param outBindingFile
- * @throws Exception
- */
- public static boolean setWsdlLocationAndWrite(InputStream bindingFileStream, URI wsdlLocation,
- File outBindingFile) throws Exception {
- Document doc = readDocument(bindingFileStream);
-
- // Find and set wsdlLocation
- Element bindings = doc.getDocumentElement();
- String oldLocation = bindings.getAttribute(LOCATION_ATTR_NAME);
- if (oldLocation != null && !"".equals(oldLocation)) {
- return false;
- }
- bindings.setAttribute(LOCATION_ATTR_NAME, wsdlLocation.toURL().toExternalForm());
-
- // Save to outBindingFile
- TransformerFactory transformerFactory = TransformerFactory.newInstance();
- Transformer transformer = transformerFactory.newTransformer();
- transformer.setOutputProperty(OutputKeys.INDENT, "yes");
- DOMSource source = new DOMSource(doc);
-
- if (!outBindingFile.exists()) {
- outBindingFile.getParentFile().mkdirs();
- }
- FileOutputStream fos = new FileOutputStream(outBindingFile);
- StreamResult result = new StreamResult(fos);
- transformer.transform(source, result);
- return true;
- }
-
- static void setWsdlLocationInBindingsIfNotSet(File baseDir, File outDir, WsdlOption o, Log log)
- throws MojoExecutionException {
- try {
- String[] bindingFiles = o.getBindingFiles();
- for (int c = 0; c < bindingFiles.length; c++) {
- String bindingFilePath = bindingFiles[c];
- File bindingFile = new File(bindingFilePath);
- File outFile = new File(outDir, "" + c + "-" + bindingFile.getName());
- URI wsdlLocation = o.getWsdlURI(baseDir.toURI());
- FileInputStream is = new FileInputStream(bindingFile);
- boolean wasSet = setWsdlLocationAndWrite(is, wsdlLocation, outFile);
- if (log != null) {
- log.info("Checked binding file " + bindingFilePath + " " + wasSet);
- }
- if (wasSet) {
- bindingFiles[c] = outFile.getAbsolutePath();
- }
- }
- } catch (Exception e) {
- throw new MojoExecutionException("Error setting wsdlLocation in binding file", e);
- }
- }
-
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.cxf.maven_plugin;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.net.URI;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.logging.Log;
+
+public final class BindingFileHelper {
+ static final String LOCATION_ATTR_NAME = "wsdlLocation";
+
+ private BindingFileHelper() {
+ }
+
+ static Document readDocument(InputStream is) throws Exception {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document doc = db.parse(is);
+ doc.getDocumentElement().normalize();
+ return doc;
+ }
+
+ /**
+ * Reads bindingFile from given stream, sets the attribute wsdlLocation on the top element bindings to the
+ * given wsdlLocation and writes the resulting binding file to outBindingFile
+ *
+ * @param bindingFileStream
+ * @param wsdlLocation
+ * @param outBindingFile
+ * @throws Exception
+ */
+ public static boolean setWsdlLocationAndWrite(InputStream bindingFileStream, URI wsdlLocation,
+ File outBindingFile) throws Exception {
+ Document doc = readDocument(bindingFileStream);
+
+ // Find and set wsdlLocation
+ Element bindings = doc.getDocumentElement();
+ String oldLocation = bindings.getAttribute(LOCATION_ATTR_NAME);
+ if (oldLocation != null && !"".equals(oldLocation)) {
+ return false;
+ }
+ bindings.setAttribute(LOCATION_ATTR_NAME, wsdlLocation.toURL().toExternalForm());
+
+ // Save to outBindingFile
+ TransformerFactory transformerFactory = TransformerFactory.newInstance();
+ Transformer transformer = transformerFactory.newTransformer();
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+ DOMSource source = new DOMSource(doc);
+
+ if (!outBindingFile.exists()) {
+ outBindingFile.getParentFile().mkdirs();
+ }
+ FileOutputStream fos = new FileOutputStream(outBindingFile);
+ StreamResult result = new StreamResult(fos);
+ transformer.transform(source, result);
+ return true;
+ }
+
+ static void setWsdlLocationInBindingsIfNotSet(File baseDir, File outDir, WsdlOption o, Log log)
+ throws MojoExecutionException {
+ try {
+ String[] bindingFiles = o.getBindingFiles();
+ for (int c = 0; c < bindingFiles.length; c++) {
+ String bindingFilePath = bindingFiles[c];
+ File bindingFile = new File(bindingFilePath);
+ File outFile = new File(outDir, "" + c + "-" + bindingFile.getName());
+ URI wsdlLocation = o.getWsdlURI(baseDir.toURI());
+ FileInputStream is = new FileInputStream(bindingFile);
+ boolean wasSet = setWsdlLocationAndWrite(is, wsdlLocation, outFile);
+ if (log != null) {
+ log.info("Checked binding file " + bindingFilePath + " " + wasSet);
+ }
+ if (wasSet) {
+ bindingFiles[c] = outFile.getAbsolutePath();
+ }
+ }
+ } catch (Exception e) {
+ throw new MojoExecutionException("Error setting wsdlLocation in binding file", e);
+ }
+ }
+
+}
Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/BindingFileHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/BindingFileHelper.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlArtifact.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlArtifact.java?rev=886957&r1=886956&r2=886957&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlArtifact.java (original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlArtifact.java Thu Dec 3 22:26:58 2009
@@ -1,65 +1,65 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.cxf.maven_plugin;
-
-/**
- * Represents a wsdl file that is stored in a maven repository
- */
-public class WsdlArtifact {
- private String groupId;
- private String artifactId;
- private String version;
- private String type;
-
- public WsdlArtifact() {
- type = "wsdl";
- }
-
- public String getGroupId() {
- return groupId;
- }
- public void setGroupId(String groupId) {
- this.groupId = groupId;
- }
- public String getArtifactId() {
- return artifactId;
- }
- public void setArtifactId(String artifactId) {
- this.artifactId = artifactId;
- }
- public String getVersion() {
- return version;
- }
- public void setVersion(String version) {
- this.version = version;
- }
- public String getType() {
- return type;
- }
- public void setType(String type) {
- this.type = type;
- }
-
- public boolean doesMatch(WsdlArtifact artifact) {
- return type.equals(artifact.getType()) && groupId.equals(artifact.getGroupId())
- && artifactId.equals(artifact.getArtifactId())
- && (version == null || version.equals(artifact.getVersion()));
- }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.cxf.maven_plugin;
+
+/**
+ * Represents a wsdl file that is stored in a maven repository
+ */
+public class WsdlArtifact {
+ private String groupId;
+ private String artifactId;
+ private String version;
+ private String type;
+
+ public WsdlArtifact() {
+ type = "wsdl";
+ }
+
+ public String getGroupId() {
+ return groupId;
+ }
+ public void setGroupId(String groupId) {
+ this.groupId = groupId;
+ }
+ public String getArtifactId() {
+ return artifactId;
+ }
+ public void setArtifactId(String artifactId) {
+ this.artifactId = artifactId;
+ }
+ public String getVersion() {
+ return version;
+ }
+ public void setVersion(String version) {
+ this.version = version;
+ }
+ public String getType() {
+ return type;
+ }
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public boolean doesMatch(WsdlArtifact artifact) {
+ return type.equals(artifact.getType()) && groupId.equals(artifact.getGroupId())
+ && artifactId.equals(artifact.getArtifactId())
+ && (version == null || version.equals(artifact.getVersion()));
+ }
+}
Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlArtifact.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlArtifact.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: cxf/trunk/maven-plugins/codegen-plugin/src/test/java/org/apache/cxf/maven_plugin/BindingFileHelperTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/test/java/org/apache/cxf/maven_plugin/BindingFileHelperTest.java?rev=886957&r1=886956&r2=886957&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/test/java/org/apache/cxf/maven_plugin/BindingFileHelperTest.java (original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/test/java/org/apache/cxf/maven_plugin/BindingFileHelperTest.java Thu Dec 3 22:26:58 2009
@@ -1,81 +1,81 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.cxf.maven_plugin;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.net.URI;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.maven.plugin.MojoExecutionException;
-
-public class BindingFileHelperTest extends TestCase {
- private static final File OUTFILE = new File("target/test-data/testbinding.xml");
- private static final String TEST_WSDL_URL = "http://testwsdl";
-
- public void testBindingWithWsdlLocation() throws Exception {
- try {
- OUTFILE.delete();
- } catch (Exception e) {
- // Do not fail if delete fails
- }
- InputStream is = this.getClass().getResourceAsStream("/bindingWithWsdlLocation.xml");
- boolean wasSet = BindingFileHelper.setWsdlLocationAndWrite(is, new URI(TEST_WSDL_URL), OUTFILE);
- Assert.assertFalse("This binding file should not be changed", wasSet);
- Assert.assertFalse(OUTFILE.exists());
- }
-
- public void testBindingWithoutWsdlLocation() throws Exception {
- try {
- OUTFILE.delete();
- } catch (Exception e) {
- // Do not fail if delete fails
- }
- InputStream is = this.getClass().getResourceAsStream("/bindingWithoutWsdlLocation.xml");
- BindingFileHelper.setWsdlLocationAndWrite(is, new URI(TEST_WSDL_URL), OUTFILE);
-
- Document doc = BindingFileHelper.readDocument(new FileInputStream(OUTFILE));
- Element bindings = doc.getDocumentElement();
- String location = bindings.getAttribute(BindingFileHelper.LOCATION_ATTR_NAME);
- Assert.assertEquals(TEST_WSDL_URL, location);
- }
-
- public void testSetBindingForWsdlOption() throws MojoExecutionException {
- WsdlOption o = new WsdlOption();
- o.setWsdl("test.wsdl");
- File baseDir = new File(".");
- File tempDir = new File(baseDir, "target" + File.separator + "tempbindings");
- File bindingFile = new File(baseDir, "src/test/resources/bindingWithoutWsdlLocation.xml");
- o.setBindingFiles(new String[] {
- bindingFile.getAbsolutePath()
- });
-
- BindingFileHelper.setWsdlLocationInBindingsIfNotSet(baseDir, tempDir, o, null);
- String bindingFilePath = o.getBindingFiles()[0];
- File expectedBindingFile = new File(tempDir, "0-bindingWithoutWsdlLocation.xml");
- Assert.assertEquals("Binding file should be the temp file", expectedBindingFile.getAbsolutePath(),
- bindingFilePath);
- }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.cxf.maven_plugin;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.net.URI;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.maven.plugin.MojoExecutionException;
+
+public class BindingFileHelperTest extends TestCase {
+ private static final File OUTFILE = new File("target/test-data/testbinding.xml");
+ private static final String TEST_WSDL_URL = "http://testwsdl";
+
+ public void testBindingWithWsdlLocation() throws Exception {
+ try {
+ OUTFILE.delete();
+ } catch (Exception e) {
+ // Do not fail if delete fails
+ }
+ InputStream is = this.getClass().getResourceAsStream("/bindingWithWsdlLocation.xml");
+ boolean wasSet = BindingFileHelper.setWsdlLocationAndWrite(is, new URI(TEST_WSDL_URL), OUTFILE);
+ Assert.assertFalse("This binding file should not be changed", wasSet);
+ Assert.assertFalse(OUTFILE.exists());
+ }
+
+ public void testBindingWithoutWsdlLocation() throws Exception {
+ try {
+ OUTFILE.delete();
+ } catch (Exception e) {
+ // Do not fail if delete fails
+ }
+ InputStream is = this.getClass().getResourceAsStream("/bindingWithoutWsdlLocation.xml");
+ BindingFileHelper.setWsdlLocationAndWrite(is, new URI(TEST_WSDL_URL), OUTFILE);
+
+ Document doc = BindingFileHelper.readDocument(new FileInputStream(OUTFILE));
+ Element bindings = doc.getDocumentElement();
+ String location = bindings.getAttribute(BindingFileHelper.LOCATION_ATTR_NAME);
+ Assert.assertEquals(TEST_WSDL_URL, location);
+ }
+
+ public void testSetBindingForWsdlOption() throws MojoExecutionException {
+ WsdlOption o = new WsdlOption();
+ o.setWsdl("test.wsdl");
+ File baseDir = new File(".");
+ File tempDir = new File(baseDir, "target" + File.separator + "tempbindings");
+ File bindingFile = new File(baseDir, "src/test/resources/bindingWithoutWsdlLocation.xml");
+ o.setBindingFiles(new String[] {
+ bindingFile.getAbsolutePath()
+ });
+
+ BindingFileHelper.setWsdlLocationInBindingsIfNotSet(baseDir, tempDir, o, null);
+ String bindingFilePath = o.getBindingFiles()[0];
+ File expectedBindingFile = new File(tempDir, "0-bindingWithoutWsdlLocation.xml");
+ Assert.assertEquals("Binding file should be the temp file", expectedBindingFile.getAbsolutePath(),
+ bindingFilePath);
+ }
+}
Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/test/java/org/apache/cxf/maven_plugin/BindingFileHelperTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/test/java/org/apache/cxf/maven_plugin/BindingFileHelperTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/test/resources/bindingWithWsdlLocation.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/test/resources/bindingWithWsdlLocation.xml
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Thu Dec 3 22:26:58 2009
@@ -1 +1 @@
-text/plain
+text/xml
Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/test/resources/bindingWithoutWsdlLocation.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: cxf/trunk/maven-plugins/codegen-plugin/src/test/resources/bindingWithoutWsdlLocation.xml
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Thu Dec 3 22:26:58 2009
@@ -1 +1 @@
-text/plain
+text/xml
Propchange: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/ParameterizedTypeFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/SimpleParameterizedType.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/ws1/WS1.aegis.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Propchange: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/jaxws/AegisJaxwsGetTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/LogLevel.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/LogLevel.java?rev=886957&r1=886956&r2=886957&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/LogLevel.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/LogLevel.java Thu Dec 3 22:26:58 2009
@@ -1,89 +1,89 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.cxf.jaxrs.ext.logging;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.logging.Level;
-
-import javax.xml.bind.annotation.XmlEnum;
-import javax.xml.bind.annotation.XmlTransient;
-
-/**
- * Log level of {@link LogRecord}. Based on SLF4J being popular facade for loggers like JUL, Log4J, JCL and so
- * on. Severities order is: FATAL > ERROR > WARN > INFO > DEBUG > TRACE.
- * <p>
- * Mapping of levels:
- * <ol>
- * <li>JUL - same as <a href="http://www.slf4j.org/apidocs/org/slf4j/bridge/SLF4JBridgeHandler.html">SLF4J
- * approach</a>.</li>
- * <li>Log4J - levels are identical</li>
- * </ol>
- */
-@XmlEnum
-public enum LogLevel {
- ALL,
- FATAL,
- ERROR,
- WARN,
- INFO,
- DEBUG,
- TRACE,
- OFF;
-
- @XmlTransient
- private static Map<Level, LogLevel> fromJul = new HashMap<Level, LogLevel>();
-
- @XmlTransient
- private static Map<LogLevel, Level> toJul = new HashMap<LogLevel, Level>();
-
- static {
- fromJul.put(Level.ALL, LogLevel.ALL);
- fromJul.put(Level.SEVERE, LogLevel.ERROR);
- fromJul.put(Level.WARNING, LogLevel.WARN);
- fromJul.put(Level.INFO, LogLevel.INFO);
- fromJul.put(Level.FINE, LogLevel.DEBUG);
- fromJul.put(Level.FINER, LogLevel.DEBUG);
- fromJul.put(Level.FINEST, LogLevel.TRACE);
- fromJul.put(Level.OFF, LogLevel.OFF);
-
- toJul.put(LogLevel.ALL, Level.ALL);
- toJul.put(LogLevel.FATAL, Level.SEVERE);
- toJul.put(LogLevel.ERROR, Level.SEVERE);
- toJul.put(LogLevel.WARN, Level.WARNING);
- toJul.put(LogLevel.INFO, Level.INFO);
- toJul.put(LogLevel.DEBUG, Level.FINE);
- toJul.put(LogLevel.TRACE, Level.FINEST);
- toJul.put(LogLevel.OFF, Level.OFF);
- }
-
- /**
- * Creates this enum from JUL {@link Level}.
- */
- public static LogLevel fromJUL(Level level) {
- return fromJul.get(level);
- }
-
- /**
- * Creates this JUL {@link Level} from this enum.
- */
- public static Level toJUL(LogLevel level) {
- return toJul.get(level);
- }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.cxf.jaxrs.ext.logging;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Level;
+
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlTransient;
+
+/**
+ * Log level of {@link LogRecord}. Based on SLF4J being popular facade for loggers like JUL, Log4J, JCL and so
+ * on. Severities order is: FATAL > ERROR > WARN > INFO > DEBUG > TRACE.
+ * <p>
+ * Mapping of levels:
+ * <ol>
+ * <li>JUL - same as <a href="http://www.slf4j.org/apidocs/org/slf4j/bridge/SLF4JBridgeHandler.html">SLF4J
+ * approach</a>.</li>
+ * <li>Log4J - levels are identical</li>
+ * </ol>
+ */
+@XmlEnum
+public enum LogLevel {
+ ALL,
+ FATAL,
+ ERROR,
+ WARN,
+ INFO,
+ DEBUG,
+ TRACE,
+ OFF;
+
+ @XmlTransient
+ private static Map<Level, LogLevel> fromJul = new HashMap<Level, LogLevel>();
+
+ @XmlTransient
+ private static Map<LogLevel, Level> toJul = new HashMap<LogLevel, Level>();
+
+ static {
+ fromJul.put(Level.ALL, LogLevel.ALL);
+ fromJul.put(Level.SEVERE, LogLevel.ERROR);
+ fromJul.put(Level.WARNING, LogLevel.WARN);
+ fromJul.put(Level.INFO, LogLevel.INFO);
+ fromJul.put(Level.FINE, LogLevel.DEBUG);
+ fromJul.put(Level.FINER, LogLevel.DEBUG);
+ fromJul.put(Level.FINEST, LogLevel.TRACE);
+ fromJul.put(Level.OFF, LogLevel.OFF);
+
+ toJul.put(LogLevel.ALL, Level.ALL);
+ toJul.put(LogLevel.FATAL, Level.SEVERE);
+ toJul.put(LogLevel.ERROR, Level.SEVERE);
+ toJul.put(LogLevel.WARN, Level.WARNING);
+ toJul.put(LogLevel.INFO, Level.INFO);
+ toJul.put(LogLevel.DEBUG, Level.FINE);
+ toJul.put(LogLevel.TRACE, Level.FINEST);
+ toJul.put(LogLevel.OFF, Level.OFF);
+ }
+
+ /**
+ * Creates this enum from JUL {@link Level}.
+ */
+ public static LogLevel fromJUL(Level level) {
+ return fromJul.get(level);
+ }
+
+ /**
+ * Creates this JUL {@link Level} from this enum.
+ */
+ public static Level toJUL(LogLevel level) {
+ return toJul.get(level);
+ }
+}
Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/LogLevel.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/LogLevel.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/LogRecord.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/LogRecord.java?rev=886957&r1=886956&r2=886957&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/LogRecord.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/LogRecord.java Thu Dec 3 22:26:58 2009
@@ -1,167 +1,167 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.cxf.jaxrs.ext.logging;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.text.MessageFormat;
-import java.util.Date;
-
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.commons.lang.Validate;
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-
-/**
- * Log entry serializable to XML. Based on common set of {@link java.util.logging.LogRecord} and
- * {@link org.apache.log4j.spi.LoggingEvent} attributes.
- * <p>
- * LogRecord are never null; if some attributes are not set (e.g. logger name, or rendered cause taken from
- * Throwable) empty strings are returned.
- */
-@XmlRootElement(namespace = "http://cxf.apache.org/jaxrs/log")
-public class LogRecord {
-
- private Date eventTimestamp = new Date();
- private LogLevel level = LogLevel.INFO;
- private String message = "";
- private String loggerName = "";
- private String threadName = "";
- private String throwable = "";
-
- /**
- * Creates this object from JUL LogRecord. Most attributes are copied, others are converted as follows:
- * raw {@link java.util.logging.LogRecord#getMessage() message} is formatted with
- * {@link java.util.logging.LogRecord#getParameters() parameters} using {@link MessageFormat}, attached
- * {@link java.util.logging.LogRecord#getThrown() throwable} has full stack trace dumped, and log levels
- * are mapped as specified in {@link LogRecord}.
- *
- * @param julRecord log record to convert.
- * @return conversion result.
- */
- public static LogRecord fromJUL(java.util.logging.LogRecord julRecord) {
- Validate.notNull(julRecord, "julRecord is null");
- LogRecord record = new LogRecord();
- record.setEventTimestamp(new Date(julRecord.getMillis()));
- record.setLevel(LogLevel.fromJUL(julRecord.getLevel()));
- record.setLoggerName(julRecord.getLoggerName());
- if (julRecord.getThrown() != null) {
- record.setThrowable(julRecord.getThrown());
- }
- if (julRecord.getParameters() != null) {
- record.setMessage(MessageFormat.format(julRecord.getMessage(), julRecord.getParameters()));
- } else {
- record.setMessage(julRecord.getMessage());
- }
- record.setThreadName(Integer.toString(julRecord.getThreadID()));
- return record;
- }
-
- @XmlElement(namespace = "http://cxf.apache.org/jaxrs/log")
- public Date getEventTimestamp() {
- return eventTimestamp;
- }
-
- public void setEventTimestamp(Date eventTimestamp) {
- Validate.notNull(eventTimestamp, "eventTimestamp is null");
- this.eventTimestamp = eventTimestamp;
- }
-
- @XmlElement(namespace = "http://cxf.apache.org/jaxrs/log")
- public LogLevel getLevel() {
- return level;
- }
-
- public void setLevel(LogLevel level) {
- Validate.notNull(level, "level is null");
- this.level = level;
- }
-
- /**
- * Formatted message with parameters filled in.
- */
- @XmlElement(namespace = "http://cxf.apache.org/jaxrs/log")
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String renderedMessage) {
- Validate.notNull(level, "message is null");
- this.message = renderedMessage;
- }
-
- @XmlElement(namespace = "http://cxf.apache.org/jaxrs/log")
- public String getLoggerName() {
- return loggerName;
- }
-
- public void setLoggerName(String loggerName) {
- Validate.notNull(level, "loggerName is null");
- this.loggerName = loggerName;
- }
-
- @XmlElement(namespace = "http://cxf.apache.org/jaxrs/log")
- public String getThreadName() {
- return threadName;
- }
-
- public void setThreadName(String threadName) {
- Validate.notNull(level, "threadName is null");
- this.threadName = threadName;
- }
-
- /**
- * Full stack trace of {@link Throwable} associated with log record.
- */
- @XmlElement(namespace = "http://cxf.apache.org/jaxrs/log")
- public String getThrowable() {
- return throwable;
- }
-
- public void setThrowable(String throwable) {
- Validate.notNull(throwable, "throwable is null");
- this.throwable = throwable;
- }
-
- public void setThrowable(Throwable thr) {
- Validate.notNull(thr, "throwable is null");
- StringWriter sw = new StringWriter();
- thr.printStackTrace(new PrintWriter(sw));
- this.throwable = sw.getBuffer().toString();
- }
-
- @Override
- public boolean equals(Object obj) {
- return EqualsBuilder.reflectionEquals(obj, this);
- }
-
- @Override
- public int hashCode() {
- return HashCodeBuilder.reflectionHashCode(this);
- }
-
- @Override
- public String toString() {
- return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
- }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.cxf.jaxrs.ext.logging;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.text.MessageFormat;
+import java.util.Date;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.commons.lang.Validate;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+/**
+ * Log entry serializable to XML. Based on common set of {@link java.util.logging.LogRecord} and
+ * {@link org.apache.log4j.spi.LoggingEvent} attributes.
+ * <p>
+ * LogRecord are never null; if some attributes are not set (e.g. logger name, or rendered cause taken from
+ * Throwable) empty strings are returned.
+ */
+@XmlRootElement(namespace = "http://cxf.apache.org/jaxrs/log")
+public class LogRecord {
+
+ private Date eventTimestamp = new Date();
+ private LogLevel level = LogLevel.INFO;
+ private String message = "";
+ private String loggerName = "";
+ private String threadName = "";
+ private String throwable = "";
+
+ /**
+ * Creates this object from JUL LogRecord. Most attributes are copied, others are converted as follows:
+ * raw {@link java.util.logging.LogRecord#getMessage() message} is formatted with
+ * {@link java.util.logging.LogRecord#getParameters() parameters} using {@link MessageFormat}, attached
+ * {@link java.util.logging.LogRecord#getThrown() throwable} has full stack trace dumped, and log levels
+ * are mapped as specified in {@link LogRecord}.
+ *
+ * @param julRecord log record to convert.
+ * @return conversion result.
+ */
+ public static LogRecord fromJUL(java.util.logging.LogRecord julRecord) {
+ Validate.notNull(julRecord, "julRecord is null");
+ LogRecord record = new LogRecord();
+ record.setEventTimestamp(new Date(julRecord.getMillis()));
+ record.setLevel(LogLevel.fromJUL(julRecord.getLevel()));
+ record.setLoggerName(julRecord.getLoggerName());
+ if (julRecord.getThrown() != null) {
+ record.setThrowable(julRecord.getThrown());
+ }
+ if (julRecord.getParameters() != null) {
+ record.setMessage(MessageFormat.format(julRecord.getMessage(), julRecord.getParameters()));
+ } else {
+ record.setMessage(julRecord.getMessage());
+ }
+ record.setThreadName(Integer.toString(julRecord.getThreadID()));
+ return record;
+ }
+
+ @XmlElement(namespace = "http://cxf.apache.org/jaxrs/log")
+ public Date getEventTimestamp() {
+ return eventTimestamp;
+ }
+
+ public void setEventTimestamp(Date eventTimestamp) {
+ Validate.notNull(eventTimestamp, "eventTimestamp is null");
+ this.eventTimestamp = eventTimestamp;
+ }
+
+ @XmlElement(namespace = "http://cxf.apache.org/jaxrs/log")
+ public LogLevel getLevel() {
+ return level;
+ }
+
+ public void setLevel(LogLevel level) {
+ Validate.notNull(level, "level is null");
+ this.level = level;
+ }
+
+ /**
+ * Formatted message with parameters filled in.
+ */
+ @XmlElement(namespace = "http://cxf.apache.org/jaxrs/log")
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String renderedMessage) {
+ Validate.notNull(level, "message is null");
+ this.message = renderedMessage;
+ }
+
+ @XmlElement(namespace = "http://cxf.apache.org/jaxrs/log")
+ public String getLoggerName() {
+ return loggerName;
+ }
+
+ public void setLoggerName(String loggerName) {
+ Validate.notNull(level, "loggerName is null");
+ this.loggerName = loggerName;
+ }
+
+ @XmlElement(namespace = "http://cxf.apache.org/jaxrs/log")
+ public String getThreadName() {
+ return threadName;
+ }
+
+ public void setThreadName(String threadName) {
+ Validate.notNull(level, "threadName is null");
+ this.threadName = threadName;
+ }
+
+ /**
+ * Full stack trace of {@link Throwable} associated with log record.
+ */
+ @XmlElement(namespace = "http://cxf.apache.org/jaxrs/log")
+ public String getThrowable() {
+ return throwable;
+ }
+
+ public void setThrowable(String throwable) {
+ Validate.notNull(throwable, "throwable is null");
+ this.throwable = throwable;
+ }
+
+ public void setThrowable(Throwable thr) {
+ Validate.notNull(thr, "throwable is null");
+ StringWriter sw = new StringWriter();
+ thr.printStackTrace(new PrintWriter(sw));
+ this.throwable = sw.getBuffer().toString();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return EqualsBuilder.reflectionEquals(obj, this);
+ }
+
+ @Override
+ public int hashCode() {
+ return HashCodeBuilder.reflectionHashCode(this);
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
+ }
+}
Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/LogRecord.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/LogRecord.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/LogRecordsList.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/LogRecordsList.java?rev=886957&r1=886956&r2=886957&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/LogRecordsList.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/LogRecordsList.java Thu Dec 3 22:26:58 2009
@@ -1,65 +1,65 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.cxf.jaxrs.ext.logging;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.commons.lang.Validate;
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-
-/**
- * List of {@link LogRecord}s. Necessary wrapper for {@link List} used in JAXB context.
- */
-@XmlRootElement(namespace = "http://cxf.apache.org/jaxrs/log")
-public class LogRecordsList {
-
- private List<LogRecord> logRecords = new ArrayList<LogRecord>();
-
- @XmlElement(name = "logRecord", namespace = "http://cxf.apache.org/jaxrs/log")
- public List<LogRecord> getLogRecords() {
- return logRecords;
- }
-
- public void setLogRecords(List<LogRecord> logRecords) {
- Validate.notNull(logRecords, "logRecords is null");
- this.logRecords = logRecords;
- }
-
- @Override
- public boolean equals(Object obj) {
- return EqualsBuilder.reflectionEquals(obj, this);
- }
-
- @Override
- public int hashCode() {
- return HashCodeBuilder.reflectionHashCode(this);
- }
-
- @Override
- public String toString() {
- return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
- }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.cxf.jaxrs.ext.logging;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.commons.lang.Validate;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+/**
+ * List of {@link LogRecord}s. Necessary wrapper for {@link List} used in JAXB context.
+ */
+@XmlRootElement(namespace = "http://cxf.apache.org/jaxrs/log")
+public class LogRecordsList {
+
+ private List<LogRecord> logRecords = new ArrayList<LogRecord>();
+
+ @XmlElement(name = "logRecord", namespace = "http://cxf.apache.org/jaxrs/log")
+ public List<LogRecord> getLogRecords() {
+ return logRecords;
+ }
+
+ public void setLogRecords(List<LogRecord> logRecords) {
+ Validate.notNull(logRecords, "logRecords is null");
+ this.logRecords = logRecords;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return EqualsBuilder.reflectionEquals(obj, this);
+ }
+
+ @Override
+ public int hashCode() {
+ return HashCodeBuilder.reflectionHashCode(this);
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
+ }
+}
Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/LogRecordsList.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/LogRecordsList.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPushBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPushBean.java?rev=886957&r1=886956&r2=886957&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPushBean.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPushBean.java Thu Dec 3 22:26:58 2009
@@ -1,308 +1,308 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.cxf.jaxrs.ext.logging.atom;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.logging.Handler;
-import java.util.logging.Logger;
-
-import org.apache.commons.lang.Validate;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.jaxrs.ext.logging.LogLevel;
-import org.apache.cxf.jaxrs.ext.logging.atom.converter.Converter;
-import org.apache.cxf.jaxrs.ext.logging.atom.deliverer.Deliverer;
-
-/**
- * Bean used to configure {@link AtomPushHandler JUL handler} with Spring instead of properties file. See
- * {@link AtomPushHandler} class for detailed description of parameters. Next to configuration of handler,
- * Spring bean offers simple configuration of associated loggers that share ATOM push-style handler.
- * <p>
- * General rules:
- * <ul>
- * <li>When {@link #setDeliverer(Deliverer) deliverer} property is not set explicitly, URL must be set to
- * create default deliverer.</li>
- * <li>When {@link #setConverter(Converter) converter} property is not set explicitly, default converter is
- * created.</li>
- * <li>When {@link #setLoggers(String) loggers} property is used, it overrides pair of
- * {@link #setLogger(String) logger} and {@link #setLevel(String) level} properties; and vice versa.</li>
- * <li>When logger is not set, handler is attached to root logger (named ""); when level is not set for
- * logger, default "INFO" level is used.</li>
- * <li>When {@link #setBatchSize(String) batchSize} property is not set or set to wrong value, default batch
- * size of "1" is used.</li>
- * <li>When deliverer property is NOT set, use of "retryXxx" properties causes creation of retrying default
- * deliverer.</li>
- * </ul>
- * Examples:
- * <p>
- * ATOM push handler with registered with root logger for all levels or log events, pushing one feed per event
- * to specified URL, using default delivery and conversion methods:
- *
- * <pre>
- * <bean class="org.apache.cxf.jaxrs.ext.logging.atom.AtomPushBean"
- * init-method="init">
- * <property name="url" value="http://localhost:9080/feed"/>
- * <property name="level" value="ALL" />
- * </bean>
- * </pre>
- *
- * ATOM push handler registered with multiple loggers and listening for different levels (see
- * {@link #setLoggers(String) loggers} property description for syntax details). Custom deliverer will take
- * care of feeds, each of which carries batch of 10 log events:
- *
- * <pre>
- * <bean id="soapDeliverer" ...
- * ...
- * <bean class="org.apache.cxf.jaxrs.ext.logging.atom.AtomPushBean"
- * init-method="init">
- * <property name="deliverer">
- * <ref bean="soapDeliverer"/>
- * </property>
- * <property name="loggers" value="
- * org.apache.cxf:DEBUG,
- * org.apache.cxf.jaxrs,
- * org.apache.cxf.bus:ERROR" />
- * <property name="batchSize" value="10" />
- * </bean>
- * </pre>
- */
-public final class AtomPushBean {
-
- private AtomPushEngineConfigurator conf = new AtomPushEngineConfigurator();
- private List<LoggerLevel> loggers = new ArrayList<LoggerLevel>();
- private boolean initialized;
-
- /**
- * Creates unconfigured and uninitialized bean. To configure setters must be used, then {@link #init()}
- * must be called.
- */
- public AtomPushBean() {
- initSingleLogger();
- }
-
- private void initSingleLogger() {
- loggers = new ArrayList<LoggerLevel>();
- loggers.add(new LoggerLevel("", "INFO"));
- }
-
- /**
- * Set URL used when custom deliverer is not set (default deliverer is being created).
- */
- public void setUrl(String url) {
- checkInit();
- Validate.notNull(url, "url is null");
- conf.setUrl(url);
- }
-
- /**
- * Set initialized deliverer.
- */
- public void setDeliverer(Deliverer deliverer) {
- checkInit();
- Validate.notNull(deliverer, "deliverer is null");
- conf.setDeliverer(deliverer);
- }
-
- /**
- * Set initialized converter.
- */
- public void setConverter(Converter converter) {
- checkInit();
- Validate.notNull(converter, "converter is null");
- conf.setConverter(converter);
- }
-
- /**
- * Set one or more loggers and levels descriptor. <br>
- * Parsed input syntax is:
- *
- * <pre>
- * loggers := <logger>(<separator><logger>)*
- * logger := <name>[":"<level>]
- * separator := "," | " " | "\n"
- * </pre>
- *
- * Examples:
- * <p>
- * Two loggers and two levels: <br>
- * <tt>org.apache.cxf:INFO, org.apache.cxf.jaxrs:DEBUG</tt>
- * <p>
- * Three loggers, first with default "INFO" level: <br>
- * <tt>org.apache.cxf, org.apache.cxf.jaxrs:DEBUG, namedLogger:ERROR</tt><br>
- * <p>
- * One logger with default "INFO" level: <br>
- * <tt>org.apache.cxf</tt><br>
- */
- public void setLoggers(String loggers) {
- checkInit();
- Validate.notNull(loggers, "loggers is null");
- parseLoggers(loggers);
- }
-
- /**
- * Name of logger to associate with ATOM push handler; empty string for root logger.
- */
- public void setLogger(String logger) {
- checkInit();
- Validate.notNull(logger, "logger is null");
- if (loggers.size() != 1) {
- initSingleLogger();
- }
- loggers.get(0).setLogger(logger);
- }
-
- /**
- * Name of level that logger will use publishing log events to ATOM push handler; empty string for default
- * "INFO" level.
- */
- public void setLevel(String level) {
- checkInit();
- Validate.notNull(level, "level is null");
- if (loggers.size() != 1) {
- initSingleLogger();
- }
- loggers.get(0).setLevel(level);
- }
-
- /**
- * Size of batch; empty string for default one element batch.
- */
- public void setBatchSize(String batchSize) {
- checkInit();
- Validate.notNull(batchSize, "batchSize is null");
- conf.setBatchSize(batchSize);
- }
-
- /**
- * Retry pause calculation strategy, either "linear" or "exponential".
- */
- public void setRetryPause(String retryPause) {
- checkInit();
- Validate.notNull(retryPause, "retryPause is null");
- conf.setRetryPause(retryPause);
- }
-
- /**
- * Retry pause time (in seconds).
- */
- public void setRetryPauseTime(String time) {
- checkInit();
- Validate.notNull(time, "time is null");
- conf.setRetryPauseTime(time);
- }
-
- /**
- * Retry timeout (in seconds).
- */
- public void setRetryTimeout(String timeout) {
- checkInit();
- Validate.notNull(timeout, "timeout is null");
- conf.setRetryTimeout(timeout);
- }
-
- /**
- * Conversion output type: "feed" or "entry".
- */
- public void setOutput(String output) {
- checkInit();
- Validate.notNull(output, "output is null");
- conf.setOutput(output);
- }
-
- /**
- * Multiplicity of subelement of output: "one" or "many".
- */
- public void setMultiplicity(String multiplicity) {
- checkInit();
- Validate.notNull(multiplicity, "multiplicity is null");
- conf.setMultiplicity(multiplicity);
- }
-
- /**
- * Entry data format: "content" or "extension".
- */
- public void setFormat(String format) {
- checkInit();
- Validate.notNull(format, "format is null");
- conf.setFormat(format);
- }
-
- /**
- * Initializes bean; creates ATOM push handler based on current properties state, and attaches handler to
- * logger(s).
- */
- public void init() {
- checkInit();
- initialized = true;
- Handler h = new AtomPushHandler(conf.createEngine());
- for (int i = 0; i < loggers.size(); i++) {
- Logger l = LogUtils.getL7dLogger(AtomPushBean.class, null, loggers.get(i).getLogger());
- l.addHandler(h);
- l.setLevel(LogLevel.toJUL(LogLevel.valueOf(loggers.get(i).getLevel())));
- }
- }
-
- private void checkInit() {
- if (initialized) {
- throw new IllegalStateException("Bean is already initialized");
- }
- }
-
- private void parseLoggers(String param) {
- loggers = new ArrayList<LoggerLevel>();
- StringTokenizer st1 = new StringTokenizer(param, ", \t\n\r\f");
- while (st1.hasMoreTokens()) {
- String tok = st1.nextToken();
- int idx = tok.indexOf(":");
- if (idx != -1) {
- loggers.add(new LoggerLevel(tok.substring(0, idx), tok.substring(idx + 1, tok.length())));
- } else {
- loggers.add(new LoggerLevel(tok, "INFO"));
- }
- }
- }
-
- private static class LoggerLevel {
- private String logger;
- private String level;
-
- public LoggerLevel(String logger, String level) {
- this.logger = logger;
- this.level = level;
- }
-
- public String getLogger() {
- return logger;
- }
-
- public void setLogger(String logger) {
- this.logger = logger;
- }
-
- public String getLevel() {
- return level;
- }
-
- public void setLevel(String level) {
- this.level = level;
- }
-
- }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.cxf.jaxrs.ext.logging.atom;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.logging.Handler;
+import java.util.logging.Logger;
+
+import org.apache.commons.lang.Validate;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.jaxrs.ext.logging.LogLevel;
+import org.apache.cxf.jaxrs.ext.logging.atom.converter.Converter;
+import org.apache.cxf.jaxrs.ext.logging.atom.deliverer.Deliverer;
+
+/**
+ * Bean used to configure {@link AtomPushHandler JUL handler} with Spring instead of properties file. See
+ * {@link AtomPushHandler} class for detailed description of parameters. Next to configuration of handler,
+ * Spring bean offers simple configuration of associated loggers that share ATOM push-style handler.
+ * <p>
+ * General rules:
+ * <ul>
+ * <li>When {@link #setDeliverer(Deliverer) deliverer} property is not set explicitly, URL must be set to
+ * create default deliverer.</li>
+ * <li>When {@link #setConverter(Converter) converter} property is not set explicitly, default converter is
+ * created.</li>
+ * <li>When {@link #setLoggers(String) loggers} property is used, it overrides pair of
+ * {@link #setLogger(String) logger} and {@link #setLevel(String) level} properties; and vice versa.</li>
+ * <li>When logger is not set, handler is attached to root logger (named ""); when level is not set for
+ * logger, default "INFO" level is used.</li>
+ * <li>When {@link #setBatchSize(String) batchSize} property is not set or set to wrong value, default batch
+ * size of "1" is used.</li>
+ * <li>When deliverer property is NOT set, use of "retryXxx" properties causes creation of retrying default
+ * deliverer.</li>
+ * </ul>
+ * Examples:
+ * <p>
+ * ATOM push handler with registered with root logger for all levels or log events, pushing one feed per event
+ * to specified URL, using default delivery and conversion methods:
+ *
+ * <pre>
+ * <bean class="org.apache.cxf.jaxrs.ext.logging.atom.AtomPushBean"
+ * init-method="init">
+ * <property name="url" value="http://localhost:9080/feed"/>
+ * <property name="level" value="ALL" />
+ * </bean>
+ * </pre>
+ *
+ * ATOM push handler registered with multiple loggers and listening for different levels (see
+ * {@link #setLoggers(String) loggers} property description for syntax details). Custom deliverer will take
+ * care of feeds, each of which carries batch of 10 log events:
+ *
+ * <pre>
+ * <bean id="soapDeliverer" ...
+ * ...
+ * <bean class="org.apache.cxf.jaxrs.ext.logging.atom.AtomPushBean"
+ * init-method="init">
+ * <property name="deliverer">
+ * <ref bean="soapDeliverer"/>
+ * </property>
+ * <property name="loggers" value="
+ * org.apache.cxf:DEBUG,
+ * org.apache.cxf.jaxrs,
+ * org.apache.cxf.bus:ERROR" />
+ * <property name="batchSize" value="10" />
+ * </bean>
+ * </pre>
+ */
+public final class AtomPushBean {
+
+ private AtomPushEngineConfigurator conf = new AtomPushEngineConfigurator();
+ private List<LoggerLevel> loggers = new ArrayList<LoggerLevel>();
+ private boolean initialized;
+
+ /**
+ * Creates unconfigured and uninitialized bean. To configure setters must be used, then {@link #init()}
+ * must be called.
+ */
+ public AtomPushBean() {
+ initSingleLogger();
+ }
+
+ private void initSingleLogger() {
+ loggers = new ArrayList<LoggerLevel>();
+ loggers.add(new LoggerLevel("", "INFO"));
+ }
+
+ /**
+ * Set URL used when custom deliverer is not set (default deliverer is being created).
+ */
+ public void setUrl(String url) {
+ checkInit();
+ Validate.notNull(url, "url is null");
+ conf.setUrl(url);
+ }
+
+ /**
+ * Set initialized deliverer.
+ */
+ public void setDeliverer(Deliverer deliverer) {
+ checkInit();
+ Validate.notNull(deliverer, "deliverer is null");
+ conf.setDeliverer(deliverer);
+ }
+
+ /**
+ * Set initialized converter.
+ */
+ public void setConverter(Converter converter) {
+ checkInit();
+ Validate.notNull(converter, "converter is null");
+ conf.setConverter(converter);
+ }
+
+ /**
+ * Set one or more loggers and levels descriptor. <br>
+ * Parsed input syntax is:
+ *
+ * <pre>
+ * loggers := <logger>(<separator><logger>)*
+ * logger := <name>[":"<level>]
+ * separator := "," | " " | "\n"
+ * </pre>
+ *
+ * Examples:
+ * <p>
+ * Two loggers and two levels: <br>
+ * <tt>org.apache.cxf:INFO, org.apache.cxf.jaxrs:DEBUG</tt>
+ * <p>
+ * Three loggers, first with default "INFO" level: <br>
+ * <tt>org.apache.cxf, org.apache.cxf.jaxrs:DEBUG, namedLogger:ERROR</tt><br>
+ * <p>
+ * One logger with default "INFO" level: <br>
+ * <tt>org.apache.cxf</tt><br>
+ */
+ public void setLoggers(String loggers) {
+ checkInit();
+ Validate.notNull(loggers, "loggers is null");
+ parseLoggers(loggers);
+ }
+
+ /**
+ * Name of logger to associate with ATOM push handler; empty string for root logger.
+ */
+ public void setLogger(String logger) {
+ checkInit();
+ Validate.notNull(logger, "logger is null");
+ if (loggers.size() != 1) {
+ initSingleLogger();
+ }
+ loggers.get(0).setLogger(logger);
+ }
+
+ /**
+ * Name of level that logger will use publishing log events to ATOM push handler; empty string for default
+ * "INFO" level.
+ */
+ public void setLevel(String level) {
+ checkInit();
+ Validate.notNull(level, "level is null");
+ if (loggers.size() != 1) {
+ initSingleLogger();
+ }
+ loggers.get(0).setLevel(level);
+ }
+
+ /**
+ * Size of batch; empty string for default one element batch.
+ */
+ public void setBatchSize(String batchSize) {
+ checkInit();
+ Validate.notNull(batchSize, "batchSize is null");
+ conf.setBatchSize(batchSize);
+ }
+
+ /**
+ * Retry pause calculation strategy, either "linear" or "exponential".
+ */
+ public void setRetryPause(String retryPause) {
+ checkInit();
+ Validate.notNull(retryPause, "retryPause is null");
+ conf.setRetryPause(retryPause);
+ }
+
+ /**
+ * Retry pause time (in seconds).
+ */
+ public void setRetryPauseTime(String time) {
+ checkInit();
+ Validate.notNull(time, "time is null");
+ conf.setRetryPauseTime(time);
+ }
+
+ /**
+ * Retry timeout (in seconds).
+ */
+ public void setRetryTimeout(String timeout) {
+ checkInit();
+ Validate.notNull(timeout, "timeout is null");
+ conf.setRetryTimeout(timeout);
+ }
+
+ /**
+ * Conversion output type: "feed" or "entry".
+ */
+ public void setOutput(String output) {
+ checkInit();
+ Validate.notNull(output, "output is null");
+ conf.setOutput(output);
+ }
+
+ /**
+ * Multiplicity of subelement of output: "one" or "many".
+ */
+ public void setMultiplicity(String multiplicity) {
+ checkInit();
+ Validate.notNull(multiplicity, "multiplicity is null");
+ conf.setMultiplicity(multiplicity);
+ }
+
+ /**
+ * Entry data format: "content" or "extension".
+ */
+ public void setFormat(String format) {
+ checkInit();
+ Validate.notNull(format, "format is null");
+ conf.setFormat(format);
+ }
+
+ /**
+ * Initializes bean; creates ATOM push handler based on current properties state, and attaches handler to
+ * logger(s).
+ */
+ public void init() {
+ checkInit();
+ initialized = true;
+ Handler h = new AtomPushHandler(conf.createEngine());
+ for (int i = 0; i < loggers.size(); i++) {
+ Logger l = LogUtils.getL7dLogger(AtomPushBean.class, null, loggers.get(i).getLogger());
+ l.addHandler(h);
+ l.setLevel(LogLevel.toJUL(LogLevel.valueOf(loggers.get(i).getLevel())));
+ }
+ }
+
+ private void checkInit() {
+ if (initialized) {
+ throw new IllegalStateException("Bean is already initialized");
+ }
+ }
+
+ private void parseLoggers(String param) {
+ loggers = new ArrayList<LoggerLevel>();
+ StringTokenizer st1 = new StringTokenizer(param, ", \t\n\r\f");
+ while (st1.hasMoreTokens()) {
+ String tok = st1.nextToken();
+ int idx = tok.indexOf(":");
+ if (idx != -1) {
+ loggers.add(new LoggerLevel(tok.substring(0, idx), tok.substring(idx + 1, tok.length())));
+ } else {
+ loggers.add(new LoggerLevel(tok, "INFO"));
+ }
+ }
+ }
+
+ private static class LoggerLevel {
+ private String logger;
+ private String level;
+
+ public LoggerLevel(String logger, String level) {
+ this.logger = logger;
+ this.level = level;
+ }
+
+ public String getLogger() {
+ return logger;
+ }
+
+ public void setLogger(String logger) {
+ this.logger = logger;
+ }
+
+ public String getLevel() {
+ return level;
+ }
+
+ public void setLevel(String level) {
+ this.level = level;
+ }
+
+ }
+}
Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPushBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPushBean.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPushEngine.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPushEngine.java?rev=886957&r1=886956&r2=886957&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPushEngine.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPushEngine.java Thu Dec 3 22:26:58 2009
@@ -1,151 +1,151 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.cxf.jaxrs.ext.logging.atom;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import org.apache.abdera.model.Element;
-import org.apache.commons.lang.Validate;
-import org.apache.cxf.jaxrs.ext.logging.LogRecord;
-import org.apache.cxf.jaxrs.ext.logging.atom.converter.Converter;
-import org.apache.cxf.jaxrs.ext.logging.atom.deliverer.Deliverer;
-
-/**
- * Package private ATOM push-style engine. Engine enqueues log records as they are {@link #publish(LogRecord)
- * published}. After queue size exceeds {@link #getBatchSize() batch size} processing of collection of these
- * records (in size of batch size) is triggered.
- * <p>
- * Processing is done in separate thread not to block publishing interface. Processing is two step: first list
- * of log records is transformed by {@link Converter converter} to ATOM {@link Element element} and then it is
- * pushed out by {@link Deliverer deliverer} to client. Next to transport deliverer is indirectly responsible
- * for marshaling ATOM element to XML.
- * <p>
- * Processing is done by single threaded {@link java.util.concurrent.Executor executor}; next batch of records
- * is taken from queue only when currently processed batch finishes and queue has enough elements to proceed.
- * <p>
- * First failure of any delivery shuts engine down. To avoid this situation engine must have registered
- * reliable deliverer or use wrapping
- * {@link org.apache.cxf.jaxrs.ext.logging.atom.deliverer.RetryingDeliverer}.
- */
-// TODO add internal diagnostics - log messages somewhere except for logger :D
-final class AtomPushEngine {
- private List<LogRecord> queue = new ArrayList<LogRecord>();
- private ExecutorService executor = Executors.newSingleThreadExecutor();
- private int batchSize = 1;
- private Converter converter;
- private Deliverer deliverer;
-
- /**
- * Put record to publishing queue. Engine accepts published records only if is in proper state - is
- * properly configured (has deliverer and converter registered) and is not shot down; otherwise calls to
- * publish are ignored.
- *
- * @param record record to be published.
- */
- public synchronized void publish(LogRecord record) {
- Validate.notNull(record, "record is null");
- if (isValid()) {
- queue.add(record);
- if (queue.size() >= batchSize) {
- publishBatch(queue);
- queue = new ArrayList<LogRecord>();
- }
- }
- }
-
- /**
- * Shuts engine down.
- */
- public synchronized void shutdown() {
- executor.shutdownNow();
- }
-
- private boolean isValid() {
- if (deliverer == null) {
- // TODO report cause
- System.err.println("deliverer is not set");
- return false;
- }
- if (converter == null) {
- System.err.println("converter is not set");
- return false;
- }
- if (executor.isShutdown()) {
- System.err.println("engine shutdown");
- return false;
- }
- return true;
- }
-
- private void publishBatch(final List<LogRecord> batch) {
- executor.execute(new Runnable() {
- public void run() {
- try {
- LoggingThread.markSilent(true);
- // syncing for safe converter/deliverer on the fly replacement
- synchronized (this) {
- // TODO diagnostic output here: System.out.println(element.toString());
- List<? extends Element> elements = converter.convert(batch);
- for (Element element : elements) {
- if (!deliverer.deliver(element)) {
- System.err.println("Delivery failed, shutting engine down");
- executor.shutdownNow();
- break;
- }
- }
- }
- } catch (InterruptedException e) {
- // no action on executor.shutdownNow();
- } finally {
- LoggingThread.markSilent(false);
- }
- }
- });
- }
-
- public int getBatchSize() {
- return batchSize;
- }
-
- public void setBatchSize(int batchSize) {
- Validate.isTrue(batchSize > 0, "batch size is not greater than zero");
- this.batchSize = batchSize;
- }
-
- public Converter getConverter() {
- return converter;
- }
-
- public synchronized void setConverter(Converter converter) {
- Validate.notNull(converter, "converter is null");
- this.converter = converter;
- }
-
- public Deliverer getDeliverer() {
- return deliverer;
- }
-
- public synchronized void setDeliverer(Deliverer deliverer) {
- Validate.notNull(deliverer, "deliverer is null");
- this.deliverer = deliverer;
- }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.cxf.jaxrs.ext.logging.atom;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.apache.abdera.model.Element;
+import org.apache.commons.lang.Validate;
+import org.apache.cxf.jaxrs.ext.logging.LogRecord;
+import org.apache.cxf.jaxrs.ext.logging.atom.converter.Converter;
+import org.apache.cxf.jaxrs.ext.logging.atom.deliverer.Deliverer;
+
+/**
+ * Package private ATOM push-style engine. Engine enqueues log records as they are {@link #publish(LogRecord)
+ * published}. After queue size exceeds {@link #getBatchSize() batch size} processing of collection of these
+ * records (in size of batch size) is triggered.
+ * <p>
+ * Processing is done in separate thread not to block publishing interface. Processing is two step: first list
+ * of log records is transformed by {@link Converter converter} to ATOM {@link Element element} and then it is
+ * pushed out by {@link Deliverer deliverer} to client. Next to transport deliverer is indirectly responsible
+ * for marshaling ATOM element to XML.
+ * <p>
+ * Processing is done by single threaded {@link java.util.concurrent.Executor executor}; next batch of records
+ * is taken from queue only when currently processed batch finishes and queue has enough elements to proceed.
+ * <p>
+ * First failure of any delivery shuts engine down. To avoid this situation engine must have registered
+ * reliable deliverer or use wrapping
+ * {@link org.apache.cxf.jaxrs.ext.logging.atom.deliverer.RetryingDeliverer}.
+ */
+// TODO add internal diagnostics - log messages somewhere except for logger :D
+final class AtomPushEngine {
+ private List<LogRecord> queue = new ArrayList<LogRecord>();
+ private ExecutorService executor = Executors.newSingleThreadExecutor();
+ private int batchSize = 1;
+ private Converter converter;
+ private Deliverer deliverer;
+
+ /**
+ * Put record to publishing queue. Engine accepts published records only if is in proper state - is
+ * properly configured (has deliverer and converter registered) and is not shot down; otherwise calls to
+ * publish are ignored.
+ *
+ * @param record record to be published.
+ */
+ public synchronized void publish(LogRecord record) {
+ Validate.notNull(record, "record is null");
+ if (isValid()) {
+ queue.add(record);
+ if (queue.size() >= batchSize) {
+ publishBatch(queue);
+ queue = new ArrayList<LogRecord>();
+ }
+ }
+ }
+
+ /**
+ * Shuts engine down.
+ */
+ public synchronized void shutdown() {
+ executor.shutdownNow();
+ }
+
+ private boolean isValid() {
+ if (deliverer == null) {
+ // TODO report cause
+ System.err.println("deliverer is not set");
+ return false;
+ }
+ if (converter == null) {
+ System.err.println("converter is not set");
+ return false;
+ }
+ if (executor.isShutdown()) {
+ System.err.println("engine shutdown");
+ return false;
+ }
+ return true;
+ }
+
+ private void publishBatch(final List<LogRecord> batch) {
+ executor.execute(new Runnable() {
+ public void run() {
+ try {
+ LoggingThread.markSilent(true);
+ // syncing for safe converter/deliverer on the fly replacement
+ synchronized (this) {
+ // TODO diagnostic output here: System.out.println(element.toString());
+ List<? extends Element> elements = converter.convert(batch);
+ for (Element element : elements) {
+ if (!deliverer.deliver(element)) {
+ System.err.println("Delivery failed, shutting engine down");
+ executor.shutdownNow();
+ break;
+ }
+ }
+ }
+ } catch (InterruptedException e) {
+ // no action on executor.shutdownNow();
+ } finally {
+ LoggingThread.markSilent(false);
+ }
+ }
+ });
+ }
+
+ public int getBatchSize() {
+ return batchSize;
+ }
+
+ public void setBatchSize(int batchSize) {
+ Validate.isTrue(batchSize > 0, "batch size is not greater than zero");
+ this.batchSize = batchSize;
+ }
+
+ public Converter getConverter() {
+ return converter;
+ }
+
+ public synchronized void setConverter(Converter converter) {
+ Validate.notNull(converter, "converter is null");
+ this.converter = converter;
+ }
+
+ public Deliverer getDeliverer() {
+ return deliverer;
+ }
+
+ public synchronized void setDeliverer(Deliverer deliverer) {
+ Validate.notNull(deliverer, "deliverer is null");
+ this.deliverer = deliverer;
+ }
+}
Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPushEngine.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPushEngine.java
------------------------------------------------------------------------------
svn:keywords = Rev Date