    001// Licensed under the Apache License, Version 2.0 (the "License");
    002// you may not use this file except in compliance with the License.
    003// You may obtain a copy of the License at
    004//
    005//     http://www.apache.org/licenses/LICENSE-2.0
    006//
    007// Unless required by applicable law or agreed to in writing, software
    008// distributed under the License is distributed on an "AS IS" BASIS,
    009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    010// See the License for the specific language governing permissions and
    011// limitations under the License.
    012
    013package org.apache.tapestry5.ioc.annotations;
    014
    015import org.apache.tapestry5.ioc.def.ServiceDef;
    016
    017import java.lang.annotation.Documented;
    018import java.lang.annotation.Retention;
    019import java.lang.annotation.Target;
    020
    021import static java.lang.annotation.ElementType.METHOD;
    022import static java.lang.annotation.ElementType.TYPE;
    023import static java.lang.annotation.RetentionPolicy.RUNTIME;
    024
    025/**
    026 * Used to define one or more {@linkplain ServiceDef#getMarkers() marker annotations} for a service implementation. This
    027 * allows for injection based on the combination of type and marker interface. These marker interfaces should not have
    028 * any values. The mere presence of the marker annotation is all that is needed.
    029 *
    030 * When applied to a module class, this sets the default markers for all services within the module.  Markers are
    031 * additive, so a Marker annotation on the implementation class and/or specified with {@link
    032 * org.apache.tapestry5.ioc.ServiceBindingOptions#withMarker(Class[])} will accumulate; a service may have any number of
    033 * markers.  Generally one or two is enough.
    034 *
    035 * @see org.apache.tapestry5.ioc.ObjectLocator#getService(Class, Class[])
    036 */
    037@Target(
    038        {TYPE, METHOD})
    039@Retention(RUNTIME)
    040@Documented
    041@UseWith({AnnotationUseContext.SERVICE, AnnotationUseContext.MODULE})
    042public @interface Marker
    043{
    044    /**
    045     * The type of annotation (which will be present at the injection point).
    046     */
    047    Class[] value();
    048}