/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * $Header:$ */ package org.apache.beehive.controls.api.context; import java.beans.beancontext.BeanContextServices; import java.beans.PropertyChangeEvent; import java.beans.PropertyVetoException; import java.lang.annotation.Annotation; import java.lang.reflect.AnnotatedElement; import java.lang.reflect.Method; import org.apache.beehive.controls.api.bean.ControlBean; import org.apache.beehive.controls.api.events.EventSet; import org.apache.beehive.controls.api.properties.PropertyMap; /** * The ControlBeanContext interface defines the basic set of contextual services and lifecycle * events for Java ControlBean implementations. *
* ControlBeanContext also extends the java.beans.beancontext.BeanContextServices
* interface, so it also provide core Java Beans services for managing contained controls,
* looking up contextual services, and locating the parent {@link java.beans.beancontext.BeanContext} context.
*
* A Control implementation class can obtain access to the ControlBeanContext associated
* with it by declaring an instance field of this type and annotating it with the
* org.apache.beehive.controls.api.context.Context
annotation, as in the following
* example:
*
*
* The Java Control runtime will automatically initialize this field to a reference to the
* ControlBeanContext associated with the implementation instance.
*/
public interface ControlBeanContext extends BeanContextServices
{
/**
* Returns the public or extension interface associated with the context
*/
public Class getControlInterface();
/**
* Returns the current value of PropertySet for the associated control, or
* null if the property set has not been bound. Actual bindings for property
* values may be the result of annotations on the control field or class,
* property setting via factory arguments or setter APIs, or external
* configuration.
*
* @param propertySet the PropertySet to return
* @return the requested PropertySet instance, or null if not bound
*
* @see org.apache.beehive.controls.api.properties.PropertySet
*/
public
* import org.apache.beehive.controls.api.context.Context;
* import org.apache.beehive.controls.api.context.ControlBeanContext;
*
*
id
parameter is relative to
* the current nesting context, not an absolute control id.
*/
public ControlBean getBean(String id);
/**
* The Lifecycle event interface defines a set of lifecycle events exposed by the
* ControlBeanContext to any registered listener.
*/
@EventSet
public interface LifeCycle
{
/**
* The onCreate event is delivered when the control implementation instance for
* the associated bean has been instantiated and fully initialized.
*/
public void onCreate();
/**
* The onPropertyChange event is delivered when a property setter method is
* called for a bound property on the Java Control.
*
* @see org.apache.beehive.controls.api.packaging.PropertyInfo
*/
public void onPropertyChange(PropertyChangeEvent pce);
/**
* The onVetoableChange event is delivered when a property setter method is
* called for a constrained property on the Java Control. A PropertyVetoException
* may be thrown to veto the change made by the client.
*
* @see org.apache.beehive.controls.api.packaging.PropertyInfo
*/
public void onVetoableChange(PropertyChangeEvent pce) throws PropertyVetoException;
}
/**
* Registers a new listener for LifeCycle events on the context.
*
* @see org.apache.beehive.controls.api.context.ControlBeanContext.LifeCycle
*/
public void addLifeCycleListener(LifeCycle listener);
/**
* Removes a currently registered LifeCycle event listener on the context.
*
* @see org.apache.beehive.controls.api.context.ControlBeanContext.LifeCycle
*/
public void removeLifeCycleListener(LifeCycle listener);
}