jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r757775 [1/2] - /jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/
Date Tue, 24 Mar 2009 13:07:50 GMT
Author: mduerig
Date: Tue Mar 24 13:07:48 2009
New Revision: 757775

URL: http://svn.apache.org/viewvc?rev=757775&view=rev
Log:
JCR-1695: Improve and promote spi-logger

Added:
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/AbstractLogger.java   (with props)
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/BatchLogger.java   (with props)
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/IdFactoryLogger.java   (with props)
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/LogWriter.java   (with props)
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/LogWriterProvider.java   (with props)
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/NameFactoryLogger.java   (with props)
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/PathFactoryLogger.java   (with props)
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/QValueFactoryLogger.java   (with props)
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java   (with props)
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/SessionInfoLogger.java   (with props)
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/Slf4jLogWriter.java   (with props)
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/Slf4jLogWriterProvider.java   (with props)
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/SpiLoggerFactory.java   (with props)

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/AbstractLogger.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/AbstractLogger.java?rev=757775&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/AbstractLogger.java (added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/AbstractLogger.java Tue Mar 24 13:07:48 2009
@@ -0,0 +1,106 @@
+/*
+ * 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.jackrabbit.spi.commons.logging;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * Common base class for all log wrappers of SPI entities.
+ */
+public class AbstractLogger {
+
+    /**
+     * The {@link LogWriter} used by this instance for persisting log messages.
+     */
+    protected final LogWriter writer;
+
+    /**
+     * Create a new instance of this log wrapper which uses <code>writer
+     * </code> for persisting log messages.
+     * @param writer
+     */
+    public AbstractLogger(LogWriter writer) {
+        super();
+        this.writer = writer;
+    }
+
+    /**
+     * Execute a <code>thunk</code> of a method which might throw a {@link RepositoryException}. The call
+     * is logged to {@link #writer} right before it is actually performed and after it returns. Any
+     * exception thrown by the call is logged before it is re-thrown.
+     * @param thunk  thunk of the method to execute
+     * @param methodName  the name of the method
+     * @param args  the arguments passed to the method
+     * @return  the value returned from executing the <code>thunk</code>
+     * @throws RepositoryException  if executing the <code>thunk</code> throws an Exception the
+     *   exception is re-thrown.
+     */
+    protected Object execute(Callable thunk, String methodName, Object[] args) throws RepositoryException {
+        writer.enter(methodName, args);
+        Object result = null;
+        try {
+            result = thunk.call();
+            writer.leave(methodName, args, result);
+            return result;
+        }
+        catch (RepositoryException e) {
+            writer.error(methodName, args, e);
+            throw e;
+        }
+        catch (RuntimeException e) {
+            writer.error(methodName, args, e);
+            throw e;
+        }
+    }
+
+    /**
+     * Execute a <code>thunk</code> of a method which does not throw any checked exception. The
+     * call is logged to {@link #writer} right before it is actually performed and after it returns.
+     * @param thunk  thunk of the method to execute
+     * @param methodName  the name of the method
+     * @param args  the arguments passed to the method
+     * @return  the value returned from executing the <code>thunk</code>
+     */
+    protected Object execute(SafeCallable thunk, String methodName, Object[] args)  {
+        writer.enter(methodName, args);
+        Object result = null;
+        try {
+            result = thunk.call();
+            writer.leave(methodName, args, result);
+            return result;
+        }
+        catch (RuntimeException e) {
+            writer.error(methodName, args, e);
+            throw e;
+        }
+    }
+
+    /**
+     * Type of thunk used in {@link AbstractLogger#execute(Callable, String, Object[])
+     */
+    protected interface Callable {
+        public Object call() throws RepositoryException;
+    }
+
+    /**
+     * Type of thunk used in {@link AbstractLogger#execute(SafeCallable, String, Object[])
+     */
+    protected interface SafeCallable {
+        public Object call();
+    }
+
+}

Propchange: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/AbstractLogger.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/BatchLogger.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/BatchLogger.java?rev=757775&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/BatchLogger.java (added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/BatchLogger.java Tue Mar 24 13:07:48 2009
@@ -0,0 +1,137 @@
+/*
+ * 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.jackrabbit.spi.commons.logging;
+
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.spi.Batch;
+import org.apache.jackrabbit.spi.ItemId;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.QValue;
+
+/**
+ * Log wrapper for a {@link Batch}.
+ */
+public class BatchLogger extends AbstractLogger implements Batch {
+    private final Batch batch;
+
+    /**
+     * Create a new instance for the given <code>batch</code> which uses
+     * <code>writer</code> for persisting log messages.
+     * @param batch
+     * @param writer
+     */
+    public BatchLogger(Batch batch, LogWriter writer) {
+        super(writer);
+        this.batch = batch;
+    }
+
+    /**
+     * @return  the wrapped Batch
+     */
+    public Batch getBatch() {
+        return batch;
+    }
+
+    // -----------------------------------------------------< Batch >---
+
+    public void addNode(final NodeId parentId, final Name nodeName, final Name nodetypeName, final String uuid)
+            throws RepositoryException {
+
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                batch.addNode(parentId, nodeName, nodetypeName, uuid);
+                return null;
+            }}, "addNode(NodeId, Name, Name, String)", new Object[]{parentId, nodeName, nodetypeName, uuid});
+    }
+
+    public void addProperty(final NodeId parentId, final Name propertyName, final QValue value)
+            throws RepositoryException {
+
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                batch.addProperty(parentId, propertyName, value);
+                return null;
+            }}, "addProperty(NodeId, Name, QValue)", new Object[]{parentId, propertyName, value});
+    }
+
+    public void addProperty(final NodeId parentId, final Name propertyName, final QValue[] values)
+            throws RepositoryException {
+
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                batch.addProperty(parentId, propertyName, values);
+                return null;
+            }}, "addProperty(NodeId, Name, QValue[])", new Object[]{parentId, propertyName, values});
+    }
+
+    public void setValue(final PropertyId propertyId, final QValue value) throws RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                batch.setValue(propertyId, value);
+                return null;
+            }}, "setValue(PropertyId, QValue)", new Object[]{propertyId, value});
+    }
+
+    public void setValue(final PropertyId propertyId, final QValue[] values) throws RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                batch.setValue(propertyId, values);
+                return null;
+            }}, "setValue(PropertyId, QValue[])", new Object[]{propertyId, values});
+    }
+
+    public void remove(final ItemId itemId) throws RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                batch.remove(itemId);
+                return null;
+            }}, "remove(ItemId)", new Object[]{itemId});
+    }
+
+    public void reorderNodes(final NodeId parentId, final NodeId srcNodeId, final NodeId beforeNodeId)
+            throws RepositoryException {
+
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                batch.reorderNodes(parentId, srcNodeId, beforeNodeId);
+                return null;
+            }}, "reorderNodes(NodeId, NodeId, NodeId)", new Object[]{parentId, srcNodeId, beforeNodeId});
+    }
+
+    public void setMixins(final NodeId nodeId, final Name[] mixinNodeTypeNames) throws RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                batch.setMixins(nodeId, mixinNodeTypeNames);
+                return null;
+            }}, "setMixins(NodeId, Name[])", new Object[]{nodeId, mixinNodeTypeNames});
+    }
+
+    public void move(final NodeId srcNodeId, final NodeId destParentNodeId, final Name destName)
+            throws RepositoryException {
+
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                batch.move(srcNodeId, destParentNodeId, destName);
+                return null;
+            }}, "move(NodeId, NodeId, Name)", new Object[]{srcNodeId, destParentNodeId, destName});
+    }
+
+
+}

