stefan 2004/07/13 08:49:19
Modified: proposals/jcrri/src/org/apache/slide/jcr/core/nodetype
builtin_nodetypes.xml
proposals/jcrri/src/org/apache/slide/jcr/core/observation
ObservationManagerFactory.java
proposals/jcrri/src/org/apache/slide/jcr/core/state
PersistentItemStateManager.java
Log:
jcrri
Revision Changes Path
1.2 +1 -1
jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/nodetype/builtin_nodetypes.xml
Index: builtin_nodetypes.xml
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/nodetype/builtin_nodetypes.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- builtin_nodetypes.xml 30 Jun 2004 14:39:08 -0000 1.1
+++ builtin_nodetypes.xml 13 Jul 2004 15:49:18 -0000 1.2
@@ -105,7 +105,7 @@
<propertyDef name="jcr:frozenMixinTypes" type="String" valueConstraint=""
defaultValue="" autoCreate="false" mandatory="false" onParentVersion="ABORT"
protected="true" primaryItem="false" multiple="true"/>
<propertyDef name="jcr:frozenUUID" type="String" valueConstraint=""
defaultValue="" autoCreate="true" mandatory="true" onParentVersion="ABORT"
protected="true" primaryItem="false" multiple="false"/>
<propertyDef name="" type="undefined" valueConstraint="" defaultValue=""
autoCreate="false" mandatory="false" onParentVersion="ABORT" protected="true"
primaryItem="false" multiple="true"/>
- <childNodeDef name="" requiredPrimaryTypes="nt:base" defaultPrimaryType=""
autoCreate="false" mandatory="false" onParentVersion="ABORT" protected="false"
primaryItem="false" sameNameSibs="true"/>
+ <childNodeDef name="" requiredPrimaryTypes="nt:base" defaultPrimaryType=""
autoCreate="false" mandatory="false" onParentVersion="ABORT" protected="true"
primaryItem="false" sameNameSibs="true"/>
</nodeType>
<nodeType name="nt:query" mixin="false" orderableChildNodes="false"
supertypes="nt:base">
<propertyDef name="jcr:statement" type="String" valueConstraint=""
defaultValue="" autoCreate="false" mandatory="false" onParentVersion="COPY"
protected="false" primaryItem="false" multiple="false"/>
1.3 +174 -153
jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/observation/ObservationManagerFactory.java
Index: ObservationManagerFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/observation/ObservationManagerFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ObservationManagerFactory.java 2 Jul 2004 16:24:37 -0000 1.2
+++ ObservationManagerFactory.java 13 Jul 2004 15:49:19 -0000 1.3
@@ -24,19 +24,23 @@
package org.apache.slide.jcr.core.observation;
-import org.apache.slide.jcr.core.ItemManager;
-import org.apache.slide.jcr.core.TicketImpl;
import org.apache.commons.collections.Buffer;
import org.apache.commons.collections.BufferUtils;
import org.apache.commons.collections.UnboundedFifoBuffer;
import org.apache.log4j.Logger;
+import org.apache.slide.jcr.core.ItemManager;
+import org.apache.slide.jcr.core.TicketImpl;
-import javax.jcr.observation.*;
-import javax.jcr.observation.EventListener;
import javax.jcr.RepositoryException;
-import javax.jcr.nodetype.NodeTypeManager;
import javax.jcr.nodetype.NodeType;
-import java.util.*;
+import javax.jcr.nodetype.NodeTypeManager;
+import javax.jcr.observation.EventListener;
+import javax.jcr.observation.EventListenerIterator;
+import javax.jcr.observation.ObservationManager;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
/**
* The class <code>ObservationManagerFactory</code> creates new
@@ -48,27 +52,41 @@
*/
final public class ObservationManagerFactory implements EventDispatcher, Runnable {
- /** Logger instance for this class */
+ /**
+ * Logger instance for this class
+ */
private static final Logger log
- = Logger.getLogger(ObservationManagerFactory.class);
+ = Logger.getLogger(ObservationManagerFactory.class);
- /** Dummy DispatchAction indicating the notification thread to end */
+ /**
+ * Dummy DispatchAction indicating the notification thread to end
+ */
private static final DispatchAction DISPOSE_MARKER = new DispatchAction(null,
null);
- /** Currently active <code>EventConsumer</code>s for notification */
+ /**
+ * Currently active <code>EventConsumer</code>s for notification
+ */
private Set activeConsumers = new HashSet();
- /** Set of <code>EventConsumer</code>s for read only Set access */
+ /**
+ * Set of <code>EventConsumer</code>s for read only Set access
+ */
private Set readOnlyConsumers;
- /** synchronization monitor for listener changes */
+ /**
+ * synchronization monitor for listener changes
+ */
private Object consumerChange = new Object();
- /** Contains the pending events that will be delivered to event listeners */
+ /**
+ * Contains the pending events that will be delivered to event listeners
+ */
private Buffer eventQueue
- = BufferUtils.blockingBuffer(new UnboundedFifoBuffer());
+ = BufferUtils.blockingBuffer(new UnboundedFifoBuffer());
- /** The background notification thread */
+ /**
+ * The background notification thread
+ */
private Thread notificationThread;
/**
@@ -76,9 +94,9 @@
* and starts the notification thread deamon.
*/
public ObservationManagerFactory() {
- notificationThread = new Thread(this, "ObservationManager");
- notificationThread.setDaemon(true);
- notificationThread.start();
+ notificationThread = new Thread(this, "ObservationManager");
+ notificationThread.setDaemon(true);
+ notificationThread.start();
}
/**
@@ -86,41 +104,41 @@
* effectively stop the background notification thread.
*/
public void dispose() {
- // dispatch dummy event to mark end of notification
- eventQueue.add(DISPOSE_MARKER);
- try {
- notificationThread.join();
- } catch (InterruptedException e) {
- // FIXME log exception ?
- }
- log.info("Notification of EventListeners stopped.");
+ // dispatch dummy event to mark end of notification
+ eventQueue.add(DISPOSE_MARKER);
+ try {
+ notificationThread.join();
+ } catch (InterruptedException e) {
+ // FIXME log exception ?
+ }
+ log.info("Notification of EventListeners stopped.");
}
/**
* Returns an unmodifieable <code>Set</code> of <code>EventConsumer</code>s.
+ *
* @return <code>Set</code> of <code>EventConsumer</code>s.
*/
private Set getConsumers() {
- synchronized (consumerChange) {
- if (readOnlyConsumers == null) {
- readOnlyConsumers = Collections.unmodifiableSet(
- new HashSet(activeConsumers));
- }
- return readOnlyConsumers;
- }
+ synchronized (consumerChange) {
+ if (readOnlyConsumers == null) {
+ readOnlyConsumers = Collections.unmodifiableSet(new
HashSet(activeConsumers));
+ }
+ return readOnlyConsumers;
+ }
}
/**
* Creates a new <code>ticket</code> local <code>ObservationManager</code>
* with an associated <code>NamespaceResolver</code>.
*
- * @param ticket the ticket.
+ * @param ticket the ticket.
* @param itemMgr the <code>ItemManager</code> of the <code>ticket</code>.
* @return an <code>ObservationManager</code>.
*/
public ObservationManager createObservationManager(TicketImpl ticket,
- ItemManager itemMgr) {
- return new TicketLocalObservationManager(ticket, itemMgr);
+ ItemManager itemMgr) {
+ return new TicketLocalObservationManager(ticket, itemMgr);
}
@@ -129,23 +147,23 @@
* thread.
*/
public void run() {
- DispatchAction action;
- while ((action = (DispatchAction)eventQueue.remove()) != DISPOSE_MARKER) {
+ DispatchAction action;
+ while ((action = (DispatchAction) eventQueue.remove()) != DISPOSE_MARKER) {
- log.debug("got EventStateCollection");
- log.debug("event delivery to " + action.eventConsumers.size() + "
consumers started...");
- for (Iterator it = action.eventConsumers.iterator(); it.hasNext(); ) {
- EventConsumer c = (EventConsumer)it.next();
- try {
- c.consumeEvents(action.eventStates);
- } catch (Throwable t) {
- log.error("EventConsumer threw exception.", t);
- // move on to the next consumer
- }
- }
- log.debug("event delivery finished.");
+ log.debug("got EventStateCollection");
+ log.debug("event delivery to " + action.eventConsumers.size() + "
consumers started...");
+ for (Iterator it = action.eventConsumers.iterator(); it.hasNext();) {
+ EventConsumer c = (EventConsumer) it.next();
+ try {
+ c.consumeEvents(action.eventStates);
+ } catch (Throwable t) {
+ log.error("EventConsumer threw exception.", t);
+ // move on to the next consumer
+ }
+ }
+ log.debug("event delivery finished.");
- }
+ }
}
//-------------------------< EventDispatcher >------------------------------
@@ -154,7 +172,7 @@
* @see EventDispatcher#dispatchEvents
*/
public void dispatchEvents(EventStateCollection events) {
- eventQueue.add(new DispatchAction(events, getConsumers()));
+ eventQueue.add(new DispatchAction(events, getConsumers()));
}
//----------------------------< adapter class >-----------------------------
@@ -166,105 +184,108 @@
*/
class TicketLocalObservationManager implements ObservationManager {
- /**
- * The <code>Ticket</code> this <code>ObservationManager</code>
- * belongs to.
- */
- private TicketImpl ticket;
-
- /**
- * The <code>ItemManager</code> for this <code>ObservationManager</code>.
- */
- private ItemManager itemMgr;
-
- /**
- * Creates an <code>ObservationManager</code> instance.
- *
- * @param ticket the <code>Ticket</code> this ObservationManager
- * belongs to.
- * @param itemMgr [EMAIL PROTECTED] org.apache.slide.jcr.core.ItemManager}
of the passed
- * <code>Ticket</code>.
- *
- * @exception NullPointerException if <code>ticket</code> or
<code>itemMgr</code>
- * is <code>null</code>.
- */
- TicketLocalObservationManager(TicketImpl ticket,
- ItemManager itemMgr) {
- if (ticket == null) throw new NullPointerException("ticket");
- if (itemMgr == null) throw new NullPointerException("itemMgr");
-
- this.ticket = ticket;
- this.itemMgr = itemMgr;
- }
-
- /**
- * @see ObservationManager#addEventListener
- */
- public void addEventListener(EventListener listener,
- long eventTypes,
- String absPath,
- boolean isDeep,
- String[] uuid,
- String[] nodeTypeName,
- boolean noLocal)
- throws RepositoryException {
-
- // create NodeType instances from names
- NodeType[] nodeTypes;
- if (nodeTypeName == null) {
- nodeTypes = null;
- } else {
- NodeTypeManager ntMgr = ticket.getWorkspace().getNodeTypeManager();
- nodeTypes = new NodeType[nodeTypeName.length];
- for (int i = 0; i < nodeTypes.length; i++) {
- nodeTypes[i] = ntMgr.getNodeType(nodeTypeName[i]);
- }
- }
-
- // create filter
- EventFilter filter = new EventFilter(itemMgr,
- ticket,
- eventTypes,
- absPath,
- isDeep,
- uuid,
- nodeTypes,
- noLocal);
-
- EventConsumer consumer =
- new EventConsumer(ticket, listener, filter);
-
- synchronized (consumerChange) {
- // remove existing if any
- activeConsumers.remove(consumer);
- // re-add it
- activeConsumers.add(consumer);
- // reset read only consumer set
- readOnlyConsumers = null;
- }
- }
-
- /**
- * @see
ObservationManager#removeEventListener(javax.jcr.observation.EventListener)
- */
- public void removeEventListener(EventListener listener)
- throws RepositoryException {
- EventConsumer consumer =
- new EventConsumer(ticket, listener, EventFilter.BLOCK_ALL);
-
- synchronized (consumerChange) {
- activeConsumers.remove(consumer);
- // reset read only listener set
- readOnlyConsumers = null;
- }
- }
-
- /**
- * @see ObservationManager#getRegisteredEventListeners()
- */
- public EventListenerIterator getRegisteredEventListeners()
- throws RepositoryException {
- return new EventListenerIteratorImpl(ticket, getConsumers());
- }
+ /**
+ * The <code>Ticket</code> this <code>ObservationManager</code>
+ * belongs to.
+ */
+ private TicketImpl ticket;
+
+ /**
+ * The <code>ItemManager</code> for this <code>ObservationManager</code>.
+ */
+ private ItemManager itemMgr;
+
+ /**
+ * Creates an <code>ObservationManager</code> instance.
+ *
+ * @param ticket the <code>Ticket</code> this ObservationManager
+ * belongs to.
+ * @param itemMgr [EMAIL PROTECTED] org.apache.slide.jcr.core.ItemManager} of
the passed
+ * <code>Ticket</code>.
+ * @throws NullPointerException if <code>ticket</code> or <code>itemMgr</code>
+ * is <code>null</code>.
+ */
+ TicketLocalObservationManager(TicketImpl ticket,
+ ItemManager itemMgr) {
+ if (ticket == null) {
+ throw new NullPointerException("ticket");
+ }
+ if (itemMgr == null) {
+ throw new NullPointerException("itemMgr");
+ }
+
+ this.ticket = ticket;
+ this.itemMgr = itemMgr;
+ }
+
+ /**
+ * @see ObservationManager#addEventListener
+ */
+ public void addEventListener(EventListener listener,
+ long eventTypes,
+ String absPath,
+ boolean isDeep,
+ String[] uuid,
+ String[] nodeTypeName,
+ boolean noLocal)
+ throws RepositoryException {
+
+ // create NodeType instances from names
+ NodeType[] nodeTypes;
+ if (nodeTypeName == null) {
+ nodeTypes = null;
+ } else {
+ NodeTypeManager ntMgr = ticket.getWorkspace().getNodeTypeManager();
+ nodeTypes = new NodeType[nodeTypeName.length];
+ for (int i = 0; i < nodeTypes.length; i++) {
+ nodeTypes[i] = ntMgr.getNodeType(nodeTypeName[i]);
+ }
+ }
+
+ // create filter
+ EventFilter filter = new EventFilter(itemMgr,
+ ticket,
+ eventTypes,
+ absPath,
+ isDeep,
+ uuid,
+ nodeTypes,
+ noLocal);
+
+ EventConsumer consumer =
+ new EventConsumer(ticket, listener, filter);
+
+ synchronized (consumerChange) {
+ // remove existing if any
+ activeConsumers.remove(consumer);
+ // re-add it
+ activeConsumers.add(consumer);
+ // reset read only consumer set
+ readOnlyConsumers = null;
+ }
+ }
+
+ /**
+ * @see
ObservationManager#removeEventListener(javax.jcr.observation.EventListener)
+ */
+ public void removeEventListener(EventListener listener)
+ throws RepositoryException {
+ EventConsumer consumer =
+ new EventConsumer(ticket, listener, EventFilter.BLOCK_ALL);
+
+ synchronized (consumerChange) {
+ activeConsumers.remove(consumer);
+ // reset read only listener set
+ readOnlyConsumers = null;
+ }
+ }
+
+ /**
+ * @see ObservationManager#getRegisteredEventListeners()
+ */
+ public EventListenerIterator getRegisteredEventListeners()
+ throws RepositoryException {
+ return new EventListenerIteratorImpl(ticket, getConsumers());
+ }
}
}
1.5 +0 -0
jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/state/PersistentItemStateManager.java
Index: PersistentItemStateManager.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/state/PersistentItemStateManager.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]