01: // Copyright 2004, 2005 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // 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.examples.impl;
16:
17: import org.apache.examples.Adder;
18: import org.apache.examples.Calculator;
19: import org.apache.examples.Divider;
20: import org.apache.examples.Multiplier;
21: import org.apache.examples.Subtracter;
22:
23: /**
24: * Implementation of the {@link org.apache.examples.Calculator}
25: * service interface. Acts as a facade, delegating each operation to other
26: * services. The <code>hivemind.BuilderFactory</code>
27: *
28: * @author Howard Lewis Ship
29: */
30: public class CalculatorImpl implements Calculator {
31: private Adder _adder;
32: private Subtracter _subtracter;
33: private Multiplier _multiplier;
34: private Divider _divider;
35:
36: public double add(double arg0, double arg1) {
37: return _adder.add(arg0, arg1);
38: }
39:
40: public double subtract(double arg0, double arg1) {
41: return _subtracter.subtract(arg0, arg1);
42: }
43:
44: public double multiply(double arg0, double arg1) {
45: return _multiplier.multiply(arg0, arg1);
46: }
47:
48: public double divide(double arg0, double arg1) {
49: return _divider.divide(arg0, arg1);
50: }
51:
52: public void setAdder(Adder adder) {
53: _adder = adder;
54: }
55:
56: public void setDivider(Divider divider) {
57: _divider = divider;
58: }
59:
60: public void setMultiplier(Multiplier multiplier) {
61: _multiplier = multiplier;
62: }
63:
64: public void setSubtracter(Subtracter subtracter) {
65: _subtracter = subtracter;
66: }
67:
68: }
|