001 // Copyright 2007 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.examples.annotations.calculator;
016
017 import org.apache.examples.Adder;
018 import org.apache.examples.Calculator;
019 import org.apache.examples.Divider;
020 import org.apache.examples.Multiplier;
021 import org.apache.examples.Subtracter;
022 import org.apache.examples.impl.AdderImpl;
023 import org.apache.examples.impl.CalculatorImpl;
024 import org.apache.examples.impl.DividerImpl;
025 import org.apache.examples.impl.MultiplierImpl;
026 import org.apache.examples.impl.SubtracterImpl;
027 import org.apache.hivemind.annotations.AbstractAnnotatedModule;
028 import org.apache.hivemind.annotations.definition.Module;
029 import org.apache.hivemind.annotations.definition.Service;
030
031 /**
032 * Example of an annotated module that creates a calculator.
033 *
034 * @author Huegen
035 */
036 @Module( id="calculator" )
037 public class CalculatorModule extends AbstractAnnotatedModule
038 {
039
040 @Service( id="Adder" )
041 public Adder getAdderService()
042 {
043 return new AdderImpl();
044 }
045
046 @Service( id="Subtracter" )
047 public Subtracter getSubtractorService()
048 {
049 return new SubtracterImpl();
050 }
051
052 @Service( id="Multiplier" )
053 public Multiplier getMultiplierService()
054 {
055 return new MultiplierImpl();
056 }
057
058 @Service( id="Divider" )
059 public Divider getDividerService()
060 {
061 return new DividerImpl();
062 }
063
064 @Service( id="Calculator" )
065 public Calculator getCalculatorService()
066 {
067 CalculatorImpl result = new CalculatorImpl();
068 return autowireProperties(result);
069 }
070
071 }