001/*
002 * JGrapes Event Driven Framework
003 * Copyright (C) 2016-2018 Michael N. Lipp
004 * 
005 * This program is free software; you can redistribute it and/or modify it 
006 * under the terms of the GNU Affero General Public License as published by 
007 * the Free Software Foundation; either version 3 of the License, or 
008 * (at your option) any later version.
009 * 
010 * This program is distributed in the hope that it will be useful, but 
011 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
012 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License 
013 * for more details.
014 * 
015 * You should have received a copy of the GNU Affero General Public License along 
016 * with this program; if not, see <http://www.gnu.org/licenses/>.
017 */
018
019package org.jgrapes.core.annotation;
020
021import java.lang.annotation.Documented;
022import java.lang.annotation.ElementType;
023import java.lang.annotation.Retention;
024import java.lang.annotation.RetentionPolicy;
025import java.lang.annotation.Target;
026
027import org.jgrapes.core.Channel;
028import org.jgrapes.core.ClassChannel;
029import org.jgrapes.core.Manager;
030import org.jgrapes.core.annotation.Handler.NoChannel;
031
032/**
033 * This annotation marks a component type's attribute of type 
034 * {@link Manager} as a slot for the component type's manager. 
035 * A value is automatically assigned to such an attribute 
036 * when the component type is attached to the component tree or by 
037 * {@link org.jgrapes.core.Components#manager(ComponentType)}
038 * (or {@link org.jgrapes.core.Components#manager(ComponentType, Channel)}).
039 */
040@Documented
041@Retention(RetentionPolicy.RUNTIME)
042@Target(ElementType.FIELD)
043public @interface ComponentManager {
044
045    /**
046     * Specifies the channel to be associated with the component type
047     * instance as a {@link ClassChannel}'s key.
048     * 
049     * @return the channel
050     */
051    Class<? extends Channel> channel() default NoChannel.class;
052
053    /**
054     * Specifies the channel to be associated with the component type
055     * instance as a {@link org.jgrapes.core.NamedChannel}'s 
056     * key (a <code>String</code>).
057     * 
058     * @return the channel
059     */
060    String namedChannel() default "";
061}