Skip to content

Commit

Permalink
Merge branch 'feature/QI-408-assembler-adapters' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
eskatos committed Feb 10, 2014
2 parents a2fdf32 + 6b90bb6 commit dab2f9f
Show file tree
Hide file tree
Showing 106 changed files with 1,414 additions and 1,538 deletions.
446 changes: 446 additions & 0 deletions core/bootstrap/src/main/java/org/qi4j/bootstrap/Assemblers.java

Large diffs are not rendered by default.

Expand Up @@ -61,7 +61,7 @@ public void shouldBeEqualToItself()
public void assemble( ModuleAssembly module )
throws AssemblyException
{
new EntityTestAssembler( Visibility.layer ).assemble( module );
new EntityTestAssembler().visibleIn( Visibility.layer ).assemble( module );
module.objects( EntityCompositeEqualityTest.class );
module.entities( MyComposite.class );
}
Expand Down
Expand Up @@ -671,7 +671,7 @@ public void assemble( ModuleAssembly module )
module.entities( BelowLayerVisible.class ).visibleIn( Visibility.layer );
module.entities( BelowModuleVisible.class ).visibleIn( Visibility.module );

new EntityTestAssembler( Visibility.application ).assemble( module );
new EntityTestAssembler().visibleIn( Visibility.application ).assemble( module );
}
}

Expand Down
Expand Up @@ -671,7 +671,7 @@ public void assemble( ModuleAssembly module )
module.objects( BelowLayerVisible.class ).visibleIn( Visibility.layer );
module.objects( BelowModuleVisible.class ).visibleIn( Visibility.module );

new EntityTestAssembler( Visibility.application ).assemble( module );
new EntityTestAssembler().visibleIn( Visibility.application ).assemble( module );
}
}

Expand Down
Expand Up @@ -670,7 +670,7 @@ public void assemble( ModuleAssembly module )
module.services( BelowLayerVisible.class ).visibleIn( Visibility.layer );
module.services( BelowModuleVisible.class ).visibleIn( Visibility.module );

new EntityTestAssembler( Visibility.application ).assemble( module );
new EntityTestAssembler().visibleIn( Visibility.application ).assemble( module );
}
}

Expand Down
Expand Up @@ -671,7 +671,7 @@ public void assemble( ModuleAssembly module )
module.transients( BelowLayerVisible.class ).visibleIn( Visibility.layer );
module.transients( BelowModuleVisible.class ).visibleIn( Visibility.module );

new EntityTestAssembler( Visibility.application ).assemble( module );
new EntityTestAssembler().visibleIn( Visibility.application ).assemble( module );
}
}

Expand Down
Expand Up @@ -672,7 +672,7 @@ public void assemble( ModuleAssembly module )
module.values( BelowLayerVisible.class ).visibleIn( Visibility.layer );
module.values( BelowModuleVisible.class ).visibleIn( Visibility.module );

new EntityTestAssembler( Visibility.application ).assemble( module );
new EntityTestAssembler().visibleIn( Visibility.application ).assemble( module );
}
}

Expand Down
Expand Up @@ -13,11 +13,11 @@
*/
package org.qi4j.test;

import org.qi4j.api.common.Visibility;
import org.qi4j.api.value.ValueSerialization;
import org.qi4j.bootstrap.Assembler;
import org.qi4j.bootstrap.Assemblers;
import org.qi4j.bootstrap.AssemblyException;
import org.qi4j.bootstrap.ModuleAssembly;
import org.qi4j.bootstrap.ServiceDeclaration;
import org.qi4j.entitystore.memory.MemoryEntityStoreService;
import org.qi4j.spi.uuid.UuidIdentityGeneratorService;
import org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationService;
Expand All @@ -26,28 +26,18 @@
* Helper assembler that adds an in-memory EntityStore, a UUID generator, and an Entity type registry to the module
*/
public class EntityTestAssembler
implements Assembler
extends Assemblers.VisibilityIdentity<EntityTestAssembler>
{

Visibility visibility;

public EntityTestAssembler( Visibility visibility )
{
this.visibility = visibility;
}

public EntityTestAssembler()
{
this( Visibility.application );
}

@Override
public void assemble( ModuleAssembly module )
throws AssemblyException
{
module.services( MemoryEntityStoreService.class ).visibleIn( visibility );
module.services( UuidIdentityGeneratorService.class ).visibleIn( visibility );
ServiceDeclaration service = module.services( MemoryEntityStoreService.class ).visibleIn( visibility() );
if( hasIdentity() )
{
service.identifiedBy( identity() );
}
module.services( UuidIdentityGeneratorService.class ).visibleIn( visibility() );
module.services( OrgJsonValueSerializationService.class ).taggedWith( ValueSerialization.Formats.JSON );
}

}
Expand Up @@ -17,52 +17,28 @@
*/
package org.qi4j.cache.ehcache.assembly;

