Author: mreutegg
Date: Tue Nov 6 02:22:50 2007
New Revision: 592358
URL: http://svn.apache.org/viewvc?rev=592358&view=rev
Log:
JCR-1204: Redesign SPI observation
- modules in sandbox
Added:
jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientSubscription.java
(with props)
jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteSubscription.java
(with props)
jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerSubscription.java
(with props)
jackrabbit/sandbox/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventSubscriptionImpl.java
(with props)
Modified:
jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RepositorySetup.java
jackrabbit/sandbox/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/LogAnalyzer.java
jackrabbit/sandbox/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/RepositoryServiceLogger.java
jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java
jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java
jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerObject.java
jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java
jackrabbit/sandbox/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
jackrabbit/sandbox/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/SessionInfoImpl.java
Modified: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RepositorySetup.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RepositorySetup.java?rev=592358&r1=592357&r2=592358&view=diff
==============================================================================
--- jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RepositorySetup.java
(original)
+++ jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RepositorySetup.java
Tue Nov 6 02:22:50 2007
@@ -204,8 +204,6 @@
throw new RepositoryException(e.getMessage());
} catch (InvalidNodeTypeDefException e) {
throw new RepositoryException(e.getMessage());
- } catch (org.apache.jackrabbit.name.NameException e) {
- throw new RepositoryException(e.getMessage());
} finally {
try {
is.close();
Modified: jackrabbit/sandbox/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/LogAnalyzer.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/LogAnalyzer.java?rev=592358&r1=592357&r2=592358&view=diff
==============================================================================
--- jackrabbit/sandbox/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/LogAnalyzer.java
(original)
+++ jackrabbit/sandbox/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/LogAnalyzer.java
Tue Nov 6 02:22:50 2007
@@ -50,7 +50,7 @@
/**
* Runs the <code>LogAnalyzer</code> on a given log file. Calls to the
- * method {@link org.apache.jackrabbit.spi.RepositoryService#getEvents(org.apache.jackrabbit.spi.SessionInfo,
long, org.apache.jackrabbit.spi.EventFilter[])}
+ * method {@link org.apache.jackrabbit.spi.RepositoryService#getEvents(org.apache.jackrabbit.spi.Subscription,
long)}
* are excluded because they contain a timeout parameter which would affect
* the statistics adversely.
*
Modified: jackrabbit/sandbox/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/RepositoryServiceLogger.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/RepositoryServiceLogger.java?rev=592358&r1=592357&r2=592358&view=diff
==============================================================================
--- jackrabbit/sandbox/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/RepositoryServiceLogger.java
(original)
+++ jackrabbit/sandbox/spi/spi-logger/src/main/java/org/apache/jackrabbit/spi/logger/RepositoryServiceLogger.java
Tue Nov 6 02:22:50 2007
@@ -36,6 +36,7 @@
import org.apache.jackrabbit.spi.Path;
import org.apache.jackrabbit.spi.NameFactory;
import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.spi.Subscription;
import javax.jcr.RepositoryException;
import javax.jcr.Credentials;
@@ -90,7 +91,7 @@
public Object call() throws RepositoryException {
return service.getPathFactory();
}
- }, "PathFactory()", new Object[]{});
+ }, "getPathFactory()", new Object[]{});
}
public IdFactory getIdFactory() throws RepositoryException {
@@ -541,25 +542,57 @@
new Object[]{new Integer(i), path, new Boolean(b), strings, qNames, new Boolean(b1)});
}
- public EventBundle[] getEvents(final SessionInfo sessionInfo,
- final long l,
- final EventFilter[] eventFilters)
+ public Subscription createSubscription(final SessionInfo sessionInfo,
+ final EventFilter[] eventFilters)
+ throws UnsupportedRepositoryOperationException, RepositoryException {
+ return (Subscription) execute(new Callable() {
+ public Object call() throws RepositoryException {
+ return service.createSubscription(sessionInfo, eventFilters);
+ }
+ }, "createSubscription(SessionInfo,EventFilter[])",
+ new Object[]{eventFilters});
+ }
+
+ public EventBundle[] getEvents(final Subscription subscription,
+ final long l)
throws RepositoryException, UnsupportedRepositoryOperationException, InterruptedException
{
final InterruptedException[] ex = new InterruptedException[1];
EventBundle[] bundles = (EventBundle[]) execute(new Callable() {
public Object call() throws RepositoryException {
try {
- return service.getEvents(sessionInfo, l, eventFilters);
+ return service.getEvents(subscription, l);
} catch (InterruptedException e) {
ex[0] = e;
return null;
}
}
- }, "getEvents(SessionInfo,long,EventFilter[])", new Object[]{new Long(l)});
+ }, "getEvents(Subscription,long)", new Object[]{new Long(l)});
if (ex[0] != null) {
throw ex[0];
}
return bundles;
+ }
+
+ public void updateEventFilters(final Subscription subscription,
+ final EventFilter[] eventFilters)
+ throws RepositoryException {
+ execute(new Callable() {
+ public Object call() throws RepositoryException {
+ service.updateEventFilters(subscription, eventFilters);
+ return null;
+ }
+ }, "updateEventFilters(Subscription,EventFilter[])",
+ new Object[]{eventFilters});
+ }
+
+ public void dispose(final Subscription subscription)
+ throws RepositoryException {
+ execute(new Callable() {
+ public Object call() throws RepositoryException {
+ service.dispose(subscription);
+ return null;
+ }
+ }, "dispose(Subscription)", new Object[]{});
}
public Map getRegisteredNamespaces(final SessionInfo sessionInfo)
Modified: jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java?rev=592358&r1=592357&r2=592358&view=diff
==============================================================================
--- jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java
(original)
+++ jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java
Tue Nov 6 02:22:50 2007
@@ -36,10 +36,12 @@
import org.apache.jackrabbit.spi.Path;
import org.apache.jackrabbit.spi.NameFactory;
import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.spi.Subscription;
import org.apache.jackrabbit.spi.rmi.remote.RemoteRepositoryService;
import org.apache.jackrabbit.spi.rmi.remote.RemoteSessionInfo;
import org.apache.jackrabbit.spi.rmi.remote.RemoteIterator;
import org.apache.jackrabbit.spi.rmi.remote.RemoteQueryInfo;
+import org.apache.jackrabbit.spi.rmi.remote.RemoteSubscription;
import org.apache.jackrabbit.spi.rmi.common.SerializableInputStream;
import org.apache.jackrabbit.value.QValueFactoryImpl;
@@ -673,13 +675,49 @@
/**
* {@inheritDoc}
*/
- public EventBundle[] getEvents(SessionInfo sessionInfo,
- long timeout,
+ public Subscription createSubscription(SessionInfo sessionInfo,
+ EventFilter[] filters)
+ throws UnsupportedRepositoryOperationException, RepositoryException {
+ try {
+ return new ClientSubscription(remoteService.createSubscription(
+ getRemoteSessionInfo(sessionInfo), filters));
+ } catch (RemoteException e) {
+ throw new RemoteRepositoryException(e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public EventBundle[] getEvents(Subscription subscription,
+ long timeout)
+ throws RepositoryException, InterruptedException {
+ try {
+ return getRemoteSubscription(subscription).getEvents(timeout);
+ } catch (RemoteException e) {
+ throw new RemoteRepositoryException(e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void updateEventFilters(Subscription subscription,
EventFilter[] filters)
- throws RepositoryException, UnsupportedRepositoryOperationException, InterruptedException
{
+ throws RepositoryException {
try {
- return remoteService.getEvents(getRemoteSessionInfo(sessionInfo),
- timeout, filters);
+ getRemoteSubscription(subscription).setFilters(filters);
+ } catch (RemoteException e) {
+ throw new RemoteRepositoryException(e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void dispose(Subscription subscription) throws RepositoryException {
+ try {
+ getRemoteSubscription(subscription).dispose();
} catch (RemoteException e) {
throw new RemoteRepositoryException(e);
}
@@ -788,6 +826,22 @@
} else {
throw new RepositoryException("Unknown SessionInfo implementation: " +
sessionInfo.getClass().getName());
+ }
+ }
+
+ /**
+ *
+ * @param subscription
+ * @return
+ * @throws RepositoryException
+ */
+ private RemoteSubscription getRemoteSubscription(Subscription subscription)
+ throws RepositoryException {
+ if (subscription instanceof ClientSubscription) {
+ return ((ClientSubscription) subscription).getRemoteSubscription();
+ } else {
+ throw new RepositoryException("Unknown Subscription implementation: " +
+ subscription.getClass().getName());
}
}
}
Added: jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientSubscription.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientSubscription.java?rev=592358&view=auto
==============================================================================
--- jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientSubscription.java
(added)
+++ jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientSubscription.java
Tue Nov 6 02:22:50 2007
@@ -0,0 +1,39 @@
+/*
+ * 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.rmi.client;
+
+import org.apache.jackrabbit.spi.Subscription;
+import org.apache.jackrabbit.spi.rmi.remote.RemoteSubscription;
+
+/**
+ * <code>ClientSubscription</code>...
+ */
+class ClientSubscription implements Subscription {
+
+ private final RemoteSubscription subscription;
+
+ public ClientSubscription(RemoteSubscription subscription) {
+ this.subscription = subscription;
+ }
+
+ /**
+ * @return the underlying remote subscription.
+ */
+ RemoteSubscription getRemoteSubscription() {
+ return subscription;
+ }
+}
Propchange: jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientSubscription.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java?rev=592358&r1=592357&r2=592358&view=diff
==============================================================================
--- jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java
(original)
+++ jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java
Tue Nov 6 02:22:50 2007
@@ -24,7 +24,6 @@
import org.apache.jackrabbit.spi.PropertyInfo;
import org.apache.jackrabbit.spi.LockInfo;
import org.apache.jackrabbit.spi.EventFilter;
-import org.apache.jackrabbit.spi.EventBundle;
import org.apache.jackrabbit.spi.SessionInfo;
import org.apache.jackrabbit.spi.NodeInfo;
import org.apache.jackrabbit.spi.commons.SerializableBatch;
@@ -573,27 +572,18 @@
throws RepositoryException, RemoteException;
/**
- * Retrieves the events that occurred since the last call to this
- * method.
+ * Creates a new remote subscription.
*
* @param sessionInfo the session info.
- * @param timeout a timeout in milliseconds to wait at most for an
- * event bundle.
- * @param filters the filters that are applied to the events as
- * they occurred on the repository.
- * @return an array of <code>EventBundle</code>s representing the external
- * events that occurred.
- * @throws RepositoryException if an error occurs while retrieving the
- * event bundles or the currently set bundle
- * identifier in <code>sessionInfo</code>
- * references an unknown or outdated event
- * bundle.
- * @throws RemoteException if an error occurs.
- * @see org.apache.jackrabbit.spi.RepositoryService#getEvents(org.apache.jackrabbit.spi.SessionInfo,
long, org.apache.jackrabbit.spi.EventFilter[])
- */
- public EventBundle[] getEvents(RemoteSessionInfo sessionInfo, long timeout,
- EventFilter[] filters)
- throws RepositoryException, InterruptedException, RemoteException;
+ * @param filters the initial list of filters.
+ * @return a remote subscription.
+ * @throws RepositoryException if an error occurs while creating the
+ * subscription.
+ * @throws RemoteException if an other error occurs.
+ */
+ public RemoteSubscription createSubscription(RemoteSessionInfo sessionInfo,
+ EventFilter[] filters)
+ throws RepositoryException, RemoteException;
/**
* Retrieve all registered namespaces. The namespace to prefix mapping is
@@ -680,7 +670,7 @@
* @return
* @throws javax.jcr.RepositoryException
* @throws RemoteException if an error occurs.
- * @see org.apache.jackrabbit.spi.RepositoryService#getQNodeTypeDefinition(org.apache.jackrabbit.spi.SessionInfo,
Name)
+ * @see org.apache.jackrabbit.spi.RepositoryService#getQNodeTypeDefinitions(SessionInfo,
Name[])
*/
public RemoteIterator getQNodeTypeDefinitions(RemoteSessionInfo sessionInfo, Name[] ntNames)
throws RepositoryException, RemoteException;
}
Added: jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteSubscription.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteSubscription.java?rev=592358&view=auto
==============================================================================
--- jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteSubscription.java
(added)
+++ jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteSubscription.java
Tue Nov 6 02:22:50 2007
@@ -0,0 +1,85 @@
+/*
+ * 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.rmi.remote;
+
+import org.apache.jackrabbit.spi.EventBundle;
+import org.apache.jackrabbit.spi.SessionInfo;
+import org.apache.jackrabbit.spi.Subscription;
+import org.apache.jackrabbit.spi.EventFilter;
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.spi.Event;
+
+import javax.jcr.RepositoryException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * <code>RemoteSubscription</code>...
+ */
+public interface RemoteSubscription extends Remote {
+
+ /**
+ * Retrieves the events that occurred since the last call to this method.
+ *
+ * @param timeout a timeout in milliseconds to wait at most for an event
+ * bundle.
+ * @return an array of <code>EventBundle</code>s representing the external
+ * events that occurred.
+ * @throws RepositoryException if an error occurs while retrieving the event
+ * bundles.
+ * @throws RemoteException if an error occurs.
+ * @see org.apache.jackrabbit.spi.RepositoryService#getEvents(SessionInfo, long, Subscription)
+ */
+ public EventBundle[] getEvents(long timeout)
+ throws RepositoryException, InterruptedException, RemoteException;
+
+ /**
+ * Sets events filters on this subscription. When this method returns all
+ * events that go through this subscription and have been generated after
+ * this method call must be filtered using the passed <code>filters</code>.
+ * <p/>
+ * An implementation is required to accept at least event filter instances
+ * created by {@link RepositoryService#createEventFilter}. Optionally an
+ * implementation may also support event filters instanciated by the client
+ * itself. An implementation may require special deployment in that case,
+ * e.g. to make the event filter implementation class available to the
+ * repository server.
+ *
+ * @param filters the filters that are applied to the events as they
+ * occurred on the repository. An event is included in an
+ * event bundle if it is {@link EventFilter#accept(Event,
+ * boolean)} accept}ed by at least one of the supplied
+ * filters. If an empty array is passed none of the potential
+ * events are include in an event bundle. This allows a
+ * client to skip or ignore events for a certain period of
+ * time.
+ * @throws RepositoryException if an error occurs while setting new filters.
+ * @throws RemoteException if a communication error occurs.
+ * @throws NullPointerException if <code>filters</code> is null.
+ */
+ public void setFilters(EventFilter[] filters)
+ throws RepositoryException, RemoteException;
+
+ /**
+ * Indicates to this subscription that it will no longer be needed.
+ *
+ * @throws RepositoryException if an error occurs while this subscription is
+ * disposed.
+ * @throws RemoteException if a communication error occurs.
+ */
+ public void dispose() throws RepositoryException, RemoteException;
+}
Propchange: jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteSubscription.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerObject.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerObject.java?rev=592358&r1=592357&r2=592358&view=diff
==============================================================================
--- jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerObject.java
(original)
+++ jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerObject.java
Tue Nov 6 02:22:50 2007
@@ -16,6 +16,12 @@
*/
package org.apache.jackrabbit.spi.rmi.server;
+import org.apache.jackrabbit.spi.EventFilter;
+import org.apache.jackrabbit.spi.SessionInfo;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.spi.commons.EventFilterImpl;
+
import javax.jcr.RepositoryException;
import javax.jcr.ValueFormatException;
import javax.jcr.UnsupportedRepositoryOperationException;
@@ -37,6 +43,7 @@
import javax.jcr.version.VersionException;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;
+import java.util.Set;
/**
* <code>ServerObject</code> provides utility methods to server objects.
@@ -102,5 +109,41 @@
} else {
return new RepositoryException(ex.getMessage());
}
+ }
+
+ /**
+ * Creates filter using the passed repository service.
+ *
+ * @param service the repository service
+ * @param sInfo the session info.
+ * @param filters the event filters created by the repository service.
+ * @return array of filter instances created by the passed repository
+ * service.
+ * @throws RepositoryException if an error occurs.
+ */
+ protected EventFilter[] createLocalEventFilters(RepositoryService service,
+ SessionInfo sInfo,
+ EventFilter[] filters)
+ throws RepositoryException {
+ if (filters == null) {
+ return null;
+ }
+ for (int i = 0; i < filters.length; i++) {
+ if (filters[i] instanceof EventFilterImpl) {
+ EventFilterImpl e = (EventFilterImpl) filters[i];
+ Set nodeTypeNames = e.getNodeTypeNames();
+ Name[] ntNames = null;
+ if (nodeTypeNames != null) {
+ ntNames = (Name[]) nodeTypeNames.toArray(new Name[nodeTypeNames.size()]);
+ }
+ filters[i] = service.createEventFilter(sInfo,
+ e.getEventTypes(), e.getAbsPath(), e.isDeep(),
+ e.getUUIDs(), ntNames, e.getNoLocal());
+ } else {
+ throw new RepositoryException("Unknown EventFilter implementation: " +
+ filters[i].getClass().getName());
+ }
+ }
+ return filters;
}
}
Modified: jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java?rev=592358&r1=592357&r2=592358&view=diff
==============================================================================
--- jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java
(original)
+++ jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java
Tue Nov 6 02:22:50 2007
@@ -20,6 +20,7 @@
import org.apache.jackrabbit.spi.rmi.remote.RemoteSessionInfo;
import org.apache.jackrabbit.spi.rmi.remote.RemoteQueryInfo;
import org.apache.jackrabbit.spi.rmi.remote.RemoteIterator;
+import org.apache.jackrabbit.spi.rmi.remote.RemoteSubscription;
import org.apache.jackrabbit.spi.ItemId;
import org.apache.jackrabbit.spi.RepositoryService;
import org.apache.jackrabbit.spi.SessionInfo;
@@ -31,12 +32,10 @@
import org.apache.jackrabbit.spi.PropertyInfo;
import org.apache.jackrabbit.spi.LockInfo;
import org.apache.jackrabbit.spi.EventFilter;
-import org.apache.jackrabbit.spi.EventBundle;
import org.apache.jackrabbit.spi.QNodeTypeDefinition;
import org.apache.jackrabbit.spi.QueryInfo;
import org.apache.jackrabbit.spi.ChildInfo;
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.Name;
@@ -45,8 +44,6 @@
import org.apache.jackrabbit.spi.commons.QPropertyDefinitionImpl;
import org.apache.jackrabbit.spi.commons.QNodeDefinitionImpl;
import org.apache.jackrabbit.spi.commons.QNodeTypeDefinitionImpl;
-import org.apache.jackrabbit.spi.commons.EventImpl;
-import org.apache.jackrabbit.spi.commons.EventBundleImpl;
import org.apache.jackrabbit.spi.commons.ChildInfoImpl;
import org.apache.jackrabbit.spi.commons.NodeInfoImpl;
import org.apache.jackrabbit.spi.commons.PropertyInfoImpl;
@@ -688,63 +685,23 @@
Name[] nodeTypeName,
boolean noLocal)
throws RepositoryException, RemoteException {
- try {
- // some implementations may rely on createEventFilter being called
- service.createEventFilter(getSessionInfo(sessionInfo), eventTypes,
- absPath, isDeep, uuid, nodeTypeName, noLocal);
- Set ntNames = null;
- if (nodeTypeName != null) {
- ntNames = new HashSet(Arrays.asList(nodeTypeName));
- }
- return new EventFilterImpl(eventTypes, absPath, isDeep, uuid, ntNames, noLocal);
- } catch (RepositoryException e) {
- throw getRepositoryException(e);
+ Set ntNames = null;
+ if (nodeTypeName != null) {
+ ntNames = new HashSet(Arrays.asList(nodeTypeName));
}
+ return new EventFilterImpl(eventTypes, absPath, isDeep, uuid, ntNames, noLocal);
}
/**
* {@inheritDoc}
*/
- public EventBundle[] getEvents(RemoteSessionInfo sessionInfo,
- long timeout,
- EventFilter[] filters)
- throws RepositoryException, InterruptedException, RemoteException {
+ public RemoteSubscription createSubscription(RemoteSessionInfo sessionInfo,
+ EventFilter[] filters)
+ throws RepositoryException, RemoteException {
try {
- SessionInfo sInfo;
- try {
- sInfo = getSessionInfo(sessionInfo);
- } catch (RepositoryException e) {
- throw new InterruptedException();
- }
- // create local event filter instances
- filters = createLocalEventFilters(sInfo, filters);
- EventBundle[] bundles = service.getEvents(sInfo, timeout, filters);
- EventBundle[] serBundles = new EventBundle[bundles.length];
- for (int i = 0; i < bundles.length; i++) {
- List events = new ArrayList();
- for (Iterator it = bundles[i].getEvents(); it.hasNext(); ) {
- Event e = (Event) it.next();
- ItemId id;
- // make sure node ids are serializable
- NodeId parentId = e.getParentId();
- parentId = idFactory.createNodeId(
- parentId.getUniqueID(), parentId.getPath());
- if (e.getItemId().denotesNode()) {
- NodeId nodeId = (NodeId) e.getItemId();
- id = idFactory.createNodeId(nodeId.getUniqueID(), nodeId.getPath());
- } else {
- PropertyId propId = (PropertyId) e.getItemId();
- id = idFactory.createPropertyId(parentId, propId.getName());
- }
- Event serEvent = new EventImpl(e.getType(),
- e.getPath(), id, parentId,
- e.getPrimaryNodeTypeName(),
- e.getMixinTypeNames(), e.getUserID());
- events.add(serEvent);
- }
- serBundles[i] = new EventBundleImpl(events, bundles[i].isLocal());
- }
- return serBundles;
+ SessionInfo sInfo = getSessionInfo(sessionInfo);
+ return new ServerSubscription(service, sInfo,
+ service.createSubscription(sInfo, filters), idFactory);
} catch (RepositoryException e) {
throw getRepositoryException(e);
}
@@ -871,42 +828,6 @@
throw new RepositoryException("Unknown RemoteSessionInfo: " +
((RemoteObject) sInfo).getRef());
}
- }
-
- /**
- * Creates filter instances created by the underlying repository service.
- *
- * @param sInfo the session info.
- * @param filters the event filters created by this server repository
- * service.
- * @return array of filter instances created by the underlying repository
- * service.
- * @throws RepositoryException if an error occurs.
- */
- private EventFilter[] createLocalEventFilters(SessionInfo sInfo,
- EventFilter[] filters)
- throws RepositoryException {
- if (filters == null) {
- return null;
- }
- for (int i = 0; i < filters.length; i++) {
- if (filters[i] instanceof EventFilterImpl) {
- EventFilterImpl e = (EventFilterImpl) filters[i];
- Set nodeTypeNames = e.getNodeTypeNames();
- Name[] ntNames = null;
- if (nodeTypeNames != null) {
- ntNames = (Name[]) nodeTypeNames.toArray(
- new Name[nodeTypeNames.size()]);
- }
- filters[i] = service.createEventFilter(sInfo,
- e.getEventTypes(), e.getAbsPath(), e.isDeep(),
- e.getUUIDs(), ntNames, e.getNoLocal());
- } else {
- throw new RepositoryException("Unknown EventFilter implementation: " +
- filters[i].getClass().getName());
- }
- }
- return filters;
}
/**
Added: jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerSubscription.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerSubscription.java?rev=592358&view=auto
==============================================================================
--- jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerSubscription.java
(added)
+++ jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerSubscription.java
Tue Nov 6 02:22:50 2007
@@ -0,0 +1,135 @@
+/*
+ * 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.rmi.server;
+
+import org.apache.jackrabbit.spi.rmi.remote.RemoteSubscription;
+import org.apache.jackrabbit.spi.EventBundle;
+import org.apache.jackrabbit.spi.EventFilter;
+import org.apache.jackrabbit.spi.Subscription;
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.spi.SessionInfo;
+import org.apache.jackrabbit.spi.Event;
+import org.apache.jackrabbit.spi.ItemId;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.spi.commons.EventImpl;
+import org.apache.jackrabbit.spi.commons.EventBundleImpl;
+
+import javax.jcr.RepositoryException;
+import java.rmi.RemoteException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * <code>ServerSubscription</code>...
+ */
+class ServerSubscription extends ServerObject implements RemoteSubscription {
+
+ /**
+ * The repository service.
+ */
+ private final RepositoryService service;
+
+ /**
+ * The session info where this subscription belongs to.
+ */
+ private final SessionInfo sessionInfo;
+
+ /**
+ * The server side subscription.
+ */
+ private final Subscription subscription;
+
+ /**
+ * The id factory.
+ */
+ private final IdFactory idFactory;
+
+ public ServerSubscription(RepositoryService service,
+ SessionInfo sessionInfo,
+ Subscription subscription,
+ IdFactory idFactory) throws RemoteException {
+ this.service = service;
+ this.sessionInfo = sessionInfo;
+ this.subscription = subscription;
+ this.idFactory = idFactory;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public EventBundle[] getEvents(long timeout)
+ throws RepositoryException, InterruptedException, RemoteException {
+ try {
+ EventBundle[] bundles = service.getEvents(subscription, timeout);
+ EventBundle[] serBundles = new EventBundle[bundles.length];
+ for (int i = 0; i < bundles.length; i++) {
+ List events = new ArrayList();
+ for (Iterator it = bundles[i].getEvents(); it.hasNext(); ) {
+ Event e = (Event) it.next();
+ ItemId id;
+ // make sure node ids are serializable
+ NodeId parentId = e.getParentId();
+ parentId = idFactory.createNodeId(
+ parentId.getUniqueID(), parentId.getPath());
+ if (e.getItemId().denotesNode()) {
+ NodeId nodeId = (NodeId) e.getItemId();
+ id = idFactory.createNodeId(nodeId.getUniqueID(), nodeId.getPath());
+ } else {
+ PropertyId propId = (PropertyId) e.getItemId();
+ id = idFactory.createPropertyId(parentId, propId.getName());
+ }
+ Event serEvent = new EventImpl(e.getType(),
+ e.getPath(), id, parentId,
+ e.getPrimaryNodeTypeName(),
+ e.getMixinTypeNames(), e.getUserID());
+ events.add(serEvent);
+ }
+ serBundles[i] = new EventBundleImpl(events, bundles[i].isLocal());
+ }
+ return serBundles;
+ } catch (RepositoryException e) {
+ throw getRepositoryException(e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setFilters(EventFilter[] filters)
+ throws RepositoryException, RemoteException {
+ try {
+ filters = createLocalEventFilters(service, sessionInfo, filters);
+ service.updateEventFilters(subscription, filters);
+ } catch (RepositoryException e) {
+ throw getRepositoryException(e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void dispose() throws RepositoryException, RemoteException {
+ try {
+ service.dispose(subscription);
+ } catch (RepositoryException e) {
+ throw getRepositoryException(e);
+ }
+ }
+}
Propchange: jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerSubscription.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: jackrabbit/sandbox/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventSubscriptionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventSubscriptionImpl.java?rev=592358&view=auto
==============================================================================
--- jackrabbit/sandbox/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventSubscriptionImpl.java
(added)
+++ jackrabbit/sandbox/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventSubscriptionImpl.java
Tue Nov 6 02:22:50 2007
@@ -0,0 +1,54 @@
+/*
+ * 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.spi2dav;
+
+import org.apache.jackrabbit.spi.Subscription;
+
+/**
+ * <code>EventSubscriptionImpl</code>...
+ */
+public class EventSubscriptionImpl implements Subscription {
+
+ /**
+ * The subscription id.
+ */
+ private final String id;
+
+ /**
+ * The session info that was used to create this subscription.
+ */
+ private final SessionInfoImpl sessionInfo;
+
+ public EventSubscriptionImpl(String id, SessionInfoImpl sessionInfo) {
+ this.id = id;
+ this.sessionInfo = sessionInfo;
+ }
+
+ /**
+ * @return the subscription id.
+ */
+ String getId() {
+ return id;
+ }
+
+ /**
+ * @return the session info that was used to create this subscription.
+ */
+ SessionInfoImpl getSessionInfo() {
+ return sessionInfo;
+ }
+}
Propchange: jackrabbit/sandbox/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventSubscriptionImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jackrabbit/sandbox/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java?rev=592358&r1=592357&r2=592358&view=diff
==============================================================================
--- jackrabbit/sandbox/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
(original)
+++ jackrabbit/sandbox/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
Tue Nov 6 02:22:50 2007
@@ -135,6 +135,7 @@
import org.apache.jackrabbit.spi.NameFactory;
import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.Subscription;
import org.apache.jackrabbit.spi.commons.EventFilterImpl;
import org.apache.jackrabbit.spi.commons.EventBundleImpl;
import org.apache.jackrabbit.spi.commons.ChildInfoImpl;
@@ -264,6 +265,12 @@
}
}
+ private static void checkSubscription(Subscription subscription) throws RepositoryException
{
+ if (!(subscription instanceof EventSubscriptionImpl)) {
+ throw new RepositoryException("Unknown Subscription implementation.");
+ }
+ }
+
private static boolean isUnLockMethod(DavMethod method) {
int code = DavMethods.getMethodCode(method.getName());
return DavMethods.DAV_UNLOCK == code;
@@ -525,22 +532,11 @@
method.releaseConnection();
}
}
-
- // create a subscription on the server
- String rootUri = uriResolver.getRootItemUri(workspaceName);
- String subscriptionId = subscribe(rootUri, S_INFO, null, sessionInfo, null);
- log.debug("Subscribed on server for session info " + sessionInfo);
- sessionInfo.setSubscriptionId(subscriptionId);
return sessionInfo;
}
public void dispose(SessionInfo sessionInfo) throws RepositoryException {
checkSessionInfo(sessionInfo);
- String subscriptionId = ((SessionInfoImpl)sessionInfo).getSubscriptionId();
- if (subscriptionId != null) {
- String rootUri = uriResolver.getRootItemUri(sessionInfo.getWorkspaceName());
- unsubscribe(rootUri, subscriptionId, sessionInfo);
- }
removeClient(sessionInfo);
}
@@ -1431,16 +1427,49 @@
}
/**
- * @see RepositoryService#getEvents(SessionInfo, long, EventFilter[])
+ * @see RepositoryService#getEvents(Subscription, long)
*/
- public EventBundle[] getEvents(SessionInfo sessionInfo, long timeout, EventFilter[] filters)
+ public EventBundle[] getEvents(Subscription subscription, long timeout)
throws RepositoryException, UnsupportedRepositoryOperationException {
- checkSessionInfo(sessionInfo);
+ checkSubscription(subscription);
+
+ EventSubscriptionImpl subscr = (EventSubscriptionImpl) subscription;
+ String rootUri = uriResolver.getRootItemUri(
+ subscr.getSessionInfo().getWorkspaceName());
+
+ return poll(rootUri, subscr.getId(), timeout, subscr.getSessionInfo());
+ }
- SessionInfoImpl sessionInfoImpl = (SessionInfoImpl)sessionInfo;
+ /**
+ * @see RepositoryService#createSubscription(SessionInfo, EventFilter[])
+ */
+ public Subscription createSubscription(SessionInfo sessionInfo,
+ EventFilter[] filters)
+ throws UnsupportedRepositoryOperationException, RepositoryException {
+ checkSessionInfo(sessionInfo);
String rootUri = uriResolver.getRootItemUri(sessionInfo.getWorkspaceName());
+ String subscriptionId = subscribe(rootUri, S_INFO, null, sessionInfo, null);
+ log.debug("Subscribed on server for session info " + sessionInfo);
+ return new EventSubscriptionImpl(subscriptionId, (SessionInfoImpl) sessionInfo);
+ }
+
+ /**
+ * @see RepositoryService#updateEventFilters(Subscription, EventFilter[])
+ */
+ public void updateEventFilters(Subscription subscription,
+ EventFilter[] filters)
+ throws RepositoryException {
+ // do nothing ...
+ // this is actually not correct because we listen for everything and
+ // rely on the client of the repository service to filter the events
+ }
- return poll(rootUri, sessionInfoImpl.getSubscriptionId(), timeout, sessionInfoImpl);
+ public void dispose(Subscription subscription) throws RepositoryException {
+ checkSubscription(subscription);
+ EventSubscriptionImpl subscr = (EventSubscriptionImpl) subscription;
+ String rootUri = uriResolver.getRootItemUri(
+ subscr.getSessionInfo().getWorkspaceName());
+ unsubscribe(rootUri, subscr.getId(), subscr.getSessionInfo());
}
private String subscribe(String uri, SubscriptionInfo subscriptionInfo,
Modified: jackrabbit/sandbox/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/SessionInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/SessionInfoImpl.java?rev=592358&r1=592357&r2=592358&view=diff
==============================================================================
--- jackrabbit/sandbox/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/SessionInfoImpl.java
(original)
+++ jackrabbit/sandbox/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/SessionInfoImpl.java
Tue Nov 6 02:22:50 2007
@@ -92,28 +92,6 @@
}
/**
- * Returns the subscriptionId for this <code>SessionInfo</code> or
- * <code>null</code> if no subscription is present.
- *
- * @return the subscriptionId for this <code>SessionInfo</code>.
- */
- String getSubscriptionId() {
- return subscriptionId;
- }
-
- /**
- * Sets a new subscriptionId for this <code>SessionInfo</code>.
- *
- * @param subscriptionId the new subscriptionId.
- * @return the old subscriptionId or <code>null</code> if there was none.
- */
- String setSubscriptionId(String subscriptionId) {
- String old = this.subscriptionId;
- this.subscriptionId = subscriptionId;
- return old;
- }
-
- /**
* Returns the id of the most recently submitted batch or <code>null</code>
* it no batch has been submitted yet.
*
|