Propchange: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/BatchLogger.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/IdFactoryLogger.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/IdFactoryLogger.java?rev=757775&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/IdFactoryLogger.java (added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/IdFactoryLogger.java Tue Mar 24 13:07:48 2009
@@ -0,0 +1,77 @@
+/*
+ * 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.jackrabbit.spi.commons.logging;
+
+import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.PropertyId;
+
+/**
+ * Log wrapper for an {@link IdFactory}.
+ */
+public class IdFactoryLogger extends AbstractLogger implements IdFactory {
+    private final IdFactory idFactory;
+
+    /**
+     * Create a new instance for the given <code>idFactory</code> which uses
+     * <code>writer</code> for persisting log messages.
+     * @param idFactory
+     * @param writer
+     */
+    public IdFactoryLogger(IdFactory idFactory, LogWriter writer) {
+        super(writer);
+        this.idFactory = idFactory;
+    }
+
+    /**
+     * @return  the wrapped IdFactory
+     */
+    public IdFactory getIdFactory() {
+        return idFactory;
+    }
+
+    public PropertyId createPropertyId(final NodeId parentId, final Name propertyName) {
+        return (PropertyId) execute(new SafeCallable() {
+            public Object call() {
+                return idFactory.createPropertyId(parentId, propertyName);
+            }}, "createPropertyId(NodeId, Name)", new Object[]{parentId, propertyName});
+    }
+
+    public NodeId createNodeId(final NodeId parentId, final Path path) {
+        return (NodeId) execute(new SafeCallable() {
+            public Object call() {
+                return idFactory.createNodeId(parentId, path);
+            }}, "createNodeId(NodeId, Path)", new Object[]{parentId, path});
+    }
+
+    public NodeId createNodeId(final String uniqueID, final Path path) {
+        return (NodeId) execute(new SafeCallable() {
+            public Object call() {
+                return idFactory.createNodeId(uniqueID, path);
+            }}, "createNodeId(String, Path)", new Object[]{uniqueID, path});
+    }
+
+    public NodeId createNodeId(final String uniqueID) {
+        return (NodeId) execute(new SafeCallable() {
+            public Object call() {
+                return idFactory.createNodeId(uniqueID);
+            }}, "createNodeId(String)", new Object[]{uniqueID});
+    }
+
+}

Propchange: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/IdFactoryLogger.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/LogWriter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/LogWriter.java?rev=757775&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/LogWriter.java (added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/LogWriter.java Tue Mar 24 13:07:48 2009
@@ -0,0 +1,59 @@
+/*
+ * 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.jackrabbit.spi.commons.logging;
+
+/**
+ * A LogWriter provides methods for persisting log messages by some implementation
+ * specific means. Implementations must be thread safe. That is, implementations must
+ * cope with any thread concurrently calling any method of this interface at any time.
+ */
+public interface LogWriter {
+
+    /**
+     * Implementation specific time stamp which is logged along with each log
+     * message. The values returned by this method should be monotone with respect
+     * to the time they represent.
+     * @return
+     */
+    public long systemTime();
+
+    /**
+     * Called right before a method of a SPI entity is called.
+     * @param methodName  name of the method which a about to be called
+     * @param args  arguments passed to the methods which is about to be called.
+     */
+    public void enter(String methodName, Object[] args);
+
+    /**
+     * Called right after a method of a SPI entity has been called if no
+     * exception was thrown.
+     * @param methodName  name of the method which has been called
+     * @param args  arguments passed to the method which has been called
+     * @param result  return value of the method which has been called
+     */
+    public void leave(String methodName, Object[] args, Object result);
+
+    /**
+     * Called right after a method of a SPI entity has been called and an
+     * exception was thrown.
+     * @param methodName  name of the method which has been called
+     * @param args  arguments passed to the method which has been called
+     * @param e  exception which was thrown by the method which has
+     *   been called
+     */
+    public void error(String methodName, Object[] args, Exception e);
+}

Propchange: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/LogWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/LogWriterProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/LogWriterProvider.java?rev=757775&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/LogWriterProvider.java (added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/LogWriterProvider.java Tue Mar 24 13:07:48 2009
@@ -0,0 +1,74 @@
+/*
+ * 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.jackrabbit.spi.commons.logging;
+
+import org.apache.jackrabbit.spi.Batch;
+import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.spi.NameFactory;
+import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.spi.SessionInfo;
+
+/**
+ * LogWriterProvider instances provide {@link LogWriter}s for the individual
+ * SPI entities.
+ */
+public interface LogWriterProvider {
+
+    /**
+     * @param service
+     * @return  A LogWriter for logging calls to <code>service</code>.
+     */
+    public LogWriter getLogWriter(RepositoryService service);
+
+    /**
+     * @param nameFactory
+     * @return  A LogWriter for logging calls to <code>nameFactory</code>.
+     */
+    public LogWriter getLogWriter(NameFactory nameFactory);
+
+    /**
+     * @param pathFactory
+     * @return  A LogWriter for logging calls to <code>pathFactory</code>.
+     */
+    public LogWriter getLogWriter(PathFactory pathFactory);
+
+    /**
+     * @param idFactory
+     * @return  A LogWriter for logging calls to <code>idFactory</code>.
+     */
+    public LogWriter getLogWriter(IdFactory idFactory);
+
+    /**
+     * @param qValueFactory
+     * @return  A LogWriter for logging calls to <code>qValueFactory</code>.
+     */
+    public LogWriter getLogWriter(QValueFactory qValueFactory);
+
+    /**
+     * @param sessionInfo
+     * @return  A LogWriter for logging calls to <code>sessionInfo</code>.
+     */
+    public LogWriter getLogWriter(SessionInfo sessionInfo);
+
+    /**
+     * @param batch
+     * @return  A LogWriter for logging calls to <code>batch</code>.
+     */
+    public LogWriter getLogWriter(Batch batch);
+}

Propchange: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/LogWriterProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/NameFactoryLogger.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/NameFactoryLogger.java?rev=757775&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/NameFactoryLogger.java (added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/NameFactoryLogger.java Tue Mar 24 13:07:48 2009
@@ -0,0 +1,60 @@
+/*
+ * 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.jackrabbit.spi.commons.logging;
+
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.NameFactory;
+
+/**
+ * Log wrapper for a {@link NameFactory}.
+ */
+public class NameFactoryLogger extends AbstractLogger implements NameFactory {
+    private final NameFactory nameFactory;
+
+    /**
+     * Create a new instance for the given <code>nameFactory</code> which uses
+     * <code>writer</code> for persisting log messages.
+     * @param nameFactory
+     * @param writer
+     */
+    public NameFactoryLogger(NameFactory nameFactory, LogWriter writer) {
+        super(writer);
+        this.nameFactory = nameFactory;
+    }
+
+    /**
+     * @return  the wrapped NameFactory
+     */
+    public NameFactory getNameFactory() {
+        return nameFactory;
+    }
+
+    public Name create(final String namespaceURI, final String localName) {
+        return (Name) execute(new SafeCallable() {
+            public Object call() {
+                return nameFactory.create(namespaceURI, localName);
+            }}, "create(String, String)", new Object[]{namespaceURI, localName});
+    }
+
+    public Name create(final String nameString) {
+        return (Name) execute(new SafeCallable() {
+            public Object call() {
+                return nameFactory.create(nameString);
+            }}, "create(String)", new Object[]{nameString});
+    }
+
+}

Propchange: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/NameFactoryLogger.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/PathFactoryLogger.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/PathFactoryLogger.java?rev=757775&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/PathFactoryLogger.java (added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/PathFactoryLogger.java Tue Mar 24 13:07:48 2009
@@ -0,0 +1,148 @@
+/*
+ * 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.jackrabbit.spi.commons.logging;
+
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.spi.Path.Element;
+
+/**
+ * Log wrapper for a {@link PathFactory}.
+ */
+public class PathFactoryLogger extends AbstractLogger implements PathFactory {
+    private final PathFactory pathFactory;
+
+    /**
+     * Create a new instance for the given <code>pathFactory</code> which uses
+     * <code>writer</code> for persisting log messages.
+     * @param pathFactory
+     * @param writer
+     */
+    public PathFactoryLogger(PathFactory pathFactory, LogWriter writer) {
+        super(writer);
+        this.pathFactory = pathFactory;
+    }
+
+    /**
+     * @return  the wrapped PathFactory
+     */
+    public PathFactory getPathFactory() {
+        return pathFactory;
+    }
+
+    public Path create(final Path parent, final Path relPath, final boolean normalize)
+            throws RepositoryException {
+
+        return (Path) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return pathFactory.create(parent, relPath, normalize);
+            }}, "create(Path, Path, boolean)", new Object[]{parent, relPath, Boolean.valueOf(normalize)});
+    }
+
+    public Path create(final Path parent, final Name name, final boolean normalize)
+            throws RepositoryException {
+
+        return (Path) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return pathFactory.create(parent, name, normalize);
+            }}, "create(Path, Name, boolean)", new Object[]{parent, name, Boolean.valueOf(normalize)});
+    }
+
+    public Path create(final Path parent, final Name name, final int index, final boolean normalize)
+            throws RepositoryException {
+
+        return (Path) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return pathFactory.create(parent, name, index, normalize);
+            }}, "create(Path, Name, int, boolean)", new Object[]{parent, name, new Integer(index),
+                    Boolean.valueOf(normalize)});
+    }
+
+    public Path create(final Name name) {
+        return (Path) execute(new SafeCallable() {
+            public Object call() {
+                return pathFactory.create(name);
+            }}, "create(Name)", new Object[]{name});
+    }
+
+    public Path create(final Name name, final int index) {
+        return (Path) execute(new SafeCallable() {
+            public Object call() {
+                return pathFactory.create(name, index);
+            }}, "create(Name, int)", new Object[]{name, new Integer(index)});
+    }
+
+    public Path create(final Element[] elements) {
+        return (Path) execute(new SafeCallable() {
+            public Object call() {
+                return pathFactory.create(elements);
+            }}, "create(Element[])", new Object[]{elements});
+    }
+
+    public Path create(final String pathString) {
+        return (Path) execute(new SafeCallable() {
+            public Object call() {
+                return pathFactory.create(pathString);
+            }}, "create(String)", new Object[]{pathString});
+    }
+
+    public Element createElement(final Name name) {
+        return (Element) execute(new SafeCallable() {
+            public Object call() {
+                return pathFactory.createElement(name);
+            }}, "createElement(Name)", new Object[]{name});
+    }
+
+    public Element createElement(final Name name, final int index) {
+        return (Element) execute(new SafeCallable() {
+            public Object call() {
+                return pathFactory.createElement(name, index);
+            }}, "createElement(Name)", new Object[]{name, new Integer(index)});
+    }
+
+    public Element getCurrentElement() {
+        return (Element) execute(new SafeCallable() {
+            public Object call() {
+                return pathFactory.getCurrentElement();
+            }}, "getCurrentElement()", new Object[]{});
+    }
+
+    public Element getParentElement() {
+        return (Element) execute(new SafeCallable() {
+            public Object call() {
+                return pathFactory.getParentElement();
+            }}, "getParentElement()", new Object[]{});
+    }
+
+    public Element getRootElement() {
+        return (Element) execute(new SafeCallable() {
+            public Object call() {
+                return pathFactory.getRootElement();
+            }}, "getRootElement()", new Object[]{});
+    }
+
+    public Path getRootPath() {
+        return (Path) execute(new SafeCallable() {
+            public Object call() {
+                return pathFactory.getRootPath();
+            }}, "getRootPath()", new Object[]{});
+    }
+
+}

