View Javadoc

1   /*
2    * Copyright 2006-2009 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.event;
18  
19  import org.springframework.osgi.service.importer.OsgiServiceDependency;
20  
21  /**
22   * Dedicated event for OSGi dependencies that are imported in a timed manner.
23   * The event indicates that a dependency is missing and a bean inside the
24   * application context will start waiting for it, for a specified amount of time
25   * (given as a maximum).
26   * 
27   * <p/> Note that the actual waiting starts shortly after the event is
28   * dispatched however, there are no guarantees on when this will happen as it
29   * depends on the number of listeners interested in this event (and the amount
30   * of work done once the event is received).
31   * 
32   * @author Costin Leau
33   * 
34   */
35  public class OsgiServiceDependencyWaitStartingEvent extends OsgiServiceDependencyEvent {
36  
37  	private final long timeToWait;
38  
39  
40  	/**
41  	 * Constructs a new <code>OsgiServiceDependencyWaitStartingEvent</code>
42  	 * instance.
43  	 * 
44  	 * @param source event source (usually the service importer)
45  	 * @param dependency dependency description
46  	 * @param timeToWait wait duration
47  	 */
48  	public OsgiServiceDependencyWaitStartingEvent(Object source, OsgiServiceDependency dependency, long timeToWait) {
49  		super(source, dependency);
50  		this.timeToWait = timeToWait;
51  	}
52  
53  	/**
54  	 * Returns the time (in milliseconds) the source will wait for the OSGi
55  	 * service to appear.
56  	 * 
57  	 * @return Returns the timeToWait
58  	 */
59  	public long getTimeToWait() {
60  		return timeToWait;
61  	}
62  }