Package org.apache.beehive.controls.api.assembly

Examples of org.apache.beehive.controls.api.assembly.ControlAssemblyException


                URL url = new URL("file:" + filePath);
                list.add(url);
            }
            catch (IOException e)
            {
                throw new ControlAssemblyException("Unable to include path " +
                    paths[i] + " in classpath. Caught " +
                    e.getClass().getName() + " trying to form this path as a URL.", e);
            }
        }
View Full Code Here


    {
        if ( !moduleRoot.exists() || !srcOutputRoot.exists() )
            throw new IOException( "Directories " + moduleRoot + " or " + srcOutputRoot + " don't exist!");

        if ( factoryName == null )
            throw new ControlAssemblyException( "Missing context factory names" );

        if ( cl == null )
            throw new ControlAssemblyException( "Must specify a classloader" );

        ClassLoader origCL = Thread.currentThread().getContextClassLoader();
        Thread.currentThread().setContextClassLoader( cl );

        try
        {
            // Create the requested ControlAssemblyContext.Factory
            Class factoryClass = cl.loadClass( factoryName );
            ControlAssemblyContext.Factory factory = (ControlAssemblyContext.Factory)factoryClass.newInstance();

            // Iterate over control types
            Set<String> controlTypes = controlTypeToImpl.keySet();
            for ( String ct : controlTypes )
            {
                // Search for applicable ControlAssemblers as specified on the control impls
                String cImpl = controlTypeToImpl.get( ct );
                Class cImplClass = cl.loadClass( cImpl );

                ControlImplementation a = (ControlImplementation)cImplClass.getAnnotation(ControlImplementation.class);
                if ( a == null )
                    throw new ControlAssemblyException( "Control implementation class=" + cImpl + " missing ControlImplementation annotation" );

                // For each non-default ControlAssembler, create one and call it.
                Class<? extends ControlAssembler> assemblerClass = a.assembler();
                if ( !assemblerClass.equals(DefaultControlAssembler.class) )
                {
                    ControlAssembler assembler = assemblerClass.newInstance();
                    Set<String> clients = controlTypeToClients.get( ct );
                    ControlAssemblyContext cac = factory.newInstance(
                        cl.loadClass(ct), null, clients, moduleRoot, moduleName, srcOutputRoot );
                    assembler.assemble( cac );
                }
            }
        }
        catch ( ControlAssemblyException cae )
        {
            // just rethrow ControlAssemblyExceptions, which will typically come from user-provided assemblers.
            throw cae;
        }
        catch ( Throwable t )
        {
            // Not expecting any throwables other than ControlAssemblyExceptions, so consider them as
            // unexpected infrastructure issues and wrap them in a CAE.
            throw new ControlAssemblyException( "Assembly infrastructure exception",  t);
        }
        finally
        {
            Thread.currentThread().setContextClassLoader( origCL );
        }
View Full Code Here

            ci = q.poll();
        }

        if ( _controlMostDerivedIntf == null )
            throw new ControlAssemblyException( "Invalid control type: " + controlIntfOrExt.getName() );
    }
View Full Code Here

                URL url = new URL("file:" + filePath);
                list.add(url);
            }
            catch (IOException e)
            {
                throw new ControlAssemblyException("Unable to include path " +
                    paths[i] + " in classpath. Caught " +
                    e.getClass().getName() + " trying to form this path as a URL.", e);
            }
        }
View Full Code Here

                URL url = new URL("file:" + filePath);
                list.add(url);
            }
            catch (IOException e)
            {
                throw new ControlAssemblyException("Unable to include path " +
                    paths[i] + " in classpath. Caught " +
                    e.getClass().getName() + " trying to form this path as a URL.", e);
            }
        }
View Full Code Here

    {
        if ( !moduleRoot.exists() || !srcOutputRoot.exists() )
            throw new IOException( "Directories " + moduleRoot + " or " + srcOutputRoot + " don't exist!");

        if ( factoryName == null )
            throw new ControlAssemblyException( "Missing context factory names" );

        if ( cl == null )
            throw new ControlAssemblyException( "Must specify a classloader" );

        ClassLoader origCL = Thread.currentThread().getContextClassLoader();
        Thread.currentThread().setContextClassLoader( cl );

        try
        {
            // Create the requested ControlAssemblyContext.Factory
            Class factoryClass = cl.loadClass( factoryName );
            ControlAssemblyContext.Factory factory = (ControlAssemblyContext.Factory)factoryClass.newInstance();

            // Iterate over control types
            Set<String> controlTypes = controlTypeToImpl.keySet();
            for ( String ct : controlTypes )
            {
                // Search for applicable ControlAssemblers as specified on the control impls
                String cImpl = controlTypeToImpl.get( ct );
                Class cImplClass = cl.loadClass( cImpl );

                ControlImplementation a = (ControlImplementation)cImplClass.getAnnotation(ControlImplementation.class);
                if ( a == null )
                    throw new ControlAssemblyException( "Control implementation class=" + cImpl + " missing ControlImplementation annotation" );

                // For each non-default ControlAssembler, create one and call it.
                Class<? extends ControlAssembler> assemblerClass = a.assembler();
                if ( !assemblerClass.equals(DefaultControlAssembler.class) )
                {
                    ControlAssembler assembler = assemblerClass.newInstance();
                    Set<String> clients = controlTypeToClients.get( ct );
                    ControlAssemblyContext cac = factory.newInstance(
                        cl.loadClass(ct), null, clients, moduleRoot, moduleName, srcOutputRoot );
                    assembler.assemble( cac );
                }
            }
        }
        catch ( ControlAssemblyException cae )
        {
            // just rethrow ControlAssemblyExceptions, which will typically come from user-provided assemblers.
            throw cae;
        }
        catch ( Throwable t )
        {
            // Not expecting any throwables other than ControlAssemblyExceptions, so consider them as
            // unexpected infrastructure issues and wrap them in a CAE.
            throw new ControlAssemblyException( "Assembly infrastructure exception",  t);
        }
        finally
        {
            Thread.currentThread().setContextClassLoader( origCL );
        }
View Full Code Here

            ci = q.poll();
        }

        if ( _controlMostDerivedIntf == null )
            throw new ControlAssemblyException( "Invalid control type: " + controlIntfOrExt.getName() );
    }
View Full Code Here

TOP

Related Classes of org.apache.beehive.controls.api.assembly.ControlAssemblyException

Copyright © 2018 www.massapicom. 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.