KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > hivemind > service > impl > BuilderParameter


1 // Copyright 2004, 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.hivemind.service.impl;
16
17 import java.util.ArrayList JavaDoc;
18 import java.util.HashMap JavaDoc;
19 import java.util.Iterator JavaDoc;
20 import java.util.List JavaDoc;
21 import java.util.Map JavaDoc;
22
23 import org.apache.hivemind.ServiceImplementationFactoryParameters;
24 import org.apache.hivemind.impl.BaseLocatable;
25
26 /**
27  * Parameter object used with {@link org.apache.hivemind.service.impl.BuilderFactory}.
28  *
29  * @author Howard Lewis Ship
30  */

31 public class BuilderParameter extends BaseLocatable
32 {
33     private String JavaDoc _className;
34
35     private List JavaDoc _properties = new ArrayList JavaDoc();
36
37     private List JavaDoc _parameters = new ArrayList JavaDoc();
38
39     /** @since 1.1 */
40     private Map JavaDoc _typeFacetMap = new HashMap JavaDoc();
41
42     private List JavaDoc _events = new ArrayList JavaDoc();
43
44     private String JavaDoc _initializeMethod;
45
46     private boolean _autowireServices;
47
48     public String JavaDoc getClassName()
49     {
50         return _className;
51     }
52
53     public void addParameter(BuilderFacet facet)
54     {
55         _parameters.add(facet);
56     }
57
58     public List JavaDoc getParameters()
59     {
60         return _parameters;
61     }
62
63     public void addProperty(BuilderFacet facet)
64     {
65         _properties.add(facet);
66     }
67
68     public List JavaDoc getProperties()
69     {
70         return _properties;
71     }
72
73     /** @since 1.1 */
74     public BuilderFacet getFacetForType(ServiceImplementationFactoryParameters factoryParameters,
75             Class JavaDoc targetType)
76     {
77         BuilderFacet result = (BuilderFacet) _typeFacetMap.get(targetType);
78
79         if (result == null)
80         {
81             for (Iterator JavaDoc i = _properties.iterator(); i.hasNext();)
82             {
83                 BuilderFacet facet = (BuilderFacet) i.next();
84
85                 if (facet.canAutowireConstructorParameter()
86                         && facet.isAssignableToType(factoryParameters, targetType))
87                 {
88                     result = facet;
89                     break;
90                 }
91             }
92
93             _typeFacetMap.put(targetType, result);
94         }
95
96         return result;
97     }
98
99     public void setClassName(String JavaDoc string)
100     {
101         _className = string;
102     }
103
104     public void addEventRegistration(EventRegistration registration)
105     {
106         _events.add(registration);
107     }
108
109     public List JavaDoc getEventRegistrations()
110     {
111         return _events;
112     }
113
114     public String JavaDoc getInitializeMethod()
115     {
116         return _initializeMethod;
117     }
118
119     public void setInitializeMethod(String JavaDoc string)
120     {
121         _initializeMethod = string;
122     }
123
124     public boolean getAutowireServices()
125     {
126         return _autowireServices;
127     }
128
129     public void setAutowireServices(boolean autowireServices)
130     {
131         _autowireServices = autowireServices;
132     }
133
134 }
Popular Tags