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;
032
033 /**
034 * <p>Provides beanlet instances access to their runtime context.</p>
035 *
036 * <p>The {@code BeanletContext} exposes information on the beanlet's definition
037 * through the {@code BeanletMetaData} interface. Additionally, beanlets can
038 * obtain the {@code BeanletReference}, which is associated with beanlet method
039 * calls.</p>
040 *
041 * <p>An instance of the {@code BeanletContext} can only be obtained through
042 * dependency injection.</p>
043 *
044 * @param <T> the beanlet type.
045 * @see Inject
046 * @author Leon van Zantvoort
047 */
048 public interface BeanletContext<T> {
049
050 /**
051 * Returns beanlet definition information for the underlying beanlet.
052 *
053 * @return meta data for the given underlying beanlet.
054 */
055 BeanletMetaData<T> getBeanletMetaData();
056
057 /**
058 * Returns the beanlet reference that is associated with the current call.
059 *
060 * @throws BeanletStateException thrown if no reference is associated with
061 * current call. Note that references are only associated with calls on
062 * proxy methods, or event executions for non static beanlets.
063 */
064 BeanletReference<T> reference() throws BeanletStateException;
065 }