You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by js...@apache.org on 2006/04/05 20:43:46 UTC

svn commit: r391704 - in /incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container: ContainerAware.java JBIContainer.java

Author: jstrachan
Date: Wed Apr  5 11:43:46 2006
New Revision: 391704

URL: http://svn.apache.org/viewcvs?rev=391704&view=rev
Log:
added a little hook to make it easy to wire listeners to the container for easier wiring

Added:
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/ContainerAware.java   (with props)
Modified:
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java

Added: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/ContainerAware.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/ContainerAware.java?rev=391704&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/ContainerAware.java (added)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/ContainerAware.java Wed Apr  5 11:43:46 2006
@@ -0,0 +1,27 @@
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * 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.apache.servicemix.jbi.container;
+
+/**
+ * An interface for components which are aware of the container to which they are attached.
+ * 
+ * @version $Revision$
+ */
+public interface ContainerAware {
+
+    public void setContainer(JBIContainer container);
+}

Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/ContainerAware.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/ContainerAware.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/ContainerAware.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java?rev=391704&r1=391703&r2=391704&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java Wed Apr  5 11:43:46 2006
@@ -1113,6 +1113,10 @@
 	}
     
     public void addListener(EventListener listener) {
+        if (listener instanceof ContainerAware) {
+            ContainerAware containerAware = (ContainerAware) listener;
+            containerAware.setContainer(this);
+        }
         if (listener instanceof ExchangeListener) {
             listeners.add(ExchangeListener.class, (ExchangeListener) listener);
         }
@@ -1150,6 +1154,13 @@
     
     public Object[] getListeners(Class lc) {
         return listeners.getListeners(lc);
+    }
+    
+    public void setListeners(EventListener[] listeners) {
+        for (int i = 0; i < listeners.length; i++) {
+            EventListener listener = listeners[i];
+            addListener(listener);
+        }
     }
     
     public void callListeners(MessageExchange exchange) {