Examples of ControlException


Examples of org.apache.beehive.controls.api.ControlException

        // Services are always provided by the parent context.
        //
        ControlBeanContext cbc = getControlBeanContext();
        BeanContext bc = cbc.getBeanContext();
        if (bc == null || !(bc instanceof BeanContextServices))
            throw new ControlException("Can't locate service context: " + bc);

        //
        // Call getService on the parent context, using this bean as the requestor and the
        // associated peer context instance as the child and event listener parameters.
        //
View Full Code Here

Examples of org.apache.beehive.controls.api.ControlException

                    break;
                }
            }
            if (!found)
            {
                throw new ControlException("Can't find base control interface for " + controlIntf);
            }
        }
        return controlIntf;
    }
View Full Code Here

Examples of org.apache.beehive.controls.api.ControlException

            }

            //
            // Version requirement failed
            //
            throw new ControlException( "Control extension " + intfName + " fails version requirement: requires interface version " +
                    majorRequired + "." + minorRequired + ", found interface version " +
                    majorPresent + "." + minorPresent + "." );
        }
    }
View Full Code Here

Examples of org.apache.beehive.controls.api.ControlException

        }
        catch (TooManyListenersException tmle)
        {
            // This would be highly unusual... it implies that the registration for service
            // revocation notifications failed for some reason.
            throw new ControlException("Unable to register for service events", tmle);
        }
    }
View Full Code Here

Examples of org.apache.beehive.controls.api.ControlException

     * Called during XMLDecoder reconstruction of a ControlBean.
     */
    public void decodeImpl(Object impl)
    {
        if (impl != _control)
            throw new ControlException("Cannot change implementation");
    };
View Full Code Here