Propchange: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/PathFactoryLogger.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/QValueFactoryLogger.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/QValueFactoryLogger.java?rev=757775&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/QValueFactoryLogger.java (added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/QValueFactoryLogger.java Tue Mar 24 13:07:48 2009
@@ -0,0 +1,165 @@
+/*
+ * 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.jackrabbit.spi.commons.logging;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Calendar;
+
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.QValueFactory;
+
+/**
+ * Log wrapper for a {@link QValueFactory}.
+ */
+public class QValueFactoryLogger extends AbstractLogger implements QValueFactory {
+    private final QValueFactory qValueFactory;
+
+    /**
+     * Create a new instance for the given <code>qValueFactory</code> which uses
+     * <code>writer</code> for persisting log messages.
+     * @param qValueFactory
+     * @param writer
+     */
+    public QValueFactoryLogger(QValueFactory qValueFactory, LogWriter writer) {
+        super(writer);
+        this.qValueFactory = qValueFactory;
+    }
+
+    /**
+     * @return  the wrapped QValueFactory
+     */
+    public QValueFactory getQValueFactory() {
+        return qValueFactory;
+    }
+
+    public QValue create(final String value, final int type) throws RepositoryException {
+        return (QValue) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return qValueFactory.create(value, type);
+            }}, "create(String, int)", new Object[]{value, new Integer(type)});
+    }
+
+    public QValue create(final Calendar value) throws RepositoryException {
+        return (QValue) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return qValueFactory.create(value);
+            }}, "create(Calendar)", new Object[]{value});
+    }
+
+    public QValue create(final double value) throws RepositoryException {
+        return (QValue) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return qValueFactory.create(value);
+            }}, "create(double)", new Object[]{new Double(value)});
+    }
+
+    public QValue create(final long value) throws RepositoryException {
+        return (QValue) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return qValueFactory.create(value);
+            }}, "create(long)", new Object[]{new Long(value)});
+    }
+
+    public QValue create(final boolean value) throws RepositoryException {
+        return (QValue) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return qValueFactory.create(value);
+            }}, "create(boolean)", new Object[]{Boolean.valueOf(value)});
+    }
+
+    public QValue create(final Name value) throws RepositoryException {
+        return (QValue) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return qValueFactory.create(value);
+            }}, "create(Name)", new Object[]{value});
+    }
+
+    public QValue create(final Path value) throws RepositoryException {
+        return (QValue) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return qValueFactory.create(value);
+            }}, "create(Path)", new Object[]{value});
+    }
+
+    public QValue create(final byte[] value) throws RepositoryException {
+        return (QValue) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return qValueFactory.create(value);
+            }}, "create(byte[])", new Object[]{value});
+    }
+
+    public QValue create(final InputStream value) throws RepositoryException, IOException {
+        final String methodName = "create(InputStream)";
+        final Object[] args = new Object[]{value};
+        final IOException[] ex = new IOException[1];
+
+        QValue result = (QValue) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                try {
+                    return qValueFactory.create(value);
+                }
+                catch (IOException e) {
+                    ex[0] = e;
+                    return null;
+                }
+            }}, methodName, args);
+
+        if (ex[0] != null) {
+            throw ex[0];
+        }
+
+        return result;
+    }
+
+    public QValue create(final File value) throws RepositoryException, IOException {
+        final String methodName = "create(File)";
+        final Object[] args = new Object[]{value};
+        final IOException[] ex = new IOException[1];
+
+        QValue result = (QValue) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                try {
+                    return qValueFactory.create(value);
+                }
+                catch (IOException e) {
+                    ex[0] = e;
+                    return null;
+                }
+            }}, methodName, args);
+
+        if (ex[0] != null) {
+            throw ex[0];
+        }
+
+        return result;
+    }
+
+    public QValue[] computeAutoValues(final QPropertyDefinition propertyDefinition) throws RepositoryException {
+        return (QValue[]) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return qValueFactory.computeAutoValues(propertyDefinition);
+            }}, "computeAutoValues(QPropertyDefinition)", new Object[]{propertyDefinition});
+    }
+
+}

