1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.osgi.service.importer.support.internal.aop;
18
19 import org.osgi.framework.Bundle;
20 import org.osgi.framework.ServiceReference;
21 import org.springframework.osgi.service.importer.ServiceReferenceProxy;
22 import org.springframework.util.Assert;
23
24 /**
25 * Simple {@link ServiceReference} proxy which simply does delegation, without
26 * any extra features. It's main purpose is to allow the consistent behaviour
27 * between dynamic and static proxies.
28 *
29 * @author Costin Leau
30 *
31 */
32 public class StaticServiceReferenceProxy implements ServiceReferenceProxy {
33
34 private static final int HASH_CODE = StaticServiceReferenceProxy.class.hashCode() * 13;
35
36 private final ServiceReference target;
37
38
39 /**
40 * Constructs a new <code>StaticServiceReferenceProxy</code> instance.
41 *
42 * @param target service reference
43 */
44 public StaticServiceReferenceProxy(ServiceReference target) {
45 Assert.notNull(target);
46 this.target = target;
47 }
48
49 public Bundle getBundle() {
50 return target.getBundle();
51 }
52
53 public Object getProperty(String key) {
54 return target.getProperty(key);
55 }
56
57 public String[] getPropertyKeys() {
58 return target.getPropertyKeys();
59 }
60
61 public Bundle[] getUsingBundles() {
62 return target.getUsingBundles();
63 }
64
65 public boolean isAssignableTo(Bundle bundle, String className) {
66 return target.isAssignableTo(bundle, className);
67 }
68
69 public ServiceReference getTargetServiceReference() {
70 return target;
71 }
72
73 public boolean equals(Object obj) {
74 if (obj instanceof StaticServiceReferenceProxy) {
75 StaticServiceReferenceProxy other = (StaticServiceReferenceProxy) obj;
76 return (target.equals(other.target));
77 }
78 return false;
79 }
80
81 public int hashCode() {
82 return HASH_CODE + target.hashCode();
83 }
84 }