Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 58725 invoked from network); 6 Jul 2007 06:29:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Jul 2007 06:29:09 -0000 Received: (qmail 21944 invoked by uid 500); 6 Jul 2007 12:29:10 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 21920 invoked by uid 500); 6 Jul 2007 12:29:10 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 21910 invoked by uid 99); 6 Jul 2007 12:29:10 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Jul 2007 05:29:10 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Jul 2007 05:29:06 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 2BD021A981A; Fri, 6 Jul 2007 05:28:44 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r553862 - in /jackrabbit/trunk/contrib/spi: commons/src/main/java/org/apache/jackrabbit/spi/commons/ spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/ spi-rmi/src/main/ja... Date: Fri, 06 Jul 2007 12:28:43 -0000 To: commits@jackrabbit.apache.org From: mreutegg@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070706122844.2BD021A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mreutegg Date: Fri Jul 6 05:28:42 2007 New Revision: 553862 URL: http://svn.apache.org/viewvc?view=rev&rev=553862 Log: JCR-1014: Convert Batch implementation in spi-rmi from remote object into a local one Added: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/SerializableBatch.java (with props) Removed: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteBatch.java jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerBatch.java Modified: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientBatch.java jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java Added: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/SerializableBatch.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/SerializableBatch.java?view=auto&rev=553862 ============================================================================== --- jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/SerializableBatch.java (added) +++ jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/SerializableBatch.java Fri Jul 6 05:28:42 2007 @@ -0,0 +1,305 @@ +/* + * 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; + +import org.apache.jackrabbit.spi.Batch; +import org.apache.jackrabbit.spi.NodeId; +import org.apache.jackrabbit.spi.QValue; +import org.apache.jackrabbit.spi.PropertyId; +import org.apache.jackrabbit.spi.ItemId; +import org.apache.jackrabbit.spi.SessionInfo; +import org.apache.jackrabbit.name.QName; + +import javax.jcr.RepositoryException; +import javax.jcr.ValueFormatException; +import javax.jcr.PathNotFoundException; +import javax.jcr.AccessDeniedException; +import javax.jcr.UnsupportedRepositoryOperationException; +import javax.jcr.ItemNotFoundException; +import javax.jcr.nodetype.ConstraintViolationException; +import javax.jcr.nodetype.NoSuchNodeTypeException; +import javax.jcr.lock.LockException; +import javax.jcr.version.VersionException; +import java.io.Serializable; +import java.util.List; +import java.util.ArrayList; +import java.util.Iterator; + +/** + * SerializableBatch implements a serializable SPI Batch, which + * simply records all calls and replays them when asked for. The client of + * this batch must ensure that the passed {@link QValue} instances are + * serializable, otherwise the serializing the Batch will fail! + */ +public class SerializableBatch implements Batch, Serializable { + + private List recording = new ArrayList(); + + private final ItemId itemId; + + /** + * Creates a new SerializableBatch. + * + * @param itemId the id of the item where save was called. To indicate that + * save was called on the session, the id of the root node + * must be passed. + */ + public SerializableBatch(ItemId itemId) { + this.itemId = itemId; + } + + /** + * @return the item id where save was called for this batch. + */ + public ItemId getSaveTarget() { + return itemId; + } + + /** + * Replays this batch on the given batch. For a description of + * the exception see {@link org.apache.jackrabbit.spi.RepositoryService#submit(Batch)}. + * + * @param batch the target batch. + */ + public void replay(Batch batch) throws PathNotFoundException, ItemNotFoundException, NoSuchNodeTypeException, ValueFormatException, VersionException, LockException, ConstraintViolationException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException { + for (Iterator it = recording.iterator(); it.hasNext(); ) { + ((Operation) it.next()).replay(batch); + } + } + + //----------------------------< Batch >------------------------------------- + + public void addNode(NodeId parentId, + QName nodeName, + QName nodetypeName, + String uuid) { + recording.add(new AddNode(parentId, nodeName, nodetypeName, uuid)); + } + + public void addProperty(NodeId parentId, QName propertyName, QValue value) { + recording.add(new AddProperty(parentId, propertyName, + new QValue[]{value}, false)); + } + + public void addProperty(NodeId parentId, + QName propertyName, + QValue[] values) { + recording.add(new AddProperty(parentId, propertyName, values, true)); + } + + public void setValue(PropertyId propertyId, QValue value) { + recording.add(new SetValue(propertyId, new QValue[]{value}, false)); + } + + public void setValue(PropertyId propertyId, QValue[] values) { + recording.add(new SetValue(propertyId, values, true)); + } + + public void remove(ItemId itemId) { + recording.add(new Remove(itemId)); + } + + public void reorderNodes(NodeId parentId, + NodeId srcNodeId, + NodeId beforeNodeId) { + recording.add(new ReorderNodes(parentId, srcNodeId, beforeNodeId)); + } + + public void setMixins(NodeId nodeId, QName[] mixinNodeTypeIds) { + recording.add(new SetMixins(nodeId, mixinNodeTypeIds)); + } + + public void move(NodeId srcNodeId, + NodeId destParentNodeId, + QName destName) { + recording.add(new Move(srcNodeId, destParentNodeId, destName)); + } + + //----------------------------< internal >---------------------------------- + + public interface Operation extends Serializable { + + /** + * Replays this operation on the given batch. + * + * @param batch the batch. + * @throws RepositoryException if an error occurs replaying the + * operation. + */ + public void replay(Batch batch) throws RepositoryException; + } + + private static class AddNode implements Operation { + + private final NodeId parentId; + + private final QName nodeName; + + private final QName nodetypeName; + + private final String uuid; + + AddNode(NodeId parentId, QName nodeName, QName nodetypeName, String uuid) { + this.parentId = parentId; + this.nodeName = nodeName; + this.nodetypeName = nodetypeName; + this.uuid = uuid; + } + + /** + * {@inheritDoc} + */ + public void replay(Batch batch) throws RepositoryException { + batch.addNode(parentId, nodeName, nodetypeName, uuid); + } + } + + private static class AddProperty implements Operation { + + private final NodeId parentId; + + private final QName propertyName; + + private final QValue[] values; + + private final boolean isMultiValued; + + AddProperty(NodeId parentId, QName propertyName, + QValue[] values, boolean isMultiValued) { + this.parentId = parentId; + this.propertyName = propertyName; + this.values = values; + this.isMultiValued = isMultiValued; + } + + /** + * {@inheritDoc} + */ + public void replay(Batch batch) throws RepositoryException { + if (isMultiValued) { + batch.addProperty(parentId, propertyName, values); + } else { + batch.addProperty(parentId, propertyName, values[0]); + } + } + } + + private static class SetValue implements Operation { + + private final PropertyId propertyId; + + private final QValue[] values; + + private final boolean isMultiValued; + + SetValue(PropertyId propertyId, QValue[] values, boolean isMultiValued) { + this.propertyId = propertyId; + this.values = values; + this.isMultiValued = isMultiValued; + } + + /** + * {@inheritDoc} + */ + public void replay(Batch batch) throws RepositoryException { + if (isMultiValued) { + batch.setValue(propertyId, values); + } else { + batch.setValue(propertyId, values[0]); + } + } + } + + private static class Remove implements Operation { + + private final ItemId itemId; + + Remove(ItemId itemId) { + this.itemId = itemId; + } + + /** + * {@inheritDoc} + */ + public void replay(Batch batch) throws RepositoryException { + batch.remove(itemId); + } + } + + private static class ReorderNodes implements Operation { + + private final NodeId parentId; + + private final NodeId srcNodeId; + + private final NodeId beforeNodeId; + + ReorderNodes(NodeId parentId, NodeId srcNodeId, NodeId beforeNodeId) { + this.parentId = parentId; + this.srcNodeId = srcNodeId; + this.beforeNodeId = beforeNodeId; + } + + /** + * {@inheritDoc} + */ + public void replay(Batch batch) throws RepositoryException { + batch.reorderNodes(parentId, srcNodeId, beforeNodeId); + } + } + + private static class SetMixins implements Operation { + + private final NodeId nodeId; + + private final QName[] mixinNodeTypeIds; + + SetMixins(NodeId nodeId, QName[] mixinNodeTypeIds) { + this.nodeId = nodeId; + this.mixinNodeTypeIds = mixinNodeTypeIds; + } + + /** + * {@inheritDoc} + */ + public void replay(Batch batch) throws RepositoryException { + batch.setMixins(nodeId, mixinNodeTypeIds); + } + } + + private static class Move implements Operation { + + private final NodeId srcNodeId; + + private final NodeId destParentNodeId; + + private final QName destName; + + Move(NodeId srcNodeId, NodeId destParentNodeId, QName destName) { + this.srcNodeId = srcNodeId; + this.destParentNodeId = destParentNodeId; + this.destName = destName; + } + + /** + * {@inheritDoc} + */ + public void replay(Batch batch) throws RepositoryException { + batch.move(srcNodeId, destParentNodeId, destName); + } + } +} Propchange: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/SerializableBatch.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientBatch.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientBatch.java?view=diff&rev=553862&r1=553861&r2=553862 ============================================================================== --- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientBatch.java (original) +++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientBatch.java Fri Jul 6 05:28:42 2007 @@ -21,40 +21,43 @@ import org.apache.jackrabbit.spi.QValue; import org.apache.jackrabbit.spi.PropertyId; import org.apache.jackrabbit.spi.ItemId; -import org.apache.jackrabbit.spi.rmi.remote.RemoteBatch; +import org.apache.jackrabbit.spi.commons.SerializableBatch; +import org.apache.jackrabbit.spi.rmi.remote.RemoteSessionInfo; import org.apache.jackrabbit.name.QName; -import javax.jcr.RepositoryException; -import javax.jcr.ValueFormatException; -import javax.jcr.PathNotFoundException; -import javax.jcr.ItemExistsException; -import javax.jcr.AccessDeniedException; -import javax.jcr.UnsupportedRepositoryOperationException; -import javax.jcr.nodetype.ConstraintViolationException; -import javax.jcr.lock.LockException; -import javax.jcr.version.VersionException; -import java.rmi.RemoteException; - /** - * ClientBatch implements a SPI {@link Batch} which wraps a remote - * batch. + * ClientBatch implements a SPI {@link Batch} which wraps a + * serializable batch. */ class ClientBatch implements Batch { /** - * The remote batch. + * The remote session info. + */ + private final RemoteSessionInfo remoteSession; + + /** + * The underlying serializable batch. */ - private final RemoteBatch remoteBatch; + private final SerializableBatch batch; - ClientBatch(RemoteBatch remoteBatch) { - this.remoteBatch = remoteBatch; + ClientBatch(ItemId itemId, RemoteSessionInfo remoteSession) { + this.remoteSession = remoteSession; + this.batch = new SerializableBatch(itemId); } /** * @return the wrapped remote batch. */ - RemoteBatch getRemoteBatch() { - return remoteBatch; + public SerializableBatch getSerializableBatch() { + return batch; + } + + /** + * @return the remote session info associated with this batch. + */ + public RemoteSessionInfo getRemoteSessionInfo() { + return remoteSession; } /** @@ -63,24 +66,15 @@ public void addNode(NodeId parentId, QName nodeName, QName nodetypeName, - String uuid) throws RepositoryException { - try { - remoteBatch.addNode(parentId, nodeName, nodetypeName, uuid); - } catch (RemoteException e) { - throw new RemoteRepositoryException(e); - } + String uuid) { + batch.addNode(parentId, nodeName, nodetypeName, uuid); } /** * {@inheritDoc} */ - public void addProperty(NodeId parentId, QName propertyName, QValue value) - throws ValueFormatException, VersionException, LockException, ConstraintViolationException, PathNotFoundException, ItemExistsException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException { - try { - remoteBatch.addProperty(parentId, propertyName, value); - } catch (RemoteException e) { - throw new RemoteRepositoryException(e); - } + public void addProperty(NodeId parentId, QName propertyName, QValue value) { + batch.addProperty(parentId, propertyName, value); } /** @@ -88,47 +82,29 @@ */ public void addProperty(NodeId parentId, QName propertyName, - QValue[] values) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, PathNotFoundException, ItemExistsException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException { - try { - remoteBatch.addProperty(parentId, propertyName, values); - } catch (RemoteException e) { - throw new RemoteRepositoryException(e); - } + QValue[] values) { + batch.addProperty(parentId, propertyName, values); } /** * {@inheritDoc} */ - public void setValue(PropertyId propertyId, QValue value) - throws RepositoryException { - try { - remoteBatch.setValue(propertyId, value); - } catch (RemoteException e) { - throw new RemoteRepositoryException(e); - } + public void setValue(PropertyId propertyId, QValue value) { + batch.setValue(propertyId, value); } /** * {@inheritDoc} */ - public void setValue(PropertyId propertyId, QValue[] values) - throws RepositoryException { - try { - remoteBatch.setValue(propertyId, values); - } catch (RemoteException e) { - throw new RemoteRepositoryException(e); - } + public void setValue(PropertyId propertyId, QValue[] values) { + batch.setValue(propertyId, values); } /** * {@inheritDoc} */ - public void remove(ItemId itemId) throws RepositoryException { - try { - remoteBatch.remove(itemId); - } catch (RemoteException e) { - throw new RemoteRepositoryException(e); - } + public void remove(ItemId itemId) { + batch.remove(itemId); } /** @@ -136,24 +112,15 @@ */ public void reorderNodes(NodeId parentId, NodeId srcNodeId, - NodeId beforeNodeId) throws RepositoryException { - try { - remoteBatch.reorderNodes(parentId, srcNodeId, beforeNodeId); - } catch (RemoteException e) { - throw new RemoteRepositoryException(e); - } + NodeId beforeNodeId) { + batch.reorderNodes(parentId, srcNodeId, beforeNodeId); } /** * {@inheritDoc} */ - public void setMixins(NodeId nodeId, QName[] mixinNodeTypeIds) - throws RepositoryException { - try { - remoteBatch.setMixins(nodeId, mixinNodeTypeIds); - } catch (RemoteException e) { - throw new RemoteRepositoryException(e); - } + public void setMixins(NodeId nodeId, QName[] mixinNodeTypeIds) { + batch.setMixins(nodeId, mixinNodeTypeIds); } /** @@ -161,11 +128,7 @@ */ public void move(NodeId srcNodeId, NodeId destParentNodeId, - QName destName) throws RepositoryException { - try { - remoteBatch.move(srcNodeId, destParentNodeId, destName); - } catch (RemoteException e) { - throw new RemoteRepositoryException(e); - } + QName destName) { + batch.move(srcNodeId, destParentNodeId, destName); } } Modified: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java?view=diff&rev=553862&r1=553861&r2=553862 ============================================================================== --- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java (original) +++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java Fri Jul 6 05:28:42 2007 @@ -306,12 +306,7 @@ */ public Batch createBatch(ItemId itemId, SessionInfo sessionInfo) throws RepositoryException { - try { - return new ClientBatch(remoteService.createBatch( - itemId, getRemoteSessionInfo(sessionInfo))); - } catch (RemoteException e) { - throw new RemoteRepositoryException(e); - } + return new ClientBatch(itemId, getRemoteSessionInfo(sessionInfo)); } /** @@ -320,7 +315,9 @@ public void submit(Batch batch) throws PathNotFoundException, ItemNotFoundException, NoSuchNodeTypeException, ValueFormatException, VersionException, LockException, ConstraintViolationException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException { if (batch instanceof ClientBatch) { try { - remoteService.submit(((ClientBatch) batch).getRemoteBatch()); + ClientBatch clientBatch = (ClientBatch) batch; + remoteService.submit(clientBatch.getRemoteSessionInfo(), + clientBatch.getSerializableBatch()); } catch (RemoteException e) { throw new RemoteRepositoryException(e); } Modified: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java?view=diff&rev=553862&r1=553861&r2=553862 ============================================================================== --- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java (original) +++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java Fri Jul 6 05:28:42 2007 @@ -28,6 +28,7 @@ import org.apache.jackrabbit.spi.QNodeTypeDefinition; import org.apache.jackrabbit.spi.SessionInfo; import org.apache.jackrabbit.spi.NodeInfo; +import org.apache.jackrabbit.spi.commons.SerializableBatch; import org.apache.jackrabbit.name.QName; import org.apache.jackrabbit.name.Path; @@ -90,7 +91,7 @@ * @return a RemoteSessionInfo if impersonate was * successful. * @throws RemoteException if an error occurs. - * @see RepositoryService#impersonate(SessionInfo, Credentials) + * @see org.apache.jackrabbit.spi.RepositoryService#impersonate(SessionInfo, Credentials) */ public RemoteSessionInfo impersonate(RemoteSessionInfo sessionInfo, Credentials credentials) @@ -230,29 +231,17 @@ throws RepositoryException, RemoteException; /** - * Indicates the start of a set of operations that cause modifications - * on the underlaying persistence layer. All modification called on the - * Batch must be executed at once or non must be executed. - * - * @param itemId - * @param sessionInfo - * @return - * @throws RemoteException if an error occurs. - * @see org.apache.jackrabbit.spi.RepositoryService#createBatch(org.apache.jackrabbit.spi.ItemId, org.apache.jackrabbit.spi.SessionInfo) - */ - public RemoteBatch createBatch(ItemId itemId, - RemoteSessionInfo sessionInfo) - throws RepositoryException, RemoteException; - - /** * Submits a batch. * - * @param batch the remote batch + * @param sessionInfo + * @param batch the batch * @throws RepositoryException * @throws RemoteException if an error occurs. * @see org.apache.jackrabbit.spi.RepositoryService#submit(org.apache.jackrabbit.spi.Batch) */ - public void submit(RemoteBatch batch) throws RepositoryException, RemoteException; + public void submit(RemoteSessionInfo sessionInfo, + SerializableBatch batch) + throws RepositoryException, RemoteException; /** * Modified: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java?view=diff&rev=553862&r1=553861&r2=553862 ============================================================================== --- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java (original) +++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java Fri Jul 6 05:28:42 2007 @@ -18,7 +18,6 @@ import org.apache.jackrabbit.spi.rmi.remote.RemoteRepositoryService; import org.apache.jackrabbit.spi.rmi.remote.RemoteSessionInfo; -import org.apache.jackrabbit.spi.rmi.remote.RemoteBatch; import org.apache.jackrabbit.spi.rmi.remote.RemoteQueryInfo; import org.apache.jackrabbit.spi.rmi.remote.RemoteIterator; import org.apache.jackrabbit.spi.ItemId; @@ -39,6 +38,7 @@ import org.apache.jackrabbit.spi.ItemInfo; import org.apache.jackrabbit.spi.Event; import org.apache.jackrabbit.spi.IdFactory; +import org.apache.jackrabbit.spi.Batch; import org.apache.jackrabbit.spi.commons.EventFilterImpl; import org.apache.jackrabbit.spi.commons.QPropertyDefinitionImpl; import org.apache.jackrabbit.spi.commons.QNodeDefinitionImpl; @@ -49,6 +49,7 @@ import org.apache.jackrabbit.spi.commons.NodeInfoImpl; import org.apache.jackrabbit.spi.commons.PropertyInfoImpl; import org.apache.jackrabbit.spi.commons.LockInfoImpl; +import org.apache.jackrabbit.spi.commons.SerializableBatch; import org.apache.jackrabbit.name.QName; import org.apache.jackrabbit.name.Path; import org.apache.jackrabbit.identifier.IdFactoryImpl; @@ -98,11 +99,6 @@ private final Map activeSessionInfos = Collections.synchronizedMap(new HashMap()); /** - * Maps remote stubs to {@link ServerBatch}es. - */ - private final Map activeBatches = Collections.synchronizedMap(new HashMap()); - - /** * Creates a new server repository service. * * @param service repository service to remote. @@ -176,8 +172,8 @@ public void dispose(RemoteSessionInfo sessionInfo) throws RepositoryException, RemoteException { try { - activeSessionInfos.remove(RemoteObject.toStub(sessionInfo)); service.dispose(getSessionInfo(sessionInfo)); + activeSessionInfos.remove(RemoteObject.toStub(sessionInfo)); } catch (RepositoryException e) { throw getRepositoryException(e); } @@ -354,34 +350,15 @@ /** * {@inheritDoc} */ - public RemoteBatch createBatch(ItemId itemId, - RemoteSessionInfo sessionInfo) + public void submit(RemoteSessionInfo sessionInfo, SerializableBatch batch) throws RepositoryException, RemoteException { try { - ServerBatch sBatch = new ServerBatch( - service.createBatch(itemId, getSessionInfo(sessionInfo))); - activeBatches.put(RemoteObject.toStub(sBatch), sBatch); - return sBatch; + Batch local = service.createBatch( + batch.getSaveTarget(), getSessionInfo(sessionInfo)); + batch.replay(local); + service.submit(local); } catch (RepositoryException e) { throw getRepositoryException(e); - } - } - - /** - * {@inheritDoc} - */ - public void submit(RemoteBatch batch) throws RepositoryException, RemoteException { - ServerBatch sBatch = (ServerBatch) activeBatches.remove( - RemoteObject.toStub(batch)); - if (sBatch != null) { - try { - service.submit(sBatch.getBatch()); - } catch (RepositoryException e) { - throw getRepositoryException(e); - } - } else { - throw new RepositoryException("Unknown RemoteBatch: " + - ((RemoteObject) batch).getRef()); } }