geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r777650 - in /geronimo/sandbox/blueprint: blueprint-api/src/main/java/org/osgi/service/blueprint/container/ blueprint-core/src/main/java/org/apache/geronimo/blueprint/ blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/
Date Fri, 22 May 2009 18:35:46 GMT
Author: gnodet
Date: Fri May 22 18:35:46 2009
New Revision: 777650

URL: http://svn.apache.org/viewvc?rev=777650&view=rev
Log:
Update to latest eventing api for blueprint

Added:
    geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintEvent.java
    geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintListener.java
  (contents, props changed)
      - copied, changed from r777624, geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintContainerListener.java
Removed:
    geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintContainerListener.java
Modified:
    geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/EventConstants.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/BlueprintContextEventSender.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/DefaultBlueprintContextEventSender.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/UnaryServiceReferenceRecipe.java

Added: geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintEvent.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintEvent.java?rev=777650&view=auto
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintEvent.java
(added)
+++ geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintEvent.java
Fri May 22 18:35:46 2009
@@ -0,0 +1,220 @@
+/*
+ * Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
+ *
+ * Licensed 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.osgi.service.blueprint.container;
+
+import org.osgi.framework.Bundle;
+
+/**
+ * A Blueprint Event.
+ *
+ * <p>
+ * <code>BlueprintEvent</code> objects are delivered to all registered <code>BlueprintListener</code>
+ * service objects. BlueprintEvents must be asynchronously delivered in chronological order
+ * with respect to each listener.  In addition, when a listener is registered, the blueprint
extender
+ * will send to this listener the last event for each blueprint bundle managed by this extender.
+ *
+ * <p>
+ * A type code is used to identify the type of event. The following event types are defined:
+ * <ul>
+ * <li>{@link #CREATING}
+ * <li>{@link #CREATED}
+ * <li>{@link #DESTROYING}
+ * <li>{@link #DESTROYED}
+ * <li>{@link #FAILURE}
+ * <li>{@link #GRACE_PERIOD}
+ * <li>{@link #WAITING}
+ * </ul>
+ *
+ * <p>
+ * <h2>Blueprint Events and EventAdmin</h2>
+ * In addition to calling the registered {@link BlueprintListener}s, the blueprint extender
+ * must also send those events to the EventAdmin service, if it is available. <br/>
+ * See {@link EventConstants} for more informations.
+ *
+ * @see BlueprintListener
+ * @see EventConstants
+ */
+public class BlueprintEvent {
+
+	/**
+	 * The Blueprint extender has started creating a Blueprint Container for the bundle.
+	 */
+	public static final int CREATING = 1;
+	/**
+	 * The Blueprint extender has creating a Blueprint Container for the bundle.
+	 * This event is sent after the BlueprintContainer service has been registered.
+	 */
+	public static final int CREATED = 2;
+	/**
+	 * The Blueprint extender has started detroying the Blueprint Container for the bundle.
+	 */
+	public static final int DESTROYING = 3;
+	/**
+	 * The Blueprint Container for the bundle has been completely destroyed.
+	 * This event is sent after the BlueprintContainer service has been unregistered.
+	 */
+	public static final int DESTROYED = 4;
+	/**
+	 * The Blueprint Container creation for the bundle has failed.
+	 * If this event is sent after a timeout in the Grace Period, the {@link #getDependencies()}
+	 * method must return an array of missing mandatory dependencies.  The event must also contain
+	 * the cause of the failure as a <code>Throwable</code> through the {@link #getException()}
method.
+	 */
+	public static final int FAILURE = 5;
+	/**
+	 * The Blueprint Container has entered the Grace Period.
+	 * The list of missing dependencies must be made available through the {@link #getDependencies()}
+ 	 * method.
+	 */
+	public static final int GRACE_PERIOD = 6;
+	/**
+	 * The Blueprint Extender is waiting on the availability of a service to satisfy an
+	 * invocation on a referenced service.
+	 * The missing dependency must be made available through the {@link #getDependencies()}
+	 * method which will return an array containing one filter object as a String.
+	 */
+	public static final int WAITING = 7;
+
+
+	/**
+	 * Type of this event.
+	 *
+	 * @see #getType()
+	 */
+	private final int type;
+	/**
+	 * The time when the event occured.
+	 *
+	 * @see #getTimestamp()
+	 */
+	private final long timestamp;
+	/**
+	 * The blueprint bundle.
+	 *
+	 * @see #getBundle()
+	 */
+	private final Bundle bundle;
+	/**
+ 	 * The blueprint extender bundle.
+ 	 *
+ 	 * @see #getExtenderBundle()
+ 	 */
+	private final Bundle extenderBundle;
+	/**
+	 * An array containing filters identifying the missing dependencies.
+	 *
+	 * @see #getDependencies()
+	 */
+	private final String[] dependencies;
+	/**
+	 * Cause of the failure.
+	 *
+	 * @see #getException()
+	 */
+	private final Throwable exception;
+
+
+	public BlueprintEvent(int type, Bundle bundle, Bundle extenderBundle) {
+		this(type, bundle, extenderBundle, null, null);
+	}
+
+	public BlueprintEvent(int type, Bundle bundle, Bundle extenderBundle, String[] dependencies)
{
+		this(type, bundle, extenderBundle, dependencies, null);
+	}
+
+	public BlueprintEvent(int type, Bundle bundle, Bundle extenderBundle, Throwable exception)
{
+		this(type, bundle, extenderBundle, null, exception);
+	}
+
+	public BlueprintEvent(int type, Bundle bundle, Bundle extenderBundle, String[] dependencies,
Throwable exception) {
+		this.type = type;
+		this.timestamp = System.currentTimeMillis();
+		this.bundle = bundle;
+		this.extenderBundle = extenderBundle;
+		this.dependencies = dependencies;
+		this.exception = exception;
+	}
+
+	/**
+	 * Return the type of this event.
+	 * <p>
+	 * The type values are:
+	 * <ul>
+	 * <li>{@link #CREATING}
+	 * <li>{@link #CREATED}
+	 * <li>{@link #DESTROYING}
+	 * <li>{@link #DESTROYED}
+	 * <li>{@link #FAILURE}
+	 * <li>{@link #GRACE_PERIOD}
+	 * <li>{@link #WAITING}
+	 * </ul>
+	 *
+	 * @return The type of this event.
+	 */
+	public int getType() {
+		return type;
+	}
+
+	/**
+	 * Return the time at which this event occured.
+	 *
+	 * @return The time at which this event occured.
+	 */
+	public long getTimestamp() {
+		return timestamp;
+	}
+
+	/**
+	 * Return the blueprint bundle.
+	 *
+	 * @return The blueprint bundle.  Never <code>null</code>.
+	 */
+	public Bundle getBundle() {
+		return bundle;
+	}
+
+	/**
+	 * Return the Bundle of the blueprint extender.
+	 *
+	 * @return The Bundle of the blueprint extender.  Never <code>null</code>.
+	 */
+	public Bundle getExtenderBundle() {
+		return extenderBundle;
+	}
+
+	/**
+	 * Return the filters identifying the missing dependencies that caused this event.
+	 * <p>
+	 * This field is only valid for {@link #WAITING},
+	 * {@link #GRACE_PERIOD} and {@link #FAILURE}
+	 * events.
+	 *
+	 * @return The missing dependencies informations.  May be <code>null</code>.
+	 */
+	public String[] getDependencies() {
+		return dependencies;
+	}
+
+	/**
+	 * Return the cause for a {@link #FAILURE} event.
+	 *
+	 * @return The cause of the failure.  May be <code>null</code>.
+	 */
+	public Throwable getException() {
+		return exception;
+	}
+
+}