Propchange: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/QValueFactoryLogger.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java?rev=757775&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java (added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java Tue Mar 24 13:07:48 2009
@@ -0,0 +1,660 @@
+/*
+ * 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.jackrabbit.spi.commons.logging;
+
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.jcr.Credentials;
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.spi.Batch;
+import org.apache.jackrabbit.spi.EventBundle;
+import org.apache.jackrabbit.spi.EventFilter;
+import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.spi.ItemId;
+import org.apache.jackrabbit.spi.LockInfo;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.NameFactory;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.NodeInfo;
+import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.PropertyInfo;
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.spi.QueryInfo;
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.spi.SessionInfo;
+import org.apache.jackrabbit.spi.Subscription;
+
+/**
+ * Log wrapper for a {@link RepositoryService}.
+ */
+public class RepositoryServiceLogger extends AbstractLogger implements RepositoryService {
+    private final RepositoryService service;
+
+    /**
+     * Create a new instance for the given <code>service</code> which uses
+     * <code>writer</code> for persisting log messages.
+     * @param service
+     * @param writer
+     */
+    public RepositoryServiceLogger(RepositoryService service, LogWriter writer) {
+        super(writer);
+        this.service = service;
+    }
+
+    /**
+     * @return  the wrapped RepositoryService
+     */
+    public RepositoryService getRepositoryService() {
+        return service;
+    }
+
+    public NameFactory getNameFactory() throws RepositoryException {
+        return (NameFactory) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getNameFactory();
+            }
+        }, "getNameFactory()", new Object[]{});
+    }
+
+    public PathFactory getPathFactory() throws RepositoryException {
+        return (PathFactory) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getPathFactory();
+            }
+        }, "getPathFactory()", new Object[]{});
+    }
+
+    public IdFactory getIdFactory() throws RepositoryException {
+        return (IdFactory) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getIdFactory();
+            }
+        }, "getIdFactory()", new Object[]{});
+    }
+
+    public QValueFactory getQValueFactory() throws RepositoryException {
+        return (QValueFactory) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getQValueFactory();
+            }
+        }, "getQValueFactory()", new Object[]{});
+    }
+
+    public Map getRepositoryDescriptors() throws RepositoryException {
+        return (Map) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getRepositoryDescriptors();
+            }
+        }, "getRepositoryDescriptors()", new Object[]{});
+    }
+
+    public SessionInfo obtain(final Credentials credentials, final String workspaceName)
+            throws RepositoryException {
+
+        return (SessionInfo) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.obtain(credentials, workspaceName);
+            }
+        }, "obtain(Credentials, String)", new Object[]{credentials, workspaceName});
+    }
+
+    public SessionInfo obtain(final SessionInfo sessionInfo, final String workspaceName)
+            throws RepositoryException {
+
+        return (SessionInfo) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.obtain(unwrap(sessionInfo), workspaceName);
+            }
+        }, "obtain(SessionInfo, String)", new Object[]{unwrap(sessionInfo), workspaceName});
+    }
+
+    public SessionInfo impersonate(final SessionInfo sessionInfo, final Credentials credentials)
+            throws RepositoryException {
+
+        return (SessionInfo) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.impersonate(unwrap(sessionInfo), credentials);
+            }
+        }, "impersonate(SessionInfo, Credentials)", new Object[]{unwrap(sessionInfo), credentials});
+    }
+
+    public void dispose(final SessionInfo sessionInfo) throws RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.dispose(unwrap(sessionInfo));
+                return null;
+            }
+        }, "dispose(SessionInfo)", new Object[]{unwrap(sessionInfo)});
+    }
+
+    public String[] getWorkspaceNames(final SessionInfo sessionInfo) throws RepositoryException {
+        return (String[]) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getWorkspaceNames(unwrap(sessionInfo));
+            }
+        }, "getWorkspaceNames(SessionInfo)", new Object[]{unwrap(sessionInfo)});
+    }
+
+    public boolean isGranted(final SessionInfo sessionInfo, final ItemId itemId, final String[] actions)
+            throws RepositoryException {
+
+        return ((Boolean) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return Boolean.valueOf(service.isGranted(unwrap(sessionInfo), itemId, actions));
+            }
+        }, "isGranted(SessionInfo, ItemId, String[])", new Object[] { unwrap(sessionInfo), itemId, actions }))
+                .booleanValue();
+    }
+
+    public QNodeDefinition getNodeDefinition(final SessionInfo sessionInfo, final NodeId nodeId)
+            throws RepositoryException {
+
+        return (QNodeDefinition) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getNodeDefinition(unwrap(sessionInfo), nodeId);
+            }
+        }, "getNodeDefinition(SessionInfo, NodeId)", new Object[]{unwrap(sessionInfo), nodeId});
+    }
+
+    public QPropertyDefinition getPropertyDefinition(final SessionInfo sessionInfo,
+            final PropertyId propertyId) throws RepositoryException {
+
+        return (QPropertyDefinition) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getPropertyDefinition(unwrap(sessionInfo), propertyId);
+            }
+        }, "getPropertyDefinition(SessionInfo, PropertyId)", new Object[]{unwrap(sessionInfo), propertyId});
+    }
+
+    public NodeInfo getNodeInfo(final SessionInfo sessionInfo, final NodeId nodeId)
+            throws RepositoryException {
+
+        return (NodeInfo) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getNodeInfo(unwrap(sessionInfo), nodeId);
+            }
+        }, "getNodeInfo(SessionInfo, NodeId)", new Object[]{unwrap(sessionInfo), nodeId});
+    }
+
+    public Iterator getItemInfos(final SessionInfo sessionInfo, final NodeId nodeId)
+            throws RepositoryException {
+
+        return (Iterator) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getItemInfos(unwrap(sessionInfo), nodeId);
+            }
+        }, "getItemInfos(SessionInfo, NodeId)", new Object[]{unwrap(sessionInfo), nodeId});
+    }
+
+    public Iterator getChildInfos(final SessionInfo sessionInfo, final NodeId parentId)
+            throws RepositoryException {
+
+        return (Iterator) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getChildInfos(unwrap(sessionInfo), parentId);
+            }
+        }, "getChildInfos(SessionInfo, NodeId)", new Object[]{unwrap(sessionInfo), parentId});
+    }
+
+    public PropertyInfo getPropertyInfo(final SessionInfo sessionInfo, final PropertyId propertyId)
+            throws RepositoryException {
+
+        return (PropertyInfo) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getPropertyInfo(unwrap(sessionInfo), propertyId);
+            }
+        }, "getPropertyInfo(SessionInfo,PropertyId)", new Object[]{unwrap(sessionInfo), propertyId});
+    }
+
+    public Batch createBatch(final SessionInfo sessionInfo, final ItemId itemId) throws RepositoryException {
+        return (Batch) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.createBatch(unwrap(sessionInfo), itemId);
+            }
+        }, "createBatch(SessionInfo, ItemId)", new Object[]{unwrap(sessionInfo), itemId});
+    }
+
+    public void submit(final Batch batch) throws RepositoryException {
+
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.submit(unwrap(batch));
+                return null;
+            }
+        }, "submit(Batch)", new Object[]{unwrap(batch)});
+    }
+
+    public void importXml(final SessionInfo sessionInfo, final NodeId parentId, final InputStream xmlStream,
+            final int uuidBehaviour) throws RepositoryException {
+
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.importXml(unwrap(sessionInfo), parentId, xmlStream, uuidBehaviour);
+                return null;
+            }
+        }, "importXml(SessionInfo, NodeId, InputStream, int)",
+                new Object[]{unwrap(sessionInfo), parentId, xmlStream, new Integer(uuidBehaviour)});
+    }
+
+    public void move(final SessionInfo sessionInfo, final NodeId srcNodeId, final NodeId destParentNodeId,
+            final Name destName) throws RepositoryException {
+
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.move(unwrap(sessionInfo), srcNodeId, destParentNodeId, destName);
+                return null;
+            }
+        }, "move(SessionInfo, NodeId, NodeId, Name)",
+                new Object[]{unwrap(sessionInfo), srcNodeId, destParentNodeId, destName});
+    }
+
+    public void copy(final SessionInfo sessionInfo, final String srcWorkspaceName, final NodeId srcNodeId,
+            final NodeId destParentNodeId, final Name destName) throws RepositoryException {
+
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.copy(unwrap(sessionInfo), srcWorkspaceName, srcNodeId, destParentNodeId, destName);
+                return null;
+            }
+        }, "copy(SessionInfo, String, NodeId, NodeId, Name)",
+                new Object[]{unwrap(sessionInfo), srcWorkspaceName, srcNodeId, destParentNodeId, destName});
+    }
+
+    public void update(final SessionInfo sessionInfo, final NodeId nodeId, final String srcWorkspaceName)
+            throws RepositoryException {
+
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.update(unwrap(sessionInfo), nodeId, srcWorkspaceName);
+                return null;
+            }
+        }, "update(SessionInfo, NodeId, String)", new Object[]{unwrap(sessionInfo), nodeId, srcWorkspaceName});
+    }
+
+    public void clone(final SessionInfo sessionInfo, final String srcWorkspaceName, final NodeId srcNodeId,
+            final NodeId destParentNodeId, final Name destName, final boolean removeExisting)
+            throws RepositoryException {
+
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.clone(unwrap(sessionInfo), srcWorkspaceName, srcNodeId, destParentNodeId, destName,
+                        removeExisting);
+                return null;
+            }
+        }, "clone(SessionInfo, String, NodeId, NodeId, Name, boolean)",
+                new Object[] { unwrap(sessionInfo), srcWorkspaceName, srcNodeId, destParentNodeId, destName,
+                Boolean.valueOf(removeExisting) });
+    }
+
+    public LockInfo getLockInfo(final SessionInfo sessionInfo, final NodeId nodeId)
+            throws RepositoryException {
+
+        return (LockInfo) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getLockInfo(unwrap(sessionInfo), nodeId);
+            }
+        }, "getLockInfo(SessionInfo, NodeId)", new Object[]{unwrap(sessionInfo), nodeId});
+    }
+
+    public LockInfo lock(final SessionInfo sessionInfo, final NodeId nodeId, final boolean deep,
+            final boolean sessionScoped) throws RepositoryException {
+
+        return (LockInfo) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.lock(unwrap(sessionInfo), nodeId, deep, sessionScoped);
+            }
+        }, "lock(SessionInfo, NodeId, boolean, boolean)",
+                new Object[]{unwrap(sessionInfo), nodeId, Boolean.valueOf(deep), Boolean.valueOf(sessionScoped)});
+    }
+
+    public LockInfo lock(final SessionInfo sessionInfo, final NodeId nodeId, final boolean deep,
+            final boolean sessionScoped, final long timeoutHint, final String ownerHint)
+            throws RepositoryException {
+
+        return (LockInfo) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.lock(unwrap(sessionInfo), nodeId, deep, sessionScoped, timeoutHint, ownerHint);
+            }
+        }, "lock(SessionInfo, NodeId, boolean, boolean, long, String)",
+                new Object[] { unwrap(sessionInfo),
+                nodeId, Boolean.valueOf(deep), Boolean.valueOf(sessionScoped), new Long(timeoutHint),
+                ownerHint });
+    }
+
+    public void refreshLock(final SessionInfo sessionInfo, final NodeId nodeId)
+            throws RepositoryException {
+
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.refreshLock(unwrap(sessionInfo), nodeId);
+                return null;
+            }
+        }, "refreshLock(SessionInfo, NodeId)", new Object[]{unwrap(sessionInfo), nodeId});
+    }
+
+    public void unlock(final SessionInfo sessionInfo, final NodeId nodeId)
+            throws RepositoryException {
+
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.unlock(unwrap(sessionInfo), nodeId);
+                return null;
+            }
+        }, "unlock(SessionInfo, NodeId)", new Object[]{unwrap(sessionInfo), nodeId});
+    }
+
+    public NodeId checkin(final SessionInfo sessionInfo, final NodeId nodeId) throws RepositoryException {
+
+        return (NodeId) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.checkin(unwrap(sessionInfo), nodeId);
+            }
+        }, "checkin(SessionInfo, NodeId)", new Object[]{unwrap(sessionInfo), nodeId});
+    }
+
+    public void checkout(final SessionInfo sessionInfo, final NodeId nodeId)
+            throws RepositoryException {
+
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.checkout(unwrap(sessionInfo), nodeId);
+                return null;
+            }
+        }, "checkout(SessionInfo, NodeId)", new Object[]{unwrap(sessionInfo), nodeId});
+    }
+
+    public void removeVersion(final SessionInfo sessionInfo, final NodeId versionHistoryId,
+            final NodeId versionId) throws RepositoryException {
+
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.removeVersion(unwrap(sessionInfo), versionHistoryId, versionId);
+                return null;
+            }
+        }, "removeVersion(SessionInfo, NodeId, NodeId)",
+                new Object[]{unwrap(sessionInfo), versionHistoryId, versionId});
+    }
+
+    public void restore(final SessionInfo sessionInfo, final NodeId nodeId, final NodeId versionId,
+            final boolean removeExisting) throws RepositoryException {
+
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.restore(unwrap(sessionInfo), nodeId, versionId, removeExisting);
+                return null;
+            }
+        }, "restore(SessionInfo, NodeId, NodeId, boolean)",
+                new Object[]{unwrap(sessionInfo), nodeId, versionId, Boolean.valueOf(removeExisting)});
+    }
+
+    public void restore(final SessionInfo sessionInfo, final NodeId[] nodeIds, final boolean removeExisting)
+            throws RepositoryException {
+
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.restore(unwrap(sessionInfo), nodeIds, removeExisting);
+                return null;
+            }
+        }, "restore(SessionInfo, NodeId[], boolean)",
+                new Object[]{unwrap(sessionInfo), nodeIds, Boolean.valueOf(removeExisting)});
+    }
+
+    public Iterator merge(final SessionInfo sessionInfo, final NodeId nodeId, final String srcWorkspaceName,
+            final boolean bestEffort) throws RepositoryException {
+
+        return (Iterator) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.merge(unwrap(sessionInfo), nodeId, srcWorkspaceName, bestEffort);
+            }
+        }, "merge(SessionInfo, NodeId, String, boolean)",
+                new Object[]{unwrap(sessionInfo), nodeId, srcWorkspaceName, Boolean.valueOf(bestEffort)});
+    }
+
+    public void resolveMergeConflict(final SessionInfo sessionInfo, final NodeId nodeId,
+            final NodeId[] mergeFailedIds, final NodeId[] predecessorIds) throws RepositoryException {
+
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.resolveMergeConflict(unwrap(sessionInfo), nodeId, mergeFailedIds, predecessorIds);
+                return null;
+            }
+        }, "resolveMergeConflict(SessionInfo, NodeId, NodeId[], NodeId[])",
+                new Object[]{unwrap(sessionInfo), nodeId, mergeFailedIds, predecessorIds});
+    }
+
+    public void addVersionLabel(final SessionInfo sessionInfo, final NodeId versionHistoryId,
+            final NodeId versionId, final Name label, final boolean moveLabel) throws RepositoryException {
+
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.addVersionLabel(unwrap(sessionInfo), versionHistoryId, versionId, label, moveLabel);
+                return null;
+            }
+        }, "addVersionLabel(SessionInfo, NodeId, NodeId, Name, boolean)",
+                new Object[]{unwrap(sessionInfo), versionHistoryId, versionId, label, Boolean.valueOf(moveLabel)});
+    }
+
+    public void removeVersionLabel(final SessionInfo sessionInfo, final NodeId versionHistoryId,
+            final NodeId versionId, final Name label) throws RepositoryException {
+
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.removeVersionLabel(unwrap(sessionInfo), versionHistoryId, versionId, label);
+                return null;
+            }
+        }, "removeVersionLabel(SessionInfo, NodeId, NodeId, Name)",
+                new Object[]{unwrap(sessionInfo), versionHistoryId, versionId, label});
+    }
+
+    public String[] getSupportedQueryLanguages(final SessionInfo sessionInfo) throws RepositoryException {
+        return (String[]) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getSupportedQueryLanguages(unwrap(sessionInfo));
+            }
+        }, "getSupportedQueryLanguages(SessionInfo)", new Object[]{unwrap(sessionInfo)});
+    }
+
+    public void checkQueryStatement(final SessionInfo sessionInfo, final String statement,
+            final String language, final Map namespaces) throws RepositoryException {
+
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.checkQueryStatement(unwrap(sessionInfo), statement, language, namespaces);
+                return null;
+            }
+        }, "checkQueryStatement(SessionInfo, String, String, Map)",
+                new Object[]{unwrap(sessionInfo), statement, language, namespaces});
+    }
+
+    public QueryInfo executeQuery(final SessionInfo sessionInfo, final String statement,
+            final String language, final Map namespaces) throws RepositoryException {
+
+        return (QueryInfo) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.executeQuery(unwrap(sessionInfo), statement, language, namespaces);
+            }
+        }, "executeQuery(SessionInfo, String, String, Map)",
+                new Object[]{unwrap(sessionInfo), statement, language, namespaces});
+    }
+
+    public EventFilter createEventFilter(final SessionInfo sessionInfo, final int eventTypes,
+            final Path absPath, final boolean isDeep, final String[] uuid, final Name[] qnodeTypeName,
+            final boolean noLocal) throws RepositoryException {
+
+        return (EventFilter) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.createEventFilter(unwrap(sessionInfo), eventTypes, absPath, isDeep, uuid,
+                       qnodeTypeName, noLocal);
+            }
+        }, "createEventFilter(SessionInfo, int, Path, boolean, String[], Name[], boolean)",
+                new Object[]{unwrap(sessionInfo), new Integer(eventTypes), absPath, Boolean.valueOf(isDeep), uuid,
+                qnodeTypeName, Boolean.valueOf(noLocal)});
+    }
+
+    public Subscription createSubscription(final SessionInfo sessionInfo, final EventFilter[] filters)
+            throws RepositoryException {
+
+        return (Subscription) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.createSubscription(unwrap(sessionInfo), filters);
+            }
+        }, "createSubscription(SessionInfo, EventFilter[])",
+                new Object[]{unwrap(sessionInfo), filters});
+    }
+
+    public EventBundle[] getEvents(final Subscription subscription, final long timeout)
+            throws RepositoryException, InterruptedException {
+
+        final String methodName = "getEvents(Subscription, long)";
+        final Object[] args = new Object[]{subscription, new Long(timeout)};
+        final InterruptedException[] ex = new InterruptedException[1];
+
+        EventBundle[] result = (EventBundle[]) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                try {
+                    return service.getEvents(subscription, timeout);
+                } catch (InterruptedException e) {
+                    writer.error(methodName, args, e);
+                    ex[0] = e;
+                    return null;
+                }
+            }
+        }, methodName, args);
+
+        if (ex[0] != null) {
+            throw ex[0];
+        }
+
+        return result;
+    }
+
+    public void updateEventFilters(final Subscription subscription, final EventFilter[] eventFilters)
+            throws RepositoryException {
+
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.updateEventFilters(subscription, eventFilters);
+                return null;
+            }
+        }, "updateEventFilters(Subscription, EventFilter[])",
+                new Object[]{subscription, eventFilters});
+    }
+
+    public void dispose(final Subscription subscription) throws RepositoryException {
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.dispose(subscription);
+                return null;
+            }
+        }, "dispose(Subscription)", new Object[]{});
+    }
+
+    public Map getRegisteredNamespaces(final SessionInfo sessionInfo) throws RepositoryException {
+        return (Map) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getRegisteredNamespaces(unwrap(sessionInfo));
+            }
+        }, "getRegisteredNamespaces(SessionInfo)", new Object[]{unwrap(sessionInfo)});
+    }
+
+    public String getNamespaceURI(final SessionInfo sessionInfo, final String prefix)
+            throws RepositoryException {
+        return (String) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getNamespaceURI(unwrap(sessionInfo), prefix);
+            }
+        }, "getNamespaceURI(SessionInfo, String)", new Object[]{unwrap(sessionInfo), prefix});
+    }
+
+    public String getNamespacePrefix(final SessionInfo sessionInfo, final String uri)
+            throws RepositoryException {
+
+        return (String) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getNamespacePrefix(unwrap(sessionInfo), uri);
+            }
+        }, "getNamespacePrefix(SessionInfo, String)", new Object[]{unwrap(sessionInfo), uri});
+    }
+
+    public void registerNamespace(final SessionInfo sessionInfo, final String prefix, final String uri)
+            throws RepositoryException {
+
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.registerNamespace(unwrap(sessionInfo), prefix, uri);
+                return null;
+            }
+        }, "registerNamespace(SessionInfo, String, String)", new Object[]{unwrap(sessionInfo), prefix, uri});
+    }
+
+    public void unregisterNamespace(final SessionInfo sessionInfo, final String uri)
+            throws RepositoryException {
+
+        execute(new Callable() {
+            public Object call() throws RepositoryException {
+                service.unregisterNamespace(unwrap(sessionInfo), uri);
+                return null;
+            }
+        }, "unregisterNamespace(SessionInfo, String)", new Object[]{unwrap(sessionInfo), uri});
+    }
+
+    public Iterator getQNodeTypeDefinitions(final SessionInfo sessionInfo) throws RepositoryException {
+        return (Iterator) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getQNodeTypeDefinitions(unwrap(sessionInfo));
+            }
+        }, "getQNodeTypeDefinitions(SessionInfo)", new Object[]{unwrap(sessionInfo)});
+    }
+
+    public Iterator getQNodeTypeDefinitions(final SessionInfo sessionInfo, final Name[] nodetypeNames)
+            throws RepositoryException {
+
+        return (Iterator) execute(new Callable() {
+            public Object call() throws RepositoryException {
+                return service.getQNodeTypeDefinitions(unwrap(sessionInfo), nodetypeNames);
+            }
+        }, "getQNodeTypeDefinitions(SessionInfo, Name[])", new Object[]{unwrap(sessionInfo), nodetypeNames});
+    }
+
+    // -----------------------------------------------------< private  >---
+
+    private static SessionInfo unwrap(SessionInfo sessionInfo) {
+        if (sessionInfo instanceof SessionInfoLogger) {
+            return ((SessionInfoLogger) sessionInfo).getSessionInfo();
+        }
+        else {
+            return sessionInfo;
+        }
+    }
+
+    private static Batch unwrap(Batch batch) {
+        if (batch instanceof BatchLogger) {
+            return ((BatchLogger) batch).getBatch();
+        }
+        else {
+            return batch;
+        }
+    }
+
+}

