cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amicha...@apache.org
Subject svn commit: r884657 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/converter/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/loggin...
Date Thu, 26 Nov 2009 18:08:38 GMT
Author: amichalec
Date: Thu Nov 26 18:08:37 2009
New Revision: 884657

URL: http://svn.apache.org/viewvc?rev=884657&view=rev
Log:
Simpler configuration, AtomPub support, refactoring.

Added:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/converter/
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/converter/Converter.java
      - copied, changed from r883650, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/Converter.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/converter/StandardConverter.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/deliverer/
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/deliverer/Deliverer.java
      - copied, changed from r883650, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/Deliverer.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/deliverer/FireAndForgetDeliverer.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/deliverer/RetryingDeliverer.java
      - copied, changed from r883650, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/RetryingDeliverer.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/deliverer/WebClientDeliverer.java
      - copied, changed from r883650, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/WebClientDeliverer.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/logging_atompush_atompub.properties
Removed:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/Converter.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/Deliverer.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/MultiEntryContentConverter.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/MultiEntryExtensionConverter.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/RetryingDeliverer.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/SingleEntryContentConverter.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/SingleEntryExtensionConverter.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/WebClientDeliverer.java
Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPushBean.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPushEngine.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPushEngineConfigurator.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPushHandler.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPushSpringTest.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPushTest.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/logging_atompush.properties
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/logging_atompush_batch.properties

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=884657&r1=884656&r2=884657&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 Nov 26 18:08:37 2009
@@ -27,6 +27,8 @@
 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. Next to
@@ -81,6 +83,7 @@
  *   </bean>
  * </pre>
  */
+// TODO add support for conversion setup (output, entries, logs, format)
 public final class AtomPushBean {
 
     private AtomPushEngineConfigurator conf = new AtomPushEngineConfigurator();
@@ -187,7 +190,7 @@
         Validate.notNull(batchSize, "batchSize is null");
         conf.setBatchSize(batchSize);
     }
-    
+
     /**
      * Retry pause calculation strategy, either "linear" or "exponential".
      */
@@ -214,7 +217,7 @@
         Validate.notNull(timeout, "timeout is null");
         conf.setRetryTimeout(timeout);
     }
