01: // Copyright 2007 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;
16:
17: import org.apache.tapestry.ioc.annotations.Scope;
18: import org.apache.tapestry.ioc.def.ServiceDef;
19:
20: /**
21: * Allows a module to bind service interfaces to service implementation classes in support of
22: * autobuilding services. A ServiceBinder is passed to to a method with the following signature:
23: * <code>public static void bind(ServiceBinder binder)</code>. This is an adaptation of ideas
24: * from <a href="http://code.google.com/p/google-guice/">Guice</a>.
25: */
26: public interface ServiceBinder {
27: /**
28: * Defines a service in terms of an implementation class, without a service interface. In this
29: * case, the service will not be proxiable (proxying requires a service interface) and
30: * {@link ServiceDef#getServiceInterface()} will return the implementation class. In this
31: * situation, the service will not be proxied; it will be instantiated fully on first reference
32: * (ignoring its scope, if any) and will not be decorated.
33: *
34: * @param <T>
35: * @param implementationClass
36: * @return
37: */
38: <T> ServiceBindingOptions bind(Class<T> implementationClass);
39:
40: /**
41: * Binds the service interface to a service implementation class. The default service name is
42: * the unqualified name of the service interface. The default service scope is "singleton",
43: * unless the service implementation class includes the {@link Scope} annotation.
44: *
45: * @param <T>
46: * @param serviceInterface
47: * service interface (used when locating services, and when building proxies)
48: * @param serviceImplementation
49: * implementation class that implements the service interface
50: * @return binding options, used to specify additional details about the service.
51: */
52: <T> ServiceBindingOptions bind(Class<T> serviceInterface,
53: Class<? extends T> serviceImplementation);
54: }
|