import org.qi4j.api.common.Visibility;
import org.qi4j.bootstrap.Assembler;
import org.qi4j.bootstrap.Assemblers;
import org.qi4j.bootstrap.AssemblyException;
import org.qi4j.bootstrap.ModuleAssembly;
import org.qi4j.bootstrap.ServiceDeclaration;
import org.qi4j.cache.ehcache.EhCacheConfiguration;
import org.qi4j.cache.ehcache.EhCachePoolService;

public class EhCacheAssembler
implements Assembler
extends Assemblers.VisibilityIdentityConfig<EhCacheAssembler>
{

private Visibility visibility = Visibility.module;
private Visibility configVisibility = Visibility.module;
private ModuleAssembly configModule = null;

public EhCacheAssembler()
{
}

public EhCacheAssembler( Visibility visibility )
{
this.visibility = visibility;
}

public EhCacheAssembler visibleIn( Visibility visibility )
{
this.visibility = visibility;
return this;
}

public EhCacheAssembler withConfig( ModuleAssembly configModule, Visibility configVisibility )
{
this.configModule = configModule;
this.configVisibility = configVisibility;
return this;
}

@Override
public void assemble( ModuleAssembly module )
throws AssemblyException
{
module.services( EhCachePoolService.class ).visibleIn( visibility );
if( configModule != null )
ServiceDeclaration service = module.services( EhCachePoolService.class ).visibleIn( visibility() );
if( hasIdentity() )
{
service.identifiedBy( identity() );
}
if( hasConfig() )
{
configModule.entities( EhCacheConfiguration.class ).visibleIn( configVisibility );
configModule().entities( EhCacheConfiguration.class ).visibleIn( configVisibility() );
}
}

}
Expand Up @@ -34,12 +34,12 @@ public void assemble( ModuleAssembly module )
{
// END SNIPPET: assembly
ModuleAssembly confModule = module.layer().module( "confModule" );
new EntityTestAssembler( Visibility.layer ).assemble( confModule );
new EntityTestAssembler().visibleIn( Visibility.layer ).assemble( confModule );

// START SNIPPET: assembly
new EhCacheAssembler( Visibility.module ).
withConfig( confModule, Visibility.layer ).
assemble( module );
// START SNIPPET: assembly
new EhCacheAssembler().
withConfig( confModule, Visibility.layer ).
assemble( module );
}
// END SNIPPET: assembly
}
Expand Up @@ -17,51 +17,29 @@
*/
package org.qi4j.cache.memcache;

import org.qi4j.api.common.Visibility;
import org.qi4j.bootstrap.Assembler;
import org.qi4j.bootstrap.Assemblers;
import org.qi4j.bootstrap.AssemblyException;
import org.qi4j.bootstrap.ModuleAssembly;
import org.qi4j.bootstrap.ServiceDeclaration;

