001: // Copyright 2004, 2005 The Apache Software Foundation
002: //
003: // Licensed under the Apache License, Version 2.0 (the "License");
004: // you may not use this file except in compliance with the License.
005: // You may obtain a copy of the License at
006: //
007: // http://www.apache.org/licenses/LICENSE-2.0
008: //
009: // Unless required by applicable law or agreed to in writing, software
010: // distributed under the License is distributed on an "AS IS" BASIS,
011: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012: // See the License for the specific language governing permissions and
013: // limitations under the License.
014:
015: package org.apache.hivemind.service.impl;
016:
017: import java.util.ArrayList;
018: import java.util.HashMap;
019: import java.util.Iterator;
020: import java.util.List;
021: import java.util.Map;
022:
023: import org.apache.hivemind.ServiceImplementationFactoryParameters;
024: import org.apache.hivemind.impl.BaseLocatable;
025:
026: /**
027: * Parameter object used with {@link org.apache.hivemind.service.impl.BuilderFactory}.
028: *
029: * @author Howard Lewis Ship
030: */
031: public class BuilderParameter extends BaseLocatable {
032: private String _className;
033:
034: private List _properties = new ArrayList();
035:
036: private List _parameters = new ArrayList();
037:
038: /** @since 1.1 */
039: private Map _typeFacetMap = new HashMap();
040:
041: private List _events = new ArrayList();
042:
043: private String _initializeMethod;
044:
045: private boolean _autowireServices;
046:
047: public String getClassName() {
048: return _className;
049: }
050:
051: public void addParameter(BuilderFacet facet) {
052: _parameters.add(facet);
053: }
054:
055: public List getParameters() {
056: return _parameters;
057: }
058:
059: public void addProperty(BuilderFacet facet) {
060: _properties.add(facet);
061: }
062:
063: public List getProperties() {
064: return _properties;
065: }
066:
067: /** @since 1.1 */
068: public BuilderFacet getFacetForType(
069: ServiceImplementationFactoryParameters factoryParameters,
070: Class targetType) {
071: BuilderFacet result = (BuilderFacet) _typeFacetMap
072: .get(targetType);
073:
074: if (result == null) {
075: for (Iterator i = _properties.iterator(); i.hasNext();) {
076: BuilderFacet facet = (BuilderFacet) i.next();
077:
078: if (facet.canAutowireConstructorParameter()
079: && facet.isAssignableToType(factoryParameters,
080: targetType)) {
081: result = facet;
082: break;
083: }
084: }
085:
086: _typeFacetMap.put(targetType, result);
087: }
088:
089: return result;
090: }
091:
092: public void setClassName(String string) {
093: _className = string;
094: }
095:
096: public void addEventRegistration(EventRegistration registration) {
097: _events.add(registration);
098: }
099:
100: public List getEventRegistrations() {
101: return _events;
102: }
103:
104: public String getInitializeMethod() {
105: return _initializeMethod;
106: }
107:
108: public void setInitializeMethod(String string) {
109: _initializeMethod = string;
110: }
111:
112: public boolean getAutowireServices() {
113: return _autowireServices;
114: }
115:
116: public void setAutowireServices(boolean autowireServices) {
117: _autowireServices = autowireServices;
118: }
119:
120: }
|