Examples of org.apache.beehive.controls.api.ControlException

        {
            beanInfo = Introspector.getBeanInfo(control.getClass());
        }
        catch (IntrospectionException ie)
        {
            throw new ControlException("Unable to locate BeanInfo", ie);
        }

        //
        // Cast the encoding stream to an XMLEncoder (only encoding supported) and then set
        // the stream owner to the bean being persisted
        //
        XMLEncoder xmlOut = (XMLEncoder)out;
        Object owner = xmlOut.getOwner();
        xmlOut.setOwner(control);
        try
        {

            //
            // The default implementation of property persistence will use BeanInfo to
            // incrementally compare oldInstance property values to newInstance property values.  
            // Because the bean instance PropertyMap holds only the values that have been
            // modified, this process can be optimized by directly writing out only the properties
            // found in the map.
            //
            BeanPropertyMap beanMap = control.getPropertyMap();
            PropertyDescriptor [] propDescriptors = beanInfo.getPropertyDescriptors();
            for (PropertyKey pk : beanMap.getPropertyKeys())
            {
                //
                // Locate the PropertyDescriptor for the modified property, and use it to write
                // the property value to the encoder stream
                //
                String propName = pk.getPropertyName();
                boolean found = false;
                for (int i = 0; i < propDescriptors.length; i++)
                {
                    if (propName.equals(propDescriptors[i].getName()))
                    {
                        found = true;

                        // Only write the property if it is not flagged as transient
                        Object transientVal = propDescriptors[i].getValue("transient");
                        if (transientVal == null || transientVal.equals(Boolean.FALSE))
                        {
                            xmlOut.writeStatement(
                                new Statement(oldInstance,
                                      propDescriptors[i].getWriteMethod().getName(),
                                      new Object [] {beanMap.getProperty(pk)}));
                        }
                    }
                }
                if (found == false)
                {
                    throw new ControlException("Unknown property in bean PropertyMap: " + pk);
                }
            }

            //
            // Get the bean context associated with the bean, and persist any nested controls
            //
            ControlBeanContext cbc = control.getControlBeanContext();
            if (cbc.size() != 0)
            {
                xmlOut.setPersistenceDelegate(ControlBeanContext.class,
                                              new ContextPersistenceDelegate());

                Iterator nestedIter = cbc.iterator();
                while (nestedIter.hasNext())
                {
                    Object bean = nestedIter.next();
                    if (bean instanceof ControlBean)
                    {
                        xmlOut.writeStatement(
                            new Statement(cbc, "add", new Object [] { bean } ));
                    }
                }
            }

            //
            // Restore any listeners associated with the control
            //
            EventSetDescriptor [] eventSetDescriptors = beanInfo.getEventSetDescriptors();
            for (int i = 0; i < eventSetDescriptors.length; i++)
            {
                EventSetDescriptor esd = eventSetDescriptors[i];
                Method listenersMethod = esd.getGetListenerMethod();
                String addListenerName = esd.getAddListenerMethod().getName();
                if (listenersMethod != null)
                {
                    //
                    // Get the list of listeners, and then add statements to incrementally
                    // add them in the same order
                    //
                    try
                    {
                        Object [] lstnrs = (Object [])listenersMethod.invoke(control,
                                                                             new Object []{});
                        for (int j = 0; j < lstnrs.length; j++)
                        {
                            //
                            // If this is a generated EventAdaptor class, then set the delegate
                            // explicitly
                            //
                            if (lstnrs[j] instanceof EventAdaptor)
                                xmlOut.setPersistenceDelegate(lstnrs[j].getClass(),
                                                              new AdaptorPersistenceDelegate());
                            xmlOut.writeStatement(
                                new Statement(control, addListenerName, new Object [] {lstnrs[j]}));
                        }
                    }
                    catch (Exception iae)
                    {
                        throw new ControlException("Unable to initialize listeners", iae);
                    }
                }
            }

            //
View Full Code Here

Examples of org.apache.beehive.controls.api.ControlException

        //
        // From the located methods, identify the home/bean interfaces.
        //
        if (remoteHome != null) {
            if (localHome != null)
                throw new ControlException(controlInterface + " extends multiple EJB home interfaces.");
            _homeInterface = getRoot(remoteHome, derivesFrom);
        }
        else if (localHome != null)
            _homeInterface = getRoot(localHome, derivesFrom);
        else throw new ControlException(controlInterface + " does not extend the EJBHome or EJBLocalHome interfaces");

        if (remoteBean != null) {
            if (localBean != null)
                throw new ControlException("Interface " + controlInterface + " extends multiple EJB object interfaces.");
            _beanInterface = getRoot(remoteBean, derivesFrom);
        }
        else if (localBean != null)
            _beanInterface = getRoot(localBean, derivesFrom);
        else throw new ControlException("Interface " + controlInterface + " does not extend the EJBObject or EJBLocalObject interfaces");

        // Identify the bean type via bean interface reflection
        _beanType = "Session";
        Method [] homeMethods = _homeInterface.getMethods();
        for (int i = 0; i < homeMethods.length; i++) {
View Full Code Here

Examples of org.apache.beehive.controls.api.ControlException

     */
    public void onCreate() {

        super.onCreate();
        if (_beanType != EJBControlImpl.SESSION_BEAN)
            throw new ControlException("Attempting to use a session bean control with a bean that is not a session bean");
    }
View Full Code Here

Examples of org.apache.beehive.controls.api.ControlException

            Object beanInstance = createMethod.invoke(_homeInstance, null);
            _autoCreated = true;
            return beanInstance;
        }
        catch (NoSuchMethodException e) {
            throw new ControlException("Cannot auto-create session bean instance because no null argument create() method exists.  To use this bean, you will need to call create() directly with the appropriate parameters");
        }
        catch (InvocationTargetException e) {
            _lastException = e.getTargetException();

            throw new ControlException("Unable to create session bean instance", _lastException);
        }
        catch (Exception e) {
            throw new ControlException("Unable to invoke home interface create method", e);
        }
    }
View Full Code Here

Examples of org.apache.beehive.controls.api.ControlException

        if (_beanInstance != null)
            return _beanInstance;

        // Attempt to resolve bean instance from cached primary key
        if (_lastKey == null)
            throw new ControlException("Unable to locate a target bean instance, because a successful create or finder method has not been executed.");

        Class [] findArgType = new Class[]{_lastKey.getClass()};
        try {
            Method finder = _homeInterface.getMethod("findByPrimaryKey", findArgType);
            return finder.invoke(_homeInstance, new Object []{_lastKey});
        }
        catch (NoSuchMethodException nsme) {
            throw new ControlException("Unable to locate findByPrimaryKey method on home interface", nsme);
        }
        catch (InvocationTargetException ite) {
            _lastException = ite.getTargetException();
            throw new ControlException("Failure to locate entity instance associated with the last primary key", _lastException);
        }
        catch (Exception e) {
            throw new ControlException("Unexpected exception in auto-find", e);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.