archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdu...@apache.org
Subject svn commit: r694152 - in /archiva/sandbox/archiva-event: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/archiva/ src/main/java/org/apache/archiva/event/ src/main/java/org/apache/archiva/event/impl...
Date Thu, 11 Sep 2008 07:05:58 GMT
Author: jdumay
Date: Thu Sep 11 00:05:57 2008
New Revision: 694152

URL: http://svn.apache.org/viewvc?rev=694152&view=rev
Log:
Init import of event framework

Added:
    archiva/sandbox/archiva-event/
    archiva/sandbox/archiva-event/pom.xml
    archiva/sandbox/archiva-event/src/
    archiva/sandbox/archiva-event/src/main/
    archiva/sandbox/archiva-event/src/main/java/
    archiva/sandbox/archiva-event/src/main/java/org/
    archiva/sandbox/archiva-event/src/main/java/org/apache/
    archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/
    archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/
    archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/Event.java
    archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/EventBus.java
    archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/EventEmitter.java
    archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/EventMessage.java
    archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/EventObserver.java
    archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/GenericPredicate.java
    archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/impl/
    archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/impl/JmsEventBus.java
    archiva/sandbox/archiva-event/src/main/resources/
    archiva/sandbox/archiva-event/src/test/
    archiva/sandbox/archiva-event/src/test/java/
    archiva/sandbox/archiva-event/src/test/java/com/
    archiva/sandbox/archiva-event/src/test/java/com/mycompany/
    archiva/sandbox/archiva-event/src/test/java/com/mycompany/archiva-events/

Added: archiva/sandbox/archiva-event/pom.xml
URL: http://svn.apache.org/viewvc/archiva/sandbox/archiva-event/pom.xml?rev=694152&view=auto
==============================================================================
--- archiva/sandbox/archiva-event/pom.xml (added)
+++ archiva/sandbox/archiva-event/pom.xml Thu Sep 11 00:05:57 2008
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>com.mycompany</groupId>
+  <artifactId>archiva-events</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <name>archiva-events</name>
+  <url>http://maven.apache.org</url>
+  <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>2.0.2</version>
+                <configuration>
+                    <source>1.5</source>
+                    <target>1.5</target>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+  <dependencies>
+      <dependency>
+          <groupId>commons-collections</groupId>
+          <artifactId>commons-collections</artifactId>
+          <version>3.2.1</version>
+      </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>

Added: archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/Event.java
URL: http://svn.apache.org/viewvc/archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/Event.java?rev=694152&view=auto
==============================================================================
--- archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/Event.java (added)
+++ archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/Event.java Thu Sep
11 00:05:57 2008
@@ -0,0 +1,36 @@
+package org.apache.archiva.event;
+
+/**
+ * Encaptulation of both the EventEmitter and the EventMessage
+ * to represent a single event
+ */
+public final class Event
+{
+    private final EventEmitter emitter;
+
+    private final EventMessage message;
+
+    public Event(EventEmitter emitter, EventMessage message)
+    {
+        this.emitter = emitter;
+        this.message = message;
+    }
+
+    /**
+     * Get the Emitter who emitted the Event
+     * @return emitter
+     */
+    public EventEmitter getEmitter()
+    {
+        return emitter;
+    }
+
+    /**
+     * Get the EventMessage
+     * @return message
+     */
+    public EventMessage getMessage()
+    {
+        return message;
+    }
+}

Added: archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/EventBus.java
URL: http://svn.apache.org/viewvc/archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/EventBus.java?rev=694152&view=auto
==============================================================================
--- archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/EventBus.java (added)
+++ archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/EventBus.java Thu
Sep 11 00:05:57 2008
@@ -0,0 +1,26 @@
+package org.apache.archiva.event;
+
+/**
+ * Allows a emitter to publish
+ */
+public interface EventBus
+{
+    /**
+     * Emit a event
+     * @param emitter
+     * @param message
+     */
+    void emit(EventEmitter emitter, EventMessage message);
+
+    /**
+     * Allows the subscriber to receive messages from this event bus
+     * @param observer
+     */
+    void subscribe(EventObserver observer);
+
+    /**
+     * Stops the observer from receiving any messages
+     * @param observer
+     */
+    void unsubscribe(EventObserver observer);
+}

Added: archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/EventEmitter.java
URL: http://svn.apache.org/viewvc/archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/EventEmitter.java?rev=694152&view=auto
==============================================================================
--- archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/EventEmitter.java
(added)
+++ archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/EventEmitter.java
Thu Sep 11 00:05:57 2008
@@ -0,0 +1,5 @@
+package org.apache.archiva.event;
+
+public interface EventEmitter
+{
+}

Added: archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/EventMessage.java
URL: http://svn.apache.org/viewvc/archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/EventMessage.java?rev=694152&view=auto
==============================================================================
--- archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/EventMessage.java
(added)
+++ archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/EventMessage.java
Thu Sep 11 00:05:57 2008
@@ -0,0 +1,6 @@
+package org.apache.archiva.event;
+
+public interface EventMessage
+{
+
+}

Added: archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/EventObserver.java
URL: http://svn.apache.org/viewvc/archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/EventObserver.java?rev=694152&view=auto
==============================================================================
--- archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/EventObserver.java
(added)
+++ archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/EventObserver.java
Thu Sep 11 00:05:57 2008
@@ -0,0 +1,6 @@
+package org.apache.archiva.event;
+
+public interface EventObserver
+{
+    void observe(Event event);
+}

Added: archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/GenericPredicate.java
URL: http://svn.apache.org/viewvc/archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/GenericPredicate.java?rev=694152&view=auto
==============================================================================
--- archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/GenericPredicate.java
(added)
+++ archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/GenericPredicate.java
Thu Sep 11 00:05:57 2008
@@ -0,0 +1,12 @@
+package org.apache.archiva.event;
+
+import org.apache.commons.collections.Predicate;
+
+/**
+ *
+ * @author jdumay
+ */
+public interface GenericPredicate<T> extends Predicate
+{
+    public boolean evaluate(T object);
+}

Added: archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/impl/JmsEventBus.java
URL: http://svn.apache.org/viewvc/archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/impl/JmsEventBus.java?rev=694152&view=auto
==============================================================================
--- archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/impl/JmsEventBus.java
(added)
+++ archiva/sandbox/archiva-event/src/main/java/org/apache/archiva/event/impl/JmsEventBus.java
Thu Sep 11 00:05:57 2008
@@ -0,0 +1,54 @@
+package org.apache.archiva.event.impl;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.archiva.event.Event;
+import org.apache.archiva.event.EventBus;
+import org.apache.archiva.event.EventEmitter;
+import org.apache.archiva.event.EventMessage;
+import org.apache.archiva.event.EventObserver;
+
+public class JmsEventBus implements EventBus
+{
+    private final Set<EventObserver> observers = Collections.synchronizedSet(new HashSet());
+
+    public JmsEventBus()
+    {
+        
+    }
+
+    public void emit(EventEmitter emitter, EventMessage message)
+    {
+        final Event event = new Event(emitter, message);
+        for (EventObserver observer : observers)
+        {
+            observer.observe(event);
+        }
+    }
+
+    public void subscribe(EventObserver observer)
+    {
+        //todo
+    }
+
+    public void unsubscribe(EventObserver observer)
+    {
+        //todo
+    }
+
+    private class PointToPointObserver implements EventObserver
+    {
+        private final EventObserver observer;
+
+        public PointToPointObserver(EventObserver observer)
+        {
+            this.observer = observer;
+        }
+
+        public void observe(Event event)
+        {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+    }
+}



Mime
View raw message