You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2005/06/21 23:13:06 UTC
svn commit: r191727 - in
/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit:
rmi/client/ rmi/iterator/ rmi/observation/ rmi/remote/ rmi/server/ value/
Author: jukka
Date: Tue Jun 21 14:13:03 2005
New Revision: 191727
URL: http://svn.apache.org/viewcvs?rev=191727&view=rev
Log:
JCR-97: Improve Checkstyle conformance in JCR-RMI
Modified:
incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientAdapterFactory.java
incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientObservationManager.java
incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientSession.java
incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientWorkspace.java
incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/iterator/ArrayEventListenerIterator.java
incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/observation/ClientEventPoll.java
incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/observation/Queue.java
incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/observation/ServerEventListenerProxy.java
incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteEventCollection.java
incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteObservationManager.java
incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteProperty.java
incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteQueryManager.java
incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/RemoteAdapterFactory.java
incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerAdapterFactory.java
incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerEventCollection.java
incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerObservationManager.java
incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerSession.java
incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerWorkspace.java
incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BaseNonStreamValue.java
incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BinaryValue.java
Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientAdapterFactory.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientAdapterFactory.java?rev=191727&r1=191726&r2=191727&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientAdapterFactory.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientAdapterFactory.java Tue Jun 21 14:13:03 2005
@@ -109,7 +109,7 @@
RemoteObservationManager remote) {
return new ClientObservationManager(remote);
}
-
+
/**
* Creates and returns a
* {@link ClientNamespaceRegistry ClientClientNamespaceRegistry} instance.
Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientObservationManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientObservationManager.java?rev=191727&r1=191726&r2=191727&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientObservationManager.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientObservationManager.java Tue Jun 21 14:13:03 2005
@@ -19,7 +19,6 @@
import java.rmi.RemoteException;
import javax.jcr.RepositoryException;
-import javax.jcr.Session;
import javax.jcr.observation.EventListener;
import javax.jcr.observation.EventListenerIterator;
import javax.jcr.observation.ObservationManager;
@@ -37,14 +36,14 @@
* <p>
* This class does not require the
* {@link org.apache.jackrabbit.rmi.client.LocalAdapterFactory} and consequently
- * calls the base class constructor with a <code>null</code> factory.
+ * calls the base class constructor with a <code>null</code> factory.
* <p>
* See the <a href="../observation/package.html><code>observation</code></a>
* package comment for a description on how event listener registration and
- * notification is implemented.
- *
+ * notification is implemented.
+ *
* @author Felix Meschberger
- *
+ *
* @see org.apache.jackrabbit.rmi.observation.ClientEventPoll
*/
public class ClientObservationManager extends ClientObject implements
@@ -52,15 +51,15 @@
/** The remote observation manager */
private final RemoteObservationManager remote;
-
+
/** The ClientEventPoll class internally used for event dispatching */
private ClientEventPoll poller;
-
+
/**
* Creates an instance of this class talking to the given remote observation
* manager.
- *
- * @param remote The {@link RemoteObservationManager} backing this
+ *
+ * @param remote The {@link RemoteObservationManager} backing this
* client-side observation manager.
*/
public ClientObservationManager(RemoteObservationManager remote) {
@@ -69,13 +68,13 @@
}
/** {@inheritDoc} */
- public void addEventListener(EventListener listener, int eventTypes,
- String absPath, boolean isDeep, String[] uuid,
- String[] nodeTypeName, boolean noLocal)
+ public void addEventListener(EventListener listener, int eventTypes,
+ String absPath, boolean isDeep, String[] uuid,
+ String[] nodeTypeName, boolean noLocal)
throws RepositoryException {
try {
long listenerId = getClientEventPoll().addListener(listener);
- remote.addEventListener(listenerId, eventTypes, absPath,
+ remote.addEventListener(listenerId, eventTypes, absPath,
isDeep, uuid, nodeTypeName, noLocal);
} catch (RemoteException ex) {
throw new RemoteRepositoryException(ex);
@@ -99,11 +98,13 @@
}
//---------- internal ------------------------------------------------------
-
+
/**
* Returns the {@link ClientEventPoll} instance used by this (client-side)
* observation manager. This method creates the instance on the first call
* and starts the poller thread to wait for remote events.
+ *
+ * @return poller instance
*/
private synchronized ClientEventPoll getClientEventPoll() {
if (poller == null) {
Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientSession.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientSession.java?rev=191727&r1=191726&r2=191727&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientSession.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientSession.java Tue Jun 21 14:13:03 2005
@@ -64,7 +64,7 @@
/** The adapted remote session. */
private RemoteSession remote;
-
+
/**
* The adapted workspace of this session. This field is set on the first
* call to the {@link #getWorkspace()} method assuming, that a workspace
@@ -128,13 +128,13 @@
public Workspace getWorkspace() {
if (workspace == null) {
try {
- workspace =
+ workspace =
getFactory().getWorkspace(this, remote.getWorkspace());
} catch (RemoteException ex) {
throw new RemoteRuntimeException(ex);
}
}
-
+
return workspace;
}
@@ -223,13 +223,13 @@
/**
* Returns the {@link SerialValueFactory#getInstance()}.
- *
+ *
* {@inheritDoc}
*/
public ValueFactory getValueFactory() {
return SerialValueFactory.getInstance();
}
-
+
/** {@inheritDoc} */
public void checkPermission(String path, String actions)
throws AccessControlException, RepositoryException {
Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientWorkspace.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientWorkspace.java?rev=191727&r1=191726&r2=191727&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientWorkspace.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/client/ClientWorkspace.java Tue Jun 21 14:13:03 2005
@@ -162,14 +162,14 @@
throws RepositoryException {
if (observationManager == null) {
try {
- observationManager =
+ observationManager =
getFactory().
getObservationManager(remote.getObservationManager());
} catch (RemoteException ex) {
throw new RemoteRepositoryException(ex);
}
}
-
+
return observationManager;
}
Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/iterator/ArrayEventListenerIterator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/iterator/ArrayEventListenerIterator.java?rev=191727&r1=191726&r2=191727&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/iterator/ArrayEventListenerIterator.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/iterator/ArrayEventListenerIterator.java Tue Jun 21 14:13:03 2005
@@ -16,8 +16,6 @@
*/
package org.apache.jackrabbit.rmi.iterator;
-import javax.jcr.observation.Event;
-import javax.jcr.observation.EventIterator;
import javax.jcr.observation.EventListener;
import javax.jcr.observation.EventListenerIterator;
@@ -29,7 +27,7 @@
*
* @author Felix Meschberger
*/
-public class ArrayEventListenerIterator extends ArrayIterator
+public class ArrayEventListenerIterator extends ArrayIterator
implements EventListenerIterator {
/**
Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/observation/ClientEventPoll.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/observation/ClientEventPoll.java?rev=191727&r1=191726&r2=191727&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/observation/ClientEventPoll.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/observation/ClientEventPoll.java Tue Jun 21 14:13:03 2005
@@ -46,7 +46,7 @@
* implement the <code>Object.hashCode()</code> and <code>Object.equals()</code>
* contracts for them to be handled correctly by this class.
* </ol>
- *
+ *
* @author Felix Meschberger
* @see #run()
*/
@@ -54,47 +54,48 @@
/** logger */
private static final Log log = LogFactory.getLog(ClientEventPoll.class);
-
+
/**
* The time in milliseconds the {@link #run()} method should be waiting
* for remote events.
- * @see #run()
+ * @see #run()
*/
private static final long POLL_TIMEOUT = 5000;
-
+
/** The thread name */
private static final String THREAD_NAME = "Client Event Poller";
-
+
/** The primitive unique identifier generator. */
private static long counter = 0;
-
+
/** The {@link RemoteObservationManager} called for the new events. */
private final RemoteObservationManager remote;
-
+
/** The map of locally registered listeners indexed by the unique identifier */
private Map listenerMap = new HashMap();
-
+
/** The map of unique identifieres indexed by the registered listeners */
private Map idMap = new HashMap();
-
+
/**
* Flag indicating whether the {@link #run()} method should terminate.
* @see #run()
*/
private boolean running = true;
-
+
/**
* Creates an instance of this class talking to the given
* {@link RemoteObservationManager}.
- *
+ *
* @param remote The remote observation manager which is asked for new
* events. This must not be <code>null</code>.
- *
+ *
* @throws NullPointerException if <code>remote</code> is <code>null</code>.
*/
- public ClientEventPoll(RemoteObservationManager remote) {
+ public ClientEventPoll(RemoteObservationManager remote)
+ throws NullPointerException {
super(THREAD_NAME);
-
+
// check remote and assign
if (remote == null) {
throw new NullPointerException("remote");
@@ -105,9 +106,9 @@
/**
* Registers the given local listener with this instance and returns the
* unique identifier assigned to it.
- *
+ *
* @param listener The <code>EventListener</code> to register.
- *
+ *
* @return The unique identifier assigned to the newly registered event
* listener.
*/
@@ -117,13 +118,13 @@
idMap.put(listener, id);
return id.longValue();
}
-
+
/**
* Unregisters the given local listener from this instance and returns the
* unique identifier assigned to it.
- *
+ *
* @param listener The <code>EventListener</code> to unregister.
- *
+ *
* @return The unique identifier assigned to the unregistered event listener
* or <code>-1</code> if the listener was not registered.
*/
@@ -133,30 +134,32 @@
listenerMap.remove(key);
return key.longValue();
}
-
+
return -1;
}
-
+
/**
* Returns an array of the registered event listeners.
+ *
+ * @return registered event listeners
*/
public synchronized EventListener[] getListeners() {
return (EventListener[]) listenerMap.values().toArray(
new EventListener[(listenerMap.size())]);
}
-
+
/**
* Indicates to the {@link #run()} method, that asking for events should
* be terminated.
- *
+ *
* @see #run()
*/
public void terminate() {
this.running = false;
}
-
+
//---------- Thread overwrite ---------------------------------------------
-
+
/**
* Checks for remote events and dispatches them to the locally registered
* event listeners. This is how this method works:
@@ -167,92 +170,96 @@
* waiting for a specified time (5 seconds).
* <li>If no event was received in the specified time go back to step #1.
* <li>Extract the unique listener identifier from the remote event and
- * find it in the list of locally registered event listeners. Go back to
+ * find it in the list of locally registered event listeners. Go back to
* step #1 if no such listener exists.
* <li>Convert the remote event list to an <code>EventIterator</code> and
* call the <code>EventListener.onEvent()</code> method.
* <li>Go back to step #1.
- * </ol>
+ * </ol>
*/
public void run() {
while (running) {
try {
// ask for an event waiting at most POLL_TIMEOUT milliseconds
RemoteEventCollection remoteEvent = remote.getNextEvent(POLL_TIMEOUT);
-
+
// poll time out, check running and ask again
if (remoteEvent == null) {
continue;
}
-
+
// extract the listener id from the remote event and find
// the locally registered event listener
Long id = new Long(remoteEvent.getListenerId());
EventListener listener = (EventListener) listenerMap.get(id);
-
+
// if the listener is not registered (anymore), the event is
// silently ignored, running is checked and the server asked again
if (listener == null) {
continue;
}
-
+
// otherwise convert the remote events into an EventIterator
// and the listener is called
- RemoteEventCollection.RemoteEvent[] remoteEvents = remoteEvent.getEvents();
+ RemoteEventCollection.RemoteEvent[] remoteEvents = remoteEvent.getEvents();
EventIterator events = toEvents(remoteEvents);
try {
listener.onEvent(events);
} catch (Exception e) {
log.error("Unexpected failure of Listener " + listener, e);
}
-
+
} catch (RemoteException re) {
log.error("Problem handling event. Looking for next one.", re);
}
}
}
-
+
//---------- internal -----------------------------------------------------
-
+
/**
* Converts an array of {@link RemoteEventCollection.RemoteEvent} instances to an
* instance of <code>EventIterator</code> suitable to be sent to the
* event listener.
+ *
+ * @param remoteEvents array of remote events
+ * @return event iterator
+ * @throws RemoteException on RMI errors
*/
- private EventIterator toEvents(RemoteEventCollection.RemoteEvent[] remoteEvents)
+ private EventIterator toEvents(RemoteEventCollection.RemoteEvent[] remoteEvents)
throws RemoteException {
Event[] events = new Event[remoteEvents.length];
- for (int i=0; i < events.length; i++) {
+ for (int i = 0; i < events.length; i++) {
events[i] = new JCREvent(remoteEvents[i]);
}
return new ArrayEventIterator(events);
}
-
+
/**
* The <code>JCREvent</code> class is a simple implementation of the JCR
* <code>Event</code> interface to be sent to the locally registered
* event listeners.
- *
+ *
* @author Felix Meschberger
*/
private static class JCREvent implements Event {
-
+
/** The event type */
private final int type;
-
+
/** The path of the repository item underlying the event */
private final String path;
-
+
/** The user id of the session originating the event */
private final String userID;
/**
* Creates an instance of this class from the contents of the given
* <code>remoteEvent</code>.
- *
+ *
* @param remoteEvent The {@link RemoteEventCollection.RemoteEvent} instance
* providing the data for this event.
- *
+ *
* @throws RemoteException if an RMI error occurrs.
*/
private JCREvent(RemoteEventCollection.RemoteEvent remoteEvent) throws RemoteException {
@@ -260,18 +267,18 @@
path = remoteEvent.getPath();
userID = remoteEvent.getUserID();
}
-
- /** @inheritDoc */
+
+ /** {@inheritDoc} */
public int getType() {
return type;
}
-
- /** @inheritDoc */
+
+ /** {@inheritDoc} */
public String getPath() {
return path;
}
-
- /** @inheritDoc */
+
+ /** {@inheritDoc} */
public String getUserID() {
return userID;
}
Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/observation/Queue.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/observation/Queue.java?rev=191727&r1=191726&r2=191727&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/observation/Queue.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/observation/Queue.java Tue Jun 21 14:13:03 2005
@@ -21,15 +21,15 @@
/**
* The <code>Queue</code> class is a very simple queue assuming that there is
* at least one consumer and potentially multiple producers. This class poses
- * no restrictions on the size of the queue.
- *
+ * no restrictions on the size of the queue.
+ *
* @author Felix Meschberger
*/
public class Queue {
/** The linked list implementing the queue of data */
private final LinkedList queue;
-
+
/**
* Creates an instance of this queue.
*/
@@ -42,6 +42,8 @@
* <p>
* After appending the element, the queue is notified such that threads
* waiting to retrieve an element from the queue are woken up.
+ *
+ * @param object the object to be added
*/
public void put(Object object) {
synchronized (queue) {
@@ -53,14 +55,14 @@
/**
* Returns the first element from the queue. If the queue is currently empty
* the method waits at most the given number of milliseconds.
- *
+ *
* @param timeout The maximum number of milliseconds to wait for an entry in
* the queue if the queue is empty. If zero, the method waits forever
* for an element.
- *
+ *
* @return The first element of the queue or <code>null</code> if the method
* timed out waiting for an entry.
- *
+ *
* @throws InterruptedException Is thrown if the current thread is
* interrupted while waiting for the queue to get at least one entry.
*/
@@ -70,12 +72,12 @@
if (queue.isEmpty()) {
queue.wait(timeout);
}
-
+
// return null if queue is (still) empty
if (queue.isEmpty()) {
return null;
}
-
+
// return first if queue has content now
return queue.removeFirst();
}
Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/observation/ServerEventListenerProxy.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/observation/ServerEventListenerProxy.java?rev=191727&r1=191726&r2=191727&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/observation/ServerEventListenerProxy.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/observation/ServerEventListenerProxy.java Tue Jun 21 14:13:03 2005
@@ -41,24 +41,24 @@
* <p>
* See the package overview for an explanation of the mechanisms implemented for
* event dispatching.
- *
+ *
* @author Felix Meschberger
*/
public class ServerEventListenerProxy implements EventListener {
/** logger */
- private static final Log log =
+ private static final Log log =
LogFactory.getLog(ServerEventListenerProxy.class);
-
+
/** The factory used to convert event iterators to remote events */
private final RemoteAdapterFactory factory;
-
+
/**
* The unique indentifier of the client-side event listener on whose
* behalf this listener proxy is registered.
*/
private final long listenerId;
-
+
/**
* The queue to which remote events are queue for them to be picked up
* by calls to the
@@ -66,10 +66,10 @@
* method.
*/
private final Queue queue;
-
+
/**
* Creates a new instance of this listener proxy.
- *
+ *
* @param factory The {@link RemoteAdapterFactory} used to convert the
* {@link EventIterator} instances to {@link RemoteEventCollection} objects.
* @param listenerId The unique identifier of the client-side event listener
@@ -77,18 +77,18 @@
* @param queue The sink to which events to be dispatched to the client are
* queued to be picked up.
*/
- public ServerEventListenerProxy(RemoteAdapterFactory factory,
+ public ServerEventListenerProxy(RemoteAdapterFactory factory,
long listenerId, Queue queue) {
this.factory = factory;
this.listenerId = listenerId;
this.queue = queue;
}
-
+
/**
* Converts the {@link javax.jcr.observation.Event} instances in the given
* iterator to an instance of {@link RemoteEventCollection} for them to be dispatched
* to the client-side event listener.
- *
+ *
* @param events The {@link javax.jcr.observation.Event Events} to be
* dispatched.
*/
@@ -97,27 +97,29 @@
RemoteEventCollection remoteEvent = factory.getRemoteEvent(listenerId, events);
queue.put(remoteEvent);
} catch (RemoteException re) {
- Throwable t = (re.getCause() == null) ? re : re.getCause();
+ Throwable t = (re.getCause() == null) ? re : re.getCause();
log.error("Problem creating remote event for " + listenerId, t);
}
}
-
+
//---------- Object overwrite ----------------------------------------------
-
+
/**
* Returns the client-side listener identifier as its hash code.
+ *
+ * @return hash code
*/
public int hashCode() {
return (int) listenerId;
}
-
+
/**
* Returns <code>true</code> if <code>obj</code> is either the same as this
* or a proxy for the same client-side listener, which is identicated by the
* same listener identifier.
- *
+ *
* @param obj The object to compare to.
- *
+ *
* @return <code>true</code> if <code>obj</code> is the same or a proxy for
* the same client-side listener.
*/
@@ -130,11 +132,13 @@
return false;
}
}
-
+
/**
* Returns the a string representation of this instance, which is an
* indication of this class's name and the unique identifier of the real
* event listener.
+ *
+ * @return string representation
*/
public String toString() {
return "EventListenerProxy: listenerId=" + listenerId;
Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteEventCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteEventCollection.java?rev=191727&r1=191726&r2=191727&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteEventCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteEventCollection.java Tue Jun 21 14:13:03 2005
@@ -19,33 +19,35 @@
import java.rmi.Remote;
import java.rmi.RemoteException;
-import javax.jcr.observation.Event;
-
/**
* The <code>RemoteEventCollection</code> class serves as a container for
* notifications sent to registered event listeners. Instances of this class are
* created by the server-side event listener proxies and sent to the client-side
* event poller. On the client-side the enclosed list of events is then sent to
* the listener identified by the contained listener identifier.
- *
+ *
* @author Felix Meschberger
*/
public interface RemoteEventCollection extends Remote {
/**
* Returns unique identifier of the client-side listener to which the
- * enclosed events should be sent.
+ * enclosed events should be sent.
+ *
+ * @return unique listener identifier
* @throws RemoteException on RMI errors
*/
long getListenerId() throws RemoteException;
-
+
/**
* Returns the list of events to be sent to the client-side listener
* identified by {@link #getListenerId()}.
+ *
+ * @return list of events
* @throws RemoteException on RMI errors
*/
RemoteEvent[] getEvents() throws RemoteException;
-
+
/**
* The <code>RemoteEvent</code> class provides an encapsulation of single
* events in an event list sent to a registered listener.
@@ -53,20 +55,26 @@
public static interface RemoteEvent extends Remote {
/**
* Returns the event type.
+ *
+ * @return event type
* @throws RemoteException on RMI errors
- */
+ */
int getType() throws RemoteException;
/**
* Returns the absolute path of the underlying item.
+ *
+ * @return item path
* @throws RemoteException on RMI errors
- */
+ */
String getPath() throws RemoteException;
/**
* Returns the userID of the session causing this event.
+ *
+ * @return user identifier
* @throws RemoteException on RMI errors
- */
+ */
String getUserID() throws RemoteException;
}
Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteObservationManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteObservationManager.java?rev=191727&r1=191726&r2=191727&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteObservationManager.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteObservationManager.java Tue Jun 21 14:13:03 2005
@@ -20,10 +20,6 @@
import java.rmi.RemoteException;
import javax.jcr.RepositoryException;
-import javax.jcr.observation.EventListener;
-import javax.jcr.observation.EventListenerIterator;
-
-import org.apache.jackrabbit.rmi.client.RemoteRepositoryException;
/**
* Remote version of the JCR {@link javax.jcr.observation.ObservationManager ObservationManager}
@@ -36,19 +32,19 @@
* <p>
* See the <a href="../observation/package.html><code>observation</code></a>
* package comment for a description on how event listener registration and
- * notification is implemented.
+ * notification is implemented.
*
* @author Felix Meschberger
- *
+ *
* @see javax.jcr.observation.ObservationManager
* @see org.apache.jackrabbit.rmi.client.ClientObservationManager
* @see org.apache.jackrabbit.rmi.server.ServerObservationManager
*/
public interface RemoteObservationManager extends Remote {
-
+
/**
* Remote version of the
- * {@link javax.jcr.observation.ObservationManager#addEventListener(javax.jcr.observation.EventListener, int, java.lang.String, boolean, java.lang.String[], java.lang.String[], boolean) ObservationManager.addEventListener()}
+ * {@link javax.jcr.observation.ObservationManager#addEventListener(javax.jcr.observation.EventListener, int, String, boolean, String[], String[], boolean) ObservationManager.addEventListener()}
* method. See class comment for an explanation on how the
* <code>listenerId</code> is used.
*
@@ -66,13 +62,13 @@
* are to be sent. If <code>null</code> this parameter is ignored.
* @param noLocal <code>true</code> if only events are to be sent which do
* not originate from the session to which this instance belongs.
- *
+ *
* @throws RepositoryException on repository errors
* @throws RemoteException on RMI errors
*/
- public void addEventListener(long listenerId, int eventTypes,
- String absPath, boolean isDeep, String[] uuid,
- String[] nodeTypeName, boolean noLocal)
+ void addEventListener(long listenerId, int eventTypes,
+ String absPath, boolean isDeep, String[] uuid,
+ String[] nodeTypeName, boolean noLocal)
throws RepositoryException, RemoteException;
/**
@@ -83,28 +79,28 @@
*
* @param listenerId The identification of the listener on the client
* side to which events will be directed.
- *
+ *
* @throws RepositoryException on repository errors
* @throws RemoteException on RMI errors
*/
- public void removeEventListener(long listenerId)
+ void removeEventListener(long listenerId)
throws RepositoryException, RemoteException;
/**
* Returns the next event to be dispatched to registered event listeners. If
* no event is available, this method blocks until one is available or until
* the given timeout expires.
- *
+ *
* @param timeout The time in milliseconds to wait for the next event
* available to be dispatched. If negative or zero, this method waits
* for ever.
- *
+ *
* @return The {@link RemoteEventCollection} to be dispatched. <code>null</code> is
* returned if the method timed out waiting for an event to be
* dispatched.
- *
+ *
* @throws RemoteException on RMI errors
*/
- public RemoteEventCollection getNextEvent(long timeout)
+ RemoteEventCollection getNextEvent(long timeout)
throws RemoteException;
}
Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteProperty.java?rev=191727&r1=191726&r2=191727&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteProperty.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteProperty.java Tue Jun 21 14:13:03 2005
@@ -44,7 +44,7 @@
* available on both the client and server side. The
* {@link org.apache.jackrabbit.value.SerialValueFactory SerialValueFactory}
* class provides two convenience methods to satisfy these requirements.
- *
+ *
* @author Jukka Zitting
* @see javax.jcr.Property
* @see org.apache.jackrabbit.rmi.client.ClientProperty
Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteQueryManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteQueryManager.java?rev=191727&r1=191726&r2=191727&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteQueryManager.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/remote/RemoteQueryManager.java Tue Jun 21 14:13:03 2005
@@ -67,7 +67,7 @@
* @throws RepositoryException on repository errors
* @throws RemoteException on RMI errors
*/
- String[] getSupportedQueryLanguages()
+ String[] getSupportedQueryLanguages()
throws RepositoryException, RemoteException;
}
Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/RemoteAdapterFactory.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/RemoteAdapterFactory.java?rev=191727&r1=191726&r2=191727&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/RemoteAdapterFactory.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/RemoteAdapterFactory.java Tue Jun 21 14:13:03 2005
@@ -288,7 +288,7 @@
*
* @param listenerId The listener identifier to which the events are to be
* dispatched.
- * @param event the local events
+ * @param events the local events
* @return remote event iterator adapter
* @throws RemoteException on RMI errors
*/
Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerAdapterFactory.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerAdapterFactory.java?rev=191727&r1=191726&r2=191727&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerAdapterFactory.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerAdapterFactory.java Tue Jun 21 14:13:03 2005
@@ -114,7 +114,7 @@
ObservationManager observationManager) throws RemoteException {
return new ServerObservationManager(observationManager, this);
}
-
+
/**
* Creates a {@link ServerNamespaceRegistry ServerNamespaceRegistry}
* instance.
@@ -265,7 +265,7 @@
RemoteEventCollection.RemoteEvent[] remoteEvents;
if (events != null) {
List eventList = new ArrayList();
- for (int i=0; events.hasNext(); i++) {
+ for (int i = 0; events.hasNext(); i++) {
Event event = events.nextEvent();
try {
eventList.add(new ServerEventCollection.ServerEvent(event.getType(),
@@ -276,11 +276,10 @@
}
remoteEvents = new RemoteEventCollection.RemoteEvent[eventList.size()];
eventList.toArray(remoteEvents);
-
} else {
remoteEvents = new RemoteEventCollection.RemoteEvent[0]; // for safety
}
-
+
return new ServerEventCollection(listenerId, remoteEvents);
}
}
Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerEventCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerEventCollection.java?rev=191727&r1=191726&r2=191727&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerEventCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerEventCollection.java Tue Jun 21 14:13:03 2005
@@ -19,7 +19,6 @@
import java.rmi.RemoteException;
import org.apache.jackrabbit.rmi.remote.RemoteEventCollection;
-import org.apache.jackrabbit.rmi.remote.RemoteEventCollection.RemoteEvent;
/**
* The <code>ServerEventCollection</code> class implemnts the
@@ -35,7 +34,7 @@
* {@link org.apache.jackrabbit.rmi.server.RemoteAdapterFactory}and
* consequently calls the base class constructor with a <code>null</code>
* factory.
- *
+ *
* @author Felix Meschberger
*/
public class ServerEventCollection extends ServerObject implements
@@ -43,26 +42,26 @@
/** The unique identifier of the receiving listener */
private final long listenerId;
-
+
/**
* The list of
* {@link org.apache.jackrabbit.rmi.remote.RemoteEventCollection.RemoteEvent}.
*/
private final RemoteEvent[] events;
-
+
/**
* Creates an instance of this class.
- *
+ *
* @param listenerId The unique identifier of the client-side listener to
* which the events should be sent.
* @param events The list of {@link RemoteEvent remote events}.
- *
+ *
* @throws RemoteException on RMI errors
*/
ServerEventCollection(long listenerId, RemoteEvent[] events)
throws RemoteException {
super(null);
-
+
this.listenerId = listenerId;
this.events = events;
}
@@ -79,24 +78,29 @@
/**
* Server side implementation of the {@link RemoteEvent} interface.
- *
+ *
* {@inheritDoc}
*/
public static class ServerEvent extends ServerObject implements RemoteEvent {
-
+
+ /** Event type */
private final int type;
+
+ /** Item path */
private final String path;
+
+ /** User identifier */
private final String userID;
-
+
/**
* Creates an instance of this class.
* @param type The event type.
* @param path The absolute path to the underlying item.
* @param userId The userID of the originating session.
- *
+ *
* @throws RemoteException declared because of the declaration in the
* base class constructor called. In fact this exception is never
- * thrown.
+ * thrown.
*/
ServerEvent(int type, String path, String userId) throws RemoteException {
super(null);
@@ -104,7 +108,7 @@
this.path = path;
this.userID = userId;
}
-
+
/** {@inheritDoc} */
public String getPath() {
return path;
Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerObservationManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerObservationManager.java?rev=191727&r1=191726&r2=191727&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerObservationManager.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerObservationManager.java Tue Jun 21 14:13:03 2005
@@ -29,8 +29,8 @@
import org.apache.jackrabbit.rmi.remote.RemoteObservationManager;
/**
- * The <code>ServerObservationManager</code> class
- *
+ * The <code>ServerObservationManager</code> class
+ *
* @author Felix Meschberger
*/
/**
@@ -55,13 +55,13 @@
/** The adapted local observation manager. */
private ObservationManager observationManager;
-
+
/**
* The map of event listener proxies indexed by the unique identifier.
*/
private Map proxyMap;
-
- /**
+
+ /**
* The queue to which event listener proxies post events to be reported
* by the {@link #getNextEvent(long)} method.
*/
@@ -85,23 +85,23 @@
public void addEventListener(long listenerId, int eventTypes,
String absPath, boolean isDeep, String[] uuid, String[] nodeTypeName,
boolean noLocal) throws RepositoryException, RemoteException {
-
+
// find the proxy or create one
ServerEventListenerProxy proxy;
synchronized (this) {
if (proxyMap == null) {
proxyMap = new HashMap();
}
-
+
Long id = new Long(listenerId);
proxy = (ServerEventListenerProxy) proxyMap.get(id);
if (proxy == null) {
- proxy = new ServerEventListenerProxy(getFactory(), listenerId,
+ proxy = new ServerEventListenerProxy(getFactory(), listenerId,
getQueue());
proxyMap.put(id, proxy);
}
}
-
+
// register the proxy with the observation manager
observationManager.addEventListener(proxy, eventTypes, absPath,
isDeep, uuid, nodeTypeName, noLocal);
@@ -110,43 +110,45 @@
/** {@inheritDoc} */
public void removeEventListener(long listenerId)
throws RepositoryException, RemoteException {
-
+
// try to find the proxy in the map
ServerEventListenerProxy proxy;
synchronized (this) {
if (proxyMap == null) {
return;
}
-
+
Long id = new Long(listenerId);
proxy = (ServerEventListenerProxy) proxyMap.remove(id);
if (proxy == null) {
return;
}
}
-
+
// register the proxy with the observation manager
observationManager.removeEventListener(proxy);
}
-
+
/** {@inheritDoc} */
public RemoteEventCollection getNextEvent(long timeout) throws RemoteException {
// need the queue
checkQueue();
-
+
try {
- if (timeout < 0) timeout = 0;
+ if (timeout < 0) {
+ timeout = 0;
+ }
return (RemoteEventCollection) queue.get(timeout);
} catch (InterruptedException ie) {
// don't retry, but log
}
-
+
// did not get anything, fall back to nothing
return null;
}
-
+
//---------- internal ------------------------------------------------------
-
+
/**
* Makes sure, the {@link #queue} field is assigned a value.
*/
@@ -155,9 +157,11 @@
queue = new Queue();
}
}
-
+
/**
* Returns the <code>Channel</code> allocating it if required.
+ *
+ * @return queue
*/
private Queue getQueue() {
checkQueue();
Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerSession.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerSession.java?rev=191727&r1=191726&r2=191727&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerSession.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerSession.java Tue Jun 21 14:13:03 2005
@@ -45,7 +45,7 @@
/** The adapted local session. */
private Session session;
-
+
/**
* The server workspace for this session. This field is assigned on demand
* by the first call to {@link #getWorkspace()}. The assumption is that
@@ -97,10 +97,10 @@
/** {@inheritDoc} */
public RemoteWorkspace getWorkspace() throws RemoteException {
if (remoteWorkspace == null) {
- remoteWorkspace =
+ remoteWorkspace =
getFactory().getRemoteWorkspace(session.getWorkspace());
}
-
+
return remoteWorkspace;
}
Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerWorkspace.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerWorkspace.java?rev=191727&r1=191726&r2=191727&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerWorkspace.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/rmi/server/ServerWorkspace.java Tue Jun 21 14:13:03 2005
@@ -153,7 +153,7 @@
throws RepositoryException, RemoteException {
try {
if (remoteObservationManager == null) {
- ObservationManager observationManager =
+ ObservationManager observationManager =
workspace.getObservationManager();
remoteObservationManager =
getFactory().getRemoteObservationManager(observationManager);
@@ -163,7 +163,7 @@
throw getRepositoryException(ex);
}
}
-
+
/** {@inheritDoc} */
public String[] getAccessibleWorkspaceNames()
throws RepositoryException, RemoteException {
Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BaseNonStreamValue.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BaseNonStreamValue.java?rev=191727&r1=191726&r2=191727&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BaseNonStreamValue.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BaseNonStreamValue.java Tue Jun 21 14:13:03 2005
@@ -34,7 +34,7 @@
* methods as appropriate except for the {@link #getStream()} which must throw
* an <code>IllegalStateException</code> for this line of committed non-stream
* states.
- *
+ *
* @version $Revision$, $Date$
* @author Felix Meschberger
* @since 0.16.4.1
@@ -44,7 +44,8 @@
/**
* Default constructor with no special tasks.
*/
- protected BaseNonStreamValue() {}
+ protected BaseNonStreamValue() {
+ }
/**
* Always throws <code>IllegalStateException</code> because only non-stream
@@ -52,17 +53,19 @@
* <p>
* This method is declared final to mark that this line of implementations
* does not provide access to <code>InputStream</code>s.
- *
- * @throws IllegalStateException as defined above.
+ *
+ * @return nothing
+ * @throws IllegalStateException as defined above.
*/
- public final InputStream getStream() {
+ public final InputStream getStream() throws IllegalStateException {
throw new IllegalStateException("Stream not available");
}
/**
* Always throws a <code>ValueFormatException</code>. Implementations should
* overwrite if conversion to boolean is supported.
- *
+ *
+ * @return nothing
* @throws ValueFormatException If the value cannot be converted to a
* boolean.
*/
@@ -73,7 +76,8 @@
/**
* Always throws a <code>ValueFormatException</code>. Implementations should
* overwrite if conversion to <code>Calender</code> is supported.
- *
+ *
+ * @return nothing
* @throws ValueFormatException If the value cannot be converted to a
* <code>Calendar</code> instance.
*/
@@ -84,7 +88,8 @@
/**
* Always throws a <code>ValueFormatException</code>. Implementations should
* overwrite if conversion to double is supported.
- *
+ *
+ * @return nothing
* @throws ValueFormatException If the value cannot be converted to a
* double.
*/
@@ -95,20 +100,22 @@
/**
* Always throws a <code>ValueFormatException</code>. Implementations should
* overwrite if conversion to long is supported.
- *
+ *
+ * @return nothing
* @throws ValueFormatException If the value cannot be converted to a
* long.
*/
public long getLong() throws ValueFormatException {
throw getValueFormatException(PropertyType.TYPENAME_LONG);
}
-
+
/**
* Returns a <code>ValueFormatException</code> with a message indicating
* what kind of type conversion is not supported.
- *
+ *
+ * @return nothing
* @param destType The name of the value type to which this value cannot
- * be converted.
+ * be converted.
*/
protected ValueFormatException getValueFormatException(String destType) {
return new ValueFormatException("Cannot convert value of type "
Modified: incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BinaryValue.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BinaryValue.java?rev=191727&r1=191726&r2=191727&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BinaryValue.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-rmi/src/java/org/apache/jackrabbit/value/BinaryValue.java Tue Jun 21 14:13:03 2005
@@ -31,7 +31,7 @@
/**
* The <code>BinaryValue</code> class implements the committed value state for
* Binary values as a part of the State design pattern (Gof) used by this
- * package.
+ * package.
* <p>
* NOTE: This class forwards the <code>InputStream</code> from which it was
* created through the {@link #getStream()} method but does not close the
@@ -41,11 +41,11 @@
* This class implements {@link #readObject(ObjectInputStream)} and
* {@link #writeObject(ObjectOutputStream)} methods to (de-)serialize the
* data.
- *
+ *
* @version $Revision$, $Date$
* @author Jukka Zitting
* @since 0.16.4.1
- *
+ *
* @see org.apache.jackrabbit.value.SerialValue
*/
public class BinaryValue implements StatefulValue {
@@ -57,7 +57,7 @@
* Creates an instance on the given <code>InputStream</code>. This exact
* stream will be provided by the {@link #getStream()}, thus care must be
* taken to not inadvertendly read or close the stream.
- *
+ *
* @param stream The <code>InputStream</code> providing the value.
*/
protected BinaryValue(InputStream stream) {
@@ -67,10 +67,10 @@
/**
* Creates an instance providing the UTF-8 representation of the given
* string value.
- *
+ *
* @param value The string whose UTF-8 representation is provided as the
* value of this instance.
- *
+ *
* @throws ValueFormatException If the platform does not support UTF-8
* encoding (which is unlikely as UTF-8 is required to be available
* on all platforms).
@@ -82,12 +82,12 @@
/**
* Helper method to convert a string value into an <code>InputStream</code>
* from which the UTF-8 representation can be read.
- *
+ *
* @param value The string value to be made available through a stream.
- *
+ *
* @return The <code>InputStream</code> from which the UTF-8 representation
* of the <code>value</code> may be read.
- *
+ *
* @throws ValueFormatException If the platform does not support UTF-8
* encoding (which is unlikely as UTF-8 is required to be available
* on all platforms).
@@ -104,6 +104,8 @@
/**
* Returns the <code>InputStream</code> from which this instance has been
* created.
+ *
+ * @return value stream
*/
public InputStream getStream() {
return stream;
@@ -111,6 +113,8 @@
/**
* Returns <code>PropertyType.BINARY</code>.
+ *
+ * @return property type
*/
public int getType() {
return PropertyType.BINARY;
@@ -119,50 +123,55 @@
/**
* Always throws <code>IllegalStateException</code> because only an
* <code>InputStream</code> is available from this implementation.
- *
- * @throws IllegalStateException as defined above.
+ *
+ * @return nothing
+ * @throws IllegalStateException as defined above.
*/
- public String getString() {
+ public String getString() throws IllegalStateException {
throw new IllegalStateException("Stream already retrieved");
}
/**
* Always throws <code>IllegalStateException</code> because only an
* <code>InputStream</code> is available from this implementation.
- *
- * @throws IllegalStateException as defined above.
+ *
+ * @return nothing
+ * @throws IllegalStateException as defined above.
*/
- public long getLong() {
+ public long getLong() throws IllegalStateException {
throw new IllegalStateException("Stream already retrieved");
}
/**
* Always throws <code>IllegalStateException</code> because only an
* <code>InputStream</code> is available from this implementation.
- *
- * @throws IllegalStateException as defined above.
+ *
+ * @return nothing
+ * @throws IllegalStateException as defined above.
*/
- public double getDouble() {
+ public double getDouble() throws IllegalStateException {
throw new IllegalStateException("Stream already retrieved");
}
/**
* Always throws <code>IllegalStateException</code> because only an
* <code>InputStream</code> is available from this implementation.
- *
- * @throws IllegalStateException as defined above.
+ *
+ * @return nothing
+ * @throws IllegalStateException as defined above.
*/
- public Calendar getDate() {
+ public Calendar getDate() throws IllegalStateException {
throw new IllegalStateException("Stream already retrieved");
}
/**
* Always throws <code>IllegalStateException</code> because only an
* <code>InputStream</code> is available from this implementation.
- *
- * @throws IllegalStateException as defined above.
+ *
+ * @return nothing
+ * @throws IllegalStateException as defined above.
*/
- public boolean getBoolean() {
+ public boolean getBoolean() throws IllegalStateException {
throw new IllegalStateException("Stream already retrieved");
}
@@ -175,24 +184,25 @@
* data is copied.
*
* @throws IOException If an error occurrs writing the binary data.
- * @throws OutOfMemoryError If not enouhg memory is available to store the
+ * @throws OutOfMemoryError If not enough memory is available to store the
* binary data in the internal byte array.
*/
- private void writeObject(ObjectOutputStream out) throws IOException {
+ private void writeObject(ObjectOutputStream out)
+ throws IOException, OutOfMemoryError {
// read the input into a byte array - limited by memory available !!
- ByteArrayOutputStream bos =
+ ByteArrayOutputStream bos =
new ByteArrayOutputStream(stream.available());
byte[] buf = new byte[2048];
int rd = 0;
while ((rd = stream.read(buf)) >= 0) {
bos.write(buf, 0, rd);
}
-
+
// stream the data to the object output
out.writeInt(bos.size());
out.write(bos.toByteArray());
}
-
+
/**
* Reads the binary data from the <code>ObjectInputStream</code> into an
* internal byte array, which is then provided through a
@@ -205,7 +215,8 @@
* @throws OutOfMemoryError If not enouhg memory is available to store the
* binary data in the internal byte array.
*/
- private void readObject(ObjectInputStream in) throws IOException {
+ private void readObject(ObjectInputStream in)
+ throws IOException, OutOfMemoryError {
int size = in.readInt();
byte[] buf = new byte[size];
in.readFully(buf);