001 // Copyright 2007, 2009 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.tapestry5.ioc;
016
017 import org.apache.tapestry5.ioc.annotations.EagerLoad;
018 import org.apache.tapestry5.ioc.annotations.Scope;
019
020 import java.lang.annotation.Annotation;
021
022 /**
023 * Allows additional options for a service to be specified, overriding hard coded defaults or defaults from annotations
024 * on the service.
025 *
026 * @see org.apache.tapestry5.ioc.def.ServiceDef2
027 */
028 public interface ServiceBindingOptions
029 {
030 /**
031 * Allows a specific service id for the service to be provided, rather than the default (from the service
032 * interface). This is useful when multiple services implement the same interface, since service ids must be
033 * unique.
034 *
035 * @param id
036 * @return this binding options, for further configuration
037 */
038 ServiceBindingOptions withId(String id);
039
040 /**
041 * Sets the scope of the service, overriding the {@link Scope} annotation on the service implementation class.
042 *
043 * @param scope
044 * @return this binding options, for further configuration
045 * @see org.apache.tapestry5.ioc.ScopeConstants
046 */
047 ServiceBindingOptions scope(String scope);
048
049 /**
050 * Turns eager loading on for this service. This may also be accomplished using the {@link EagerLoad} annotation on
051 * the service implementation class.
052 *
053 * @return this binding options, for further configuration
054 */
055 ServiceBindingOptions eagerLoad();
056
057 /**
058 * Disallows service decoration for this service.
059 *
060 * @return this binding options, for further configuration
061 */
062 ServiceBindingOptions preventDecoration();
063
064 /**
065 * Defines the marker interface(s) for the service, used to connect injections by type at the point of injection
066 * with a particular service implementation, based on the intersection of type and marker interface. The containing
067 * module will sometimes provide a set of default marker annotations for all services within the module, this method
068 * allows that default to be extended.
069 *
070 * @param <T>
071 * @param marker one or more markers to add
072 * @return this binding options, for further configuration
073 */
074 <T extends Annotation> ServiceBindingOptions withMarker(Class<T>... marker);
075 }