cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amicha...@apache.org
Subject svn commit: r882804 - /cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/
Date Sat, 21 Nov 2009 00:16:07 GMT
Author: amichalec
Date: Sat Nov 21 00:16:06 2009
New Revision: 882804

URL: http://svn.apache.org/viewvc?rev=882804&view=rev
Log:
Small post-documentation changes.

Added:
    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/SingleEntryContentConverter.java
      - copied, changed from r882571, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/ContentSingleEntryConverter.java
Removed:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/ContentSingleEntryConverter.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/AtomPushEngineConfigurator.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPushHandler.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
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPushBean.java?rev=882804&r1=882803&r2=882804&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
Sat Nov 21 00:16:06 2009
@@ -187,8 +187,35 @@
         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);
+    }
+    
+    /**
      * 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/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=882804&r1=882803&r2=882804&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
Sat Nov 21 00:16:06 2009
@@ -34,7 +34,7 @@
     private String batchSize;
     private String delivererUrl;
     private String retryTimeout;
-    private String retryPauseType;
+    private String retryPause;
     private String retryPauseTime;
 
     public void setUrl(String url) {
@@ -45,8 +45,8 @@
         this.retryTimeout = retryTimeout;
     }
 
-    public void setRetryPauseType(String retryPauseType) {
-        this.retryPauseType = retryPauseType;
+    public void setRetryPause(String retryPause) {
+        this.retryPause = retryPause;
     }
 
     public void setRetryPauseTime(String retryPauseTime) {
@@ -93,14 +93,14 @@
             if (converterClass != null) {
                 c = createConverter(converterClass);
             } else {
-                c = new ContentSingleEntryConverter();
+                c = new SingleEntryContentConverter();
             }
         }
         batch = parseInt(batchSize, 1, 1);
-        if (retryPauseType != null) {
+        if (retryPause != null) {
             int timeout = parseInt(retryTimeout, 0, 0);
             int pause = parseInt(retryPauseTime, 1, 30);
-            boolean linear = !retryPauseType.equalsIgnoreCase("exponential");
+            boolean linear = !retryPause.equalsIgnoreCase("exponential");
             d = new RetryingDeliverer(d, timeout, pause, linear);
         }
         AtomPushEngine engine = new AtomPushEngine();

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=882804&r1=882803&r2=882804&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
Sat Nov 21 00:16:06 2009
@@ -34,7 +34,7 @@
  * <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 ContentSingleEntryConverter}
is used.</li>
+ * "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>
@@ -116,7 +116,7 @@
         try {
             if (lazyConfig) {
                 lazyConfig = false;
-                configure2();
+                configure();
             }
             LogRecord rec = LogRecord.fromJUL(record);
             engine.publish(rec);
@@ -141,39 +141,7 @@
      * does not allow to iterate over configuration properties to make interpretation automated
(e.g. using
      * commons-beanutils)
      */
