incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1164498 - in /sling/trunk/installer/core: ./ src/main/java/org/apache/sling/installer/api/event/ src/main/java/org/apache/sling/installer/api/tasks/ src/main/java/org/apache/sling/installer/core/impl/ src/test/java/org/apache/sling/install...
Date Fri, 02 Sep 2011 12:05:48 GMT
Author: cziegeler
Date: Fri Sep  2 12:05:48 2011
New Revision: 1164498

URL: http://svn.apache.org/viewvc?rev=1164498&view=rev
Log:
SLING-2201 : Add a listener to the installer

Added:
    sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/event/
    sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/event/InstallationEvent.java
  (with props)
    sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/event/InstallationListener.java
  (contents, props changed)
      - copied, changed from r1164395, sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/tasks/InstallationListener.java
Modified:
    sling/trunk/installer/core/pom.xml
    sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/tasks/InstallationListener.java
    sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/EntityResourceList.java
    sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/InstallListener.java
    sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/OsgiInstallerImpl.java
    sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/PersistentResourceList.java
    sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/MockBundleResource.java
    sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/tasks/MockInstallationListener.java

Modified: sling/trunk/installer/core/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/pom.xml?rev=1164498&r1=1164497&r2=1164498&view=diff
==============================================================================
--- sling/trunk/installer/core/pom.xml (original)
+++ sling/trunk/installer/core/pom.xml Fri Sep  2 12:05:48 2011
@@ -59,7 +59,8 @@
                         </Import-Package>
 						<Export-Package>
 							org.apache.sling.installer.api;version=3.1.0,
-                            org.apache.sling.installer.api.tasks;version=1.2.0
+                            org.apache.sling.installer.api.event;version=1.0.0,
+                            org.apache.sling.installer.api.tasks;version=1.1.0
                         </Export-Package>
 						<Private-Package>
 						    org.apache.sling.installer.core.impl.*

Added: sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/event/InstallationEvent.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/event/InstallationEvent.java?rev=1164498&view=auto
==============================================================================
--- sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/event/InstallationEvent.java
(added)
+++ sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/event/InstallationEvent.java
Fri Sep  2 12:05:48 2011
@@ -0,0 +1,49 @@
+/*
+ * 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.sling.installer.api.event;
+
+
+/**
+ * Optional listener which can be used to monitor the activities
+ * of the installer.
+ *
+ * @since 1.0
+ */
+public interface InstallationEvent {
+
+    public enum TYPE {
+        STARTED,
+        SUSPENDED,
+        PROCESSED
+    };
+
+    /**
+     * Return the event type.
+     */
+    TYPE getType();
+
+    /**
+     * Return the source of the event.
+     * For {@link TYPE#STARTED} and {@link TYPE#SUSPENDED} events
+     * this is <code>null</code>.
+     * For {@link TYPE#PROCESSED} events this is a
+     * {@link org.apache.sling.installer.api.tasks.TaskResource}.
+     */
+    Object getSource();
+}

Propchange: sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/event/InstallationEvent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/event/InstallationEvent.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/event/InstallationEvent.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/event/InstallationListener.java
(from r1164395, sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/tasks/InstallationListener.java)
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/event/InstallationListener.java?p2=sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/event/InstallationListener.java&p1=sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/tasks/InstallationListener.java&r1=1164395&r2=1164498&rev=1164498&view=diff
==============================================================================
--- sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/tasks/InstallationListener.java
(original)
+++ sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/event/InstallationListener.java
Fri Sep  2 12:05:48 2011
@@ -16,34 +16,19 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.sling.installer.api.tasks;
+package org.apache.sling.installer.api.event;
+
 
 /**
  * Optional listener which can be used to monitor the activities
  * of the installer.
  *
- * @since 1.2
+ * @since 1.0
  */
 public interface InstallationListener {
 
     /**
-     * A resource has been processed
-     * The state of the resource can be queried to see whether
-     * the resource has been installed or removed.
-     * @param resource The resource
-     */
-    void processed(final TaskResource resource);
-
-    /**
-     * Indication that the installer starts a new cycle.
-     * Several starting methods might be invoked one after
-     * the other without a processed or suspended inbetween.
-     */
-    void started();
-
-    /**
-     * The installer is suspended and has processed all current
-     * resources.
+     * Receive an installation event.
      */
-    void suspended();
+    void onEvent(final InstallationEvent event);
 }