Propchange: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/SessionInfoLogger.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/SessionInfoLogger.java?rev=757775&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/SessionInfoLogger.java (added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/SessionInfoLogger.java Tue Mar 24 13:07:48 2009
@@ -0,0 +1,90 @@
+/*
+ * 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.jackrabbit.spi.commons.logging;
+
+import org.apache.jackrabbit.spi.SessionInfo;
+
+/**
+ * Log wrapper for a {@link SessionInfo}.
+ */
+public class SessionInfoLogger extends AbstractLogger implements SessionInfo {
+    private final SessionInfo sessionInfo;
+
+    /**
+     * Create a new instance for the given <code>sessionInfo</code> which uses
+     * <code>writer</code> for persisting log messages.
+     * @param sessionInfo
+     * @param writer
+     */
+    public SessionInfoLogger(SessionInfo sessionInfo, LogWriter writer) {
+        super(writer);
+        this.sessionInfo = sessionInfo;
+    }
+
+    /**
+     * @return  the wrapped SessionInfo
+     */
+    public SessionInfo getSessionInfo() {
+        return sessionInfo;
+    }
+
+    // -----------------------------------------------------< SessionInfo >---
+
+    public String getUserID() {
+        return (String) execute(new SafeCallable() {
+            public Object call() {
+                return sessionInfo.getUserID();
+            }
+        }, "getUserID()", new Object[]{});
+    }
+
+    public String getWorkspaceName() {
+        return (String) execute(new SafeCallable() {
+            public Object call() {
+                return sessionInfo.getWorkspaceName();
+            }
+        }, "getWorkspaceName()", new Object[]{});
+    }
+
+    public String[] getLockTokens() {
+        return (String[]) execute(new SafeCallable() {
+            public Object call() {
+                return sessionInfo.getLockTokens();
+            }
+        }, "getLockTokens()", new Object[]{});
+    }
+
+    public void addLockToken(final String lockToken) {
+        execute(new SafeCallable() {
+            public Object call() {
+                sessionInfo.addLockToken(lockToken);
+                return null;
+            }
+        }, "addLockToken(String)", new Object[]{lockToken});
+    }
+
+    public void removeLockToken(final String lockToken) {
+        execute(new SafeCallable() {
+            public Object call() {
+                sessionInfo.removeLockToken(lockToken);
+                return null;
+            }
+        }, "removeLockToken(String)", new Object[]{lockToken});
+    }
+
+
+}

Propchange: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/SessionInfoLogger.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/Slf4jLogWriter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/Slf4jLogWriter.java?rev=757775&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/Slf4jLogWriter.java (added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/Slf4jLogWriter.java Tue Mar 24 13:07:48 2009
@@ -0,0 +1,123 @@
+/*
+ * 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.jackrabbit.spi.commons.logging;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import org.slf4j.Logger;
+
+/**
+ * {@link LogWriter} implementation which uses SLF4J for persisting log messages.
+ */
+public class Slf4jLogWriter implements LogWriter {
+    private final Logger log;
+
+    /**
+     * Create a new instance which uses the passed SLF4J logger for persisting
+     * the log messages.
+     * @param log
+     */
+    public Slf4jLogWriter(Logger log) {
+        super();
+        this.log = log;
+    }
+
+    /**
+     * Returns
+     * <pre>
+     *   System.currentTimeMillis();
+     * </pre>
+     * {@inheritDoc}
+     */
+    public long systemTime() {
+        return System.currentTimeMillis();
+    }
+
+    /**
+     * Logs the call at debug level is debug level is enabled.
+     * {@inheritDoc}
+     */
+    public void enter(final String methodName, final Object[] args) {
+        if (log.isDebugEnabled()) {
+            log.debug("ENTER(" + systemTime() + ") | " + methodName + "(" + formatArgs(args) + ")");
+        }
+    }
+
+    /**
+     * Logs the call at debug level is debug level is enabled.
+     * {@inheritDoc}
+     */
+    public void leave(final String methodName, final Object[] args, final Object result) {
+        if (log.isDebugEnabled()) {
+            log.debug("LEAVE(" + systemTime() + ") | " + methodName + "(" + formatArgs(args) + ") = "
+                    + formatResult(result));
+        }
+    }
+
+    /**
+     * Logs the exception including a stack trace at debug level is debug level is enabled.
+     * {@inheritDoc}
+     */
+    public void error(final String methodName, final Object[] args, final Exception e) {
+        if (log.isDebugEnabled()) {
+            log.debug("ERROR(" + systemTime() + ") | " + methodName + "(" + formatArgs(args) + ") | "
+                    + formatException(e));
+        }
+    }
+
+    // -----------------------------------------------------< private >---
+
+    private String formatArgs(Object[] args) {
+        StringBuffer b = new StringBuffer();
+        formatArgs(args, b);
+        return b.toString();
+    }
+
+    private String formatResult(Object result) {
+        StringBuffer b = new StringBuffer();
+        formatArg(result, b);
+        return b.toString();
+    }
+
+    private String formatException(Exception e) {
+        StringWriter sw = new StringWriter();
+        e.printStackTrace(new PrintWriter(sw));
+        return sw.toString();
+    }
+
+    private void formatArgs(Object[] args, StringBuffer b) {
+        String separator = "";
+        for (int k = 0; k < args.length; k++) {
+            b.append(separator);
+            formatArg(args[k], b);
+            separator = ", ";
+        }
+    }
+
+    private void formatArg(Object arg, StringBuffer b) {
+        if (arg instanceof Object[]) {
+            b.append('[');
+            formatArgs((Object[]) arg, b);
+            b.append(']');
+        }
+        else {
+            b.append(arg);
+        }
+    }
+
+}

Propchange: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/Slf4jLogWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/Slf4jLogWriterProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/Slf4jLogWriterProvider.java?rev=757775&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/Slf4jLogWriterProvider.java (added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/Slf4jLogWriterProvider.java Tue Mar 24 13:07:48 2009
@@ -0,0 +1,113 @@
+/*
+ * 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.jackrabbit.spi.commons.logging;
+
+import org.apache.jackrabbit.spi.Batch;
+import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.spi.NameFactory;
+import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.spi.SessionInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * {@link LogWriterProvider} instance which provides {@link Slf4jLogWriter}s.
+ */
+public class Slf4jLogWriterProvider implements LogWriterProvider {
+
+    /**
+     * Returns a {@link Slf4jLogWriter} if the logger for <code>
+     * service.getClass()</code> has debug level enabled. Returns
+     * <code>null</code> otherwise.
+     * {@inheritDoc}
+     */
+    public LogWriter getLogWriter(RepositoryService service) {
+        return getLogWriterInternal(service);
+    }
+
+    /**
+     * Returns a {@link Slf4jLogWriter} if the logger for <code>
+     * nameFactory.getClass()</code> has debug level enabled. Returns
+     * <code>null</code> otherwise.
+     * {@inheritDoc}
+     */
+    public LogWriter getLogWriter(NameFactory nameFactory) {
+        return getLogWriterInternal(nameFactory);
+    }
+
+    /**
+     * Returns a {@link Slf4jLogWriter} if the logger for <code>
+     * pathFactory.getClass()</code> has debug level enabled. Returns
+     * <code>null</code> otherwise.
+     * {@inheritDoc}
+     */
+    public LogWriter getLogWriter(PathFactory pathFactory) {
+        return getLogWriterInternal(pathFactory);
+    }
+
+    /**
+     * Returns a {@link Slf4jLogWriter} if the logger for <code>
+     * idFactory.getClass()</code> has debug level enabled. Returns
+     * <code>null</code> otherwise.
+     * {@inheritDoc}
+     */
+    public LogWriter getLogWriter(IdFactory idFactory) {
+        return getLogWriterInternal(idFactory);
+    }
+
+    /**
+     * Returns a {@link Slf4jLogWriter} if the logger for <code>
+     * valueFactory.getClass()</code> has debug level enabled. Returns
+     * <code>null</code> otherwise.
+     * {@inheritDoc}
+     */
+    public LogWriter getLogWriter(QValueFactory valueFactory) {
+        return getLogWriterInternal(valueFactory);
+    }
+
+    /**
+     * Returns a {@link Slf4jLogWriter} if the logger for <code>
+     * sessionInfo.getClass()</code> has debug level enabled. Returns
+     * <code>null</code> otherwise.
+     * {@inheritDoc}
+     */
+    public LogWriter getLogWriter(SessionInfo sessionInfo) {
+        return getLogWriterInternal(sessionInfo);
+    }
+
+    /**
+     * Returns a {@link Slf4jLogWriter} if the logger for <code>
+     * batch.getClass()</code> has debug level enabled. Returns
+     * <code>null</code> otherwise.
+     * {@inheritDoc}
+     */
+    public LogWriter getLogWriter(Batch batch) {
+        return getLogWriterInternal(batch);
+    }
+
+    // -----------------------------------------------------< private >---
+
+    private static LogWriter getLogWriterInternal(Object object) {
+        Logger log = LoggerFactory.getLogger(object.getClass());
+        return log.isDebugEnabled()
+            ? new Slf4jLogWriter(log)
+            : null;
+    }
+
+}

Propchange: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/Slf4jLogWriterProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message