001    // Copyright 2006, 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.annotations;
016    
017    import java.lang.annotation.Documented;
018    import static java.lang.annotation.ElementType.METHOD;
019    import java.lang.annotation.Retention;
020    import static java.lang.annotation.RetentionPolicy.RUNTIME;
021    import java.lang.annotation.Target;
022    
023    /**
024     * Optional, but typically used, annotation for service decorator methods, used to define which services the decorator
025     * applies to. This annotation defines a number of <em>patterns</em> that allow services across multiple modules to be
026     * selected. A decorator is applied to a service if any of its patterns match the service.
027     * <p/>
028     * TODO: Describe pattern glob-match syntax
029     * <p/>
030     * When the Match annotation is not supplied, then the decorator only applies to a single service: the service whose id
031     * matches the decorators id; that is, method <code>decorateMyService()</code> would decorate only the service provided
032     * by the <code>buildMyService()</code> method, within the same module.
033     */
034    @Target(METHOD)
035    @Retention(RUNTIME)
036    @Documented
037    @UseWith(AnnotationUseContext.SERVICE_DECORATOR)
038    public @interface Match
039    {
040    
041        /**
042         * Defines a list of patterns matched against potential service ids to identify to which services the decorator
043         * applies. A decorator is applied if <em>any</em> of the patterns match.
044         */
045        String[] value();
046    }