001    /*
002     * ============================================================================
003     * GNU Lesser General Public License
004     * ============================================================================
005     *
006     * Beanlet - JSE Application Container.
007     * Copyright (C) 2006  Leon van Zantvoort
008     * 
009     * This library is free software; you can redistribute it and/or
010     * modify it under the terms of the GNU Lesser General Public
011     * License as published by the Free Software Foundation; either
012     * version 2.1 of the License, or (at your option) any later version.
013     * 
014     * This library is distributed in the hope that it will be useful,
015     * but WITHOUT ANY WARRANTY; without even the implied warranty of
016     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
017     * Lesser General Public License for more details.
018     * 
019     * You should have received a copy of the GNU Lesser General Public
020     * License along with this library; if not, write to the Free Software
021     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
022     * 
023     * Leon van Zantvoort
024     * 243 Acalanes Drive #11
025     * Sunnyvale, CA 94086
026     * USA
027     *
028     * zantvoort@users.sourceforge.net
029     * http://beanlet.org
030     */
031    package org.beanlet.naming;
032    
033    import static java.lang.annotation.ElementType.*;
034    import java.lang.annotation.Retention;
035    import java.lang.annotation.RetentionPolicy;
036    import java.lang.annotation.Target;
037    
038    /**
039     * <p>Used to enable JNDI dependency injection.</p>
040     *
041     * <p>A member can be injected with an object from the JNDI tree if a 
042     * {@code NamingContext} is available for the specified member. Such a 
043     * {@code NamingContext} can be defined at package-, class- or at member-level. 
044     * There are two more requirements for members to support JNDI injection:
045     * <ul>
046     * <li>Members must be marked with the {@code Inject} annotation.
047     * <li>Members, for which a {@code NamingContext} is made available at package- 
048     * or class-level, must enable wiring {@code BY_NAME} or wiring {@code BY_TYPE} 
049     * through the {@code Wiring} annotation. Members that are marked with the
050     * {@code NamingContext} support wiring {@code BY_NAME} and {@code BY_TYPE} by 
051     * default.
052     * </ul></p>
053     * 
054     * <p>Members marked with this annotation MUST also be annoted with 
055     * {@code Inject}, otherwise the beanlet definition fails.</p>
056     * 
057     * <p><h3>XML Representation</h3>The following xml-fragment shows how to express 
058     * this annotation in xml.<br><pre><tt>
059     * &lt;beanlets xmlns="http://beanlet.org/schema/beanlet"
060     *           xmlns:jndi="http://beanlet.org/schema/naming"
061     *           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
062     *           xsi:schemaLocation="http://beanlet.org/schema/beanlet http://beanlet.org/schema/beanlet/beanlet_1_0.xsd
063     *                            http://beanlet.org/schema/naming http://beanlet.org/schema/naming/beanlet_naming_1_0.xsd"&gt;
064     *   &lt;beanlet name="foo" type="com.acme.Foo"&gt;
065     *     <b>&lt;jndi:naming-context&gt;
066     *       &lt;jndi:property name="java.naming.factory.initial" value="com.sun.jndi.cosnaming.CNCtxFactory"/&gt;
067     *     &lt;/jndi:naming-context&gt;</b>
068     *   &lt;/beanlet&gt;
069     * &lt;/beanlets&gt;</tt></pre></p>
070     *
071     * @see org.beanlet.Inject
072     * @see org.beanlet.Wiring
073     * @author Leon van Zantvoort
074     */
075    @Retention(RetentionPolicy.RUNTIME)
076    @Target({PACKAGE, TYPE, CONSTRUCTOR, METHOD, FIELD, PARAMETER})
077    public @interface NamingContext {
078    
079        /**
080         * Used to specify properties for the naming context.
081         */
082        NamingProperty[] value() default {};
083    }