Copied: geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintListener.java
(from r777624, geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintContainerListener.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintListener.java?p2=geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintListener.java&p1=geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintContainerListener.java&r1=777624&r2=777650&rev=777650&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintContainerListener.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintListener.java
Fri May 22 18:35:46 2009
@@ -1,27 +1,32 @@
-/**
- *  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
+/*
+ * Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
+ *
+ * Licensed 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
+ *      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.
+ * 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.osgi.service.blueprint.container;
 
-import org.osgi.framework.Bundle;
+/**
+ * Listener for <code>BlueprintEvent</code>s.
+ *
+ * @see BlueprintEvent
+ */
+public interface BlueprintListener {
+
+	/**
+ 	 * Receives notifications of a blueprint event.
+ 	 *
+ 	 * @param event The <code>BlueprintEvent</code>.
+ 	 */
+	void blueprintEvent(BlueprintEvent event);
 
-public interface BlueprintContainerListener {
-    
-    void contextCreated(Bundle forBundle);
-    
-    void contextCreationFailed(Bundle forBundle, Throwable rootCause);    
-      
 }

Propchange: geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintListener.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintListener.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/EventConstants.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/EventConstants.java?rev=777650&r1=777649&r2=777650&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/EventConstants.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/EventConstants.java
Fri May 22 18:35:46 2009
@@ -1,41 +1,164 @@
-/**
- *  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
+/*
+ * Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
+ *
+ * Licensed 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
+ *      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.
+ * 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.osgi.service.blueprint.container;
 
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Version;
+
+/**
+ * Event property names used in EventAdmin events published for a
+ * blueprint container.
+ *
+ * Each type of event is sent to a different topic:<br/>
+ * &nbsp;&nbsp;<code>org/osgi/service/blueprint/container/&lt;event-type&gt;</code><br/>
+ * where <code>&lt;event-type&gt;</code> can have the values <code>CREATING</code>,
<code>CREATED</code>,
+ * <code>DESTROYING</code>, <code>DESTROYED</code>, <code>FAILURE</code>,
<code>GRACE_PERIOD</code> or
+ * <code>WAITING</code>. <br/>
+ * Such events have the following properties:<ul>
+ *   <li><code>type<code>
+ *   <li><code>event<code>
+ *   <li><code>timestamp<code>
+ *   <li><code>bundle<code>
+ *   <li><code>bundle.symbolicName<code>
+ *   <li><code>bundle.id<code>
+ *   <li><code>bundle.version<code>
+ *   <li><code>extender.bundle<code>
+ *   <li><code>extender.bundle.symbolicName<code>
+ *   <li><code>extender.bundle.id<code>
+ *   <li><code>extender.bundle.version<code>
+ *   <li><code>dependencies<code>
+ *   <li><code>cause<code>
+ * </ul>
+ */
 public interface EventConstants {
-    
-    static final String EXTENDER_BUNDLE = "extender.bundle";
-    
-    static final String EXTENDER_ID = "extender.bundle.id";
-    
-    static final String EXTENDER_SYMBOLICNAME = "extender.bundle.symbolicName";
-    
-    static final String TOPIC_BLUEPRINT_EVENTS = "org/osgi/service/blueprint";
-    
-    static final String TOPIC_CREATED = TOPIC_BLUEPRINT_EVENTS + "/container/CREATED";
-    
-    static final String TOPIC_CREATING = TOPIC_BLUEPRINT_EVENTS + "/container/CREATING";
-    
-    static final String TOPIC_DESTROYED = TOPIC_BLUEPRINT_EVENTS + "/container/DESTROYED";
-    
-    static final String TOPIC_DESTROYING = TOPIC_BLUEPRINT_EVENTS + "/container/DESTROYING";
-    
-    static final String TOPIC_FAILURE = TOPIC_BLUEPRINT_EVENTS + "/container/FAILURE";
-    
-    static final String TOPIC_WAITING = TOPIC_BLUEPRINT_EVENTS + "/container/WAITING";
-      
+
+	/**
+	 * The type of the event that has been issued.
+	 * This property is of type {@link java.lang.Integer} and can take one of the values defined
in {@link BlueprintEvent}.
+	 */
+	public static final String TYPE = "type";
+
+	/**
+ 	 * The <code>BlueprintEvent</code> that caused this event.
+ 	 * This property is of type {@link BlueprintEvent}.
+ 	 */
+	public static final String EVENT = "event";
+
+	/**
+ 	 * The type of the event that has been issued.
+	 * This property is of type {@link java.lang.Long}.
+ 	 */
+	public static final String TIMESTAMP = "timestamp";
+
+	/**
+ 	 * The bundle property defining the blueprint bundle for which an event has been issued.
+	 * This property is of type {@link org.osgi.framework.Bundle}.
+ 	 *
+ 	 * @see Bundle
+ 	 */
+	public static final String BUNDLE = "bundle";
+
+	/**
+ 	 * The bundle id property defining the id of the blueprint bundle for which an event has
been issued.
+	 * This property is of type {@link java.lang.Integer}.
+ 	 */
+	public static final String BUNDLE_ID = "bundle.id";
+
+	/**
+ 	 * The bundle symbolic name property defining the symbolic name of
+ 	 * the blueprint bundle for which an event has been issued.
+	 * This property is of type {@link java.lang.String}.
+ 	 */
+	public static final String BUNDLE_SYMBOLICNAME = "bundle.symbolicName";
+
+	/**
+	 * The extender bundle property defining the extender bundle processing the
+	 * blueprint container for which an event has been issued.
+	 * This property is of type {@link org.osgi.framework.Bundle}.
+	 *
+	 * @see Bundle
+	 */
+	public static final String EXTENDER_BUNDLE = "extender.bundle";
+
+	/**
+	 * The extender bundle id property defining the id of the extender bundle
+	 * processing the blueprint container for which an event has been issued.
+	 * This property is of type {@link java.lang.Integer}.
+	 */
+	public static final String EXTENDER_BUNDLE_ID = "extender.bundle.id";
+
+	/**
+	 * The extender bundle symbolic name property defining the symbolic name of
+	 * the extender bundle processing the blueprint container for which an event
+	 * has been issued.
+	 * This property is of type {@link java.lang.String}.
+	 */
+	public static final String EXTENDER_BUNDLE_SYMBOLICNAME = "extender.bundle.symbolicName";
+
+	/**
+ 	 * The dependencies property containing an array of filters describing the missing
+ 	 * mandatory dependencies for a FAILED, GRACE_PERIOD or WAITING event.
+	 * This property is an array of {@link java.lang.String}.
+ 	 */
+	public static final String DEPENDENCIES = "dependencies";
+
+	/**
+ 	 * The exception property containing the cause for a FAILED event.
+	 * This property is of type {@link java.lang.Throwable}.
+ 	 */
+	public static final String EXCEPTION = "exception";
+
+	/**
+	 * Topic prefix for all events issued by the Blueprint Service
+	 */
+	public static final String TOPIC_BLUEPRINT_EVENTS = "org/osgi/service/blueprint";
+
+	/**
+	 * Topic for Blueprint Container CREATING events
+	 */
+	public static final String TOPIC_CREATING = TOPIC_BLUEPRINT_EVENTS + "/container/CREATING";
+
+	/**
+ 	 * Topic for Blueprint Container CREATED events
+ 	 */
+	public static final String TOPIC_CREATED = TOPIC_BLUEPRINT_EVENTS + "/container/CREATED";
+
+	/**
+ 	 * Topic for Blueprint Container DESTROYING events
+ 	 */
+	public static final String TOPIC_DESTROYING = TOPIC_BLUEPRINT_EVENTS + "/container/DESTROYING";
+
+	/**
+	 * Topic for Blueprint Container DESTROYED events
+	 */
+	public static final String TOPIC_DESTROYED = TOPIC_BLUEPRINT_EVENTS + "/container/DESTROYED";
+
+	/**
+ 	 * Topic for Blueprint Container FAILURE events
+ 	 */
+	public static final String TOPIC_FAILURE = TOPIC_BLUEPRINT_EVENTS + "/container/FAILURE";
+
+	/**
+ 	 * Topic for Blueprint Container GRACE_PERIOD events
+ 	 */
+	public static final String TOPIC_GRACE_PERIOD = TOPIC_BLUEPRINT_EVENTS + "/container/GRACE_PERIOD";
+
+	/**
+	 * Topic for Blueprint Container WAITING events
+	 */
+	public static final String TOPIC_WAITING = TOPIC_BLUEPRINT_EVENTS + "/container/WAITING";
+
 }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/BlueprintContextEventSender.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/BlueprintContextEventSender.java?rev=777650&r1=777649&r2=777650&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/BlueprintContextEventSender.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/BlueprintContextEventSender.java
Fri May 22 18:35:46 2009
@@ -32,8 +32,9 @@
     void sendCreated(Bundle bundle);
     void sendDestroying(Bundle bundle);
     void sendDestroyed(Bundle bundle);
-    void sendWaiting(Bundle bundle, String[] serviceObjectClass, String serviceFilter);
+    void sendGracePeriod(Bundle bundle, String[] dependencies);
     void sendFailure(Bundle bundle, Throwable cause);
-    void sendFailure(Bundle bundle, Throwable cause, String[] serviceObjectClass, String
serviceFilter);
+    void sendFailure(Bundle bundle, Throwable cause, String[] dependencies);
+    void sendWaiting(Bundle bundle, String dependency);
 
 }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java?rev=777650&r1=777649&r2=777650&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java
Fri May 22 18:35:46 2009
@@ -221,7 +221,7 @@
                         for (URI ns : namespaces) {
                             if (handlers.getNamespaceHandler(ns) == null) {
                                 if (!waitForNamespaceHandlersEventSent) {
-                                    sender.sendWaiting(getBundleContext().getBundle(), new
String[] {NamespaceHandler.class.getName() }, null);
+                                    sender.sendWaiting(getBundleContext().getBundle(), "("
+ Constants.OBJECTCLASS + "=" + NamespaceHandler.class.getName() + ")");
                                     waitForNamespaceHandlersEventSent = true;
                                 }
                                 return;
@@ -249,9 +249,8 @@
                         if (checkAllSatisfiables() || !waitForDependencies) {
                             state = State.InitialReferencesSatisfied;
                         } else {
-                            // TODO: pass correct parameters
-                            // TODO: do we need to send one event for each missing reference
?
-                            sender.sendWaiting(getBundleContext().getBundle(), null, null);
+                            // TODO: pass correct parameters for missing dependencies
+                            sender.sendGracePeriod(getBundleContext().getBundle(), null);
                             state = State.WaitForInitialReferences;
                         }
                         break;
@@ -285,8 +284,7 @@
                             state = State.InitialReferencesSatisfied2;
                         } else {
                             // TODO: pass correct parameters
-                            // TODO: do we need to send one event for each missing reference
?
-                            sender.sendWaiting(getBundleContext().getBundle(), null, null);
+                            sender.sendGracePeriod(getBundleContext().getBundle(), null);
                             state = State.WaitForInitialReferences2;
                         }
                         break;

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/DefaultBlueprintContextEventSender.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/DefaultBlueprintContextEventSender.java?rev=777650&r1=777649&r2=777650&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/DefaultBlueprintContextEventSender.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/DefaultBlueprintContextEventSender.java
Fri May 22 18:35:46 2009
@@ -32,8 +32,9 @@
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.framework.Version;
 import org.osgi.framework.ServiceReference;
-import org.osgi.service.blueprint.container.BlueprintContainerListener;
+import org.osgi.service.blueprint.container.BlueprintListener;
 import org.osgi.service.blueprint.container.EventConstants;
+import org.osgi.service.blueprint.container.BlueprintEvent;
 import org.osgi.service.event.Event;
 import org.osgi.service.event.EventAdmin;
 import org.osgi.util.tracker.ServiceTracker;
@@ -55,16 +56,16 @@
     private final Bundle extenderBundle;
     private final ServiceTracker eventAdminServiceTracker;
     private final ServiceTracker contextListenerTracker;
-    private final Map<Bundle, Object> states;
+    private final Map<Bundle, BlueprintEvent> states;
 
     public DefaultBlueprintContextEventSender(final BundleContext bundleContext) {
         this.extenderBundle = bundleContext.getBundle();
-        this.states = new ConcurrentHashMap<Bundle, Object>();
+        this.states = new ConcurrentHashMap<Bundle, BlueprintEvent>();
         this.eventAdminServiceTracker = new ServiceTracker(bundleContext, EventAdmin.class.getName(),
null);
         this.eventAdminServiceTracker.open();
-        this.contextListenerTracker = new ServiceTracker(bundleContext, BlueprintContainerListener.class.getName(),
new ServiceTrackerCustomizer() {
+        this.contextListenerTracker = new ServiceTracker(bundleContext, BlueprintListener.class.getName(),
new ServiceTrackerCustomizer() {
             public Object addingService(ServiceReference reference) {
-                BlueprintContainerListener listener = (BlueprintContainerListener) bundleContext.getService(reference);
+                BlueprintListener listener = (BlueprintListener) bundleContext.getService(reference);
                 sendInitialEvents(listener);
                 return listener;
             }
@@ -78,10 +79,10 @@
         this.registration = bundleContext.registerService(BlueprintStateManager.class.getName(),
this, null);
     }
 
-    protected void sendInitialEvents(BlueprintContainerListener listener) {
+    protected void sendInitialEvents(BlueprintListener listener) {
         if (states != null) {
-            for (Map.Entry<Bundle, Object> entry : states.entrySet()) {
-                callListener(listener, entry.getKey(), entry.getValue());
+            for (Map.Entry<Bundle, BlueprintEvent> entry : states.entrySet()) {
+                listener.blueprintEvent(entry.getValue());
             }
         }
     }
@@ -107,106 +108,118 @@
     }
 
     public void sendCreating(Bundle bundle) {
-        states.put(bundle,  CREATING);
-        sendEvent(bundle, TOPIC_CREATING, null, null, null);
+        BlueprintEvent event = new BlueprintEvent(BlueprintEvent.CREATING, bundle, extenderBundle);
+        sendEvent(event);
     }
 
     public void sendCreated(Bundle bundle) {
-        states.put(bundle,  CREATED);
-        sendEvent(bundle, TOPIC_CREATED, null, null, null);
+        BlueprintEvent event = new BlueprintEvent(BlueprintEvent.CREATED, bundle, extenderBundle);
+        sendEvent(event);
     }
 
     public void sendDestroying(Bundle bundle) {
-        states.put(bundle,  DESTROYING);
-        sendEvent(bundle, TOPIC_DESTROYING, null, null, null);
+        BlueprintEvent event = new BlueprintEvent(BlueprintEvent.DESTROYING, bundle, extenderBundle);
+        sendEvent(event);
     }
 
     public void sendDestroyed(Bundle bundle) {
-        states.put(bundle,  DESTROYED);
-        sendEvent(bundle, TOPIC_DESTROYED, null, null, null);
+        BlueprintEvent event = new BlueprintEvent(BlueprintEvent.DESTROYED, bundle, extenderBundle);
+        sendEvent(event);
     }
 
-    public void sendWaiting(Bundle bundle, String[] serviceObjectClass, String serviceFilter)
{
-        states.put(bundle,  WAITING);
-        sendEvent(bundle, TOPIC_WAITING, null, serviceObjectClass, serviceFilter);
+    public void sendGracePeriod(Bundle bundle, String[] dependencies) {
+        BlueprintEvent event = new BlueprintEvent(BlueprintEvent.GRACE_PERIOD, bundle, extenderBundle,
dependencies);
+        sendEvent(event);
+    }
+
+    public void sendWaiting(Bundle bundle, String dependency) {
+        BlueprintEvent event = new BlueprintEvent(BlueprintEvent.WAITING, bundle, extenderBundle,
new String[] { dependency });
+        sendEvent(event);
     }
 
     public void sendFailure(Bundle bundle, Throwable cause) {
-        states.put(bundle,  cause != null ? cause : FAILED);
-        sendEvent(bundle, TOPIC_FAILURE, cause, null, null);
+        BlueprintEvent event = new BlueprintEvent(BlueprintEvent.FAILURE, bundle, extenderBundle,
cause);
+        sendEvent(event);
     }
 
-    public void sendFailure(Bundle bundle, Throwable cause, String[] serviceObjectClass,
String serviceFilter) {
-        states.put(bundle,  cause != null ? cause : FAILED);
-        sendEvent(bundle, TOPIC_FAILURE, cause, serviceObjectClass, serviceFilter);
+    public void sendFailure(Bundle bundle, Throwable cause, String[] dependencies) {
+        BlueprintEvent event = new BlueprintEvent(BlueprintEvent.FAILURE, bundle, extenderBundle,
dependencies, cause);
+        sendEvent(event);
     }
 
-    public void sendEvent(Bundle bundle, String topic, Throwable cause, String[] serviceObjectClass,
String serviceFilter) {
+    public void sendEvent(BlueprintEvent event) {
+        // TODO: events should be sent asynchronously
+        LOGGER.debug("Sending blueprint container event {} for bundle {}", event, event.getBundle().getSymbolicName());
 
-        LOGGER.debug("Sending blueprint container event {} for bundle {}", topic, bundle.getSymbolicName());
+        states.put(event.getBundle(), event);
+
+        callListeners(event);
+        sendEventAdmin(event);
+    }
 
-        callListeners(bundle, topic, cause);
+    private void callListeners(BlueprintEvent event) {
+        Object[] listeners = contextListenerTracker.getServices();
+        if (listeners != null) {
+            for (Object listener : listeners) {
+                ((BlueprintListener) listener).blueprintEvent(event);
+            }
+        }
+    }
 
+    private void sendEventAdmin(BlueprintEvent event) {
         EventAdmin eventAdmin = getEventAdmin();
         if (eventAdmin == null) {
             return;
         }
 
         Dictionary<String,Object> props = new Hashtable<String,Object>();
-        props.put(org.osgi.service.event.EventConstants.BUNDLE_SYMBOLICNAME, bundle.getSymbolicName());
-        props.put(org.osgi.service.event.EventConstants.BUNDLE_ID, bundle.getBundleId());
-        props.put(org.osgi.service.event.EventConstants.BUNDLE, bundle);
-        Version version = getBundleVersion(bundle);
+        props.put(EventConstants.TYPE, event.getType());
+        props.put(EventConstants.EVENT, event);
+        props.put(EventConstants.TIMESTAMP, event.getTimestamp());
+        props.put(EventConstants.BUNDLE, event.getBundle());
+        props.put(EventConstants.BUNDLE_SYMBOLICNAME, event.getBundle().getSymbolicName());
+        props.put(EventConstants.BUNDLE_ID, event.getBundle().getBundleId());
+        Version version = getBundleVersion(event.getBundle());
         if (version != null) {
             props.put(BlueprintConstants.BUNDLE_VERSION, version);
         }
-        props.put(org.osgi.service.event.EventConstants.TIMESTAMP, System.currentTimeMillis());
         props.put(EventConstants.EXTENDER_BUNDLE, extenderBundle);
-        props.put(EventConstants.EXTENDER_ID, extenderBundle.getBundleId());
-        props.put(EventConstants.EXTENDER_SYMBOLICNAME, extenderBundle.getSymbolicName());
-        
-        if (cause != null) {
-            props.put(org.osgi.service.event.EventConstants.EXCEPTION, cause);
-        }
-        if (serviceObjectClass != null) {
-            props.put(org.osgi.service.event.EventConstants.SERVICE_OBJECTCLASS, serviceObjectClass);
-        }
-        if (serviceFilter != null) {
-            props.put(BlueprintConstants.SERVICE_FILTER, serviceFilter);
-        }
-
-        Event event = new Event(topic, props);
-        eventAdmin.postEvent(event);
-    }
-
-    private void callListeners(Bundle bundle, String topic, Throwable cause) {
-        boolean created = TOPIC_CREATED.equals(topic);
-        boolean failure = TOPIC_FAILURE.equals(topic);
-        if (created || failure) {
-            Object[] listeners = contextListenerTracker.getServices();
-            if (listeners != null) {
-                for (Object listener : listeners) {
-                    callListener((BlueprintContainerListener) listener, bundle, created ?
CREATED : cause != null ? cause : FAILED);
-                }
-            }
-        }
-    }
+        props.put(EventConstants.EXTENDER_BUNDLE_ID, extenderBundle.getBundleId());
+        props.put(EventConstants.EXTENDER_BUNDLE_SYMBOLICNAME, extenderBundle.getSymbolicName());
 
-    private void callListener(BlueprintContainerListener listener, Bundle bundle, Object
state) {
-        // TODO: listener is missing a few methods to replay the state (at least WAITING
events)
-        try {
-            if (state instanceof Integer) {
-                if ((Integer) state == CREATED) {
-                    listener.contextCreated(bundle);
-                } else if ((Integer) state == FAILED) {
-                    listener.contextCreationFailed(bundle, null);
-                }
-            } else if (state instanceof Throwable) {
-                listener.contextCreationFailed(bundle, (Throwable) state);
-            }
-        } catch (Throwable t) {
-            LOGGER.info("Error calling blueprint container listener", t);
+        if (event.getException() != null) {
+            props.put(EventConstants.EXCEPTION, event.getException());
+        }
+        if (event.getDependencies() != null) {
+            props.put(EventConstants.DEPENDENCIES, event.getDependencies());
+        }
+        String topic;
+        switch (event.getType()) {
+            case BlueprintEvent.CREATING:
+                topic = EventConstants.TOPIC_CREATING;
+                break;
+            case BlueprintEvent.CREATED:
+                topic = EventConstants.TOPIC_CREATED;
+                break;
+            case BlueprintEvent.DESTROYING:
+                topic = EventConstants.TOPIC_DESTROYING;
+                break;
+            case BlueprintEvent.DESTROYED:
+                topic = EventConstants.TOPIC_DESTROYED;
+                break;
+            case BlueprintEvent.FAILURE:
+                topic = EventConstants.TOPIC_FAILURE;
+                break;
+            case BlueprintEvent.GRACE_PERIOD:
+                topic = EventConstants.TOPIC_GRACE_PERIOD;
+                break;
+            case BlueprintEvent.WAITING:
+                topic = EventConstants.TOPIC_WAITING;
+                break;
+            default:
+                throw new IllegalStateException("Unknown blueprint event type: " + event.getType());
         }
+        eventAdmin.postEvent(new Event(topic, props));
     }
 
     private static Version getBundleVersion(Bundle bundle) {

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/UnaryServiceReferenceRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/UnaryServiceReferenceRecipe.java?rev=777650&r1=777649&r2=777650&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/UnaryServiceReferenceRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/UnaryServiceReferenceRecipe.java
Fri May 22 18:35:46 2009
@@ -150,7 +150,8 @@
         synchronized (monitor) {
             if (tracker.isStarted() && trackedServiceReference == null &&
metadata.getTimeout() > 0) {
                 Set<String> interfaces = new HashSet<String>(metadata.getInterfaceNames());
-                sender.sendWaiting(blueprintContainer.getBundleContext().getBundle(), interfaces.toArray(new
String[interfaces.size()]), getOsgiFilter());
+                // TODO: create unified filter from interfaces and filter
+                sender.sendWaiting(blueprintContainer.getBundleContext().getBundle(), null);
                 monitor.wait(metadata.getTimeout());
             }
             if (trackedServiceReference == null) {



Mime
View raw message