Author: gnodet
Date: Mon Jun 25 12:21:58 2007
New Revision: 550578

URL: http://svn.apache.org/viewvc?view=rev&rev=550578
Log:
Fix checkstyle / pmd checks

Modified:
    incubator/servicemix/trunk/core/servicemix-audit/pom.xml
    
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/AbstractAuditor.java
    
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/AuditorQueryMBean.java
    
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/jdbc/JdbcAuditor.java
    
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/lucene/DefaultLuceneCallback.java
    
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/lucene/LuceneAuditor.java
    
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/lucene/LuceneCallback.java
    
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/lucene/LuceneIndexer.java
    
incubator/servicemix/trunk/core/servicemix-audit/src/test/java/org/apache/servicemix/jbi/audit/jdbc/JdbcAuditorTest.java

Modified: incubator/servicemix/trunk/core/servicemix-audit/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-audit/pom.xml?view=diff&rev=550578&r1=550577&r2=550578
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-audit/pom.xml (original)
+++ incubator/servicemix/trunk/core/servicemix-audit/pom.xml Mon Jun 25 
12:21:58 2007
@@ -23,7 +23,7 @@
 
   <parent>
     <groupId>org.apache.servicemix</groupId>
-    <artifactId>core</artifactId>
+    <artifactId>parent</artifactId>
     <version>3.2-incubating-SNAPSHOT</version>
   </parent>
 

Modified: 
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/AbstractAuditor.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/AbstractAuditor.java?view=diff&rev=550578&r1=550577&r2=550578
==============================================================================
--- 
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/AbstractAuditor.java
 (original)
+++ 
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/AbstractAuditor.java
 Mon Jun 25 12:21:58 2007
@@ -63,8 +63,9 @@
     public void start() throws javax.jbi.JBIException {
         super.start();
         doStart();
-        if (isAsContainerListener())
-               this.container.addListener(this);
+        if (isAsContainerListener()) {
+            this.container.addListener(this);
+        }
     }
 
     /* (non-Javadoc)
@@ -150,7 +151,7 @@
         if (id == null || id.length() == 0) {
             throw new IllegalArgumentException("id should be non null and non 
empty");
         }
-        return getExchangesByIds(new String[] { id })[0];
+        return getExchangesByIds(new String[] {id })[0];
     }
     
     /* (non-Javadoc)
@@ -193,7 +194,7 @@
      * @see 
org.apache.servicemix.jbi.audit.AuditorMBean#deleteExchange(java.lang.String)
      */
     public boolean deleteExchangeById(String id) throws AuditorException {
-        return deleteExchangesByIds(new String[] { id }) == 1;
+        return deleteExchangesByIds(new String[] {id }) == 1;
     }
     
     /* (non-Javadoc)
@@ -215,7 +216,7 @@
         container.resendExchange(exchange);
     }
 
-       /**
+    /**
      * Test if Auditor should be included as a container listener
      * 
      * @return Returns the addToContainer.

Modified: 
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/AuditorQueryMBean.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/AuditorQueryMBean.java?view=diff&rev=550578&r1=550577&r2=550578
==============================================================================
--- 
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/AuditorQueryMBean.java
 (original)
+++ 
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/AuditorQueryMBean.java
 Mon Jun 25 12:21:58 2007
@@ -27,16 +27,16 @@
  * @version $Revision$
  */
 public interface AuditorQueryMBean extends AuditorMBean {
-       String[] findExchangesIDsByStatus(ExchangeStatus status) throws 
AuditorException;       
-       String[] findExchangesIDsByMessageContent(String type, String content) 
throws AuditorException;
-       String[] findExchangesIDsByMessageProperty(String type, String 
property, String value) throws AuditorException;
+    String[] findExchangesIDsByStatus(ExchangeStatus status) throws 
AuditorException;
+    String[] findExchangesIDsByMessageContent(String type, String content) 
throws AuditorException;
+    String[] findExchangesIDsByMessageProperty(String type, String property, 
String value) throws AuditorException;
 
-       /**
-        * Searches for Exchanges IDs using the supplied key-field and the 
expected content of the field 
-        * @param field
-        * @param fieldValue
-        * @return exchange ids
-        * @throws AuditorException if an error occurs
-        */
-       String[] getExchangeIds(String field, String fieldValue) throws 
AuditorException;
+    /**
+     * Searches for Exchanges IDs using the supplied key-field and the 
expected content of the field 
+     * @param field
+     * @param fieldValue
+     * @return exchange ids
+     * @throws AuditorException if an error occurs
+     */
+    String[] getExchangeIds(String field, String fieldValue) throws 
AuditorException;
 }