/**
* Memcache CachePool Assembler.
*/
public class MemcacheAssembler
implements Assembler
extends Assemblers.VisibilityIdentityConfig<MemcacheAssembler>
{
private Visibility visibility = Visibility.module;
private ModuleAssembly configModule = null;
private Visibility configVisibility = Visibility.module;

public MemcacheAssembler()
{
}

public MemcacheAssembler( Visibility visibility )
{
this.visibility = visibility;
}

public MemcacheAssembler visibleIn( Visibility visibility )
{
this.visibility = visibility;
return this;
}

public MemcacheAssembler withConfig( ModuleAssembly configModule, Visibility configVisibility )
{
this.configModule = configModule;
this.configVisibility = configVisibility;
return this;
}

@Override
public void assemble( ModuleAssembly module )
throws AssemblyException
{
module.services( MemcachePoolService.class ).visibleIn( visibility );
if( configModule != null )
ServiceDeclaration service = module.services( MemcachePoolService.class ).visibleIn( visibility() );
if( hasIdentity() )
{
service.identifiedBy( identity() );
}
if( hasConfig() )
{
configModule.entities( MemcacheConfiguration.class ).visibleIn( configVisibility );
configModule().entities( MemcacheConfiguration.class ).visibleIn( configVisibility() );
}
}
}
Expand Up @@ -45,9 +45,10 @@ public void assemble( ModuleAssembly module )
{
// END SNIPPET: assembly
ModuleAssembly confModule = module.layer().module( "confModule" );
new EntityTestAssembler( Visibility.layer ).assemble( confModule );
new EntityTestAssembler().visibleIn( Visibility.layer ).assemble( confModule );
// START SNIPPET: assembly
new MemcacheAssembler( Visibility.module ).
new MemcacheAssembler().
visibleIn( Visibility.module ).
withConfig( confModule, Visibility.layer ).
assemble( module );
// END SNIPPET: assembly
Expand Down
Expand Up @@ -17,34 +17,30 @@
*/
package org.qi4j.entitystore.file.assembly;

import org.qi4j.api.common.Visibility;
import org.qi4j.bootstrap.Assembler;
import org.qi4j.bootstrap.Assemblers;
import org.qi4j.bootstrap.AssemblyException;
import org.qi4j.bootstrap.ModuleAssembly;
import org.qi4j.bootstrap.ServiceDeclaration;
import org.qi4j.entitystore.file.FileEntityStoreConfiguration;
import org.qi4j.entitystore.file.FileEntityStoreService;
import org.qi4j.spi.uuid.UuidIdentityGeneratorService;

public class FileEntityStoreAssembler
implements Assembler
extends Assemblers.VisibilityIdentityConfig<FileEntityStoreAssembler>
{

private Visibility visibility;

public FileEntityStoreAssembler()
{
this.visibility = Visibility.module;
}

public FileEntityStoreAssembler( Visibility visibility )
{
this.visibility = visibility;
}

@Override
public void assemble( ModuleAssembly module )
throws AssemblyException
{
module.services( FileEntityStoreService.class ).visibleIn( visibility );
module.services( UuidIdentityGeneratorService.class ).visibleIn( visibility );
module.services( UuidIdentityGeneratorService.class ).visibleIn( visibility() );
ServiceDeclaration service = module.services( FileEntityStoreService.class ).visibleIn( visibility() );
if( hasIdentity() )
{
service.identifiedBy( identity() );
}
if( hasConfig() )
{
configModule().entities( FileEntityStoreConfiguration.class ).visibleIn( configVisibility() );
}
}
}
Expand Up @@ -39,10 +39,9 @@ public void assemble( ModuleAssembly module )
module.services( FileConfigurationService.class );
ModuleAssembly config = module.layer().module( "config" );
new EntityTestAssembler().assemble( config );
// START SNIPPET: assembly
new OrgJsonValueSerializationAssembler().assemble( module );
new FileEntityStoreAssembler().assemble( module );
config.entities( FileEntityStoreConfiguration.class ).visibleIn( Visibility.layer );
// START SNIPPET: assembly
new FileEntityStoreAssembler().withConfig( config, Visibility.layer ).assemble( module );
}
// END SNIPPET: assembly
}
}
Expand Up @@ -18,48 +18,32 @@
*/
package org.qi4j.entitystore.hazelcast.assembly;

import org.qi4j.api.common.Visibility;
import org.qi4j.bootstrap.Assembler;
import org.qi4j.bootstrap.Assemblers;
import org.qi4j.bootstrap.AssemblyException;
import org.qi4j.bootstrap.ModuleAssembly;
import org.qi4j.bootstrap.ServiceDeclaration;
import org.qi4j.entitystore.hazelcast.HazelcastConfiguration;
import org.qi4j.entitystore.hazelcast.HazelcastEntityStoreService;
import org.qi4j.spi.uuid.UuidIdentityGeneratorService;

public class HazelcastEntityStoreAssembler
implements Assembler
extends Assemblers.VisibilityIdentityConfig<HazelcastEntityStoreAssembler>
{

private final Visibility visibility;
private ModuleAssembly config;
private Visibility configVisibility;

public HazelcastEntityStoreAssembler()
{
this( Visibility.application );
}

public HazelcastEntityStoreAssembler( Visibility visibility )
{
this.visibility = visibility;
}

public HazelcastEntityStoreAssembler withConfigIn( ModuleAssembly config, Visibility configVisibility )
{
this.config = config;
this.configVisibility = configVisibility;
return this;
}

@Override
public void assemble( ModuleAssembly module )
throws AssemblyException
{
module.services( HazelcastEntityStoreService.class ).visibleIn( visibility ).instantiateOnStartup();
module.services( UuidIdentityGeneratorService.class ).visibleIn( visibility );
if( config != null )
module.services( UuidIdentityGeneratorService.class ).visibleIn( visibility() );
ServiceDeclaration service = module.services( HazelcastEntityStoreService.class ).
visibleIn( visibility() ).
instantiateOnStartup();
if( hasIdentity() )
{
service.identifiedBy( identity() );
}
if( hasConfig() )
{
config.entities( HazelcastConfiguration.class ).visibleIn( configVisibility );
configModule().entities( HazelcastConfiguration.class ).visibleIn( configVisibility() );
}
}
}
Expand Up @@ -44,7 +44,7 @@ public void assemble( ModuleAssembly module )
new EntityTestAssembler().assemble( configModule );
new OrgJsonValueSerializationAssembler().assemble( module );
// START SNIPPET: assembly
new HazelcastEntityStoreAssembler().withConfigIn( configModule, Visibility.layer ).assemble( module );
new HazelcastEntityStoreAssembler().withConfig( configModule, Visibility.layer ).assemble( module );
}
// END SNIPPET: assembly

Expand Down

0 comments on commit dab2f9f

Please sign in to comment.