blob: db1a506f0ca7eea697ea47d2d44c8a507bdad0e7 [file] [log] [blame]
Richard S. Hall29a62852006-09-28 20:08:11 +00001/*
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. Rodriguezcafcf242006-03-25 17:25:49 +00009 *
Richard S. Hall29a62852006-09-28 20:08:11 +000010 * http://www.apache.org/licenses/LICENSE-2.0
Michael E. Rodriguezcafcf242006-03-25 17:25:49 +000011 *
Richard S. Hall29a62852006-09-28 20:08:11 +000012 * 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. Rodriguezcafcf242006-03-25 17:25:49 +000018 */
19package org.apache.felix.servicebinder.impl;
20
21import org.apache.felix.servicebinder.architecture.DependencyChangeEvent;
22import org.apache.felix.servicebinder.architecture.InstanceChangeEvent;
23import org.apache.felix.servicebinder.architecture.ServiceBinderListener;
24
25/**
26 *
Karl Paulsd312acc2007-06-18 20:38:33 +000027 * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
Michael E. Rodriguezcafcf242006-03-25 17:25:49 +000028 */
29public 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}