Propchange: sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/event/InstallationListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/event/InstallationListener.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/event/InstallationListener.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/EntityResourceList.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/EntityResourceList.java?rev=1164498&r1=1164497&r2=1164498&view=diff
==============================================================================
--- sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/EntityResourceList.java
(original)
+++ sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/EntityResourceList.java
Fri Sep  2 12:05:48 2011
@@ -27,7 +27,8 @@ import java.util.List;
 import java.util.SortedSet;
 import java.util.TreeSet;
 
-import org.apache.sling.installer.api.tasks.InstallationListener;
+import org.apache.sling.installer.api.event.InstallationEvent;
+import org.apache.sling.installer.api.event.InstallationListener;
 import org.apache.sling.installer.api.tasks.RegisteredResource;
 import org.apache.sling.installer.api.tasks.ResourceState;
 import org.apache.sling.installer.api.tasks.TaskResource;
@@ -231,7 +232,16 @@ public class EntityResourceList implemen
 
             }
             ((RegisteredResourceImpl)toActivate).setState(state);
-            this.listener.processed(toActivate);
+            this.listener.onEvent(new InstallationEvent() {
+
+                public TYPE getType() {
+                    return TYPE.PROCESSED;
+                }
+
+                public Object getSource() {
+                    return toActivate;
+                }
+            });
             if ( state == ResourceState.UNINSTALLED ) {
                 this.cleanup(toActivate);
             }

Modified: sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/InstallListener.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/InstallListener.java?rev=1164498&r1=1164497&r2=1164498&view=diff
==============================================================================
--- sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/InstallListener.java
(original)
+++ sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/InstallListener.java
Fri Sep  2 12:05:48 2011
@@ -18,8 +18,8 @@
  */
 package org.apache.sling.installer.core.impl;
 
-import org.apache.sling.installer.api.tasks.InstallationListener;
-import org.apache.sling.installer.api.tasks.TaskResource;
+import org.apache.sling.installer.api.event.InstallationEvent;
+import org.apache.sling.installer.api.event.InstallationListener;
 import org.osgi.framework.BundleContext;
 import org.osgi.util.tracker.ServiceTracker;
 
@@ -37,32 +37,16 @@ public class InstallListener implements 
     }
 
     /**
-     * @see org.apache.sling.installer.api.tasks.InstallationListener#processed(org.apache.sling.installer.api.tasks.TaskResource)
+     * @see org.apache.sling.installer.api.event.InstallationListener#onEvent(org.apache.sling.installer.api.event.InstallationEvent)
      */