-    
+
     /**
      * Initializes bean; creates ATOM push handler based on current properties state, and attaches handler to
      * logger(s).

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=884657&r1=884656&r2=884657&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 Nov 26 18:08:37 2009
@@ -26,6 +26,8 @@
 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)
@@ -41,7 +43,8 @@
  * 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 RetryingDeliverer}.
+ * 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 {
@@ -101,10 +104,13 @@
                     // syncing for safe converter/deliverer on the fly replacement
                     synchronized (this) {
                         // TODO diagnostic output here: System.out.println(element.toString());
-                        Element element = converter.convert(batch);
-                        if (!deliverer.deliver(element)) {
-                            System.err.println("Delivery failed, shutting engine down");
-                            executor.shutdownNow();
+                        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) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPushEngineConfigurator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPushEngineConfigurator.java?rev=884657&r1=884656&r2=884657&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPushEngineConfigurator.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPushEngineConfigurator.java Thu Nov 26 18:08:37 2009
@@ -20,6 +20,15 @@
 
 import java.lang.reflect.Constructor;
 
+import org.apache.cxf.jaxrs.ext.logging.atom.converter.Converter;
+import org.apache.cxf.jaxrs.ext.logging.atom.converter.StandardConverter;
+import org.apache.cxf.jaxrs.ext.logging.atom.converter.StandardConverter.Format;
+import org.apache.cxf.jaxrs.ext.logging.atom.converter.StandardConverter.Multiplicity;
+import org.apache.cxf.jaxrs.ext.logging.atom.converter.StandardConverter.Output;
+import org.apache.cxf.jaxrs.ext.logging.atom.deliverer.Deliverer;
+import org.apache.cxf.jaxrs.ext.logging.atom.deliverer.RetryingDeliverer;
+import org.apache.cxf.jaxrs.ext.logging.atom.deliverer.WebClientDeliverer;
+
 /**
  * Package private interpreter of incomplete input of engine configuration. Used commonly by
  * {@link AtomPushHandler properties file} and {@link AtomPushBean spring} configuration schemes.
@@ -36,6 +45,9 @@
     private String retryTimeout;
     private String retryPause;
     private String retryPauseTime;
+    private String output;
+    private String multiplicity;
+    private String format;
 
     public void setUrl(String url) {
         this.delivererUrl = url;
@@ -73,10 +85,21 @@
         this.converterClass = converterClass;
     }
 
+    public void setOutput(String output) {
+        this.output = output;
+    }
+
+    public void setMultiplicity(String multiplicity) {
+        this.multiplicity = multiplicity;
+    }
+
+    public void setFormat(String format) {
+        this.format = format;
+    }
+
     public AtomPushEngine createEngine() {
         Deliverer d = deliverer;
         Converter c = converter;
-        int batch = 1;
         if (d == null) {
             if (delivererUrl != null) {
                 if (delivererClass != null) {
@@ -93,10 +116,13 @@
             if (converterClass != null) {
                 c = createConverter(converterClass);
             } else {
-                c = new SingleEntryContentConverter();
+                Output out = parseEnum(output, Output.FEED);
+                Multiplicity mul = parseEnum(multiplicity, Multiplicity.ONE);
+                Format form = parseEnum(format, Format.CONTENT);
+                c = new StandardConverter(out, mul, form);
             }
         }
-        batch = parseInt(batchSize, 1, 1);
+        int batch = parseInt(batchSize, 1, 1);
         if (retryPause != null) {
             int timeout = parseInt(retryTimeout, 0, 0);
             int pause = parseInt(retryPauseTime, 1, 30);
@@ -112,8 +138,8 @@
 
     private Deliverer createDeliverer(String clazz, String url) {
         try {
-            Constructor<?> ctor = loadClass(clazz).getConstructor(String.class);
-            return (Deliverer)ctor.newInstance(url);
+            Constructor<Deliverer> ctor = loadClass(clazz, Deliverer.class).getConstructor(String.class);
+            return ctor.newInstance(url);
         } catch (Exception e) {
             throw new IllegalArgumentException(e);
         }
@@ -121,22 +147,24 @@
 
     private Converter createConverter(String clazz) {
         try {
-            Constructor<?> ctor = loadClass(clazz).getConstructor();
-            return (Converter)ctor.newInstance();
+            Constructor<Converter> ctor = loadClass(clazz, Converter.class).getConstructor();
+            return ctor.newInstance();
         } catch (Exception e) {
             throw new IllegalArgumentException(e);
         }
     }
 
-    private Class<?> loadClass(String clazz) throws ClassNotFoundException {
+    @SuppressWarnings("unchecked")
+    private <T> Class<T> loadClass(String clazz, Class<T> ifaceClass) throws ClassNotFoundException {
         ClassLoader cl = Thread.currentThread().getContextClassLoader();
         try {
-            return cl.loadClass(clazz);
+            return (Class<T>)cl.loadClass(clazz);
         } catch (ClassNotFoundException e) {
             try {
-                // clazz could be shorted (stripped package name) retry
-                String clazz2 = getClass().getPackage().getName() + "." + clazz;
-                return cl.loadClass(clazz2);
+                // clazz could be shorted (stripped package name) retry for interface location
+                String pkg = ifaceClass.getPackage().getName();
+                String clazz2 = pkg + "." + clazz;
+                return (Class<T>)cl.loadClass(clazz2);
             } catch (Exception e1) {
                 throw new ClassNotFoundException(e.getMessage() + " or " + e1.getMessage());
             }
@@ -158,4 +186,16 @@
         }
         return ret;
     }
+
+    @SuppressWarnings("unchecked")
+    private <T extends Enum<T>> T parseEnum(String value, T defaultValue) {
+        if (value == null | "".equals(value)) {
+            return defaultValue;
+        }
+        try {
+            return (T)Enum.valueOf(defaultValue.getClass(), value.toUpperCase());
+        } catch (Exception e) {
+            return defaultValue;
+        }
+    }
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPushHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPushHandler.java?rev=884657&r1=884656&r2=884657&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPushHandler.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPushHandler.java Thu Nov 26 18:08:37 2009
@@ -22,30 +22,36 @@
 import java.util.logging.LogManager;
 
 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;
 
 /**
- * Handler pushing log records in batches as Atom Feeds to registered client. Handler responsibility is to
- * adapt to JUL framework while most of job is delegated to {@link AtomPushEngine}.
+ * Handler pushing log records in batches as Atom Feeds or Entries to registered client. Handler
+ * responsibility is to adapt to JUL framework while most of job is delegated to {@link AtomPushEngine}.
  * <p>
  * For simple configuration using properties file (one global root-level handler of this class) following
- * properties prefixed with full class name can be used:
+ * properties prefixed with full name of this class can be used:
  * <ul>
  * <li><b>url</b> - URL where feeds will be pushed (mandatory parameter)</li>
- * <li><b>converter</b> - name of class implementing {@link Converter} class. For classes from this package
- * only class name can be given e.g. instead of
- * "org.apache.cxf.jaxrs.ext.logging.atom.ContentSingleEntryConverter" one can specify
- * "ContentSingleEntryConverter". If parameter is not set {@link SingleEntryContentConverter} is used.</li>
- * <li><b>deliverer</b> - name of class implementing {@link Deliverer} class. For classes from this package
- * only class name can be given e.g. instead of "org.apache.cxf.jaxrs.ext.logging.atom.WebClientDeliverer" one
- * can specify "WebClientDeliverer". If parameter is not set {@link WebClientDeliverer} is used.</li>
  * <li><b>batchSize</b> - integer number specifying minimal number of published log records that trigger
  * processing and pushing ATOM document. If parameter is not set, is not greater than zero or is not a number,
  * batch size is set to 1.</li>
  * </ul>
- * Family of <tt>retry</tt> parameters below; availability of any of this parameters enables delivery retrying
- * (e.g. for default non-reliable deliverers) with {@link RetryingDeliverer} that can be combined with
- * provided non-reliable deliverers. Detailed explanation of these parameter, see {@link RetryingDeliverer}
- * class description.
+ * Conversion of log records into ATOM Elements can be tuned up using following parameters. Note that not all
+ * combinations are meaningful, see {@link org.apache.cxf.jaxrs.ext.logging.atom.converter.StandardConverter}
+ * for details:
+ * <ul>
+ * <li><b>output</b> - ATOM Element type pushed out, either "feed" or "entry"; when not specified or invalid
+ * value provided "feed" is used.</li>
+ * <li><b>multiplicity</b> - multiplicity of subelement(entries in feed for output=="feed" or log records in
+ * entry for output=="entry"), either "one" or "many"; when not specified or invalid value provided "one" is
+ * used.</li>
+ * <li><b>format</b> - method of embedding data in entry, either "content" or "extension"; when not specified
+ * or invalid value provided "content" is used.</li>
+ * </ul>
+ * By default delivery is served by WebClientDeliverer which does not support reliability of transport.
+ * Availability of any of this parameters enables retrying of default delivery. Detailed explanation of these
+ * parameter, see {@link org.apache.cxf.jaxrs.ext.logging.atom.deliverer.RetryingDeliverer} class description.
  * <ul>
  * <li><b>retry.pause</b> - pausing strategy of delivery retries, either <b>linear</b> or <b>exponential</b>
  * value (mandatory parameter). If mispelled linear is used.</li>
@@ -54,19 +60,37 @@
  * <li><b>retry.timeout</b> - maximum time (in seconds) retrying will be continued. If not set timeout is not
  * set (infinite loop of retries).</li>
  * </ul>
+ * Ultimate control on conversion and delivery is obtained specifying own implementation classes:
+ * <ul>
+ * <li><b>converter</b> - name of class implementing {@link Converter} class replacing default conversion and
+ * its specific parameters ("output", "multiplicity" and "format") are ignored. For classes located in same
+ * package as Converter interface only class name can be given e.g. instead of
+ * "org.apache.cxf.jaxrs.ext.logging.atom.converter.FooBarConverter" one can specify "FooBarConverter".</li>
+ * <li><b>deliverer</b> - name of class implementing {@link Deliverer} class replacing default delivery and
+ * its specific parameters ("retry.Xxx") are ignored. For classes located in same package as Deliverer
+ * interface only class name can be given e.g. instead of
+ * "org.apache.cxf.jaxrs.ext.logging.atom.deliverer.WebClientDeliverer" one can specify 
+ * "WebClientDeliverer".</li>
+ * </ul>
  * Example:
  * 
  * <pre>
  * handlers = org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler, java.util.logging.ConsoleHandler
  * .level = INFO
- * ...
+ * 
+ * # deliver to given URL triggering after each batch of 10 log records
  * org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.url = http://localhost:9080
  * org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.batchSize = 10
- * org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.deliverer = WebClientDeliverer 
- * org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.converter = foo.bar.MyConverter
+ * 
+ * # enable retrying delivery every 10 seconds for 5 minutes
  * org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.retry.pause = linear
  * org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.retry.pause.time = 10
- * org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.retry.timeout = 360
+ * org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.retry.timeout = 300
+ * 
+ * # output for AtomPub: push entries not feeds, each entry with one log record as &quot;atom:extension&quot; 
+ * org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.output = entry
+ * org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.multiplicity = one
+ * org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.format = extension
  * ...
  * </pre>
  */
