private Class<?> loadMixinClass( String name ) { try { return getClass().getClassLoader().loadClass( name ); } catch( ClassNotFoundException e ) { throw new AssemblyException( "Default UnitOfWorkFactory mixin is not present in the system." ); } } }
@Override protected void assemblyException( AssemblyException exception ) { assertThat( exception.getMessage(), containsString( "Composition Problems Report:" + NL ) ); assertThat( exception.getMessage(), containsString( " message: No implementation found for method" + NL + " method: Map doAnotherThing(String name, int value)" + NL + " types: [Person,ValueComposite]" + NL ) ); assertThat( exception.getMessage(), containsString( " message: No implementation found for method" + NL + " method: void doOneThing()" + NL + " types: [Person,ValueComposite]" + NL ) ); assertThat( exception.getMessage(), containsString( " message: No implementation found for method" + NL + " method: void goForWalk(int minutes)" + NL + " types: [Pet,ValueComposite]" + NL ) ); }
private Class<?> loadMixinClass( String name ) { try { return getClass().getClassLoader().loadClass( name ); } catch( ClassNotFoundException e ) { throw new AssemblyException( "Default UnitOfWorkFactory mixin is not present in the system." ); } } }
private Assembler createAssemblerInstance( Class<?> assemblerClass ) { if( !Assembler.class.isAssignableFrom( assemblerClass ) ) { throw new AssemblyException( "Class " + assemblerClass + " is not implementing " + Assembler.class.getName() ); } try { return (Assembler) assemblerClass.newInstance(); } catch( Exception e ) { throw new AssemblyException( "Unable to instantiate " + assemblerClass, e ); } } }
private Assembler createAssemblerInstance( Class<?> assemblerClass ) { if( !Assembler.class.isAssignableFrom( assemblerClass ) ) { throw new AssemblyException( "Class " + assemblerClass + " is not implementing " + Assembler.class.getName() ); } try { return (Assembler) assemblerClass.newInstance(); } catch( Exception e ) { throw new AssemblyException( "Unable to instantiate " + assemblerClass, e ); } } }
@SafeVarargs public AssemblerCollection( Class<? extends Assembler>... assemblyClasses ) throws AssemblyException { assemblers = new ArrayList<>(); for( Class<? extends Assembler> assemblyClass : assemblyClasses ) { try { Assembler assembler = assemblyClass.newInstance(); assemblers.add( assembler ); } catch( Exception e ) { throw new AssemblyException( "Could not instantiate assembly with class " + assemblyClass.getName(), e ); } } }
@SafeVarargs public AssemblerCollection( Class<? extends Assembler>... assemblyClasses ) throws AssemblyException { assemblers = new ArrayList<>(); for( Class<? extends Assembler> assemblyClass : assemblyClasses ) { try { Assembler assembler = assemblyClass.newInstance(); assemblers.add( assembler ); } catch( Exception e ) { throw new AssemblyException( "Could not instantiate assembly with class " + assemblyClass.getName(), e ); } } }
@SuppressWarnings( "unchecked" ) private Class<? extends Assembler> loadClass( String classname ) { Class<?> clazz; try { clazz = getClass().getClassLoader().loadClass( classname ); } catch( Exception e ) { throw new AssemblyException( "Unable to load class " + classname, e ); } if( !Assembler.class.isAssignableFrom( clazz ) ) { throw new AssemblyException( "Class " + classname + " is not implementing " + Assembler.class.getName() ); } //noinspection unchecked return (Class<? extends Assembler>) clazz; }
@SuppressWarnings( "unchecked" ) private Class<? extends Assembler> loadClass( String classname ) { Class<?> clazz; try { clazz = getClass().getClassLoader().loadClass( classname ); } catch( Exception e ) { throw new AssemblyException( "Unable to load class " + classname, e ); } if( !Assembler.class.isAssignableFrom( clazz ) ) { throw new AssemblyException( "Class " + classname + " is not implementing " + Assembler.class.getName() ); } //noinspection unchecked return (Class<? extends Assembler>) clazz; }
@Override public ObjectDeclaration objects(Class<?>... objectTypes) { List<ObjectAssemblyImpl> assemblies = new ArrayList<>(); for (Class<?> objectType : objectTypes) { if (objectType.isInterface()) { throw new AssemblyException("Interfaces can not be Polygene Objects."); } if (objectAssemblies.containsKey(objectType)) { assemblies.add(objectAssemblies.get(objectType)); } else { ObjectAssemblyImpl objectAssembly = new ObjectAssemblyImpl(objectType); objectAssemblies.put(objectType, objectAssembly); assemblies.add(objectAssembly); } } return new ObjectDeclarationImpl(assemblies); }
private void bindApplicationModel( ApplicationModel applicationModel ) { // This will resolve all dependencies try { applicationModel.accept( new BindingVisitor( applicationModel ) ); } catch( BindingException e ) { throw new AssemblyException( "Unable to bind: " + applicationModel, e ); } }
/** * Declare Assemblers. * <p>Declare several Assemblers from an Iterable of Class objects.</p> * <p>Typically used along {@link org.apache.polygene.bootstrap.ClassScanner}.</p> * @param assemblerClasses Assembler classes * @return This Module declaration * @throws AssemblyException if one of the Class is not an Assembler or unable to instantiate */ public ModuleDeclaration withAssemblers( Iterable<Class<?>> assemblerClasses ) throws AssemblyException { List<Class<?>> notAssemblers = StreamSupport.stream( assemblerClasses.spliterator(), false ) .filter( isAssignableFrom( Assembler.class ).negate() ) .collect( toList() ); if( !notAssemblers.isEmpty() ) { throw new AssemblyException( "Classes " + notAssemblers + " are not implementing " + Assembler.class.getName() ); } for( Class<?> assemblerClass : assemblerClasses ) { withAssembler( assemblerClass ); } return this; }
/** * Declare Assemblers. * <p>Declare several Assemblers from an Iterable of Class objects.</p> * <p>Typically used along {@link org.apache.polygene.bootstrap.ClassScanner}.</p> * @param assemblerClasses Assembler classes * @return This Module declaration * @throws AssemblyException if one of the Class is not an Assembler or unable to instantiate */ public ModuleDeclaration withAssemblers( Iterable<Class<?>> assemblerClasses ) throws AssemblyException { List<Class<?>> notAssemblers = StreamSupport.stream( assemblerClasses.spliterator(), false ) .filter( isAssignableFrom( Assembler.class ).negate() ) .collect( toList() ); if( !notAssemblers.isEmpty() ) { throw new AssemblyException( "Classes " + notAssemblers + " are not implementing " + Assembler.class.getName() ); } for( Class<?> assemblerClass : assemblerClasses ) { withAssembler( assemblerClass ); } return this; }
throw new AssemblyException( "Application assembler did not return any ApplicationAssembly" ); throw new AssemblyException( "Composition problems" + nl + nl + modelReport ); throw new AssemblyException( "Unable to create Application Model.", e );
throw new AssemblyException( "Application assembler did not return any ApplicationAssembly" ); throw new AssemblyException( "Composition problems" + nl + nl + modelReport ); throw new AssemblyException( "Unable to create Application Model.", e );
throw new AssemblyException("Module must have name set");
private void buildAllLayers( AssemblyHelper helper, AssemblyMaps maps, List<LayerAssemblyImpl> layerAssemblies, List<LayerModel> layerModels ) { for( LayerAssemblyImpl layerAssembly : layerAssemblies ) { UsedLayersModel usedLayersModel = new UsedLayersModel( maps.usedLayersOf( layerAssembly ) ); List<ModuleModel> moduleModels = new ArrayList<>(); String name = layerAssembly.name(); if( name == null ) { throw new AssemblyException( "Layer must have name set" ); } ActivatorsModel<Layer> layerActivators = new ActivatorsModel<>( layerAssembly.activators() ); LayerModel layerModel = new LayerModel( name, layerAssembly.metaInfo(), usedLayersModel, layerActivators, moduleModels ); for( ModuleAssemblyImpl moduleAssembly : layerAssembly.moduleAssemblies() ) { moduleModels.add( moduleAssembly.assembleModule( layerModel, helper ) ); } maps.addModel( layerAssembly, layerModel ); layerModels.add( layerModel ); } }
throw new AssemblyException( "Could not load velocity properties", e );
throw new AssemblyException( "Could not load velocity properties", e );
if( sqlVendor == null ) throw new AssemblyException( "SQL Vendor could not be determined." ); throw new AssemblyException( "SQL Vendor could not be created", ex );