Modified: 
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/jdbc/JdbcAuditor.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/jdbc/JdbcAuditor.java?view=diff&rev=550578&r1=550577&r2=550578
==============================================================================
--- 
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/jdbc/JdbcAuditor.java
 (original)
+++ 
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/jdbc/JdbcAuditor.java
 Mon Jun 25 12:21:58 2007
@@ -113,7 +113,7 @@
     
     public void exchangeSent(ExchangeEvent event) {
         MessageExchange exchange = event.getExchange();
-        if (exchange instanceof MessageExchangeImpl == false) {
+        if (!(exchange instanceof MessageExchangeImpl)) {
             throw new IllegalArgumentException("exchange should be a 
MessageExchangeImpl");
         }
         try {
@@ -186,8 +186,7 @@
         Connection connection = null;
         try {
             connection = dataSource.getConnection();
-            String[] ids = adapter.doGetIds(connection, fromIndex, toIndex);
-            return ids;
+            return adapter.doGetIds(connection, fromIndex, toIndex);
         } catch (Exception e) {
             throw new AuditorException("Could not retrieve exchange ids", e);
         } finally {
@@ -276,6 +275,7 @@
                 }
                 connection.close();
             } catch (SQLException e) {
+                // Do nothing
             }
         }
     }

Modified: 
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/lucene/DefaultLuceneCallback.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/lucene/DefaultLuceneCallback.java?view=diff&rev=550578&r1=550577&r2=550578
==============================================================================
--- 
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/lucene/DefaultLuceneCallback.java
 (original)
+++ 
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/lucene/DefaultLuceneCallback.java
 Mon Jun 25 12:21:58 2007
@@ -28,33 +28,35 @@
 
 /**
  * Default Lucene Callback implementation. Used on LuceneAuditor
+ * 
  * @author George Gastaldi (gastaldi)
  * @since 2.1
  * @version $Revision$
  */
 public class DefaultLuceneCallback implements LuceneCallback {
-       private String field;
-       private String query;
-       
-       public DefaultLuceneCallback(String field, String query) {
-               this.field = field;
-               this.query = query;
-       }
-       
-       public Object doCallback(IndexSearcher is) throws IOException {
-               try {
-                       Query queryObj = QueryParser.parse(query, field, new 
StandardAnalyzer());
-                       Hits hits = is.search(queryObj);
-                       int total = hits.length();
-                       String[] ids = new String[total];
-                       for (int i = 0; i < total; i++) {
-                               Document d = hits.doc(i);
-                               ids[i] = 
d.get("org.apache.servicemix.exchangeid");
-                       }
-                       return ids;
-               } catch (ParseException pe) {
-                       return new String[0];
-               }
-       }
+    private String field;
+
+    private String query;
+
+    public DefaultLuceneCallback(String field, String query) {
+        this.field = field;
+        this.query = query;
+    }
+
+    public Object doCallback(IndexSearcher is) throws IOException {
+        try {
+            Query queryObj = QueryParser.parse(query, field, new 
StandardAnalyzer());
+            Hits hits = is.search(queryObj);
+            int total = hits.length();
+            String[] ids = new String[total];
+            for (int i = 0; i < total; i++) {
+                Document d = hits.doc(i);
+                ids[i] = d.get("org.apache.servicemix.exchangeid");
+            }
+            return ids;
+        } catch (ParseException pe) {
+            return new String[0];
+        }
+    }
 
 }

Modified: 
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/lucene/LuceneAuditor.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/lucene/LuceneAuditor.java?view=diff&rev=550578&r1=550577&r2=550578
==============================================================================
--- 
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/lucene/LuceneAuditor.java
 (original)
+++ 
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/lucene/LuceneAuditor.java
 Mon Jun 25 12:21:58 2007
@@ -37,176 +37,183 @@
 import org.apache.servicemix.jbi.jaxp.SourceTransformer;
 
 /**
- * Lucene AuditorQuery implementation. 
- * It uses Lucene as the indexing mechanism for searching Exchanges 
- * and needs a delegated AuditorMBean to persist Exchanges. 
+ * Lucene AuditorQuery implementation. It uses Lucene as the indexing mechanism
+ * for searching Exchanges and needs a delegated AuditorMBean to persist
+ * Exchanges.
  * 
- * The Content of messages are stored as:
- *     - org.apache.servicemix.in.contents
- *     - org.apache.servicemix.out.contents, if exists
- *     - org.apache.servicemix.fault.contents, if exists
+ * The Content of messages are stored as: 
+ *  - org.apache.servicemix.in.contents
+ *  - org.apache.servicemix.out.contents, if exists
+ *  - org.apache.servicemix.fault.contents, if exists
  * 
- * Properties for IN Messages are stored as:
- *     - org.apache.servicemix.in.propertyname
- *     - org.apache.servicemix.out.propertyname, if exists
- *     - org.apache.servicemix.fault.propertyname, if exists
+ * Properties for IN Messages are stored as: 
+ *  - org.apache.servicemix.in.propertyname
+ *  - org.apache.servicemix.out.propertyname, if exists
+ *  - org.apache.servicemix.fault.propertyname, if exists
  * 
  * @author George Gastaldi
  * @since 2.1
  * @version $Revision$
  */
 public class LuceneAuditor extends AbstractAuditor implements 
AuditorQueryMBean {
-    
-       private AuditorMBean delegatedAuditor;
-       private LuceneIndexer luceneIndexer = new LuceneIndexer();
-
-       protected void doStart() throws JBIException {
-               super.doStart();
-               if (delegatedAuditor == null) {
-                       throw new JBIException("A delegated auditor must be 
provided");
-               }
-               this.delegatedAuditor.start();
-       }
-       
-       protected void doStop() throws JBIException {
-               super.doStop();
-               this.delegatedAuditor.stop();
-       }
-       
-       /**
-        * @return Returns the luceneIndexer.
-        */
-       public LuceneIndexer getLuceneIndexer() {
-               return luceneIndexer;
-       }
-
-       /**
-        * @param luceneIndexer The luceneIndexer to set.
-        */
-       public void setLuceneIndexer(LuceneIndexer luceneIndexer) {
-               this.luceneIndexer = luceneIndexer;
-       }
-
-       /**
-        * @return Returns the delegatedAuditor.
-        */
-       public AuditorMBean getDelegatedAuditor() {
-               return delegatedAuditor;
-       }
-
-       /**
-        * @param delegatedAuditor The delegatedAuditor to set.
-        */
-       public void setDelegatedAuditor(AuditorMBean delegatedAuditor) {
-               this.delegatedAuditor = delegatedAuditor;
-               if (delegatedAuditor instanceof AbstractAuditor) {
-                       
((AbstractAuditor)delegatedAuditor).setAsContainerListener(false);
-               }
-       }
-
-       public int getExchangeCount() throws AuditorException {
-               return this.delegatedAuditor.getExchangeCount();
-       }
-
-       public String[] getExchangeIdsByRange(int fromIndex, int toIndex) 
throws AuditorException {
-               return 
this.delegatedAuditor.getExchangeIdsByRange(fromIndex,toIndex);
-       }
-
-       public MessageExchange[] getExchangesByIds(String[] ids) throws 
AuditorException {
-               return this.delegatedAuditor.getExchangesByIds(ids);
-       }
-
-       public int deleteExchangesByRange(int fromIndex, int toIndex) throws 
AuditorException {
-               //TODO: Remove ids from Lucene Index
-               return 
this.delegatedAuditor.deleteExchangesByRange(fromIndex,toIndex);
-       }
-
-       public int deleteExchangesByIds(String[] ids) throws AuditorException {
-               try {
-                       this.luceneIndexer.remove(ids);
-               } catch (IOException io) {
-                       throw new AuditorException(io);
-               }
-               return this.delegatedAuditor.deleteExchangesByIds(ids);
-       }
+
+    private AuditorMBean delegatedAuditor;
+
+    private LuceneIndexer luceneIndexer = new LuceneIndexer();
+
+    protected void doStart() throws JBIException {
+        super.doStart();
+        if (delegatedAuditor == null) {
+            throw new JBIException("A delegated auditor must be provided");
+        }
+        this.delegatedAuditor.start();
+    }
+
+    protected void doStop() throws JBIException {
+        super.doStop();
+        this.delegatedAuditor.stop();
+    }
+
+    /**
+     * @return Returns the luceneIndexer.
+     */
+    public LuceneIndexer getLuceneIndexer() {
+        return luceneIndexer;
+    }
+
+    /**
+     * @param luceneIndexer
+     *            The luceneIndexer to set.
+     */
+    public void setLuceneIndexer(LuceneIndexer luceneIndexer) {
+        this.luceneIndexer = luceneIndexer;
+    }
+
+    /**
+     * @return Returns the delegatedAuditor.
+     */
+    public AuditorMBean getDelegatedAuditor() {
+        return delegatedAuditor;
+    }
+
+    /**
+     * @param delegatedAuditor
+     *            The delegatedAuditor to set.
+     */
+    public void setDelegatedAuditor(AuditorMBean delegatedAuditor) {
+        this.delegatedAuditor = delegatedAuditor;
+        if (delegatedAuditor instanceof AbstractAuditor) {
+            ((AbstractAuditor) delegatedAuditor).setAsContainerListener(false);
+        }
+    }
+
+    public int getExchangeCount() throws AuditorException {
+        return this.delegatedAuditor.getExchangeCount();
+    }
+
+    public String[] getExchangeIdsByRange(int fromIndex, int toIndex) throws 
AuditorException {
+        return this.delegatedAuditor.getExchangeIdsByRange(fromIndex, toIndex);
+    }
+
+    public MessageExchange[] getExchangesByIds(String[] ids) throws 
AuditorException {
+        return this.delegatedAuditor.getExchangesByIds(ids);
+    }
+
+    public int deleteExchangesByRange(int fromIndex, int toIndex) throws 
AuditorException {
+        // TODO: Remove ids from Lucene Index
+        return this.delegatedAuditor.deleteExchangesByRange(fromIndex, 
toIndex);
+    }
+
+    public int deleteExchangesByIds(String[] ids) throws AuditorException {
+        try {
+            this.luceneIndexer.remove(ids);
+        } catch (IOException io) {
+            throw new AuditorException(io);
+        }
+        return this.delegatedAuditor.deleteExchangesByIds(ids);
+    }
 
     public void exchangeSent(ExchangeEvent event) {
         MessageExchange exchange = event.getExchange();
-               try {
-                       Document doc = createDocument(exchange);
-                       this.luceneIndexer.add(doc,exchange.getExchangeId());
-                       if (delegatedAuditor instanceof ExchangeListener) {
-                           ((ExchangeListener) 
delegatedAuditor).exchangeSent(event);
-                       }
-               } catch (Exception e) {
-                       log.error("Error while adding to lucene", e);
-               }
-       }
-
-       public String getDescription() {
-               return "Lucene Auditor";
-       }
-
-       public String[] findExchangesIDsByStatus(ExchangeStatus status) throws 
AuditorException {
-               String field = "org.apache.servicemix.exchangestatus";
-               return getExchangeIds(field,String.valueOf(status));
-       }
-
-       public String[] findExchangesIDsByMessageContent(String type, String 
content) throws AuditorException {
-               String field = "org.apache.servicemix."+type+".contents";
-               return getExchangeIds(field,content);
-       }
-
-       public String[] findExchangesIDsByMessageProperty(String type, String 
property, String value) throws AuditorException {
-               if (property != null && 
!property.startsWith("org.apache.servicemix")) {
-                       property = "org.apache.servicemix."+type+"."+property;
-               }
-               return getExchangeIds(property,value);
-       }
-       
-       protected Document createDocument(MessageExchange me) throws 
MessagingException {
-               try {
-                       //This could be in a separated class (a 
LuceneDocumentProvider)
-                       SourceTransformer st = new SourceTransformer();
-                       Document d = new Document();
-                       
d.add(Field.Keyword("org.apache.servicemix.exchangeid",me.getExchangeId()));
-                       
d.add(Field.Keyword("org.apache.servicemix.exchangestatus",String.valueOf(me.getStatus())));
-                       
-                       String[] types = {"in","out","fault"};
-                       for (int i=0;i<types.length;i++) {
-                               String type = types[i];
-                               NormalizedMessage nm = me.getMessage(type);
-                               if (nm != null) {
-                                       
d.add(Field.UnStored("org.apache.servicemix."+type+".contents",st.contentToString(nm)));
-                                       
addMessagePropertiesToDocument(nm,d,type);
-                               }
-                       }
-                       return d;
-               } catch (MessagingException mse) {
-                       throw mse;
-               } catch (Exception ex) {
-                       throw new MessagingException("Error while creating 
Lucene Document",ex);
-               }
-       }
-       
-       protected void addMessagePropertiesToDocument(NormalizedMessage nm, 
-                       Document document, String type) throws 
MessagingException {
-               Set propertyNames = nm.getPropertyNames();
-               for (Iterator iter = propertyNames.iterator(); iter.hasNext();) 
{
-                       String propertyName = (String) iter.next();
-                       Object value = nm.getProperty(propertyName);
-                       if (value instanceof String) 
-                               //org.apache.servicemix.out.myproperty
-                               
document.add(Field.Keyword("org.apache.servicemix."+type+"."+propertyName,String.valueOf(value)));
-               }
-       }
-       
-       public String[] getExchangeIds(String queryContent, String field) 
throws AuditorException {
-               DefaultLuceneCallback dfc = new 
DefaultLuceneCallback(queryContent,field);
-               try {
-                       return (String[])luceneIndexer.search(dfc);
-               } catch (IOException e) {
-                       throw new AuditorException("Error while getting 
Exchange IDs",e);
-               }
-       }
+        try {
+            Document doc = createDocument(exchange);
+            this.luceneIndexer.add(doc, exchange.getExchangeId());
+            if (delegatedAuditor instanceof ExchangeListener) {
+                ((ExchangeListener) delegatedAuditor).exchangeSent(event);
+            }
+        } catch (Exception e) {
+            log.error("Error while adding to lucene", e);
+        }
+    }
+
+    public String getDescription() {
+        return "Lucene Auditor";
+    }
+
+    public String[] findExchangesIDsByStatus(ExchangeStatus status) throws 
AuditorException {
+        String field = "org.apache.servicemix.exchangestatus";
+        return getExchangeIds(field, String.valueOf(status));
+    }
+
+    public String[] findExchangesIDsByMessageContent(String type, String 
content) throws AuditorException {
+        String field = "org.apache.servicemix." + type + ".contents";
+        return getExchangeIds(field, content);
+    }
+
+    public String[] findExchangesIDsByMessageProperty(String type, 
+                                                      String property, 
+                                                      String value) throws 
AuditorException {
+        if (property != null && !property.startsWith("org.apache.servicemix")) 
{
+            property = "org.apache.servicemix." + type + "." + property;
+        }
+        return getExchangeIds(property, value);
+    }
+
+    protected Document createDocument(MessageExchange me) throws 
MessagingException {
+        try {
+            // This could be in a separated class (a LuceneDocumentProvider)
+            SourceTransformer st = new SourceTransformer();
+            Document d = new Document();
+            d.add(Field.Keyword("org.apache.servicemix.exchangeid", 
me.getExchangeId()));
+            d.add(Field.Keyword("org.apache.servicemix.exchangestatus", 
String.valueOf(me.getStatus())));
+
+            String[] types = {"in", "out", "fault" };
+            for (int i = 0; i < types.length; i++) {
+                String type = types[i];
+                NormalizedMessage nm = me.getMessage(type);
+                if (nm != null) {
+                    d.add(Field.UnStored("org.apache.servicemix." + type + 
".contents", st.contentToString(nm)));
+                    addMessagePropertiesToDocument(nm, d, type);
+                }
+            }
+            return d;
+        } catch (MessagingException mse) {
+            throw mse;
+        } catch (Exception ex) {
+            throw new MessagingException("Error while creating Lucene 
Document", ex);
+        }
+    }
+
+    protected void addMessagePropertiesToDocument(NormalizedMessage nm, 
+                                                  Document document, 
+                                                  String type) throws 
MessagingException {
+        Set propertyNames = nm.getPropertyNames();
+        for (Iterator iter = propertyNames.iterator(); iter.hasNext();) {
+            String propertyName = (String) iter.next();
+            Object value = nm.getProperty(propertyName);
+            if (value instanceof String) {
+                //org.apache.servicemix.out.myproperty
+                document.add(Field.Keyword("org.apache.servicemix." + type + 
"." + propertyName, String.valueOf(value)));
+            }
+        }
+    }
+
+    public String[] getExchangeIds(String queryContent, String field) throws 
AuditorException {
+        DefaultLuceneCallback dfc = new DefaultLuceneCallback(queryContent, 
field);
+        try {
+            return (String[]) luceneIndexer.search(dfc);
+        } catch (IOException e) {
+            throw new AuditorException("Error while getting Exchange IDs", e);
+        }
+    }
 }

Modified: 
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/lucene/LuceneCallback.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/lucene/LuceneCallback.java?view=diff&rev=550578&r1=550577&r2=550578
==============================================================================
--- 
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/lucene/LuceneCallback.java
 (original)
+++ 
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/lucene/LuceneCallback.java
 Mon Jun 25 12:21:58 2007
@@ -21,18 +21,23 @@
 import org.apache.lucene.search.IndexSearcher;
 
 /**
- * Lucene Callback Interface. 
- * Used on searching to be executed on synchronized blocks. 
+ * Lucene Callback Interface. Used on searching to be executed on synchronized
+ * blocks.
+ * 
  * @author George Gastaldi
  * @since 2.1
  * @version $Revision$
  */
 public interface LuceneCallback {
-       /**
-        * Called by the LuceneIndexer 
-        * @param is IndexSearcher provided by the indexer
-        * @return an object from the query
-        * @throws IOException if an error occurs during opening/searching of 
the index
-        */     
-       Object doCallback(IndexSearcher is) throws IOException;
+
+    /**
+     * Called by the LuceneIndexer
+     * 
+     * @param is
+     *            IndexSearcher provided by the indexer
+     * @return an object from the query
+     * @throws IOException
+     *             if an error occurs during opening/searching of the index
+     */
+    Object doCallback(IndexSearcher is) throws IOException;
 }

Modified: 
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/lucene/LuceneIndexer.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/lucene/LuceneIndexer.java?view=diff&rev=550578&r1=550577&r2=550578
==============================================================================
--- 
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/lucene/LuceneIndexer.java
 (original)
+++ 
incubator/servicemix/trunk/core/servicemix-audit/src/main/java/org/apache/servicemix/jbi/audit/lucene/LuceneIndexer.java
 Mon Jun 25 12:21:58 2007
@@ -27,20 +27,22 @@
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.FSDirectory;
+
+
 /**
  * Utility class for Lucene API.
  * @author george
  * @since 2.1
  * @version $Revision$
  */
-
 public class LuceneIndexer {
     protected Directory directory;
+
     private File segmentFile;
-    
+
     public LuceneIndexer() {
     }
-    
+
     public Directory getDirectory() {
         return directory;
     }
@@ -49,75 +51,71 @@
         this.directory = directory;
     }
 
-    public void setDirectoryName(File directoryName) throws IOException  {
-       this.segmentFile = new File(directoryName,"segments");
-       this.directory = 
FSDirectory.getDirectory(directoryName.toString(),!this.segmentFile.exists());
+    public void setDirectoryName(File directoryName) throws IOException {
+        this.segmentFile = new File(directoryName, "segments");
+        this.directory = FSDirectory.getDirectory(directoryName.toString(), 
!this.segmentFile.exists());
     }
-    
+
     /**
      * Drop object from Lucene index
      */
     protected void remove(String id) throws IOException {
         synchronized (directory) {
-            IndexReader ir = IndexReader.open(directory); 
-            try{
+            IndexReader ir = IndexReader.open(directory);
+            try {
                 ir.delete(new Term("org.apache.servicemix.exchangeid", id));
-            }
-            finally{
-                ir.close();    
+            } finally {
+                ir.close();
             }
         }
     }
-    
+
     protected void remove(String[] ids) throws IOException {
-       if (ids != null && ids.length > 0) {
-               synchronized (directory) {
-                   IndexReader ir = IndexReader.open(directory); 
-                   try{
-                       for (int i=0;i<ids.length;i++)
-                               ir.delete(new 
Term("org.apache.servicemix.exchangeid", ids[i]));
-                   }
-                   finally{
-                       ir.close();    
-                   }
-               }
-       }
+        if (ids != null && ids.length > 0) {
+            synchronized (directory) {
+                IndexReader ir = IndexReader.open(directory);
+                try {
+                    for (int i = 0; i < ids.length; i++) {
+                        ir.delete(new Term("org.apache.servicemix.exchangeid", 
ids[i]));
+                    }
+                } finally {
+                    ir.close();
+                }
+            }
+        }
     }
-    
+
     /**
      * Add object to Lucene index
      */
     public void add(Document lucDoc, String id) throws IOException {
         synchronized (directory) {
             IndexWriter writer = new IndexWriter(directory, new 
SimpleAnalyzer(), !segmentFile.exists());
-            try{
+            try {
                 writer.addDocument(lucDoc);
-            }
-            finally{
-                writer.close();    
+            } finally {
+                writer.close();
             }
         }
     }
-    
+
     /**
      * called when an existing document is updated.
      */
     public void update(Document lucDoc, String id) throws IOException {
         remove(id);
-        add(lucDoc,id);
+        add(lucDoc, id);
     }
-    
-    
-    public Object search (LuceneCallback lc) throws IOException {
+
+    public Object search(LuceneCallback lc) throws IOException {
         synchronized (directory) {
             IndexReader ir = IndexReader.open(directory);
             IndexSearcher is = new IndexSearcher(ir);
-            try{
+            try {
                 return lc.doCallback(is);
-            }
-            finally{
-               is.close();
-                ir.close();    
+            } finally {
+                is.close();
+                ir.close();
             }
         }
     }

Modified: 
incubator/servicemix/trunk/core/servicemix-audit/src/test/java/org/apache/servicemix/jbi/audit/jdbc/JdbcAuditorTest.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-audit/src/test/java/org/apache/servicemix/jbi/audit/jdbc/JdbcAuditorTest.java?view=diff&rev=550578&r1=550577&r2=550578
==============================================================================
--- 
incubator/servicemix/trunk/core/servicemix-audit/src/test/java/org/apache/servicemix/jbi/audit/jdbc/JdbcAuditorTest.java
 (original)
+++ 
incubator/servicemix/trunk/core/servicemix-audit/src/test/java/org/apache/servicemix/jbi/audit/jdbc/JdbcAuditorTest.java
 Mon Jun 25 12:21:58 2007
@@ -16,30 +16,29 @@
  */
 package org.apache.servicemix.jbi.audit.jdbc;
 
-import org.apache.servicemix.jbi.audit.jdbc.JdbcAuditor;
-import org.apache.servicemix.jbi.container.JBIContainer;
-import org.apache.servicemix.jbi.jaxp.StringSource;
-import org.apache.servicemix.tck.ReceiverComponent;
-import org.apache.servicemix.tck.SenderComponent;
-import org.hsqldb.jdbc.jdbcDataSource;
+import java.sql.Connection;
 
 import javax.jbi.messaging.ExchangeStatus;
 import javax.jbi.messaging.InOnly;
 import javax.jbi.messaging.MessageExchange;
 import javax.sql.DataSource;
 
-import java.sql.Connection;
-
 import junit.framework.TestCase;
 
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.tck.ReceiverComponent;
+import org.apache.servicemix.tck.SenderComponent;
+import org.hsqldb.jdbc.jdbcDataSource;
 
 public class JdbcAuditorTest extends TestCase {
 
     private DataSource dataSource;
+
     private Connection connection;
+
     private JBIContainer jbi;
-    
-    
+
     protected void setUp() throws Exception {
         jdbcDataSource ds = new jdbcDataSource();
         ds.setDatabase("jdbc:hsqldb:mem:aname");
@@ -51,7 +50,7 @@
         jbi.setEmbedded(true);
         jbi.init();
     }
-    
+
     protected void tearDown() throws Exception {
         if (jbi != null) {
             jbi.shutDown();
@@ -60,32 +59,31 @@
             connection.close();
         }
     }
-    
-    
+
     public void testInsertUpdate() throws Exception {
         jbi.start();
         SenderComponent sender = new SenderComponent();
         ReceiverComponent receiver = new ReceiverComponent();
         jbi.activateComponent(sender, "sender");
         jbi.activateComponent(receiver, "receiver");
-        
+
         JdbcAuditor auditor = new JdbcAuditor();
         auditor.setContainer(jbi);
         auditor.setDataSource(dataSource);
         auditor.afterPropertiesSet();
-        
+
         InOnly inonly = sender.createInOnlyExchange(ReceiverComponent.SERVICE, 
null, null);
         inonly.setInMessage(inonly.createMessage());
         inonly.getInMessage().setContent(new 
StringSource("<hello>world</hello>"));
         sender.send(inonly);
-        
+
         int nbMessages = auditor.getExchangeCount();
         assertEquals(1, nbMessages);
         MessageExchange[] exchanges = auditor.getExchangesByRange(0, 1);
         assertNotNull(exchanges);
         assertEquals(1, exchanges.length);
         assertEquals(ExchangeStatus.DONE, exchanges[0].getStatus());
-        
+
         auditor.resendExchange(exchanges[0]);
 
         nbMessages = auditor.getExchangeCount();
@@ -93,24 +91,24 @@
         MessageExchange exchange = auditor.getExchangeByIndex(1);
         assertNotNull(exchange);
         assertEquals(ExchangeStatus.DONE, exchange.getStatus());
-        
+
         /*
-        PreparedStatement st = connection.prepareStatement("SELECT EXCHANGE 
FROM SM_AUDIT WHERE ID = ?");
-        try {
-            st.setString(1, inonly.getExchangeId());
-            ResultSet rs = st.executeQuery();
-            assertTrue(rs.next());
-            byte[] data = rs.getBytes(1);
-            ObjectInputStream ois = new ObjectInputStream(new 
ByteArrayInputStream(data));
-            Object obj = ois.readObject();
-            assertNotNull(obj);
-            assertTrue(obj instanceof ExchangePacket);
-            assertEquals(ExchangeStatus.DONE, ((ExchangePacket) 
obj).getStatus());
-        } finally {
-            st.close();
-        }
-        */
-        
+         PreparedStatement st = connection.prepareStatement("SELECT EXCHANGE 
FROM SM_AUDIT WHERE ID = ?");
+         try {
+         st.setString(1, inonly.getExchangeId());
+         ResultSet rs = st.executeQuery();
+         assertTrue(rs.next());
+         byte[] data = rs.getBytes(1);
+         ObjectInputStream ois = new ObjectInputStream(new 
ByteArrayInputStream(data));
+         Object obj = ois.readObject();
+         assertNotNull(obj);
+         assertTrue(obj instanceof ExchangePacket);
+         assertEquals(ExchangeStatus.DONE, ((ExchangePacket) obj).getStatus());
+         } finally {
+         st.close();
+         }
+         */
+
     }
-    
+
 }


Reply via email to