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 org.apache.hivemind.ServiceImplementationFactory;
018 import org.apache.hivemind.ServiceImplementationFactoryParameters;
019
020 /**
021 * Implementation of {@link org.apache.hivemind.ServiceImplementationFactory} that can instantiate
022 * an object and then configure its properties.
023 * <p>
024 * Some thought has been given to using bytecode generation to create properties for messages,
025 * extension point id, and so forth. This is being avoided because it undermines the ability to test
026 * service implemenations as POJOs, outside the framework of HiveMind.
027 * <p>
028 * Instead the service is configured by means of the implementation's constructor and setter
029 * methods.
030 *
031 * @author Howard Lewis Ship
032 */
033 public class BuilderFactory implements ServiceImplementationFactory
034 {
035 public Object createCoreServiceImplementation(
036 ServiceImplementationFactoryParameters factoryParameters)
037 {
038 BuilderParameter parameter = (BuilderParameter) factoryParameters.getFirstParameter();
039
040 BuilderFactoryLogic logic = new BuilderFactoryLogic(factoryParameters, parameter);
041
042 return logic.createService();
043 }
044 }