@@ -152,6 +176,9 @@
         conf.setRetryPause(manager.getProperty(cname + ".retry.pause"));
         conf.setRetryPauseTime(manager.getProperty(cname + ".retry.pause.time"));
         conf.setRetryTimeout(manager.getProperty(cname + ".retry.timeout"));
+        conf.setOutput(manager.getProperty(cname + ".output"));
+        conf.setMultiplicity(manager.getProperty(cname + ".multiplicity"));
+        conf.setFormat(manager.getProperty(cname + ".format"));
         engine = conf.createEngine();
     }
 }

Copied: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/converter/Converter.java (from r883650, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/Converter.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/converter/Converter.java?p2=cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/converter/Converter.java&p1=cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/Converter.java&r1=883650&r2=884657&rev=884657&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/Converter.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/converter/Converter.java Thu Nov 26 18:08:37 2009
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.cxf.jaxrs.ext.logging.atom;
+package org.apache.cxf.jaxrs.ext.logging.atom.converter;
 
 import java.util.List;
 
@@ -24,16 +24,15 @@
 import org.apache.cxf.jaxrs.ext.logging.LogRecord;
 
 /**
- * Converts batch of log records into ATOM element to deliver. Represents strategies of conversion e.g. as
- * ATOM format extensions, as Entry content etc.
+ * Converts batch of log records into one or more ATOM Elements to deliver.
  */
 public interface Converter {
 
     /**
-     * Converts collection of log records into ATOM element.
+     * Converts given collection.
      * 
      * @param records not-null collection of records
-     * @return ATOM document representing records
+     * @return non-empty collection of ATOM Elements that represent log records
      */
-    Element convert(List<LogRecord> records);
+    List<? extends Element> convert(List<LogRecord> records);
 }

Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/converter/StandardConverter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/converter/StandardConverter.java?rev=884657&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/converter/StandardConverter.java (added)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/converter/StandardConverter.java Thu Nov 26 18:08:37 2009
@@ -0,0 +1,253 @@
+/**
+ * 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.converter;
+
+import java.io.StringWriter;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Content;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.ExtensibleElement;
+import org.apache.abdera.model.Feed;
+import org.apache.commons.lang.Validate;
+import org.apache.cxf.jaxrs.ext.logging.LogRecord;
+import org.apache.cxf.jaxrs.ext.logging.LogRecordsList;
+
+/**
+ * Converter producing ATOM Feeds on standalone Entries with LogRecords or LogRecordsLists embedded as content
+ * or extension. For configuration details see constructor documentation.
+ */
+public class StandardConverter implements Converter {
+
+    /** Conversion output */
+    public enum Output {
+        FEED,
+        ENTRY
+    }
+
+    /** Quantities of entries in feed or logrecords in entry */
+    public enum Multiplicity {
+        ONE,
+        MANY
+    }
+
+    /** Entity format */
+    public enum Format {
+        CONTENT,
+        EXTENSION
+    }
+
+    private Factory factory;
+    private Marshaller marsh;
+    private DateFormat df;
+    private Converter worker;
+
+    /**
+     * Creates configured converter. Regardless of "format", combination of "output" and "multiplicity" flags
+     * can be interpreted as follow:
+     * <ul>
+     * <li>ENTRY ONE - for each log record one entry is produced, converter returns list of entries</li>
+     * <li>ENTRY MANY - list of log records is packed in one entry, converter return one entry.</li>
+     * <li>FEED ONE - list of log records is packed in one entry, entry is inserted to feed, converter returns
+     * one feed.</li>
+     * <li>FEED MANY - for each log record one entry is produced, entries are collected in one feed, converter
+     * returns one feed.</li>
+     * </ul>
+     * 
+     * @param output whether root elements if Feed or Entry (e.g. for AtomPub).
+     * @param multiplicity for output==FEED it is multiplicity of entities in feed for output==ENTITY it is
+     *            multiplicity of log records in entity.
+     * @param format log records embedded as entry content or extension.
+     */
+    public StandardConverter(Output output, Multiplicity multiplicity, Format format) {
+        Validate.notNull(output, "output is null");
+        Validate.notNull(multiplicity, "multiplicity is null");
+        Validate.notNull(format, "format is null");
+        configure(output, multiplicity, format);
+        df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
+        factory = Abdera.getNewFactory();
+        try {
+            marsh = JAXBContext.newInstance(LogRecordsList.class).createMarshaller();
+        } catch (JAXBException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public List<? extends Element> convert(List<LogRecord> records) {
+        return worker.convert(records);
+    }
+
+    private void configure(final Output output, final Multiplicity multiplicity, final Format format) {
+        if (output == Output.ENTRY && multiplicity == Multiplicity.ONE) {
+            worker = new Converter() {
+                public List<? extends Element> convert(List<LogRecord> records) {
+                    // produces many entries, each entry with one log record
+                    List<Element> ret = new ArrayList<Element>();
+                    for (LogRecord record : records) {
+                        if (format == Format.CONTENT) {
+                            ret.add(createEntry(createContent(record)));
+                        } else {
+                            ret.add(createEntry(createExtension(record)));
+                        }
+                    }
+                    return ret;
+                }
+            };
+        }
+        if (output == Output.ENTRY && multiplicity == Multiplicity.MANY) {
+            worker = new Converter() {
+                public List<? extends Element> convert(List<LogRecord> records) {
+                    // produces one entry with list of all log records
+                    if (format == Format.CONTENT) {
+                        return Arrays.asList(createEntry(createContent(records)));
+                    } else {
+                        return Arrays.asList(createEntry(createExtension(records)));
+                    }
+                }
+            };
+        }
+        if (output == Output.FEED && multiplicity == Multiplicity.ONE) {
+            worker = new Converter() {
+                public List<? extends Element> convert(List<LogRecord> records) {
+                    // produces one feed with one entry with list of all log records
+                    if (format == Format.CONTENT) {
+                        return Arrays.asList(createFeed(createEntry(createContent(records))));
+                    } else {
+                        return Arrays.asList(createFeed(createEntry(createExtension(records))));
+                    }
+                }
+            };
+        }
+        if (output == Output.FEED && multiplicity == Multiplicity.MANY) {
+            worker = new Converter() {
+                public List<? extends Element> convert(List<LogRecord> records) {
+                    // produces one feed with many entries, each entry with one log record
+                    List<Entry> entries = new ArrayList<Entry>();
+                    for (LogRecord record : records) {
+                        if (format == Format.CONTENT) {
+                            entries.add(createEntry(createContent(record)));
+                        } else {
+                            entries.add(createEntry(createExtension(record)));
+                        }
+                    }
+                    return Arrays.asList(createFeed(entries));
+                }
+            };
+        }
+        if (worker == null) {
+            throw new IllegalArgumentException("Unsupported configuration");
+        }
+    }
+
+    private String createContent(LogRecord record) {
+        StringWriter writer = new StringWriter();
+        try {
+            marsh.marshal(record, writer);
+        } catch (JAXBException e) {
+            throw new RuntimeException(e);
+        }
+        return writer.toString();
+    }
+
+    private String createContent(List<LogRecord> records) {
+        StringWriter writer = new StringWriter();
+        LogRecordsList list = new LogRecordsList();
+        list.setLogRecords(records);
+        try {
+            marsh.marshal(list, writer);
+        } catch (JAXBException e) {
+            throw new RuntimeException(e);
+        }
+        return writer.toString();
+    }
+
+    private ExtensibleElement createExtension(LogRecord record) {
+        ExtensibleElement erec = factory.newExtensionElement(qn("logRecord"));
+        String date = df.format(record.getEventTimestamp());
+        // timezone in date does not have semicolon as XML Date requires
+        // e.g we have "2009-11-23T22:03:53.996+0100"
+        // instead of "2009-11-23T22:03:53.996+01:00"
+        date = date.substring(0, date.length() - 2) + ":" + date.substring(date.length() - 2);
+        // forget about single line "addExtension().setText()" since
+        // javac failure "org.apache.abdera.model.Element cannot be dereferenced"
+        Element e = erec.addExtension(qn("eventTimestamp"));
+        e.setText(date);
+        e = erec.addExtension(qn("level"));
+        e.setText(record.getLevel().toString());
+        e = erec.addExtension(qn("loggerName"));
+        e.setText(record.getLoggerName());
+        e = erec.addExtension(qn("message"));
+        e.setText(record.getMessage());
+        e = erec.addExtension(qn("threadName"));
+        e.setText(record.getThreadName());
+        e = erec.addExtension(qn("throwable"));
+        e.setText(record.getThrowable());
+        return erec;
+    }
+
+    private QName qn(String name) {
+        return new QName("http://cxf.apache.org/jaxrs/log", name, "log");
+    }
+
+    private ExtensibleElement createExtension(List<LogRecord> records) {
+        ExtensibleElement list = factory.newExtensionElement(qn("logRecordsList"));
+        for (LogRecord rec : records) {
+            list.addExtension(createExtension(rec));
+        }
+        return list;
+    }
+
+    private Entry createEntry(String content) {
+        Entry entry = factory.newEntry();
+        entry.setContent(content, Content.Type.XML);
+        return entry;
+    }
+
+    private Entry createEntry(ExtensibleElement ext) {
+        Entry entry = factory.newEntry();
+        entry.addExtension(ext);
+        return entry;
+    }
+
+    private Feed createFeed(Entry entry) {
+        Feed feed = factory.newFeed();
+        feed.addEntry(entry);
+        return feed;
+    }
+
+    private Feed createFeed(List<Entry> entries) {
+        Feed feed = factory.newFeed();
+        for (Entry entry : entries) {
+            feed.addEntry(entry);
+        }
+        return feed;
+    }
+}

Copied: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/deliverer/Deliverer.java (from r883650, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/Deliverer.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/deliverer/Deliverer.java?p2=cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/deliverer/Deliverer.java&p1=cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/Deliverer.java&r1=883650&r2=884657&rev=884657&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/Deliverer.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/deliverer/Deliverer.java Thu Nov 26 18:08:37 2009
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.cxf.jaxrs.ext.logging.atom;
+package org.apache.cxf.jaxrs.ext.logging.atom.deliverer;
 
 import org.apache.abdera.model.Element;
 

Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/deliverer/FireAndForgetDeliverer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/deliverer/FireAndForgetDeliverer.java?rev=884657&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/deliverer/FireAndForgetDeliverer.java (added)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/deliverer/FireAndForgetDeliverer.java Thu Nov 26 18:08:37 2009
@@ -0,0 +1,41 @@
+/**
+ * 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.deliverer;
+
+import org.apache.abdera.model.Element;
+import org.apache.commons.lang.Validate;
+
+/**
+ * Fires delivery of wrapper deliverer and forgets about status always assuming success. Fire-and-forget works
+ * only for regular flow, runtime and interrupted exceptions are not handled.
+ */
+public final class FireAndForgetDeliverer implements Deliverer {
+
+    private Deliverer deliverer;
+
+    public FireAndForgetDeliverer(Deliverer worker) {
+        Validate.notNull(worker, "worker is null");
+        deliverer = worker;
+    }
+
+    public boolean deliver(Element element) throws InterruptedException {
+        deliverer.deliver(element);
+        return true;
+    }
+}

Copied: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/deliverer/RetryingDeliverer.java (from r883650, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/RetryingDeliverer.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/deliverer/RetryingDeliverer.java?p2=cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/deliverer/RetryingDeliverer.java&p1=cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/RetryingDeliverer.java&r1=883650&r2=884657&rev=884657&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/RetryingDeliverer.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/deliverer/RetryingDeliverer.java Thu Nov 26 18:08:37 2009
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.cxf.jaxrs.ext.logging.atom;
+package org.apache.cxf.jaxrs.ext.logging.atom.deliverer;
 
 import java.util.Calendar;
 import java.util.Date;
@@ -30,7 +30,7 @@
  * is configurable strategy. Two predefined strategies are given: each time pause same amount of time (linear)
  * and each next time pause time doubles (exponential).
  */
-public class RetryingDeliverer implements Deliverer {
+public final class RetryingDeliverer implements Deliverer {
 
     private Deliverer deliverer;
     private PauseCalculator pauser;
@@ -83,16 +83,22 @@
             if (timeout == 0 || timeoutDate.after(cal.getTime())) {
                 Thread.sleep(sleep * 1000);
             } else {
+                pauser.reset();
                 return false;
             }
         }
+        pauser.reset();
         return true;
     }
 
     /** Calculates time of subsequent pauses between delivery attempts. */
     public interface PauseCalculator {
+
         /** Time of next pause (in seconds). */
         int nextPause();
+
+        /** Restarts calculation. */
+        void reset();
     }
 
     private static class ConstantPause implements PauseCalculator {
@@ -105,19 +111,28 @@
         public int nextPause() {
             return pause;
         }
+
+        public void reset() {
+        }
     }
 
     private static class ExponentialPause implements PauseCalculator {
         private int pause;
+        private int current;
 
         public ExponentialPause(int pause) {
             this.pause = pause;
+            current = pause;
         }
 
         public int nextPause() {
-            int curr = pause;
-            pause *= 2;
-            return curr;
+            int c = current;
+            current *= 2;
+            return c;
+        }
+
+        public void reset() {
+            current = pause;
         }
     }
 

Copied: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/deliverer/WebClientDeliverer.java (from r883650, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/WebClientDeliverer.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/deliverer/WebClientDeliverer.java?p2=cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/deliverer/WebClientDeliverer.java&p1=cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/WebClientDeliverer.java&r1=883650&r2=884657&rev=884657&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/WebClientDeliverer.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/deliverer/WebClientDeliverer.java Thu Nov 26 18:08:37 2009
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.cxf.jaxrs.ext.logging.atom;
+package org.apache.cxf.jaxrs.ext.logging.atom.deliverer;
 
 import java.util.Arrays;
 import java.util.List;
@@ -32,7 +32,7 @@
 /**
  * Marshaling and delivering based on JAXRS' WebClient.
  */
-public class WebClientDeliverer implements Deliverer {
+public final class WebClientDeliverer implements Deliverer {
     private WebClient wc;
 
     @SuppressWarnings("unchecked")

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPushSpringTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPushSpringTest.java?rev=884657&r1=884656&r2=884657&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPushSpringTest.java (original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPushSpringTest.java Thu Nov 26 18:08:37 2009
@@ -28,6 +28,7 @@
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 
+import org.apache.abdera.model.Element;
 import org.apache.abdera.model.Feed;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.jaxrs.client.WebClient;
@@ -40,7 +41,7 @@
 
 public class JAXRSLoggingAtomPushSpringTest extends AbstractClientServerTestBase {
 
-    private static List<Feed> retrieved = new ArrayList<Feed>();
+    private static List<Element> retrieved = new ArrayList<Element>();
 
     @BeforeClass
     public static void beforeClass() throws Exception {
@@ -97,7 +98,6 @@
             // System.out.println(feed);
             retrieved.add(feed);
         }
-
     }
 
     @Test

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPushTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPushTest.java?rev=884657&r1=884656&r2=884657&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPushTest.java (original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPushTest.java Thu Nov 26 18:08:37 2009
@@ -31,14 +31,19 @@
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 
-import org.apache.abdera.model.Element;
+import org.apache.abdera.model.Entry;
 import org.apache.abdera.model.Feed;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
 import org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler;
-import org.apache.cxf.jaxrs.ext.logging.atom.SingleEntryContentConverter;
-import org.apache.cxf.jaxrs.ext.logging.atom.WebClientDeliverer;
+import org.apache.cxf.jaxrs.ext.logging.atom.converter.Converter;
+import org.apache.cxf.jaxrs.ext.logging.atom.converter.StandardConverter;
+import org.apache.cxf.jaxrs.ext.logging.atom.converter.StandardConverter.Format;
+import org.apache.cxf.jaxrs.ext.logging.atom.converter.StandardConverter.Multiplicity;
+import org.apache.cxf.jaxrs.ext.logging.atom.converter.StandardConverter.Output;
+import org.apache.cxf.jaxrs.ext.logging.atom.deliverer.Deliverer;
+import org.apache.cxf.jaxrs.ext.logging.atom.deliverer.WebClientDeliverer;
 import org.apache.cxf.jaxrs.provider.AtomEntryProvider;
 import org.apache.cxf.jaxrs.provider.AtomFeedProvider;
 
@@ -53,7 +58,8 @@
 public class JAXRSLoggingAtomPushTest {
     private static final Logger LOG = LogUtils.getL7dLogger(JAXRSLoggingAtomPushTest.class);
     private static Server server;
-    private static List<Element> received;
+    private static List<Feed> feeds = new ArrayList<Feed>();
+    private static List<Entry> entries = new ArrayList<Entry>();
 
     @Ignore
     @Path("/")
@@ -61,7 +67,14 @@
         @POST
         public void consume(Feed feed) {
             System.out.println(feed);
-            received.add(feed);
+            feeds.add(feed);
+        }
+
+        @POST
+        @Path("/atomPub")
+        public void consume(Entry entry) {
+            System.out.println(entry);
+            entries.add(entry);
         }
     }
 
@@ -118,7 +131,8 @@
 
     @Before
     public void before() throws Exception {
-        received = new ArrayList<Element>();
+        feeds.clear();
+        entries.clear();
     }
 
     @Test
@@ -126,8 +140,8 @@
         configureLogging("resources/logging_atompush.properties");
         logSixEvents(LOG);
         // need to wait: multithreaded and client-server journey
-        Thread.sleep(3000);
-        assertEquals("Different logged events count;", 6, received.size());
+        Thread.sleep(1000);
+        assertEquals("Different logged events count;", 6, feeds.size());
     }
 
     @Test
@@ -135,23 +149,35 @@
         configureLogging("resources/logging_atompush_batch.properties");
         logSixEvents(LOG);
         // need to wait: multithreaded and client-server journey
-        Thread.sleep(3000);
+        Thread.sleep(1000);
         // 6 events / 3 element batch = 2 feeds expected
-        assertEquals("Different logged events count;", 2, received.size());
+        assertEquals("Different logged events count;", 2, feeds.size());
     }
 
     @Test
     public void testPrivateLogger() throws Exception {
         configureLogging("resources/logging_atompush_disabled.properties");
         Logger log = LogUtils.getL7dLogger(JAXRSLoggingAtomPushTest.class, null, "private-log");
-        Handler h = new AtomPushHandler(2, new SingleEntryContentConverter(),
-                                        new WebClientDeliverer("http://localhost:9080"));
+        Converter c = new StandardConverter(Output.FEED, Multiplicity.ONE, Format.CONTENT);
+        Deliverer d = new WebClientDeliverer("http://localhost:9080");
+        Handler h = new AtomPushHandler(2, c, d);
         log.addHandler(h);
         log.setLevel(Level.ALL);
         logSixEvents(log);
         // need to wait: multithreaded and client-server journey
-        Thread.sleep(3000);
+        Thread.sleep(1000);
         // 6 events / 2 element batch = 3 feeds expected
-        assertEquals("Different logged events count;", 3, received.size());
+        assertEquals("Different logged events count;", 3, feeds.size());
     }
+
+    @Test
+    public void testAtomPubEntries() throws Exception {
+        configureLogging("resources/logging_atompush_atompub.properties");
+        logSixEvents(LOG);
+        // need to wait: multithreaded and client-server journey
+        Thread.sleep(1000);
+        // 6 events logged as entries
+        assertEquals("Different logged events count;", 6, entries.size());
+    }
+
 }

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/logging_atompush.properties
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/logging_atompush.properties?rev=884657&r1=884656&r2=884657&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/logging_atompush.properties (original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/logging_atompush.properties Thu Nov 26 18:08:37 2009
@@ -25,9 +25,6 @@
 # Atom handler specific settings
 org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.url = http://localhost:9080
 org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.batchSize = 1
-org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.converter = SingleEntryExtensionConverter
-#org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.deliverer = WebClientDeliverer
-
-#org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.retry.pause = linear
-#org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.retry.pause.time = 5
-#org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.retry.timeout = 10
+org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.output = feed
+org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.entries = one
+org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.format = content

Added: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/logging_atompush_atompub.properties
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/logging_atompush_atompub.properties?rev=884657&view=auto
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/logging_atompush_atompub.properties (added)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/logging_atompush_atompub.properties Thu Nov 26 18:08:37 2009
@@ -0,0 +1,31 @@
+# Atom logger plus echo on console
+handlers = org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler, java.util.logging.ConsoleHandler
+
+# Set the default logging level for the root logger
+.level = ALL
+
+# Set logging levels for the package-named loggers 
+org.apache.cxf.systest.jaxrs.level = ALL
+
+# Need to turn off logging from surrounding environment to properly count log entries in tests
+# (specified sub-entries since root level overrides sub-levels... yes, JUL is dumb :)
+org.apache.cxf.jaxrs.level = OFF
+org.apache.cxf.phase.level = OFF
+org.apache.cxf.service.level = OFF
+org.apache.cxf.interceptor.level = OFF
+org.apache.cxf.transport.level = OFF
+org.apache.cxf.bus.level = OFF
+org.apache.cxf.configuration.level = OFF
+org.apache.cxf.endpoint.level = OFF
+org.apache.cxf.resource.level = OFF
+org.springframework.level = OFF
+org.mortbay.level = OFF
+org.apache.axiom.level = OFF
+
+# Atom handler specific settings
+org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.url = http://localhost:9080/atomPub
+org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.batchSize = 1
+org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.output = entry
+org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.multiplicity = one
+org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.format = extension
+

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/logging_atompush_batch.properties
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/logging_atompush_batch.properties?rev=884657&r1=884656&r2=884657&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/logging_atompush_batch.properties (original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/logging_atompush_batch.properties Thu Nov 26 18:08:37 2009
@@ -25,9 +25,3 @@
 # Atom handler specific settings
 org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.url = http://localhost:9080
 org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.batchSize = 3
-#org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.converter = ContentSingleEntryConverter
-#org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.deliverer = WebClientDeliverer
-
-#org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.retry.pause = linear
-#org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.retry.pause.time = 5
-#org.apache.cxf.jaxrs.ext.logging.atom.AtomPushHandler.retry.timeout = 10



Mime
View raw message