Richard S. Hall | 29a6285 | 2006-09-28 20:08:11 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
Michael E. Rodriguez | cafcf24 | 2006-03-25 17:25:49 +0000 | [diff] [blame] | 9 | * |
Richard S. Hall | 29a6285 | 2006-09-28 20:08:11 +0000 | [diff] [blame] | 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
Michael E. Rodriguez | cafcf24 | 2006-03-25 17:25:49 +0000 | [diff] [blame] | 11 | * |
Richard S. Hall | 29a6285 | 2006-09-28 20:08:11 +0000 | [diff] [blame] | 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
Michael E. Rodriguez | cafcf24 | 2006-03-25 17:25:49 +0000 | [diff] [blame] | 18 | */ |
| 19 | package org.apache.felix.servicebinder.impl; |
| 20 | |
| 21 | import org.apache.felix.servicebinder.architecture.DependencyChangeEvent; |
| 22 | import org.apache.felix.servicebinder.architecture.InstanceChangeEvent; |
| 23 | import org.apache.felix.servicebinder.architecture.ServiceBinderListener; |
| 24 | |
| 25 | /** |
| 26 | * |
Karl Pauls | d312acc | 2007-06-18 20:38:33 +0000 | [diff] [blame] | 27 | * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a> |
Michael E. Rodriguez | cafcf24 | 2006-03-25 17:25:49 +0000 | [diff] [blame] | 28 | */ |
| 29 | public class ArchitectureEventMulticaster implements ServiceBinderListener |
| 30 | { |
| 31 | /** |
| 32 | * |
| 33 | * @uml.property name="a" |
| 34 | * @uml.associationEnd multiplicity="(0 1)" |
| 35 | */ |
| 36 | protected ServiceBinderListener a; |
| 37 | |
| 38 | /** |
| 39 | * |
| 40 | * @uml.property name="b" |
| 41 | * @uml.associationEnd multiplicity="(0 1)" |
| 42 | */ |
| 43 | protected ServiceBinderListener b; |
| 44 | |
| 45 | protected ArchitectureEventMulticaster(ServiceBinderListener a, ServiceBinderListener b) |
| 46 | { |
| 47 | this.a = a; |
| 48 | this.b = b; |
| 49 | } |
| 50 | |
| 51 | public void dependencyChanged(DependencyChangeEvent e) |
| 52 | { |
| 53 | a.dependencyChanged(e); |
| 54 | b.dependencyChanged(e); |
| 55 | } |
| 56 | |
| 57 | public void instanceReferenceChanged(InstanceChangeEvent e) |
| 58 | { |
| 59 | a.instanceReferenceChanged(e); |
| 60 | b.instanceReferenceChanged(e); |
| 61 | } |
| 62 | |
| 63 | public static ServiceBinderListener add(ServiceBinderListener a, ServiceBinderListener b) |
| 64 | { |
| 65 | if (a == null) |
| 66 | return b; |
| 67 | else if (b == null) |
| 68 | return a; |
| 69 | else |
| 70 | return new ArchitectureEventMulticaster(a, b); |
| 71 | } |
| 72 | |
| 73 | public static ServiceBinderListener remove(ServiceBinderListener a, ServiceBinderListener b) |
| 74 | { |
| 75 | if ((a == null) || (a == b)) |
| 76 | return null; |
| 77 | else if (a instanceof ArchitectureEventMulticaster) |
| 78 | return add (remove (((ArchitectureEventMulticaster) a).a, b),remove (((ArchitectureEventMulticaster) a).b, b)); |
| 79 | else |
| 80 | return a; |
| 81 | } |
| 82 | } |