01: // Copyright 2006 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.tapestry.ioc.services;
16:
17: import org.apache.tapestry.ioc.util.StrategyRegistry;
18:
19: /**
20: * A service implementation builder that operates around a {@link StrategyRegistry}, implementing a
21: * version of the Gang of Four Strategy pattern.
22: * <p>
23: * The constructed service is configured with a number of adapters (that implement the same service
24: * interface). Method invocations on the service are routed to one of the adapters.
25: * <p>
26: * The first parameter of each method is used to select the appropriate adapter.
27: * <p>
28: * The ideal interface for use with this builder has only one method.
29: *
30: *
31: */
32: public interface StrategyBuilder {
33: /**
34: * Given a number of adapters implementing the service interface, builds a "dispatcher"
35: * implementations that delegates to the one of the adapters. It is an error if any of the
36: * methods takes no parameters.
37: *
38: * @param <S>
39: * the service interface type
40: * @param registry
41: * defines the adapters based on parameter type (of the first parameter)
42: * @return a service implementation
43: */
44: <S> S build(StrategyRegistry<S> registry);
45: }
|