-    // private void configure() {
-    // LogManager manager = LogManager.getLogManager();
-    // String cname = getClass().getName();
-    // String url = manager.getProperty(cname + ".url");
-    // if (url == null) {
-    // // cannot proceed
-    // return;
-    // }
-    // String deliverer = manager.getProperty(cname + ".deliverer");
-    // if (deliverer != null) {
-    // engine.setDeliverer(createDeliverer(deliverer, url));
-    // } else {
-    // // default
-    // engine.setDeliverer(new WebClientDeliverer(url));
-    // }
-    // String converter = manager.getProperty(cname + ".converter");
-    // if (converter != null) {
-    // engine.setConverter(createConverter(converter));
-    // } else {
-    // // default
-    // engine.setConverter(new ContentSingleEntryConverter());
-    // }
-    // engine.setBatchSize(toInt(manager.getProperty(cname + ".batchSize"), 1, 1));
-    // String retryType = manager.getProperty(cname + ".retry.pause");
-    // if (retryType != null) {
-    // int timeout = toInt(manager.getProperty(cname + ".retry.timeout"), 0, 0);
-    // int pause = toInt(manager.getProperty(cname + ".retry.pause.time"), 1, 30);
-    // boolean linear = !retryType.equalsIgnoreCase("exponential");
-    // Deliverer wrapped = new RetryingDeliverer(engine.getDeliverer(), timeout, pause, linear);
-    // engine.setDeliverer(wrapped);
-    // }
-    // }
-    private void configure2() {
+    private void configure() {
         LogManager manager = LogManager.getLogManager();
         String cname = getClass().getName();
         AtomPushEngineConfigurator conf = new AtomPushEngineConfigurator();
@@ -181,57 +149,9 @@
         conf.setDelivererClass(manager.getProperty(cname + ".deliverer"));
         conf.setConverterClass(manager.getProperty(cname + ".converter"));
         conf.setBatchSize(manager.getProperty(cname + ".batchSize"));
-        conf.setRetryPauseType(manager.getProperty(cname + ".retry.pause"));
+        conf.setRetryPause(manager.getProperty(cname + ".retry.pause"));
         conf.setRetryPauseTime(manager.getProperty(cname + ".retry.pause.time"));
         conf.setRetryTimeout(manager.getProperty(cname + ".retry.timeout"));
         engine = conf.createEngine();
     }
-
-//    private int toInt(String property, int defaultValue) {
-//        try {
-//            return Integer.parseInt(property);
-//        } catch (NumberFormatException e) {
-//            return defaultValue;
-//        }
-//    }
-//
-//    private int toInt(String property, int lessThan, int defaultValue) {
-//        int ret = toInt(property, defaultValue);
-//        if (ret < lessThan) {
-//            ret = defaultValue;
-//        }
-//        return ret;
-//    }
-//
-//    private Deliverer createDeliverer(String clazz, String url) {
-//        try {
-//            Constructor<?> ctor = loadClass(clazz).getConstructor(String.class);
-//            return (Deliverer)ctor.newInstance(url);
-//        } catch (Exception e) {
-//            throw new IllegalArgumentException(e);
-//        }
-//    }
-//
-//    private Converter createConverter(String clazz) {
-//        try {
-//            Constructor<?> ctor = loadClass(clazz).getConstructor();
-//            return (Converter)ctor.newInstance();
-//        } catch (Exception e) {
-//            throw new IllegalArgumentException(e);
-//        }
-//    }
-//
-//    private Class<?> loadClass(String clazz) throws ClassNotFoundException {
-//        try {
-//            return getClass().getClassLoader().loadClass(clazz);
-//        } catch (ClassNotFoundException e) {
-//            try {
-//                // clazz could be shorted (stripped package name) retry
-//                String clazz2 = getClass().getPackage().getName() + "." + clazz;
-//                return getClass().getClassLoader().loadClass(clazz2);
-//            } catch (Exception e1) {
-//                throw new ClassNotFoundException(e.getMessage() + " or " + e1.getMessage());
-//            }
-//        }
-//    }
 }

Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/MultiEntryContentConverter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/MultiEntryContentConverter.java?rev=882804&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/MultiEntryContentConverter.java
(added)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/MultiEntryContentConverter.java
Sat Nov 21 00:16:06 2009
@@ -0,0 +1,72 @@
+/**
+ * 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.io.StringWriter;
+import java.util.List;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+
+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.Feed;
+import org.apache.cxf.jaxrs.ext.logging.LogRecord;
+import org.apache.cxf.jaxrs.ext.logging.LogRecordsList;
+
+/**
+ * Multiple entries in feed, each entry content with one log record from list.
+ */
+public class MultiEntryContentConverter implements Converter {
+
+    private Factory factory;
+    private Marshaller marsh;
+
+    public MultiEntryContentConverter() {
+        factory = Abdera.getNewFactory();
+        try {
+            marsh = JAXBContext.newInstance(LogRecordsList.class).createMarshaller();
+        } catch (JAXBException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public Element convert(List<LogRecord> records) {
+        Feed feed = factory.newFeed();
+        for (LogRecord record : records) {
+            Entry entry = factory.newEntry();
+            feed.addEntry(entry);
+            Content content = factory.newContent();
+            content.setContentType(Content.Type.XML);
+            entry.setContent(content);
+            StringWriter writer = new StringWriter();
+            try {
+                marsh.marshal(record, writer);
+            } catch (JAXBException e) {
+                throw new RuntimeException(e);
+            }
+            content.setValue(writer.toString());
+        }
+        return feed;
+    }
+}

Copied: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/SingleEntryContentConverter.java
(from r882571, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/ContentSingleEntryConverter.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/SingleEntryContentConverter.java?p2=cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/SingleEntryContentConverter.java&p1=cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/ContentSingleEntryConverter.java&r1=882571&r2=882804&rev=882804&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/ContentSingleEntryConverter.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/SingleEntryContentConverter.java
Sat Nov 21 00:16:06 2009
@@ -37,12 +37,12 @@
 /**
  * Single entry in feed with content set to list of log records.
  */
-public class ContentSingleEntryConverter implements Converter {
+public class SingleEntryContentConverter implements Converter {
 
     private Factory factory;
     private Marshaller marsh;
 
-    public ContentSingleEntryConverter() {
+    public SingleEntryContentConverter() {
         factory = Abdera.getNewFactory();
         try {
             marsh = JAXBContext.newInstance(LogRecordsList.class).createMarshaller();

Modified: 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/WebClientDeliverer.java?rev=882804&r1=882803&r2=882804&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/WebClientDeliverer.java
Sat Nov 21 00:16:06 2009
@@ -29,11 +29,18 @@
 import org.apache.cxf.jaxrs.provider.AtomEntryProvider;
 import org.apache.cxf.jaxrs.provider.AtomFeedProvider;
 
+/**
+ * Marshaling and delivering based on JAXRS' WebClient.
+ */
 public class WebClientDeliverer implements Deliverer {
     private WebClient wc;
 
+    @SuppressWarnings("unchecked")
     public WebClientDeliverer(String deliveryAddress) {
-        this.wc = create(deliveryAddress);
+        Validate.notEmpty(deliveryAddress, "deliveryAddress is empty or null");
+        List<?> providers = Arrays.asList(new AtomFeedProvider(), new AtomEntryProvider());
+        wc = WebClient.create(deliveryAddress, providers);
+        wc.type("application/atom+xml");
     }
 
     public WebClientDeliverer(WebClient wc) {
@@ -46,13 +53,4 @@
         int status = res.getStatus();
         return status >= 200 && status <= 299;
     }
-
-    @SuppressWarnings("unchecked")
-    public static WebClient create(String baseAddress) {
-        Validate.notEmpty(baseAddress, "baseAddress is empty or null");
-        List<?> providers = Arrays.asList(new AtomFeedProvider(), new AtomEntryProvider());
-        WebClient wc = WebClient.create(baseAddress, providers);
-        wc.type("application/atom+xml");
-        return wc;
-    }
 }



Mime
View raw message