KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > ManualDependency


1 /*****************************************************************************
2  * Copyright (C) Codehaus.org. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  *****************************************************************************/

8 /*
9  * Created on Mar 20, 2005
10  *
11  * Author Ben Yu
12  * ZBS
13  */

14 package jfun.yan;
15
16 import jfun.yan.function.Signature;
17
18 /**
19  * ManualDependency disables auto-wiring by refusing
20  * to resolve any component part.
21  * When ManualDependency is used, all properties and
22  * parameters need to be explicitly specified using
23  * Component.withArgument(), Component.withArguments(),
24  * Component.withProperty() and Component.withProperties().
25  * <p>
26  * Codehaus.org.
27  *
28  * @author Ben Yu
29  *
30  */

31 public class ManualDependency implements Dependency {
32   private final ComponentMap cmap;
33   private final Object JavaDoc ckey;
34   
35   /**
36    * Create a new ManualDependency object.
37    * @param cmap the ComponentMap object.
38    * @param ckey the component key.
39    */

40   public ManualDependency(final ComponentMap cmap, final Object JavaDoc ckey) {
41     this.cmap = cmap;
42     this.ckey = ckey;
43   }
44   
45   public Object JavaDoc getArgument(final Signature src, int i, Class JavaDoc type){
46     throw new IrresolveableArgumentException(ckey, i, type);
47   }
48   public Object JavaDoc getProperty(Class JavaDoc component_type, Object JavaDoc local_key, Class JavaDoc type){
49     throw new IrresolveablePropertyException(ckey, local_key, type);
50   }
51   public Class JavaDoc verifyArgument(final Signature src, int i, Class JavaDoc type){
52     throw new IrresolveableArgumentException(ckey, i, type);
53   }
54   public Class JavaDoc verifyProperty(Class JavaDoc component_type, Object JavaDoc local_key, Class JavaDoc type){
55     throw new IrresolveablePropertyException(ckey, local_key, type);
56   }
57   
58   public ComponentMap getComponentMap() {
59     return cmap;
60   }
61   public Object JavaDoc getComponentKey() {
62     return ckey;
63   }
64   
65   public boolean equals(Object JavaDoc obj) {
66     if(obj instanceof ManualDependency){
67       final ManualDependency mpp2 = (ManualDependency)obj;
68       return ckey.equals(mpp2.ckey)/* && cmap.equals(mpp2.cmap)*/;
69     }
70     else return false;
71   }
72   public int hashCode() {
73     return ckey.hashCode();
74   }
75   public String JavaDoc toString() {
76     return ckey.toString();
77   }
78   public Dependency getParent(){
79     return null;
80   }
81   public Dependency getOriginal(){
82     return this;
83   }
84   public Dependency seal(){
85     return this;
86   }
87 }
88
Popular Tags