View Javadoc

1   /*
2    * Copyright 2006-2008 the original author or authors.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.springframework.osgi.service.importer;
18  
19  import org.osgi.framework.ServiceReference;
20  
21  /**
22   * {@link ServiceReference} extension used by Spring-DM service importers.
23   * 
24   * <p/> The interface aim is to decouple clients from the dynamics of the
25   * imported services. Without such a proxy, a target service change (when
26   * dealing with dynamic proxies), would force the corresponding service
27   * reference to changes as well causing returned references to become stale. To
28   * avoid this situation, the importer returns a proxy which is updated
29   * automatically so the client always calls the updated, correct service
30   * reference.
31   * 
32   * <p/> In most cases, users should not be aware of this interface. However, for
33   * cases where the service reference has to be reused for going service lookups
34   * and the OSGi platform demands the raw service reference class, this interface
35   * allows access to the target, unwrapped service reference instance (which does
36   * does not support service tracking and might become stale as explained above).
37   * 
38   * @author Costin Leau
39   * 
40   */
41  public interface ServiceReferenceProxy extends ServiceReference {
42  
43  	/**
44  	 * Returns the target, native service reference used, at the moment of the
45  	 * call, by the proxy.
46  	 * 
47  	 * @return target service reference
48  	 */
49  	ServiceReference getTargetServiceReference();
50  }