KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > xfire > YanServiceDecorator


1 package jfun.yan.xfire;
2
3 import jfun.yan.Container;
4
5
6 import org.codehaus.xfire.service.Service;
7
8 /**
9  * This decorator implementation uses a Yan Container object
10  * to obtain the Factory object for a given service type.
11  * This Factory object together with a {@link ScopePolicy} object
12  * are then used to construct an Invoker instance
13  * and set the Invoker instance to the Service object.
14  * <p>
15  * @author Ben Yu
16  * Jan 31, 2006 12:25:17 PM
17  */

18 public class YanServiceDecorator implements ServiceDecorator {
19   private final Container yan;
20   private final ScopePolicy scope;
21   /**
22    * Create a YanServiceDecorator object.
23    * @param yan the Container object.
24    * @param scope the ScopePolicy object.
25    */

26   public YanServiceDecorator(Container yan, ScopePolicy scope) {
27     this.yan = yan;
28     this.scope = scope;
29   }
30
31   public Service decorate(Service service) {
32     final Class JavaDoc type = service.getServiceInfo().getServiceClass();
33     service.setInvoker(
34       new FactoryInvoker(yan.getFactoryOfType(type), scope)
35     );
36     return service;
37   }
38
39 }
40
Popular Tags