@Override public TransientDeclaration withMixins( Class<?>... mixins ) { for( TransientDeclaration declaration : declarations ) { declaration.withMixins( mixins ); } return this; }
@Override public void assemble( ModuleAssembly module ) throws AssemblyException { // unable to add the concern, since it is applied on the prototype too! // this seems to be a generic problem with prototypes. module.transients( Map.class ).withMixins( HashMap.class ).withConcerns( ReadOnlyMapConcern.class ); }
@Override public void assemble( ModuleAssembly module ) throws AssemblyException { module.values( Hello.class ); module.transients( Hello.class ).withMixins( SpeakMixin.class ); }
@Override public void assemble( ModuleAssembly module ) throws AssemblyException { module.transients( List.class ).withTypes( FList.class ).withMixins( ArrayList.class ); }
@Override public void assemble( ModuleAssembly module ) { Class factoryMixin = loadMixinClass( "org.apache.polygene.runtime.unitofwork.UnitOfWorkFactoryMixin" ); module.services( UnitOfWorkFactory.class ) .withMixins( factoryMixin ) .identifiedBy( IDENTITY ); Class uowMixin = loadMixinClass( "org.apache.polygene.runtime.unitofwork.ModuleUnitOfWork" ); module.transients( UnitOfWork.class ) .withMixins( uowMixin ); }
@Override public void assemble( ModuleAssembly module ) { Class factoryMixin = loadMixinClass( "org.apache.polygene.runtime.unitofwork.UnitOfWorkFactoryMixin" ); module.services( UnitOfWorkFactory.class ) .withMixins( factoryMixin ) .identifiedBy( IDENTITY ); Class uowMixin = loadMixinClass( "org.apache.polygene.runtime.unitofwork.ModuleUnitOfWork" ); module.transients( UnitOfWork.class ) .withMixins( uowMixin ); }
public void assemble( ModuleAssembly module ) throws AssemblyException { new EntityTestAssembler().assemble( module ); module.transients( FooComposite.class ).withMixins( CustomFooMixin.class ); module.entities( FooEntity.class ).withMixins( FooMixin.class ); }
@Test public void givenTransientWithRuntimeMixinsWhenAssembledExpectCorrectComposition() throws ActivationException { SingletonAssembler singletonAssembler = new SingletonAssembler( module -> module.transients( SayWhat.class ).withMixins( SayThisMixin.class, SayThatMixin.class ) ); SayWhat value = singletonAssembler.transientBuilderFactory().newTransient( SayWhat.class ); assertThat( value.sayThis(), equalTo( "this" ) ); assertThat( value.sayThat(), equalTo( "that" ) ); }
public void assemble( ModuleAssembly module ) throws AssemblyException { LayerAssembly layer = module.layer(); layer.application().setName( "Script Test" ); module.transients( DomainType.class ).setMetaInfo( Scripting.JAVASCRIPT ).withMixins( ScriptMixin.class ); module.transients( HelloSpeaker.class ).setMetaInfo( Scripting.GROOVY ).withMixins( ScriptMixin.class ); module.values( HelloSpeaker.class ).setMetaInfo( Scripting.JAVASCRIPT ).withMixins( ScriptMixin.class ); }
@Test public void testGroovyClassMixin() throws Exception { // START SNIPPET: direct SingletonAssembler assembler = new SingletonAssembler( assembly -> assembly.transients( HelloSpeaker.class ) .withMixins( HelloSpeakerMixin.class ) ); HelloSpeaker speaker = assembler.module().newTransient( HelloSpeaker.class ); assertThat( speaker.sayHello(), equalTo("Hello there, Groovy") ); // END SNIPPET: direct } }
@Test public void givenTransientWithRuntimeMixinOverrideWhenAssembledExpectCorrectComposition() throws ActivationException { SingletonAssembler singletonAssembler = new SingletonAssembler( module -> module.transients( SayWhere.class ).withMixins( SayHereMixin.class ) ); SayWhere value = singletonAssembler.transientBuilderFactory().newTransient( SayWhere.class ); assertThat( value.sayHere(), equalTo( "here" ) ); assertThat( value.sayThere(), nullValue() ); }
public void assemble( ModuleAssembly module ) throws AssemblyException { new EntityTestAssembler().assemble( module ); module.transients( FooComposite.class ).withTypes( Foo.class ); module.transients( FooComposite2.class ).withTypes( Foo.class ).withMixins( CustomFooMixin.class ); module.entities( FooEntity.class ).withTypes( Foo.class ); }