jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r326437 [1/2] - /incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/
Date Wed, 19 Oct 2005 07:56:53 GMT
Author: mreutegg
Date: Wed Oct 19 00:56:37 2005
New Revision: 326437

URL: http://svn.apache.org/viewcvs?rev=326437&view=rev
Log:
JCR-256: Improve jcr decorator in jcr-ext
- added decoration for all required jcr interfaces
- added more factory methods to DecoratorFactory
- renamed SimpleDecoratorFactory to DefaultDecoratorFactory
- removed ChainedDecoratorFactory and ChainedItemDecorator
- added sample decorator: TrussDecoratorFactory

Added:
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/AbstractDecorator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratingPropertyIterator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratingVersionIterator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DefaultDecoratorFactory.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/ItemVisitorDecorator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/PropertyDecorator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/QueryDecorator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/QueryManagerDecorator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/QueryResultDecorator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/TrussDecoratorFactory.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/ValueFactoryDecorator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/VersionDecorator.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/VersionHistoryDecorator.java   (with props)
Removed:
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/ChainedDecoratorFactory.java
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/ChainedItemDecorator.java
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/SimpleDecoratorFactory.java
Modified:
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratingNodeIterator.java
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratingRangeIterator.java
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratorFactory.java
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/ItemDecorator.java
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/LockDecorator.java
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/NodeDecorator.java
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/SessionDecorator.java
    incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/WorkspaceDecorator.java

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/AbstractDecorator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/AbstractDecorator.java?rev=326437&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/AbstractDecorator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/AbstractDecorator.java Wed Oct 19 00:56:37 2005
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.decorator;
+
+import javax.jcr.Session;
+
+/**
+ * Provides fields to common objects used by any decorator:
+ * <ul>
+ * <li><code>DecoratorFactory</code>: the decorator factory in use</li>
+ * <li><code>Session</code>: the decorated session which was used to create
+ * this decorator</li>
+ * </ul>
+ */
+public abstract class AbstractDecorator {
+
+    /**
+     * The decorator factory. Used to decorate returned objects.
+     */
+    protected final DecoratorFactory factory;
+
+    /**
+     * The decorated session to which the returned objects belong.
+     */
+    protected final Session session;
+
+    /**
+     * Constructs an abstract decorator.
+     *
+     * @param factory decorator factory
+     * @param session decorated session
+     */
+    public AbstractDecorator(DecoratorFactory factory, Session session) {
+        this.factory = factory;
+        this.session = session;
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/AbstractDecorator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratingNodeIterator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratingNodeIterator.java?rev=326437&r1=326436&r2=326437&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratingNodeIterator.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratingNodeIterator.java Wed Oct 19 00:56:37 2005
@@ -30,15 +30,6 @@
 public class DecoratingNodeIterator extends DecoratingRangeIterator
         implements NodeIterator {
 
-    /** The decorator factory. Used to decorate all returned node instances. */
-    private final DecoratorFactory factory;
-
-    /** The decorated session to which the returned nodes belong. */
-    private final Session session;
-
-    /** The underlying node iterator. */
-    private final NodeIterator iterator;
-
     /**
      * Creates a decorating node iterator.
      *
@@ -49,9 +40,6 @@
     public DecoratingNodeIterator(
             DecoratorFactory factory, Session session, NodeIterator iterator) {
         super(factory, session, iterator);
-        this.factory = factory;
-        this.session = session;
-        this.iterator = iterator;
     }
 
     /**
@@ -61,8 +49,7 @@
      * @see NodeIterator#nextNode()
      */
     public Node nextNode() {
-        Node node = iterator.nextNode();
-        return factory.getNodeDecorator(session, node);
+        return (Node) next();
     }
 
 }

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratingPropertyIterator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratingPropertyIterator.java?rev=326437&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratingPropertyIterator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratingPropertyIterator.java Wed Oct 19 00:56:37 2005
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.decorator;
+
+import javax.jcr.Session;
+import javax.jcr.PropertyIterator;
+import javax.jcr.Property;
+
+/**
+ */
+public class DecoratingPropertyIterator extends DecoratingRangeIterator
+        implements PropertyIterator {
+
+    /**
+     * Creates a decorating property iterator.
+     *
+     * @param factory decorator factory
+     * @param session decorated session
+     * @param iterator underlying property iterator
+     */
+    public DecoratingPropertyIterator(DecoratorFactory factory,
+                 Session session,
+                 PropertyIterator iterator) {
+        super(factory, session, iterator);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public Property nextProperty() {
+        return (Property) next();
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratingPropertyIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratingRangeIterator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratingRangeIterator.java?rev=326437&r1=326436&r2=326437&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratingRangeIterator.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratingRangeIterator.java Wed Oct 19 00:56:37 2005
@@ -21,6 +21,8 @@
 import javax.jcr.Property;
 import javax.jcr.RangeIterator;
 import javax.jcr.Session;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionHistory;
 
 /**
  * Range iterator that decorates all iterated objects. This class is used
@@ -31,16 +33,11 @@
  * and best effort is made to decorate the objects returned by the
  * {@link #next() next()} method.
  */
-public class DecoratingRangeIterator implements RangeIterator {
-
-    /** The decorator factory. Used to decorate returned objects. */
-    private final DecoratorFactory factory;
-
-    /** The decorated session to which the returned objects belong. */
-    private final Session session;
+public class DecoratingRangeIterator
+        extends AbstractDecorator implements RangeIterator {
 
     /** The underlying iterator. */
-    private final RangeIterator iterator;
+    protected final RangeIterator iterator;
 
     /**
      * Creates a decorating iterator.
@@ -51,8 +48,7 @@
      */
     public DecoratingRangeIterator(
             DecoratorFactory factory, Session session, RangeIterator iterator) {
-        this.factory = factory;
-        this.session = session;
+        super(factory, session);
         this.iterator = iterator;
     }
 
@@ -107,15 +103,18 @@
      */
     public Object next() {
         Object object = iterator.next();
-        if (object instanceof Node) {
+        if (object instanceof Version) {
+            return factory.getVersionDecorator(session, (Version) object);
+        } else if (object instanceof VersionHistory) {
+            return factory.getVersionHistoryDecorator(session, (VersionHistory) object);
+        } else if (object instanceof Node) {
             return factory.getNodeDecorator(session, (Node) object);
         } else if (object instanceof Property) {
             return factory.getPropertyDecorator(session, (Property) object);
         } else if (object instanceof Item) {
             return factory.getItemDecorator(session, (Item) object);
         } else {
-            throw new UnsupportedOperationException(
-                    "No decorator available for " + object);
+            throw new UnsupportedOperationException("No decorator available for " + object);
         }
     }
 

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratingVersionIterator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratingVersionIterator.java?rev=326437&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratingVersionIterator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratingVersionIterator.java Wed Oct 19 00:56:37 2005
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.decorator;
+
+import org.apache.jackrabbit.decorator.DecoratorFactory;
+import org.apache.jackrabbit.decorator.DecoratingRangeIterator;
+
+import javax.jcr.version.VersionIterator;
+import javax.jcr.version.Version;
+import javax.jcr.Session;
+
+/**
+ */
+public class DecoratingVersionIterator extends DecoratingRangeIterator
+        implements VersionIterator {
+
+    /**
+     * Creates a decorating version iterator.
+     *
+     * @param factory decorator factory
+     * @param session decorated session
+     * @param iterator underlying version iterator
+     */
+    public DecoratingVersionIterator(DecoratorFactory factory,
+                 Session session,
+                 VersionIterator iterator) {
+        super(factory, session, iterator);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public Version nextVersion() {
+        return (Version) next();
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratingVersionIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratorFactory.java?rev=326437&r1=326436&r2=326437&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratorFactory.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DecoratorFactory.java Wed Oct 19 00:56:37 2005
@@ -22,6 +22,13 @@
 import javax.jcr.Repository;
 import javax.jcr.Session;
 import javax.jcr.Workspace;
+import javax.jcr.ValueFactory;
+import javax.jcr.ItemVisitor;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionHistory;
 import javax.jcr.lock.Lock;
 
 /**
@@ -72,6 +79,9 @@
 
     /**
      * Creates a node decorator.
+     * <p/>
+     * Note: this method must also take care to create appropriate decorators
+     * for subtypes of node: Version and VersionHistory!
      *
      * @param session the session (decorator) instance used to create the
      *                node decorator
@@ -103,10 +113,81 @@
     /**
      * Creates a lock decorator.
      *
-     * @param node the node (decorator) instance to which the lock is bound
-     * @param lock the underlying lock instance
+     * @param session the session (decorator) instance used to create the
+     *                lock decorator
+     * @param lock    the underlying lock instance
      * @return lock decorator
      */
-    Lock getLockDecorator(Node node, Lock lock);
+    Lock getLockDecorator(Session session, Lock lock);
+
+    /**
+     * Creates a version decorator.
+     *
+     * @param session the session (decorator) instance used to create the version
+     *                decorator
+     * @param version the underlying version instance
+     * @return version decorator
+     */
+    Version getVersionDecorator(Session session, Version version);
+
+    /**
+     * Creates a version history decorator.
+     *
+     * @param session        the session (decorator) instance used to create the
+     *                       version history decorator.
+     * @param versionHistory the underlying version history instance
+     * @return version history decorator
+     */
+    VersionHistory getVersionHistoryDecorator(Session session,
+                                              VersionHistory versionHistory);
+
+    /**
+     * Creates a query manager decorator.
+     *
+     * @param session      the session (decorator) instance used to create the
+     *                     query manager decorator.
+     * @param queryManager the underlying query manager instance.
+     * @return query manager decorator.
+     */
+    QueryManager getQueryManagerDecorator(Session session, QueryManager queryManager);
+
+    /**
+     * Creates a query decorator.
+     *
+     * @param session the session (decorator) instance used to create the query
+     *                decorator.
+     * @param query   the underlying query instance.
+     * @return query decorator.
+     */
+    Query getQueryDecorator(Session session, Query query);
+
+    /**
+     * Creates a query result decorator.
+     *
+     * @param session the session (decorator) instance used to create the query
+     *                result decorator.
+     * @param result  the underlying query result instance.
+     * @return query result decorator.
+     */
+    QueryResult getQueryResultDecorator(Session session, QueryResult result);
 
+    /**
+     * Creates a value factory decorator.
+     *
+     * @param session      the session (decorator) instance used to create the
+     *                     value factory decorator.
+     * @param valueFactory the underlying value factory instance.
+     * @return value factory decorator.
+     */
+    ValueFactory getValueFactoryDecorator(Session session, ValueFactory valueFactory);
+
+    /**
+     * Creates a item visitor decorator.
+     *
+     * @param session the session (decorator) instance used to create the item
+     *                visitor decorator.
+     * @param visitor the underlying item visitor instance.
+     * @return item visitor decorator.
+     */
+    ItemVisitor getItemVisitorDecorator(Session session, ItemVisitor visitor);
 }

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DefaultDecoratorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DefaultDecoratorFactory.java?rev=326437&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DefaultDecoratorFactory.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DefaultDecoratorFactory.java Wed Oct 19 00:56:37 2005
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.decorator;
+
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.Repository;
+import javax.jcr.Session;
+import javax.jcr.Workspace;
+import javax.jcr.ValueFactory;
+import javax.jcr.ItemVisitor;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.QueryManager;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionHistory;
+import javax.jcr.lock.Lock;
+
+/**
+ * Default implementation of a {@link DecoratorFactory}. All decorator instances
+ * simply wrap the original instance and forward the call to it.
+ */
+public class DefaultDecoratorFactory implements DecoratorFactory {
+
+    /**
+     * {@inheritDoc}
+     */
+    public Repository getRepositoryDecorator(Repository repository) {
+        return new RepositoryDecorator(this, repository);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Session getSessionDecorator(Repository repository, Session session) {
+        return new SessionDecorator(this, repository, session);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Workspace getWorkspaceDecorator(Session session, Workspace workspace) {
+        return new WorkspaceDecorator(this, session, workspace);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Node getNodeDecorator(Session session, Node node) {
+        if (node instanceof Version) {
+            return getVersionDecorator(session, (Version) node);
+        } else if (node instanceof VersionHistory) {
+            return getVersionHistoryDecorator(session, (VersionHistory) node);
+        } else {
+            return new NodeDecorator(this, session, node);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Property getPropertyDecorator(Session session, Property property) {
+        return new PropertyDecorator(this, session, property);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Lock getLockDecorator(Session session, Lock lock) {
+        return new LockDecorator(this, session, lock);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Version getVersionDecorator(Session session, Version version) {
+        return new VersionDecorator(this, session, version);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public VersionHistory getVersionHistoryDecorator(Session session,
+                                                     VersionHistory versionHistory) {
+        return new VersionHistoryDecorator(this, session, versionHistory);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Item getItemDecorator(Session session, Item item) {
+        if (item instanceof Version) {
+            return getVersionDecorator(session, (Version) item);
+        } else if (item instanceof VersionHistory) {
+            return getVersionHistoryDecorator(session, (VersionHistory) item);
+        } else if (item instanceof Node) {
+            return getNodeDecorator(session, (Node) item);
+        } else if (item instanceof Property) {
+            return getPropertyDecorator(session, (Property) item);
+        } else {
+            return new ItemDecorator(this, session, item);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QueryManager getQueryManagerDecorator(Session session,
+                                                 QueryManager queryManager) {
+        return new QueryManagerDecorator(this, session, queryManager);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Query getQueryDecorator(Session session, Query query) {
+        return new QueryDecorator(this, session, query);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public QueryResult getQueryResultDecorator(Session session,
+                                               QueryResult result) {
+        return new QueryResultDecorator(this, session, result);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public ValueFactory getValueFactoryDecorator(Session session,
+                                                 ValueFactory valueFactory) {
+        return new ValueFactoryDecorator(this, session, valueFactory);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public ItemVisitor getItemVisitorDecorator(Session session,
+                                               ItemVisitor visitor) {
+        return new ItemVisitorDecorator(this, session, visitor);
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/DefaultDecoratorFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/ItemDecorator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/ItemDecorator.java?rev=326437&r1=326436&r2=326437&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/ItemDecorator.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/ItemDecorator.java Wed Oct 19 00:56:37 2005
@@ -30,23 +30,52 @@
 import javax.jcr.version.VersionException;
 
 /**
- * TODO
  */
-public class ItemDecorator implements Item {
+public class ItemDecorator extends AbstractDecorator implements Item {
 
-    private DecoratorFactory factory;
-
-    private Session session;
+    /**
+     * The underlying item to decorate.
+     */
+    protected final Item item;
 
-    private Item item;
 
     public ItemDecorator(DecoratorFactory factory, Session session, Item item) {
-        this.factory = factory;
-        this.session = session;
+        super(factory, session);
         this.item = item;
     }
 
     /**
+     * Returns the underlying item that <code>this</code>
+     * <code>ItemDecorator</code> decorates.
+     *
+     * @return the underlying item.
+     */
+    public Item unwrap() {
+        return item;
+    }
+
+    /**
+     * Returns the underlying <code>item</code> of the <code>item</code>
+     * that decorates it. Unwrapping <code>null</code> returns <code>null</code>.
+     *
+     * @param item decorates the underlying item.
+     * @return the underlying item.
+     * @throws IllegalStateException if <code>item</code> is not of type
+     *                               {@link ItemDecorator}.
+     */
+    public static Item unwrap(Item item) {
+        if (item == null) {
+            return null;
+        }
+        if (item instanceof ItemDecorator) {
+            item = ((ItemDecorator) item).unwrap();
+        } else {
+            throw new IllegalStateException("item is not of type ItemDecorator");
+        }
+        return item;
+    }
+
+    /**
      * Returns the decorated session through which this item decorator
      * was acquired.
      *
@@ -101,14 +130,13 @@
     }
 
     /** {@inheritDoc} */
-    public boolean isSame(Item otherItem) {
-        // TODO Auto-generated method stub
-        return false;
+    public boolean isSame(Item otherItem) throws RepositoryException {
+        return item.isSame(unwrap(otherItem));
     }
 
     /** {@inheritDoc} */
     public void accept(ItemVisitor visitor) throws RepositoryException {
-        item.accept(visitor);
+        item.accept(factory.getItemVisitorDecorator(session, visitor));
     }
 
     /** {@inheritDoc} */
@@ -131,4 +159,15 @@
         item.remove();
     }
 
+    public boolean equals(Object obj) {
+        if (obj instanceof ItemDecorator) {
+            ItemDecorator other = (ItemDecorator)obj;
+            return item.equals(other.unwrap());
+        }
+        return false;
+    }
+
+    public int hashCode() {
+        return item.hashCode();
+    }
 }

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/ItemVisitorDecorator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/ItemVisitorDecorator.java?rev=326437&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/ItemVisitorDecorator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/ItemVisitorDecorator.java Wed Oct 19 00:56:37 2005
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.decorator;
+
+import javax.jcr.ItemVisitor;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.Session;
+
+/**
+ */
+public class ItemVisitorDecorator
+        extends AbstractDecorator implements ItemVisitor {
+
+    protected final ItemVisitor visitor;
+
+    public ItemVisitorDecorator(DecoratorFactory factory, Session session, ItemVisitor visitor) {
+        super(factory, session);
+        this.visitor = visitor;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public void visit(Property property) throws RepositoryException {
+        visitor.visit(factory.getPropertyDecorator(session, property));
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public void visit(Node node) throws RepositoryException {
+        visitor.visit(factory.getNodeDecorator(session, node));
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/ItemVisitorDecorator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/LockDecorator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/LockDecorator.java?rev=326437&r1=326436&r2=326437&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/LockDecorator.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/LockDecorator.java Wed Oct 19 00:56:37 2005
@@ -18,46 +18,68 @@
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
+import javax.jcr.Session;
 import javax.jcr.lock.Lock;
 import javax.jcr.lock.LockException;
 
-public class LockDecorator implements Lock {
+/**
+ *
+ */
+public class LockDecorator extends AbstractDecorator implements Lock {
 
-    private final Node node;
+    protected final Lock lock;
 
-    private final Lock lock;
-
-    public LockDecorator(Node node, Lock lock) {
-        this.node = node;
+    public LockDecorator(DecoratorFactory factory, Session session, Lock lock) {
+        super(factory, session);
         this.lock = lock;
     }
 
+    /**
+     * @inheritDoc
+     */
     public Node getNode() {
-        return node;
+        return factory.getNodeDecorator(session, lock.getNode());
     }
 
+    /**
+     * @inheritDoc
+     */
     public String getLockOwner() {
         return lock.getLockOwner();
     }
 
+    /**
+     * @inheritDoc
+     */
     public boolean isDeep() {
         return lock.isDeep();
     }
 
+    /**
+     * @inheritDoc
+     */
     public String getLockToken() {
         return lock.getLockToken();
     }
 
+    /**
+     * @inheritDoc
+     */
     public boolean isLive() throws RepositoryException {
         return lock.isLive();
     }
 
+    /**
+     * @inheritDoc
+     */
     public boolean isSessionScoped() {
         return lock.isSessionScoped();
     }
 
+    /**
+     * @inheritDoc
+     */
     public void refresh() throws LockException, RepositoryException {
         lock.refresh();
     }
-
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/NodeDecorator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/NodeDecorator.java?rev=326437&r1=326436&r2=326437&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/NodeDecorator.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/NodeDecorator.java Wed Oct 19 00:56:37 2005
@@ -35,6 +35,7 @@
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.Value;
 import javax.jcr.ValueFormatException;
+import javax.jcr.MergeException;
 import javax.jcr.lock.Lock;
 import javax.jcr.lock.LockException;
 import javax.jcr.nodetype.ConstraintViolationException;
@@ -45,23 +46,39 @@
 import javax.jcr.version.VersionException;
 import javax.jcr.version.VersionHistory;
 
-public class NodeDecorator extends ChainedItemDecorator implements Node {
+public class NodeDecorator extends ItemDecorator implements Node {
 
-    private DecoratorFactory factory;
+    protected Node node;
 
-    private Session session;
-
-    private Node node;
-
-    public NodeDecorator(
-            ItemDecorator decorator,
-            DecoratorFactory factory, Session session, Node node) {
-        super(decorator);
-        this.factory = factory;
-        this.session = session;
+    public NodeDecorator(DecoratorFactory factory, Session session, Node node) {
+        super(factory, session, node);
         this.node = node;
     }
 
+    /**
+     * Returns the underlying <code>Node</code> of the <code>node</code>
+     * that decorates it. Unwrapping <code>null</code> returns <code>null</code>.
+     *
+     * @param node decorates the underlying node.
+     * @return the underlying node.
+     * @throws IllegalStateException if <code>node</code> is not of type
+     *                               {@link NodeDecorator}.
+     */
+    public static Node unwrap(Node node) {
+        if (node == null) {
+            return null;
+        }
+        if (node instanceof NodeDecorator) {
+            node = (Node) ((NodeDecorator) node).unwrap();
+        } else {
+            throw new IllegalStateException("node is not of type NodeDecorator");
+        }
+        return node;
+    }
+
+    /**
+     * @inheritDoc
+     */
     public Node addNode(String name) throws ItemExistsException,
             PathNotFoundException, VersionException,
             ConstraintViolationException, LockException, RepositoryException {
@@ -69,6 +86,9 @@
         return factory.getNodeDecorator(session, child);
     }
 
+    /**
+     * @inheritDoc
+     */
     public Node addNode(String name, String type) throws ItemExistsException,
             PathNotFoundException, NoSuchNodeTypeException, LockException,
             VersionException, ConstraintViolationException, RepositoryException {
@@ -76,350 +96,487 @@
         return factory.getNodeDecorator(session, child);
     }
 
-    public void orderBefore(String arg0, String arg1)
+    /**
+     * @inheritDoc
+     */
+    public void orderBefore(String srcChildRelPath, String destChildRelPath)
             throws UnsupportedRepositoryOperationException, VersionException,
-            ConstraintViolationException, ItemNotFoundException, LockException,
-            RepositoryException {
-        // TODO Auto-generated method stub
-
+            ConstraintViolationException, ItemNotFoundException,
+            LockException, RepositoryException {
+        node.orderBefore(srcChildRelPath, destChildRelPath);
     }
 
-    public Property setProperty(String arg0, Value arg1)
+    /**
+     * @inheritDoc
+     */
+    public Property setProperty(String name, Value value)
             throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        Property prop = node.setProperty(name, value);
+        return factory.getPropertyDecorator(session, prop);
     }
 
-    public Property setProperty(String arg0, Value arg1, int arg2)
+    /**
+     * @inheritDoc
+     */
+    public Property setProperty(String name, Value value, int type)
             throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        Property prop = node.setProperty(name, value, type);
+        return factory.getPropertyDecorator(session, prop);
     }
 
-    public Property setProperty(String arg0, Value[] arg1)
+    /**
+     * @inheritDoc
+     */
+    public Property setProperty(String name, Value[] values)
             throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        Property prop = node.setProperty(name, values);
+        return factory.getPropertyDecorator(session, prop);
     }
 
-    public Property setProperty(String arg0, Value[] arg1, int arg2)
+    /**
+     * @inheritDoc
+     */
+    public Property setProperty(String name, Value[] values, int type)
             throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        Property prop = node.setProperty(name, values, type);
+        return factory.getPropertyDecorator(session, prop);
     }
 
-    public Property setProperty(String arg0, String[] arg1)
+    /**
+     * @inheritDoc
+     */
+    public Property setProperty(String name, String[] values)
             throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        Property prop = node.setProperty(name, values);
+        return factory.getPropertyDecorator(session, prop);
     }
 
-    public Property setProperty(String arg0, String[] arg1, int arg2)
+    /**
+     * @inheritDoc
+     */
+    public Property setProperty(String name, String[] values, int type)
             throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        Property prop = node.setProperty(name, values, type);
+        return factory.getPropertyDecorator(session, prop);
     }
 
-    public Property setProperty(String arg0, String arg1)
+    /**
+     * @inheritDoc
+     */
+    public Property setProperty(String name, String value)
             throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        Property prop = node.setProperty(name, value);
+        return factory.getPropertyDecorator(session, prop);
     }
 
-    public Property setProperty(String arg0, String arg1, int arg2)
+    /**
+     * @inheritDoc
+     */
+    public Property setProperty(String name, String value, int type)
             throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        Property prop = node.setProperty(name, value, type);
+        return factory.getPropertyDecorator(session, prop);
     }
 
-    public Property setProperty(String arg0, InputStream arg1)
+    /**
+     * @inheritDoc
+     */
+    public Property setProperty(String name, InputStream value)
             throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        Property prop = node.setProperty(name, value);
+        return factory.getPropertyDecorator(session, prop);
     }
 
-    public Property setProperty(String arg0, boolean arg1)
+    /**
+     * @inheritDoc
+     */
+    public Property setProperty(String name, boolean value)
             throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        Property prop = node.setProperty(name, value);
+        return factory.getPropertyDecorator(session, prop);
     }
 
-    public Property setProperty(String arg0, double arg1)
+    /**
+     * @inheritDoc
+     */
+    public Property setProperty(String name, double value)
             throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        Property prop = node.setProperty(name, value);
+        return factory.getPropertyDecorator(session, prop);
     }
 
-    public Property setProperty(String arg0, long arg1)
+    /**
+     * @inheritDoc
+     */
+    public Property setProperty(String name, long value)
             throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        Property prop = node.setProperty(name, value);
+        return factory.getPropertyDecorator(session, prop);
     }
 
-    public Property setProperty(String arg0, Calendar arg1)
+    /**
+     * @inheritDoc
+     */
+    public Property setProperty(String name, Calendar value)
             throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        Property prop = node.setProperty(name, value);
+        return factory.getPropertyDecorator(session, prop);
     }
 
-    public Property setProperty(String arg0, Node arg1)
+    /**
+     * @inheritDoc
+     */
+    public Property setProperty(String name, Node value)
             throws ValueFormatException, VersionException, LockException,
             ConstraintViolationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        Property prop = node.setProperty(name, NodeDecorator.unwrap(value));
+        return factory.getPropertyDecorator(session, prop);
     }
 
-    public Node getNode(String arg0) throws PathNotFoundException,
-            RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+    /**
+     * @inheritDoc
+     */
+    public Node getNode(String relPath) throws PathNotFoundException, RepositoryException {
+        Node n = node.getNode(relPath);
+        return factory.getNodeDecorator(session, n);
     }
 
+    /**
+     * @inheritDoc
+     */
     public NodeIterator getNodes() throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        return new DecoratingNodeIterator(factory, session, node.getNodes());
     }
 
-    public NodeIterator getNodes(String arg0) throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+    /**
+     * @inheritDoc
+     */
+    public NodeIterator getNodes(String namePattern)
+            throws RepositoryException {
+        return new DecoratingNodeIterator(factory, session, node.getNodes(namePattern));
     }
 
-    public Property getProperty(String arg0) throws PathNotFoundException,
-            RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+    /**
+     * @inheritDoc
+     */
+    public Property getProperty(String relPath)
+            throws PathNotFoundException, RepositoryException {
+        Property prop = node.getProperty(relPath);
+        return factory.getPropertyDecorator(session, prop);
     }
 
+    /**
+     * @inheritDoc
+     */
     public PropertyIterator getProperties() throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        return new DecoratingPropertyIterator(factory, session, node.getProperties());
     }
 
-    public PropertyIterator getProperties(String arg0)
+    /**
+     * @inheritDoc
+     */
+    public PropertyIterator getProperties(String namePattern)
             throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        return new DecoratingPropertyIterator(factory, session, node.getProperties(namePattern));
     }
 
+    /**
+     * @inheritDoc
+     */
     public Item getPrimaryItem() throws ItemNotFoundException,
             RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        return factory.getItemDecorator(session, node.getPrimaryItem());
     }
 
+    /**
+     * @inheritDoc
+     */
     public String getUUID() throws UnsupportedRepositoryOperationException,
             RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        return node.getUUID();
     }
 
+    /**
+     * @inheritDoc
+     */
     public int getIndex() throws RepositoryException {
-        // TODO Auto-generated method stub
-        return 0;
+        return node.getIndex();
     }
 
+    /**
+     * @inheritDoc
+     */
     public PropertyIterator getReferences() throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        return new DecoratingPropertyIterator(factory, session, node.getReferences());
     }
 
-    public boolean hasNode(String arg0) throws RepositoryException {
-        // TODO Auto-generated method stub
-        return false;
+    /**
+     * @inheritDoc
+     */
+    public boolean hasNode(String relPath) throws RepositoryException {
+        return node.hasNode(relPath);
     }
 
-    public boolean hasProperty(String arg0) throws RepositoryException {
-        // TODO Auto-generated method stub
-        return false;
+    /**
+     * @inheritDoc
+     */
+    public boolean hasProperty(String relPath) throws RepositoryException {
+        return node.hasProperty(relPath);
     }
 
+    /**
+     * @inheritDoc
+     */
     public boolean hasNodes() throws RepositoryException {
-        // TODO Auto-generated method stub
-        return false;
+        return node.hasNodes();
     }
 
+    /**
+     * @inheritDoc
+     */
     public boolean hasProperties() throws RepositoryException {
-        // TODO Auto-generated method stub
-        return false;
+        return node.hasProperties();
     }
 
+    /**
+     * @inheritDoc
+     */
     public NodeType getPrimaryNodeType() throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        return node.getPrimaryNodeType();
     }
 
+    /**
+     * @inheritDoc
+     */
     public NodeType[] getMixinNodeTypes() throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        return node.getMixinNodeTypes();
     }
 
-    public boolean isNodeType(String arg0) throws RepositoryException {
-        // TODO Auto-generated method stub
-        return false;
+    /**
+     * @inheritDoc
+     */
+    public boolean isNodeType(String nodeTypeName) throws RepositoryException {
+        return node.isNodeType(nodeTypeName);
     }
 
-    public void addMixin(String arg0) throws NoSuchNodeTypeException,
-            VersionException, ConstraintViolationException, LockException,
-            RepositoryException {
-        // TODO Auto-generated method stub
-
+    /**
+     * @inheritDoc
+     */
+    public void addMixin(String mixinName)
+            throws NoSuchNodeTypeException, VersionException,
+            ConstraintViolationException, LockException, RepositoryException {
+        node.addMixin(mixinName);
     }
 
-    public void removeMixin(String arg0) throws NoSuchNodeTypeException,
-            VersionException, ConstraintViolationException, LockException,
-            RepositoryException {
-        // TODO Auto-generated method stub
-
+    /**
+     * @inheritDoc
+     */
+    public void removeMixin(String mixinName)
+            throws NoSuchNodeTypeException, VersionException,
+            ConstraintViolationException, LockException, RepositoryException {
+        node.removeMixin(mixinName);
     }
 
-    public boolean canAddMixin(String arg0) throws NoSuchNodeTypeException,
-            RepositoryException {
-        // TODO Auto-generated method stub
-        return false;
+    /**
+     * @inheritDoc
+     */
+    public boolean canAddMixin(String mixinName)
+            throws NoSuchNodeTypeException, RepositoryException {
+        return node.canAddMixin(mixinName);
     }
 
+    /**
+     * @inheritDoc
+     */
     public NodeDefinition getDefinition() throws RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        return node.getDefinition();
     }
 
+    /**
+     * @inheritDoc
+     */
     public Version checkin() throws VersionException,
             UnsupportedRepositoryOperationException, InvalidItemStateException,
             LockException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        Version version = node.checkin();
+        return factory.getVersionDecorator(session, version);
     }
 
+    /**
+     * @inheritDoc
+     */
     public void checkout() throws UnsupportedRepositoryOperationException,
             LockException, RepositoryException {
-        // TODO Auto-generated method stub
-
+        node.checkout();
     }
 
-    public void doneMerge(Version arg0) throws VersionException,
-            InvalidItemStateException, UnsupportedRepositoryOperationException,
-            RepositoryException {
-        // TODO Auto-generated method stub
-
-    }
-
-    public void cancelMerge(Version arg0) throws VersionException,
-            InvalidItemStateException, UnsupportedRepositoryOperationException,
-            RepositoryException {
-        // TODO Auto-generated method stub
-
-    }
-
-    public void update(String arg0) throws NoSuchWorkspaceException,
-            AccessDeniedException, LockException, InvalidItemStateException,
-            RepositoryException {
-        // TODO Auto-generated method stub
-
+    /**
+     * @inheritDoc
+     */
+    public void doneMerge(Version version)
+            throws VersionException, InvalidItemStateException,
+            UnsupportedRepositoryOperationException, RepositoryException {
+        node.doneMerge(VersionDecorator.unwrap(version));
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public void cancelMerge(Version version)
+            throws VersionException, InvalidItemStateException,
+            UnsupportedRepositoryOperationException, RepositoryException {
+        node.cancelMerge(VersionDecorator.unwrap(version));
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public void update(String srcWorkspaceName)
+            throws NoSuchWorkspaceException, AccessDeniedException,
+            LockException, InvalidItemStateException, RepositoryException {
+        node.update(srcWorkspaceName);
     }
 
-    public NodeIterator merge(String arg0, boolean arg1)
+    /**
+     * @inheritDoc
+     */
+    public NodeIterator merge(String srcWorkspace, boolean bestEffort)
             throws NoSuchWorkspaceException, AccessDeniedException,
-            VersionException, LockException, InvalidItemStateException,
+            MergeException, LockException, InvalidItemStateException,
             RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        NodeIterator nodes = node.merge(srcWorkspace, bestEffort);
+        return new DecoratingNodeIterator(factory, session, nodes);
     }
 
-    public String getCorrespondingNodePath(String arg0)
+    /**
+     * @inheritDoc
+     */
+    public String getCorrespondingNodePath(String workspaceName)
             throws ItemNotFoundException, NoSuchWorkspaceException,
             AccessDeniedException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        return node.getCorrespondingNodePath(workspaceName);
     }
 
+    /**
+     * @inheritDoc
+     */
     public boolean isCheckedOut() throws RepositoryException {
-        // TODO Auto-generated method stub
-        return false;
+        return node.isCheckedOut();
     }
 
-    public void restore(String arg0, boolean arg1) throws VersionException,
-            ItemExistsException, UnsupportedRepositoryOperationException,
-            LockException, InvalidItemStateException, RepositoryException {
-        // TODO Auto-generated method stub
-
+    /**
+     * @inheritDoc
+     */
+    public void restore(String versionName, boolean removeExisting)
+            throws VersionException, ItemExistsException,
+            UnsupportedRepositoryOperationException, LockException,
+            InvalidItemStateException, RepositoryException {
+        node.restore(versionName, removeExisting);
     }
 
-    public void restore(Version arg0, boolean arg1) throws VersionException,
-            ItemExistsException, UnsupportedRepositoryOperationException,
-            LockException, RepositoryException {
-        // TODO Auto-generated method stub
-
+    /**
+     * @inheritDoc
+     */
+    public void restore(Version version, boolean removeExisting)
+            throws VersionException, ItemExistsException,
+            UnsupportedRepositoryOperationException, LockException,
+            RepositoryException {
+        node.restore(VersionDecorator.unwrap(version), removeExisting);
     }
 
-    public void restore(Version arg0, String arg1, boolean arg2)
+    /**
+     * @inheritDoc
+     */
+    public void restore(Version version,
+                        String relPath,
+                        boolean removeExisting)
             throws PathNotFoundException, ItemExistsException,
             VersionException, ConstraintViolationException,
             UnsupportedRepositoryOperationException, LockException,
             InvalidItemStateException, RepositoryException {
-        // TODO Auto-generated method stub
-
+        node.restore(VersionDecorator.unwrap(version), relPath, removeExisting);
     }
 
-    public void restoreByLabel(String arg0, boolean arg1)
+    /**
+     * @inheritDoc
+     */
+    public void restoreByLabel(String versionLabel, boolean removeExisting)
             throws VersionException, ItemExistsException,
             UnsupportedRepositoryOperationException, LockException,
             InvalidItemStateException, RepositoryException {
-        // TODO Auto-generated method stub
-
+        node.restoreByLabel(versionLabel, removeExisting);
     }
 
+    /**
+     * @inheritDoc
+     */
     public VersionHistory getVersionHistory()
             throws UnsupportedRepositoryOperationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        VersionHistory hist = node.getVersionHistory();
+        return factory.getVersionHistoryDecorator(session, hist);
     }
 
+    /**
+     * @inheritDoc
+     */
     public Version getBaseVersion()
             throws UnsupportedRepositoryOperationException, RepositoryException {
-        // TODO Auto-generated method stub
-        return null;
+        return factory.getVersionDecorator(session, node.getBaseVersion());
     }
 
-    public Lock lock(boolean arg0, boolean arg1)
+    /**
+     * @inheritDoc
+     */
+    public Lock lock(boolean isDeep, boolean isSessionScoped)
             throws UnsupportedRepositoryOperationException, LockException,
             AccessDeniedException, InvalidItemStateException,
             RepositoryException {
-        Lock lock = node.lock(arg0, arg1);
-        return factory.getLockDecorator(this, lock);
+        Lock lock = node.lock(isDeep, isSessionScoped);
+        return factory.getLockDecorator(session, lock);
     }
 
+    /**
+     * @inheritDoc
+     */
     public Lock getLock() throws UnsupportedRepositoryOperationException,
             LockException, AccessDeniedException, RepositoryException {
-        return node.getLock();
+        Lock lock = node.getLock();
+        return factory.getLockDecorator(session, lock);
     }
 
+    /**
+     * @inheritDoc
+     */
     public void unlock() throws UnsupportedRepositoryOperationException,
             LockException, AccessDeniedException, InvalidItemStateException,
             RepositoryException {
         node.unlock();
     }
 
+    /**
+     * @inheritDoc
+     */
     public boolean holdsLock() throws RepositoryException {
-        // TODO Auto-generated method stub
         return node.holdsLock();
     }
 
+    /**
+     * @inheritDoc
+     */
     public boolean isLocked() throws RepositoryException {
         return node.isLocked();
     }
-
 }

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/PropertyDecorator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/PropertyDecorator.java?rev=326437&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/PropertyDecorator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/PropertyDecorator.java Wed Oct 19 00:56:37 2005
@@ -0,0 +1,225 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.decorator;
+
+import javax.jcr.Property;
+import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.Session;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.lock.LockException;
+import javax.jcr.version.VersionException;
+import java.io.InputStream;
+import java.util.Calendar;
+
+/**
+ */
+public class PropertyDecorator extends ItemDecorator implements Property {
+
+    protected final Property property;
+
+    public PropertyDecorator(DecoratorFactory factory,
+                             Session session,
+                             Property property) {
+        super(factory, session, property);
+        this.property = property;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public void setValue(Value value)
+            throws ValueFormatException, VersionException, LockException,
+            ConstraintViolationException, RepositoryException {
+        property.setValue(value);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public void setValue(Value[] values)
+            throws ValueFormatException, VersionException, LockException,
+            ConstraintViolationException, RepositoryException {
+        property.setValue(values);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public void setValue(String s)
+            throws ValueFormatException, VersionException, LockException,
+            ConstraintViolationException, RepositoryException {
+        property.setValue(s);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public void setValue(String[] strings)
+            throws ValueFormatException, VersionException, LockException,
+            ConstraintViolationException, RepositoryException {
+        property.setValue(strings);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public void setValue(InputStream inputStream)
+            throws ValueFormatException, VersionException, LockException,
+            ConstraintViolationException, RepositoryException {
+        property.setValue(inputStream);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public void setValue(long l)
+            throws ValueFormatException, VersionException, LockException,
+            ConstraintViolationException, RepositoryException {
+        property.setValue(l);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public void setValue(double v)
+            throws ValueFormatException, VersionException, LockException,
+            ConstraintViolationException, RepositoryException {
+        property.setValue(v);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public void setValue(Calendar calendar)
+            throws ValueFormatException, VersionException, LockException,
+            ConstraintViolationException, RepositoryException {
+        property.setValue(calendar);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public void setValue(boolean b)
+            throws ValueFormatException, VersionException, LockException,
+            ConstraintViolationException, RepositoryException {
+        property.setValue(b);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public void setValue(Node node)
+            throws ValueFormatException, VersionException, LockException,
+            ConstraintViolationException, RepositoryException {
+        property.setValue(NodeDecorator.unwrap(node));
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public Value getValue() throws ValueFormatException, RepositoryException {
+        return property.getValue();
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public Value[] getValues() throws ValueFormatException, RepositoryException {
+        return property.getValues();
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public String getString() throws ValueFormatException, RepositoryException {
+        return property.getString();
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public InputStream getStream() throws ValueFormatException, RepositoryException {
+        return property.getStream();
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public long getLong() throws ValueFormatException, RepositoryException {
+        return property.getLong();
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public double getDouble() throws ValueFormatException, RepositoryException {
+        return property.getDouble();
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public Calendar getDate() throws ValueFormatException, RepositoryException {
+        return property.getDate();
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public boolean getBoolean() throws ValueFormatException, RepositoryException {
+        return property.getBoolean();
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public Node getNode() throws ValueFormatException, RepositoryException {
+        return factory.getNodeDecorator(session, property.getNode());
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public long getLength() throws ValueFormatException, RepositoryException {
+        return property.getLength();
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public long[] getLengths() throws ValueFormatException, RepositoryException {
+        return property.getLengths();
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public PropertyDefinition getDefinition() throws RepositoryException {
+        return property.getDefinition();
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public int getType() throws RepositoryException {
+        return property.getType();
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/PropertyDecorator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/QueryDecorator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/QueryDecorator.java?rev=326437&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/QueryDecorator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/QueryDecorator.java Wed Oct 19 00:56:37 2005
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.decorator;
+
+import org.apache.jackrabbit.decorator.DecoratorFactory;
+
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryResult;
+import javax.jcr.RepositoryException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.Node;
+import javax.jcr.ItemExistsException;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Session;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.version.VersionException;
+
+/**
+ */
+public class QueryDecorator extends AbstractDecorator implements Query {
+
+    protected final Query query;
+
+    public QueryDecorator(DecoratorFactory factory, Session session, Query query) {
+        super(factory, session);
+        this.query = query;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public QueryResult execute() throws RepositoryException {
+        return factory.getQueryResultDecorator(session, query.execute());
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public String getStatement() {
+        return query.getStatement();
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public String getLanguage() {
+        return query.getLanguage();
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public String getStoredQueryPath() throws ItemNotFoundException, RepositoryException {
+        return query.getStoredQueryPath();
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public Node storeAsNode(String absPath) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, UnsupportedRepositoryOperationException, RepositoryException {
+        Node node = query.storeAsNode(absPath);
+        return factory.getNodeDecorator(session, node);
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/QueryDecorator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/QueryManagerDecorator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/QueryManagerDecorator.java?rev=326437&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/QueryManagerDecorator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/QueryManagerDecorator.java Wed Oct 19 00:56:37 2005
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.decorator;
+
+import org.apache.jackrabbit.decorator.DecoratorFactory;
+import org.apache.jackrabbit.decorator.NodeDecorator;
+
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.Query;
+import javax.jcr.query.InvalidQueryException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.Session;
+
+/**
+ */
+public class QueryManagerDecorator
+        extends AbstractDecorator implements QueryManager {
+
+    protected final QueryManager manager;
+
+    public QueryManagerDecorator(DecoratorFactory factory, Session session, QueryManager manager) {
+        super(factory, session);
+        this.manager = manager;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public Query createQuery(String statement, String language)
+            throws InvalidQueryException, RepositoryException {
+        return factory.getQueryDecorator(session,
+                manager.createQuery(statement, language));
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public Query getQuery(Node node) throws InvalidQueryException, RepositoryException {
+        Query query = manager.getQuery(NodeDecorator.unwrap(node));
+        return factory.getQueryDecorator(session, query);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public String[] getSupportedQueryLanguages() throws RepositoryException {
+        return manager.getSupportedQueryLanguages();
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/QueryManagerDecorator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/QueryResultDecorator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/QueryResultDecorator.java?rev=326437&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/QueryResultDecorator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/QueryResultDecorator.java Wed Oct 19 00:56:37 2005
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.decorator;
+
+import org.apache.jackrabbit.decorator.DecoratorFactory;
+import org.apache.jackrabbit.decorator.DecoratingNodeIterator;
+
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.RowIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.NodeIterator;
+import javax.jcr.Session;
+
+/**
+ */
+public class QueryResultDecorator
+        extends AbstractDecorator implements QueryResult {
+
+    protected final QueryResult result;
+
+    public QueryResultDecorator(DecoratorFactory factory, Session session, QueryResult result) {
+        super(factory, session);
+        this.result = result;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public String[] getColumnNames() throws RepositoryException {
+        return result.getColumnNames();
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public RowIterator getRows() throws RepositoryException {
+        return result.getRows();
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public NodeIterator getNodes() throws RepositoryException {
+        NodeIterator nodes = result.getNodes();
+        return new DecoratingNodeIterator(factory, session, nodes);
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/QueryResultDecorator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/SessionDecorator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/SessionDecorator.java?rev=326437&r1=326436&r2=326437&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/SessionDecorator.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/SessionDecorator.java Wed Oct 19 00:56:37 2005
@@ -47,16 +47,21 @@
 import org.xml.sax.SAXException;
 
 /**
- * TODO
  */
 public class SessionDecorator implements Session {
 
-    private DecoratorFactory factory;
+    protected final DecoratorFactory factory;
 
-    private Repository repository;
+    protected final Repository repository;
 
-    private Session session;
+    protected final Session session;
 
+    /**
+     * @param factory
+     * @param repository the repository (decorator) that was used to create the
+     *                   session decorator.
+     * @param session
+     */
     public SessionDecorator(
             DecoratorFactory factory, Repository repository, Session session) {
         this.factory = factory;
@@ -121,7 +126,7 @@
      */
     public Node getRootNode() throws RepositoryException {
         Node root = session.getRootNode();
-        return factory.getNodeDecorator(session, root);
+        return factory.getNodeDecorator(this, root);
     }
 
     /**
@@ -133,7 +138,7 @@
     public Node getNodeByUUID(String uuid) throws ItemNotFoundException,
             RepositoryException {
         Node node = session.getNodeByUUID(uuid);
-        return factory.getNodeDecorator(session, node);
+        return factory.getNodeDecorator(this, node);
     }
 
     /**
@@ -147,13 +152,7 @@
     public Item getItem(String absPath) throws PathNotFoundException,
             RepositoryException {
         Item item = session.getItem(absPath);
-        if (item instanceof Node) {
-            return factory.getNodeDecorator(session, (Node) item);
-        } else if (item instanceof Property) {
-            return factory.getPropertyDecorator(session, (Property) item);
-        } else {
-            return factory.getItemDecorator(session, item);
-        }
+        return factory.getItemDecorator(this, item);
     }
 
     /**
@@ -286,7 +285,7 @@
      */
     public String getNamespaceURI(String prefix) throws NamespaceException,
             RepositoryException {
-        return session.getNamespacePrefix(prefix);
+        return session.getNamespaceURI(prefix);
     }
 
     /**
@@ -327,7 +326,7 @@
 
     public ValueFactory getValueFactory()
             throws UnsupportedRepositoryOperationException, RepositoryException {
-        return session.getValueFactory();
+        return factory.getValueFactoryDecorator(this, session.getValueFactory());
     }
 
     public boolean isLive() {

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/TrussDecoratorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/TrussDecoratorFactory.java?rev=326437&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/TrussDecoratorFactory.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/TrussDecoratorFactory.java Wed Oct 19 00:56:37 2005
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.decorator;
+
+import org.apache.log4j.Logger;
+
+import javax.jcr.Node;
+import javax.jcr.Session;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.NodeIterator;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionHistory;
+
+/**
+ * Decorator implementation that logs all calls to:
+ * <ul>
+ * <li>{@link javax.jcr.Node#getNode(String)}</li>
+ * <li>{@link javax.jcr.Node#getNodes()}</li>
+ * <li>{@link javax.jcr.Node#getNodes(String)}</li>
+ * </ul>
+ */
+public class TrussDecoratorFactory extends DefaultDecoratorFactory {
+
+    private static final Logger log = Logger.getLogger(TrussDecoratorFactory.class);
+
+    /**
+     * @inheritDoc
+     */
+    public Node getNodeDecorator(Session session, Node node) {
+        if (node instanceof Version) {
+            return getVersionDecorator(session, (Version) node);
+        } else if (node instanceof VersionHistory) {
+            return getVersionHistoryDecorator(session, (VersionHistory) node);
+        } else {
+            return new TrussNodeDecorator(this, session, node);
+        }
+    }
+
+    /**
+     * Node decorator that logs calls to {@link #getNode(String)},
+     * {@link #getNodes()} and {@link #getNodes(String)}.
+     */
+    private static final class TrussNodeDecorator extends NodeDecorator {
+
+        public TrussNodeDecorator(DecoratorFactory factory, Session session, Node node) {
+            super(factory, session, node);
+        }
+
+        /**
+         * @inheritDoc
+         */
+        public Node getNode(String relPath)
+                throws PathNotFoundException, RepositoryException {
+            log.info("<" + node.getPath() + ">.getNode(" + relPath + ")");
+            return super.getNode(relPath);
+        }
+
+        /**
+         * @inheritDoc
+         */
+        public NodeIterator getNodes() throws RepositoryException {
+            log.info("<" + node.getPath() + ">.getNodes()");
+            return super.getNodes();
+        }
+
+        /**
+         * @inheritDoc
+         */
+        public NodeIterator getNodes(String namePattern)
+                throws RepositoryException {
+            log.info("<" + node.getPath() + ">.getNodes(" + namePattern + ")");
+            return super.getNodes(namePattern);
+        }
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/TrussDecoratorFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/ValueFactoryDecorator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/ValueFactoryDecorator.java?rev=326437&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/ValueFactoryDecorator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/ValueFactoryDecorator.java Wed Oct 19 00:56:37 2005
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.decorator;
+
+import javax.jcr.ValueFactory;
+import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import java.util.Calendar;
+import java.io.InputStream;
+
+/**
+ */
+public class ValueFactoryDecorator
+        extends AbstractDecorator implements ValueFactory {
+
+    protected final ValueFactory valueFactory;
+
+    public ValueFactoryDecorator(DecoratorFactory factory, Session session, ValueFactory valueFactory) {
+        super(factory, session);
+        this.valueFactory = valueFactory;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public Value createValue(String value) {
+        return valueFactory.createValue(value);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public Value createValue(String value, int type)
+            throws ValueFormatException {
+        return valueFactory.createValue(value, type);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public Value createValue(long value) {
+        return valueFactory.createValue(value);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public Value createValue(double value) {
+        return valueFactory.createValue(value);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public Value createValue(boolean value) {
+        return valueFactory.createValue(value);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public Value createValue(Calendar value) {
+        return valueFactory.createValue(value);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public Value createValue(InputStream value) {
+        return valueFactory.createValue(value);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public Value createValue(Node value) throws RepositoryException {
+        return valueFactory.createValue(NodeDecorator.unwrap(value));
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/ValueFactoryDecorator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/VersionDecorator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/VersionDecorator.java?rev=326437&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/VersionDecorator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/VersionDecorator.java Wed Oct 19 00:56:37 2005
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.decorator;
+
+import org.apache.jackrabbit.decorator.NodeDecorator;
+import org.apache.jackrabbit.decorator.DecoratorFactory;
+
+import javax.jcr.Session;
+import javax.jcr.RepositoryException;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionHistory;
+import java.util.Calendar;
+
+/**
+ */
+public class VersionDecorator extends NodeDecorator implements Version {
+
+    protected final Version version;
+
+    public VersionDecorator(DecoratorFactory factory,
+                            Session session,
+                            Version version) {
+        super(factory, session, version);
+        this.version = version;
+    }
+
+    /**
+     * Returns the underlying <code>Version</code> of the <code>version</code>
+     * that decorates it. Unwrapping <code>null</code> returns <code>null</code>.
+     *
+     * @param version decorates the underlying version.
+     * @return the underlying version.
+     * @throws IllegalStateException if <code>version</code> is not of type
+     *                               {@link VersionDecorator}.
+     */
+    public static Version unwrap(Version version) {
+        if (version == null) {
+            return null;
+        }
+        if (version instanceof VersionDecorator) {
+            version = (Version) ((VersionDecorator) version).unwrap();
+        } else {
+            throw new IllegalStateException("version is not of type VersionDecorator");
+        }
+        return version;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public VersionHistory getContainingHistory() throws RepositoryException {
+        VersionHistory vHistory = version.getContainingHistory();
+        return factory.getVersionHistoryDecorator(session, vHistory);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public Calendar getCreated() throws RepositoryException {
+        return version.getCreated();
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public Version[] getSuccessors() throws RepositoryException {
+        Version[] successors = version.getSuccessors();
+        for (int i = 0; i < successors.length; i++) {
+            successors[i] = factory.getVersionDecorator(session, successors[i]);
+        }
+        return successors;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public Version[] getPredecessors() throws RepositoryException {
+        Version[] predecessors = version.getPredecessors();
+        for (int i = 0; i < predecessors.length; i++) {
+            predecessors[i] = factory.getVersionDecorator(session, predecessors[i]);
+        }
+        return predecessors;
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-ext/src/java/org/apache/jackrabbit/decorator/VersionDecorator.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message