-    public void processed(final TaskResource resource) {
-        final InstallationListener l = (InstallationListener) this.tracker.getService();
-        if ( l != null ) {
-            l.processed(resource);
-        }
-    }
-
-    /**
-     * @see org.apache.sling.installer.api.tasks.InstallationListener#started()
-     */
-    public void started() {
-        final InstallationListener l = (InstallationListener) this.tracker.getService();
-        if ( l != null ) {
-            l.started();
-        }
-    }
-
-    /**
-     * @see org.apache.sling.installer.api.tasks.InstallationListener#suspended()
-     */
-    public void suspended() {
-        final InstallationListener l = (InstallationListener) this.tracker.getService();
-        if ( l != null ) {
-            l.suspended();
+    public void onEvent(final InstallationEvent event) {
+        final Object[] listeners = this.tracker.getServices();
+        if ( listeners != null ) {
+            for(final Object l : listeners) {
+                if ( l instanceof InstallationListener ) {
+                    ((InstallationListener)l).onEvent(event);
+                }
+            }
         }
     }
 }

Modified: sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/OsgiInstallerImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/OsgiInstallerImpl.java?rev=1164498&r1=1164497&r2=1164498&view=diff
==============================================================================
--- sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/OsgiInstallerImpl.java
(original)
+++ sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/OsgiInstallerImpl.java
Fri Sep  2 12:05:48 2011
@@ -39,6 +39,7 @@ import org.apache.sling.installer.api.Os
 import org.apache.sling.installer.api.ResourceChangeListener;
 import org.apache.sling.installer.api.UpdateHandler;
 import org.apache.sling.installer.api.UpdateResult;
+import org.apache.sling.installer.api.event.InstallationEvent;
 import org.apache.sling.installer.api.tasks.InstallTask;
 import org.apache.sling.installer.api.tasks.InstallTaskFactory;
 import org.apache.sling.installer.api.tasks.InstallationContext;
@@ -176,7 +177,16 @@ public class OsgiInstallerImpl
     public void run() {
         this.init();
         while (active) {
-            listener.started();
+            listener.onEvent(new InstallationEvent() {
+
+                public TYPE getType() {
+                    return TYPE.STARTED;
+                }
+
+                public Object getSource() {
+                    return null;
+                }
+            });
             logger.debug("Starting new cycle");
 
             this.mergeNewlyRegisteredResources();
@@ -201,7 +211,16 @@ public class OsgiInstallerImpl
                         // No tasks to execute - wait until new resources are
                         // registered
                         logger.debug("No tasks to process, going idle");
-                        listener.suspended();
+                        listener.onEvent(new InstallationEvent() {
+
+                            public TYPE getType() {
+                                return TYPE.SUSPENDED;
+                            }
+
+                            public Object getSource() {
+                                return null;
+                            }
+                        });
                         try {
                             this.resourcesLock.wait();
                         } catch (InterruptedException ignore) {}

Modified: sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/PersistentResourceList.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/PersistentResourceList.java?rev=1164498&r1=1164497&r2=1164498&view=diff
==============================================================================
--- sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/PersistentResourceList.java
(original)
+++ sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/PersistentResourceList.java
Fri Sep  2 12:05:48 2011
@@ -34,7 +34,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.sling.installer.api.InstallableResource;
-import org.apache.sling.installer.api.tasks.InstallationListener;
+import org.apache.sling.installer.api.event.InstallationListener;
 import org.apache.sling.installer.api.tasks.RegisteredResource;
 import org.apache.sling.installer.api.tasks.TaskResource;
 import org.apache.sling.installer.api.tasks.TransformationResult;

Modified: sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/MockBundleResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/MockBundleResource.java?rev=1164498&r1=1164497&r2=1164498&view=diff
==============================================================================
--- sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/MockBundleResource.java
(original)
+++ sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/MockBundleResource.java
Fri Sep  2 12:05:48 2011
@@ -35,7 +35,6 @@ import org.osgi.framework.Constants;
  */
 public class MockBundleResource implements TaskResource, Comparable<MockBundleResource>
{
 
-    private static final long serialVersionUID = 1L;
     private final Map<String, Object> attributes = new HashMap<String, Object>();
     private final Map<String, Object> tempAttributes = new HashMap<String, Object>();
 	private ResourceState state = ResourceState.INSTALL;

Modified: sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/tasks/MockInstallationListener.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/tasks/MockInstallationListener.java?rev=1164498&r1=1164497&r2=1164498&view=diff
==============================================================================
--- sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/tasks/MockInstallationListener.java
(original)
+++ sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/tasks/MockInstallationListener.java
Fri Sep  2 12:05:48 2011
@@ -18,18 +18,12 @@
  */
 package org.apache.sling.installer.core.impl.tasks;
 
-import org.apache.sling.installer.api.tasks.InstallationListener;
-import org.apache.sling.installer.api.tasks.TaskResource;
+import org.apache.sling.installer.api.event.InstallationEvent;
+import org.apache.sling.installer.api.event.InstallationListener;
 
 public class MockInstallationListener implements InstallationListener {
 
-    public void processed(TaskResource resource) {
+    public void onEvent(final InstallationEvent event) {
+        // nothing to do
     }
-
-    public void started() {
-    }
-
-    public void suspended() {
-    }
-
 }



Mime
View raw message