Example usage for java.beans.beancontext BeanContext getBeanContext

List of usage examples for java.beans.beancontext BeanContext getBeanContext

Introduction

In this page you can find the example usage for java.beans.beancontext BeanContext getBeanContext.

Prototype

BeanContext getBeanContext();

Source Link

Document

Gets the BeanContext associated with this BeanContextChild .

Usage

From source file:no.sesat.search.datamodel.BeanDataObjectInvocationHandler.java

protected final void assureAccessAllowed(final Method method) throws IllegalAccessException {

    // we need the current ControlLevel
    BeanContext beanContext = context;
    while (null != beanContext.getBeanContext()) {
        beanContext = beanContext.getBeanContext();
    }//  w ww.j  a  va2s.  c  o m
    if (beanContext instanceof DataModelBeanContextSupport) {
        final ControlLevel level = ((DataModelBeanContextSupport) beanContext).getControlLevel();
        final AccessAllow allow = method.getAnnotation(AccessAllow.class);
        final AccessDisallow disallow = method.getAnnotation(AccessDisallow.class);

        if (LOG.isTraceEnabled()) {
            LOG.trace("level " + level);
            LOG.trace("method " + method);
            LOG.trace("allow " + allow);
            LOG.trace("disallow " + disallow);
        }

        boolean allowed = false;
        boolean disallowed = false;
        if (null != allow) {
            for (ControlLevel cl : allow.value()) {
                allowed |= cl == level;
            }
        }
        if (null != disallow) {
            for (ControlLevel cl : disallow.value()) {
                disallowed |= cl == level;
            }
        }
        if (ACCESS_CONTROLLED && ((null != allow && !allowed) || (null != disallow && disallowed))) {
            throw new DataModelAccessException(method, level);
        }
    }
}