001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  You may obtain a copy of the License at
009 *
010 *    http://www.apache.org/licenses/LICENSE-2.0
011 *
012 *  Unless required by applicable law or agreed to in writing,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License.
018 *
019 */
020package org.apache.mina.statemachine.annotation;
021
022import java.lang.annotation.ElementType;
023import java.lang.annotation.Retention;
024import java.lang.annotation.RetentionPolicy;
025import java.lang.annotation.Target;
026
027import org.apache.mina.core.filterchain.IoFilter;
028import org.apache.mina.statemachine.StateMachine;
029import org.apache.mina.statemachine.event.IoFilterEvents;
030
031/**
032 * Annotation used on methods to indicate that the method handles a specific
033 * kind of {@link IoFilterEvents} event when in a specific state. This should
034 * be used when creating {@link StateMachine}s for MINA's {@link IoFilter}
035 * interface.
036 *
037 * @author <a href="http://mina.apache.org">Apache MINA Project</a>
038 */
039@Retention(RetentionPolicy.RUNTIME)
040@Target(ElementType.METHOD)
041@TransitionAnnotation(IoFilterTransitions.class)
042public @interface IoFilterTransition {
043    /**
044     * @return Specifies the ids of one or more events handled by the annotated method. If
045     * not specified the handler method will be executed for any event.
046     */
047    IoFilterEvents[] on() default IoFilterEvents.ANY;
048
049    /**
050     * @return The id of the state or states that this handler applies to. Must be
051     * specified.
052     */
053    String[] in();
054
055    /**
056     * @return The id of the state the {@link StateMachine} should move to next after
057     * executing the annotated method. If not specified the {@link StateMachine}
058     * will remain in the same state.
059     */
060    String next() default Transition.SELF;
061
062    /**
063     * @return The weight used to order handler annotations which match the same event 
064     * in the same state. Transitions with lower weight will be matched first. The
065     * default weight is 0.
066     */
067    int weight() default 0;
068}