You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by ni...@apache.org on 2016/12/17 10:27:54 UTC
[18/81] [abbrv] [partial] zest-java git commit: ZEST-195 ;
Replace all "zest" with "polygene"
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/package.html
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/package.html b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/package.html
deleted file mode 100644
index 7c867b8..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/package.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- ~
- ~
- -->
-<html>
- <body>
- <h2>Assembly and Bootstrap API.</h2>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/main/java/org/apache/zest/bootstrap/unitofwork/DefaultUnitOfWorkAssembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/unitofwork/DefaultUnitOfWorkAssembler.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/unitofwork/DefaultUnitOfWorkAssembler.java
deleted file mode 100644
index b8d8f41..0000000
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/unitofwork/DefaultUnitOfWorkAssembler.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package org.apache.zest.bootstrap.unitofwork;
-
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.bootstrap.Assembler;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-
-public class DefaultUnitOfWorkAssembler
- implements Assembler
-{
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- Class factoryMixin = loadMixinClass( "org.apache.zest.runtime.unitofwork.UnitOfWorkFactoryMixin" );
- module.services( UnitOfWorkFactory.class ).withMixins( factoryMixin );
-
- Class uowMixin = loadMixinClass( "org.apache.zest.runtime.unitofwork.ModuleUnitOfWork" );
- module.transients( UnitOfWork.class ).withMixins( uowMixin );
- }
-
- private Class<?> loadMixinClass( String name )
- throws AssemblyException
- {
- try
- {
- return getClass().getClassLoader().loadClass( name );
- }
- catch( ClassNotFoundException e )
- {
- throw new AssemblyException( "Default UnitOfWorkFactory mixin is not present in the system." );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/AssemblySpecificationTest.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/AssemblySpecificationTest.java b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/AssemblySpecificationTest.java
new file mode 100644
index 0000000..a107af2
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/AssemblySpecificationTest.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+
+package org.apache.polygene.bootstrap;
+
+import java.math.BigDecimal;
+import java.util.Arrays;
+import java.util.function.Predicate;
+import java.util.stream.Stream;
+import org.apache.polygene.api.type.HasTypes;
+import org.junit.Test;
+
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
+public class AssemblySpecificationTest
+{
+ @Test
+ public void givenSingleMatchingTypeWhenFilteringExpectTrue()
+ {
+ Predicate<HasTypes> underTest = AssemblySpecifications.ofAnyType( String.class );
+ HasTypes hasTypes = new MockedHasTyoes( String.class );
+ assertThat( underTest.test( hasTypes ), equalTo(true) );
+ }
+
+ @Test
+ public void givenMultipleMatchingTypeWhenFilteringExpectTrue()
+ {
+ Predicate<HasTypes> underTest = AssemblySpecifications.ofAnyType( Long.class, BigDecimal.class, String.class );
+ HasTypes hasTypes = new MockedHasTyoes( String.class );
+ assertThat( underTest.test( hasTypes ), equalTo(true) );
+ }
+
+ @Test
+ public void givenSingleNonMatchingTypeWhenFilteringExpectFalse()
+ {
+ Predicate<HasTypes> underTest = AssemblySpecifications.ofAnyType( Long.class );
+ HasTypes hasTypes = new MockedHasTyoes( Integer.class );
+ assertThat( underTest.test( hasTypes ), equalTo(false) );
+ }
+
+ @Test
+ public void givenMultipleMatchingTypeWhenFilteringAgainstMultipleExpectTrue()
+ {
+ Predicate<HasTypes> underTest = AssemblySpecifications.ofAnyType( Long.class, Integer.class, BigDecimal.class );
+ HasTypes hasTypes = new MockedHasTyoes( String.class, Integer.class );
+ assertThat( underTest.test( hasTypes ), equalTo(true) );
+ }
+
+ @Test
+ public void givenMultipleNonMatchingTypeWhenFilteringAgainstSingleExpectFalse()
+ {
+ Predicate<HasTypes> underTest = AssemblySpecifications.ofAnyType( Long.class, BigDecimal.class, String.class );
+ HasTypes hasTypes = new MockedHasTyoes( Integer.class );
+ assertThat( underTest.test( hasTypes ), equalTo(false) );
+ }
+
+ @Test
+ public void givenMultipleNonMatchingTypeWhenFilteringAgainstMultipleExpectFalse()
+ {
+ Predicate<HasTypes> underTest = AssemblySpecifications.ofAnyType( Long.class, BigDecimal.class );
+ HasTypes hasTypes = new MockedHasTyoes( String.class, Integer.class );
+ assertThat( underTest.test( hasTypes ), equalTo(false) );
+ }
+
+ private static class MockedHasTyoes
+ implements HasTypes
+ {
+ private final Class[] types;
+
+ public MockedHasTyoes( Class... types)
+ {
+ this.types = types;
+ }
+
+ @Override
+ public Stream<Class<?>> types()
+ {
+ return Arrays.stream(types);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/ClassScannerTest.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/ClassScannerTest.java b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/ClassScannerTest.java
new file mode 100644
index 0000000..f257aad
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/ClassScannerTest.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.bootstrap;
+
+import org.apache.polygene.api.activation.ActivationException;
+import org.apache.polygene.bootstrap.somepackage.Test2Value;
+import org.apache.polygene.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.apache.polygene.bootstrap.ClassScanner.findClasses;
+import static org.apache.polygene.bootstrap.ClassScanner.matches;
+
+/**
+ * Test and showcase of the ClassScanner assembly utility.
+ */
+public class ClassScannerTest
+{
+ @Test
+ public void testClassScannerFiles()
+ throws ActivationException, AssemblyException
+ {
+ SingletonAssembler singleton = new SingletonAssembler()
+ {
+ @Override
+ public void assemble( ModuleAssembly module )
+ throws AssemblyException
+ {
+ new DefaultUnitOfWorkAssembler().assemble( module );
+
+ // Find all classes starting from TestValue, but include only the ones that are named *Value
+ findClasses( TestValue.class ).filter( matches( ".*Value" ) )
+ .forEach( module::values );
+ }
+ };
+
+ singleton.module().newValueBuilder( TestValue.class );
+ singleton.module().newValueBuilder( Test2Value.class );
+ }
+
+ @Test
+ public void testClassScannerJar()
+ {
+ Assert.assertEquals( 185, findClasses( Test.class ).count() );
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/DocumentationSupport.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/DocumentationSupport.java b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/DocumentationSupport.java
new file mode 100644
index 0000000..08b61d1
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/DocumentationSupport.java
@@ -0,0 +1,442 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.bootstrap;
+
+import java.util.function.Predicate;
+import org.apache.polygene.api.activation.ActivationException;
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.api.property.Property;
+import org.apache.polygene.api.service.importer.InstanceImporter;
+import org.apache.polygene.api.service.importer.NewObjectImporter;
+import org.apache.polygene.api.structure.Application;
+import org.apache.polygene.api.structure.ApplicationDescriptor;
+import org.apache.polygene.api.structure.Module;
+
+@SuppressWarnings( "ALL" )
+public class DocumentationSupport
+{
+
+ public static Predicate<ObjectAssembly> hasMyTypeSpecification = new Predicate<ObjectAssembly>()
+ {
+
+ public boolean test( ObjectAssembly item )
+ {
+ return item.types().anyMatch( type -> type.equals(String.class) );
+ }
+
+ };
+
+ public static class objects
+ implements Assembler
+ {
+
+ public static class MyObject {}
+
+ // START SNIPPET: objects
+ @Override
+ public void assemble( ModuleAssembly module )
+ throws AssemblyException
+ {
+ module.objects( MyObject.class ).visibleIn( Visibility.layer );
+ }
+ // END SNIPPET: objects
+
+ }
+
+ public static class transients
+ implements Assembler
+ {
+
+ public static interface MyTransient {}
+
+ // START SNIPPET: transients
+ @Override
+ public void assemble( ModuleAssembly module )
+ throws AssemblyException
+ {
+ module.transients( MyTransient.class ).visibleIn( Visibility.layer );
+ }
+ // END SNIPPET: transients
+
+ }
+
+ public static class values
+ implements Assembler
+ {
+
+ public static interface MyValue {}
+
+ // START SNIPPET: values
+ @Override
+ public void assemble( ModuleAssembly module )
+ throws AssemblyException
+ {
+ module.values( MyValue.class ).visibleIn( Visibility.layer );
+ }
+ // END SNIPPET: values
+
+ }
+
+ public static class entities
+ implements Assembler
+ {
+
+ public static interface MyEntity {}
+
+ // START SNIPPET: entities
+ @Override
+ public void assemble( ModuleAssembly module )
+ throws AssemblyException
+ {
+ module.entities( MyEntity.class ).visibleIn( Visibility.layer );
+ }
+ // END SNIPPET: entities
+
+ }
+
+ public static class services
+ implements Assembler
+ {
+
+ public static interface MyService {}
+
+ // START SNIPPET: services
+ @Override
+ public void assemble( ModuleAssembly module )
+ throws AssemblyException
+ {
+ module.services( MyService.class ).visibleIn( Visibility.layer );
+ }
+ // END SNIPPET: services
+
+ }
+
+ public static class taggedServices
+ implements Assembler
+ {
+
+ public static interface MyService {}
+
+ // START SNIPPET: tagged-services
+ @Override
+ public void assemble( ModuleAssembly module )
+ throws AssemblyException
+ {
+ module.services( MyService.class ).taggedWith( "foo", "bar" );
+ }
+ // END SNIPPET: tagged-services
+ }
+
+ public static class importedServices
+ implements Assembler
+ {
+
+ public static class MyService {}
+
+ // START SNIPPET: imported-services
+ @Override
+ public void assemble( ModuleAssembly module )
+ throws AssemblyException
+ {
+ module.importedServices( MyService.class ).
+ importedBy( InstanceImporter.class ).
+ setMetaInfo( new MyService() );
+
+ // OR
+
+ module.objects( MyService.class );
+ module.importedServices( MyService.class ).
+ importedBy( NewObjectImporter.class );
+ }
+ // END SNIPPET: imported-services
+ }
+
+ public static class defaultPropertyValues
+ implements Assembler
+ {
+
+ public interface MyValue { Property<String> foo(); }
+ public interface MyEntity { Property<String> cathedral(); }
+
+ // START SNIPPET: properties-defaults
+ @Override
+ public void assemble( ModuleAssembly module )
+ throws AssemblyException
+ {
+ module.values( MyValue.class );
+ MyValue myValueDefaults = module.forMixin( MyValue.class ).declareDefaults();
+ myValueDefaults.foo().set( "bar" );
+
+ module.entities( MyEntity.class );
+ MyEntity myEntityDefaults = module.forMixin( MyEntity.class ).declareDefaults();
+ myEntityDefaults.cathedral().set( "bazar" );
+ }
+ // END SNIPPET: properties-defaults
+ }
+
+ public static class singleton
+ {
+
+ public interface MyService { }
+ public interface Stuff { }
+
+ void singleton()
+ throws ActivationException, AssemblyException
+ {
+ // START SNIPPET: singleton
+ SingletonAssembler assembler = new SingletonAssembler()
+ {
+
+ @Override
+ public void assemble( ModuleAssembly module )
+ throws AssemblyException
+ {
+ module.services( MyService.class ).identifiedBy( "Foo" );
+ module.services( MyService.class ).identifiedBy( "Bar" );
+ module.objects( Stuff.class );
+ }
+
+ };
+ Module module = assembler.module();
+ Stuff stuff = module.newObject( Stuff.class );
+ // END SNIPPET: singleton
+ }
+
+ }
+
+ public static class pancake
+ {
+
+ public static class LoginAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+ public static class MenuAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+ public static class PerspectivesAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+ public static class ViewsAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+ public static class ReportingAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+ public static class PdfAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+ public static class BookkeepingAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+ public static class CashFlowAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+ public static class BalanceSheetAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+ public static class PricingAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+ public static class ProductAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+
+ private static Energy4Java zest;
+
+ // START SNIPPET: pancake
+ public static void main( String[] args )
+ throws Exception
+ {
+ zest = new Energy4Java();
+ Assembler[][][] assemblers = new Assembler[][][]{
+ { // View Layer
+ { // Login Module
+ new LoginAssembler()
+ // :
+ },
+ { // Main Workbench Module
+ new MenuAssembler(),
+ new PerspectivesAssembler(),
+ new ViewsAssembler()
+ // :
+ },
+ { // Printing Module
+ new ReportingAssembler(),
+ new PdfAssembler()
+ // :
+ }
+ },
+ { // Application Layer
+ { // Accounting Module
+ new BookkeepingAssembler(),
+ new CashFlowAssembler(),
+ new BalanceSheetAssembler()
+ // :
+ },
+ { // Inventory Module
+ new PricingAssembler(),
+ new ProductAssembler()
+ // :
+ }
+ },
+ { // Domain Layer
+ // :
+ },
+ { // Infrastructure Layer
+ // :
+ }
+ };
+ ApplicationDescriptor model = newApplication( assemblers );
+ Application runtime = model.newInstance( zest.spi() );
+ runtime.activate();
+ }
+
+ private static ApplicationDescriptor newApplication( final Assembler[][][] assemblers )
+ throws AssemblyException
+ {
+ return zest.newApplicationModel( new ApplicationAssembler()
+ {
+
+ @Override
+ public ApplicationAssembly assemble( ApplicationAssemblyFactory appFactory )
+ throws AssemblyException
+ {
+ return appFactory.newApplicationAssembly( assemblers );
+ }
+
+ } );
+ }
+ // END SNIPPET: pancake
+
+ }
+
+ public static class full
+ {
+
+ public static class CustomerViewComposite{}
+ public static class CustomerEditComposite{}
+ public static class CustomerListViewComposite{}
+ public static class CustomerSearchComposite{}
+ public static class CustomerEntity{}
+ public static class CountryEntity{}
+ public static class AddressValue{}
+ public static class LdapAuthenticationAssembler implements Assembler{ public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+ public static class ThrinkAuthorizationAssembler implements Assembler{ public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+ public static class UserTrackingAuditAssembler implements Assembler{ public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+ public static class NeoAssembler implements Assembler{ NeoAssembler( String path ) {} public void assemble( ModuleAssembly module ) throws AssemblyException { } }
+
+ // START SNIPPET: full
+ private static Energy4Java zest;
+
+ private static Application application;
+
+ public static void main( String[] args )
+ throws Exception
+ {
+ // Create a Polygene Runtime
+ zest = new Energy4Java();
+ application = zest.newApplication( new ApplicationAssembler()
+ {
+
+ @Override
+ public ApplicationAssembly assemble( ApplicationAssemblyFactory appFactory )
+ throws AssemblyException
+ {
+ ApplicationAssembly assembly = appFactory.newApplicationAssembly();
+ buildAssembly( assembly );
+ return assembly;
+ }
+
+ } );
+ // activate the application
+ application.activate();
+ }
+
+ static void buildAssembly( ApplicationAssembly app ) throws AssemblyException
+ {
+ LayerAssembly webLayer = createWebLayer( app );
+ LayerAssembly domainLayer = createDomainLayer( app );
+ LayerAssembly persistenceLayer = createInfrastructureLayer( app );
+ LayerAssembly authLayer = createAuth2Layer( app );
+ LayerAssembly messagingLayer = createMessagingLayer( app );
+
+ webLayer.uses( domainLayer );
+ domainLayer.uses( authLayer );
+ domainLayer.uses( persistenceLayer );
+ domainLayer.uses( messagingLayer );
+ }
+
+ static LayerAssembly createWebLayer( ApplicationAssembly app ) throws AssemblyException
+ {
+ LayerAssembly layer = app.layer( "web-layer" );
+ createCustomerWebModule( layer );
+ return layer;
+ }
+
+ static LayerAssembly createDomainLayer( ApplicationAssembly app ) throws AssemblyException
+ {
+ LayerAssembly layer = app.layer( "domain-layer" );
+ createCustomerDomainModule( layer );
+ // :
+ // :
+ return layer;
+ }
+
+ static LayerAssembly createInfrastructureLayer( ApplicationAssembly app ) throws AssemblyException
+ {
+ LayerAssembly layer = app.layer( "infrastructure-layer" );
+ createPersistenceModule( layer );
+ return layer;
+ }
+
+ static LayerAssembly createMessagingLayer( ApplicationAssembly app ) throws AssemblyException
+ {
+ LayerAssembly layer = app.layer( "messaging-layer" );
+ createWebServiceModule( layer );
+ createMessagingPersistenceModule( layer );
+ return layer;
+ }
+
+ static LayerAssembly createAuth2Layer( ApplicationAssembly application ) throws AssemblyException
+ {
+ LayerAssembly layer = application.layer( "auth2-layer" );
+ createAuthModule( layer );
+ return layer;
+ }
+
+ static void createCustomerWebModule( LayerAssembly layer ) throws AssemblyException
+ {
+ ModuleAssembly assembly = layer.module( "customer-web-module" );
+ assembly.transients( CustomerViewComposite.class, CustomerEditComposite.class,
+ CustomerListViewComposite.class, CustomerSearchComposite.class );
+ }
+
+ static void createCustomerDomainModule( LayerAssembly layer ) throws AssemblyException
+ {
+ ModuleAssembly assembly = layer.module( "customer-domain-module" );
+ assembly.entities( CustomerEntity.class, CountryEntity.class );
+ assembly.values( AddressValue.class );
+ }
+
+ static void createAuthModule( LayerAssembly layer ) throws AssemblyException
+ {
+ ModuleAssembly assembly = layer.module( "auth-module" );
+ new LdapAuthenticationAssembler().assemble( assembly );
+ new ThrinkAuthorizationAssembler().assemble( assembly );
+ new UserTrackingAuditAssembler().assemble( assembly );
+ }
+
+ static void createPersistenceModule( LayerAssembly layer ) throws AssemblyException
+ {
+ ModuleAssembly assembly = layer.module( "persistence-module" );
+ // Someone has created an assembler for the Neo EntityStore
+ new NeoAssembler( "./neostore" ).assemble( assembly );
+ }
+
+ // END SNIPPET: full
+ private static void createWebServiceModule( LayerAssembly layer ) throws AssemblyException
+ {
+ }
+
+ private static void createMessagingPersistenceModule( LayerAssembly layer ) throws AssemblyException
+ {
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/TestValue.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/TestValue.java b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/TestValue.java
new file mode 100644
index 0000000..74274b0
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/TestValue.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.bootstrap;
+
+import org.apache.polygene.api.value.ValueComposite;
+
+/**
+ */
+public interface TestValue
+ extends ValueComposite
+{
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/LayeredApplicationAssemblerTest.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/LayeredApplicationAssemblerTest.java b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/LayeredApplicationAssemblerTest.java
new file mode 100644
index 0000000..484d3e2
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/LayeredApplicationAssemblerTest.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.bootstrap.assembly;
+
+import org.junit.Test;
+import org.apache.polygene.api.activation.ActivationException;
+import org.apache.polygene.api.structure.Application;
+import org.apache.polygene.bootstrap.AssemblyException;
+
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
+public class LayeredApplicationAssemblerTest
+{
+ @Test
+ public void validateThatAssemblerCreatesApplication()
+ throws AssemblyException, ActivationException
+ {
+ TestApplication assembler = new TestApplication( "Test Application", "1.0.1", Application.Mode.test );
+ assembler.initialize();
+ assembler.start();
+
+ assertThat( assembler.application().name(), equalTo("Test Application") );
+ assertThat( assembler.application().version(), equalTo("1.0.1") );
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/TestApplication.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/TestApplication.java b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/TestApplication.java
new file mode 100644
index 0000000..ef5ca60
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/TestApplication.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.bootstrap.assembly;
+
+import org.apache.polygene.api.structure.Application;
+import org.apache.polygene.bootstrap.ApplicationAssembly;
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.layered.LayeredApplicationAssembler;
+import org.apache.polygene.bootstrap.LayerAssembly;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.bootstrap.assembly.config.ConfigurationLayer;
+import org.apache.polygene.bootstrap.assembly.connectivity.ConnectivityLayer;
+import org.apache.polygene.bootstrap.assembly.domain.DomainLayer;
+import org.apache.polygene.bootstrap.assembly.infrastructure.InfrastructureLayer;
+import org.apache.polygene.bootstrap.assembly.service.ServiceLayer;
+
+// START SNIPPET: application
+public class TestApplication extends LayeredApplicationAssembler
+{
+
+ public TestApplication( String name, String version, Application.Mode mode )
+ throws AssemblyException
+ {
+ super( name, version, mode );
+ }
+
+ @Override
+ protected void assembleLayers( ApplicationAssembly assembly )
+ throws AssemblyException
+ {
+ LayerAssembly configLayer = createLayer( ConfigurationLayer.class );
+ ModuleAssembly configModule = configLayer.module( "Configuration Module" );
+ LayerAssembly infraLayer = new InfrastructureLayer( configModule ).assemble( assembly.layer( InfrastructureLayer.NAME ));
+ LayerAssembly domainLayer = createLayer( DomainLayer.class );
+ LayerAssembly serviceLayer = createLayer( ServiceLayer.class );
+ LayerAssembly connectivityLayer = createLayer( ConnectivityLayer.class );
+
+ connectivityLayer.uses( serviceLayer );
+ connectivityLayer.uses( domainLayer );
+ serviceLayer.uses( domainLayer );
+ domainLayer.uses( infraLayer );
+ infraLayer.uses( configLayer );
+ }
+}
+// END SNIPPET: application
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/config/ConfigurationLayer.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/config/ConfigurationLayer.java b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/config/ConfigurationLayer.java
new file mode 100644
index 0000000..77e8d05
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/config/ConfigurationLayer.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.bootstrap.assembly.config;
+
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.layered.LayerAssembler;
+import org.apache.polygene.bootstrap.LayerAssembly;
+
+public class ConfigurationLayer implements LayerAssembler
+{
+ @Override
+ public LayerAssembly assemble( LayerAssembly layer )
+ throws AssemblyException
+ {
+ return layer;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/connectivity/ConnectivityLayer.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/connectivity/ConnectivityLayer.java b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/connectivity/ConnectivityLayer.java
new file mode 100644
index 0000000..0b657b2
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/connectivity/ConnectivityLayer.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.bootstrap.assembly.connectivity;
+
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.layered.LayerAssembler;
+import org.apache.polygene.bootstrap.LayerAssembly;
+
+public class ConnectivityLayer implements LayerAssembler
+{
+ public static final String NAME = "Connectivity";
+
+ @Override
+ public LayerAssembly assemble( LayerAssembly layer )
+ throws AssemblyException
+ {
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/domain/DomainLayer.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/domain/DomainLayer.java b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/domain/DomainLayer.java
new file mode 100644
index 0000000..5e585dd
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/domain/DomainLayer.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.bootstrap.assembly.domain;
+
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.LayerAssembly;
+import org.apache.polygene.bootstrap.layered.LayeredLayerAssembler;
+
+public class DomainLayer extends LayeredLayerAssembler
+{
+ @Override
+ public LayerAssembly assemble( LayerAssembly layer )
+ throws AssemblyException
+ {
+ createModule( layer, InvoicingModule.class );
+ createModule( layer, OrderModule.class );
+ return layer;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/domain/InvoicingModule.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/domain/InvoicingModule.java b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/domain/InvoicingModule.java
new file mode 100644
index 0000000..ecc83f9
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/domain/InvoicingModule.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.bootstrap.assembly.domain;
+
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.LayerAssembly;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.bootstrap.layered.ModuleAssembler;
+
+public class InvoicingModule
+ implements ModuleAssembler
+{
+ @Override
+ public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+ throws AssemblyException
+ {
+ return module;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/domain/OrderModule.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/domain/OrderModule.java b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/domain/OrderModule.java
new file mode 100644
index 0000000..49a6348
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/domain/OrderModule.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.bootstrap.assembly.domain;
+
+import org.apache.polygene.api.association.Association;
+import org.apache.polygene.api.property.Property;
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.LayerAssembly;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.bootstrap.layered.ModuleAssembler;
+
+public class OrderModule
+ implements ModuleAssembler
+{
+ @Override
+ public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+ throws AssemblyException
+ {
+ module.entities( Order.class, Customer.class );
+ module.values( Address.class );
+ return module;
+ }
+
+ public interface Order
+ {
+ Association<Customer> customer();
+
+ Property<Address> invoicingAddress();
+
+ Property<Address> deliveryAddress();
+ }
+
+ public interface Customer
+ {
+ }
+
+ public interface Address
+ {
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/infrastructure/IndexingModule.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/infrastructure/IndexingModule.java b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/infrastructure/IndexingModule.java
new file mode 100644
index 0000000..7f3e689
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/infrastructure/IndexingModule.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.bootstrap.assembly.infrastructure;
+
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.LayerAssembly;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.bootstrap.layered.ModuleAssembler;
+
+public class IndexingModule
+ implements ModuleAssembler
+{
+ public static final String NAME = "Indexing Module";
+ private final ModuleAssembly configModule;
+
+ public IndexingModule( ModuleAssembly configModule )
+ {
+ this.configModule = configModule;
+ }
+
+ @Override
+ public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+ throws AssemblyException
+ {
+ return module;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/infrastructure/InfrastructureLayer.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/infrastructure/InfrastructureLayer.java b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/infrastructure/InfrastructureLayer.java
new file mode 100644
index 0000000..1507555
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/infrastructure/InfrastructureLayer.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.bootstrap.assembly.infrastructure;
+
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.LayerAssembly;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.bootstrap.layered.LayerAssembler;
+import org.apache.polygene.bootstrap.layered.LayeredLayerAssembler;
+
+public class InfrastructureLayer extends LayeredLayerAssembler
+ implements LayerAssembler
+{
+ public static final String NAME = "Infrastructure Layer";
+ private final ModuleAssembly configModule;
+
+ public InfrastructureLayer( ModuleAssembly configModule )
+ {
+ this.configModule = configModule;
+ }
+
+ @Override
+ public LayerAssembly assemble( LayerAssembly layer )
+ throws AssemblyException
+ {
+ new StorageModule( configModule ).assemble( layer, layer.module( StorageModule.NAME ) );
+ new IndexingModule( configModule ).assemble( layer, layer.module( IndexingModule.NAME ) );
+ createModule( layer, SerializationModule.class );
+ return layer;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/infrastructure/SerializationModule.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/infrastructure/SerializationModule.java b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/infrastructure/SerializationModule.java
new file mode 100644
index 0000000..44cb35a
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/infrastructure/SerializationModule.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.bootstrap.assembly.infrastructure;
+
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.LayerAssembly;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.bootstrap.layered.ModuleAssembler;
+
+public class SerializationModule
+ implements ModuleAssembler
+{
+ @Override
+ public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module
+ )
+ throws AssemblyException
+ {
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/infrastructure/StorageModule.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/infrastructure/StorageModule.java b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/infrastructure/StorageModule.java
new file mode 100644
index 0000000..b59e2e9
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/infrastructure/StorageModule.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.bootstrap.assembly.infrastructure;
+
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.LayerAssembly;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.bootstrap.layered.ModuleAssembler;
+
+public class StorageModule
+ implements ModuleAssembler
+{
+ public static final String NAME = "Storage Module";
+ private final ModuleAssembly configModule;
+
+ public StorageModule( ModuleAssembly configModule )
+ {
+ this.configModule = configModule;
+ }
+
+ @Override
+ public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+ throws AssemblyException
+ {
+ return module;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/service/ServiceLayer.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/service/ServiceLayer.java b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/service/ServiceLayer.java
new file mode 100644
index 0000000..5e55350
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/assembly/service/ServiceLayer.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.bootstrap.assembly.service;
+
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.layered.LayerAssembler;
+import org.apache.polygene.bootstrap.LayerAssembly;
+
+public class ServiceLayer implements LayerAssembler
+{
+ public static final String NAME = "Service";
+
+ @Override
+ public LayerAssembly assemble( LayerAssembly layer )
+ throws AssemblyException
+ {
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/builder/ApplicationBuilderTest.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/builder/ApplicationBuilderTest.java b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/builder/ApplicationBuilderTest.java
new file mode 100644
index 0000000..d0ca6e5
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/builder/ApplicationBuilderTest.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.bootstrap.builder;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import org.apache.polygene.api.activation.ActivationException;
+import org.apache.polygene.api.mixin.Mixins;
+import org.apache.polygene.api.structure.Application;
+import org.apache.polygene.api.structure.Module;
+import org.apache.polygene.bootstrap.Assembler;
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.json.JSONException;
+import org.junit.Test;
+
+import static java.util.stream.Collectors.toList;
+import static org.apache.polygene.bootstrap.ClassScanner.findClasses;
+import static org.apache.polygene.bootstrap.ClassScanner.matches;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
+public class ApplicationBuilderTest
+{
+ @Test
+ public void givenBuilderUseWhenBuildingApplicationExpectSuccess()
+ throws AssemblyException, ActivationException
+ {
+ ApplicationBuilder builder = new ApplicationBuilder( "Build from API test." );
+ builder.withLayer( "layer1" ).using( "layer2" ).using( "layer3" );
+ builder.withLayer( "layer2" );
+ builder.withLayer( "layer3" )
+ .withModule( "test module" )
+ .withAssemblers( findClasses( getClass() ).filter( matches( ".*ServiceAssembler" ) )
+ .collect( toList() ) );
+ Application application = builder.newApplication();
+ Module module = application.findModule( "layer3", "test module" );
+ TestService service = module.findService( TestService.class ).get();
+ assertThat( service.sayHello(), equalTo( "Hello Polygene!" ) );
+ }
+
+ @Test
+ public void givenJsonWhenBuildingApplicationExpectSuccess()
+ throws JSONException, ActivationException, AssemblyException
+ {
+ ApplicationBuilder builder = ApplicationBuilder.fromJson( APPLICATION );
+ Application application = builder.newApplication();
+ Module module = application.findModule( "layer3", "test module" );
+ TestService service = module.findService( TestService.class ).get();
+ assertThat( service.sayHello(), equalTo( "Hello Polygene!" ) );
+ }
+
+ @Test
+ public void givenJsonInputStreamWhenBuildingApplicationExpectSuccess()
+ throws IOException, JSONException, ActivationException, AssemblyException
+ {
+ InputStream input = new ByteArrayInputStream( APPLICATION.getBytes( "UTF-8" ) );
+ ApplicationBuilder builder = ApplicationBuilder.fromJson( input );
+ Application application = builder.newApplication();
+ Module module = application.findModule( "layer3", "test module" );
+ TestService service = module.findService( TestService.class ).get();
+ assertThat( service.sayHello(), equalTo( "Hello Polygene!" ) );
+ }
+
+
+ private static final String APPLICATION =
+ "{\n" +
+ " \"name\": \"Build from JSON test.\",\n" +
+ " \"layers\": [\n" +
+ " {\n" +
+ " \"name\": \"layer1\",\n" +
+ " \"uses\": [ \"layer2\", \"layer3\"]\n" +
+ " },\n" +
+ " {\n" +
+ " \"name\": \"layer2\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name\": \"layer3\",\n" +
+ " \"modules\" : [\n" +
+ " {\n" +
+ " \"name\" : \"test module\",\n" +
+ " \"assemblers\" : [\n" +
+ " \"org.apache.polygene.bootstrap.builder.ApplicationBuilderTest$TestServiceAssembler\"\n" +
+ " ]\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ " ]\n" +
+ "}";
+
+ public static class TestServiceAssembler
+ implements Assembler
+ {
+ @Override
+ public void assemble( ModuleAssembly module )
+ throws AssemblyException
+ {
+ module.addServices( TestService.class );
+ }
+ }
+
+ @Mixins( TestService.TestMixin.class )
+ public interface TestService
+ {
+ String sayHello();
+
+ class TestMixin
+ implements TestService
+ {
+
+ @Override
+ public String sayHello()
+ {
+ return "Hello Polygene!";
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/somepackage/Test2Value.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/somepackage/Test2Value.java b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/somepackage/Test2Value.java
new file mode 100644
index 0000000..3902d92
--- /dev/null
+++ b/core/bootstrap/src/test/java/org/apache/polygene/bootstrap/somepackage/Test2Value.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.bootstrap.somepackage;
+
+import org.apache.polygene.api.value.ValueComposite;
+
+/**
+ */
+public interface Test2Value
+ extends ValueComposite
+{
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/test/java/org/apache/zest/bootstrap/AssemblySpecificationTest.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/AssemblySpecificationTest.java b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/AssemblySpecificationTest.java
deleted file mode 100644
index 6eac3fa..0000000
--- a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/AssemblySpecificationTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package org.apache.zest.bootstrap;
-
-import java.math.BigDecimal;
-import java.util.Arrays;
-import java.util.function.Predicate;
-import java.util.stream.Stream;
-import org.apache.zest.api.type.HasTypes;
-import org.junit.Test;
-
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
-
-public class AssemblySpecificationTest
-{
- @Test
- public void givenSingleMatchingTypeWhenFilteringExpectTrue()
- {
- Predicate<HasTypes> underTest = AssemblySpecifications.ofAnyType( String.class );
- HasTypes hasTypes = new MockedHasTyoes( String.class );
- assertThat( underTest.test( hasTypes ), equalTo(true) );
- }
-
- @Test
- public void givenMultipleMatchingTypeWhenFilteringExpectTrue()
- {
- Predicate<HasTypes> underTest = AssemblySpecifications.ofAnyType( Long.class, BigDecimal.class, String.class );
- HasTypes hasTypes = new MockedHasTyoes( String.class );
- assertThat( underTest.test( hasTypes ), equalTo(true) );
- }
-
- @Test
- public void givenSingleNonMatchingTypeWhenFilteringExpectFalse()
- {
- Predicate<HasTypes> underTest = AssemblySpecifications.ofAnyType( Long.class );
- HasTypes hasTypes = new MockedHasTyoes( Integer.class );
- assertThat( underTest.test( hasTypes ), equalTo(false) );
- }
-
- @Test
- public void givenMultipleMatchingTypeWhenFilteringAgainstMultipleExpectTrue()
- {
- Predicate<HasTypes> underTest = AssemblySpecifications.ofAnyType( Long.class, Integer.class, BigDecimal.class );
- HasTypes hasTypes = new MockedHasTyoes( String.class, Integer.class );
- assertThat( underTest.test( hasTypes ), equalTo(true) );
- }
-
- @Test
- public void givenMultipleNonMatchingTypeWhenFilteringAgainstSingleExpectFalse()
- {
- Predicate<HasTypes> underTest = AssemblySpecifications.ofAnyType( Long.class, BigDecimal.class, String.class );
- HasTypes hasTypes = new MockedHasTyoes( Integer.class );
- assertThat( underTest.test( hasTypes ), equalTo(false) );
- }
-
- @Test
- public void givenMultipleNonMatchingTypeWhenFilteringAgainstMultipleExpectFalse()
- {
- Predicate<HasTypes> underTest = AssemblySpecifications.ofAnyType( Long.class, BigDecimal.class );
- HasTypes hasTypes = new MockedHasTyoes( String.class, Integer.class );
- assertThat( underTest.test( hasTypes ), equalTo(false) );
- }
-
- private static class MockedHasTyoes
- implements HasTypes
- {
- private final Class[] types;
-
- public MockedHasTyoes( Class... types)
- {
- this.types = types;
- }
-
- @Override
- public Stream<Class<?>> types()
- {
- return Arrays.stream(types);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/test/java/org/apache/zest/bootstrap/ClassScannerTest.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/ClassScannerTest.java b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/ClassScannerTest.java
deleted file mode 100644
index bb38ff5..0000000
--- a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/ClassScannerTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.bootstrap;
-
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.bootstrap.somepackage.Test2Value;
-import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
-import org.junit.Assert;
-import org.junit.Test;
-
-import static org.apache.zest.bootstrap.ClassScanner.findClasses;
-import static org.apache.zest.bootstrap.ClassScanner.matches;
-
-/**
- * Test and showcase of the ClassScanner assembly utility.
- */
-public class ClassScannerTest
-{
- @Test
- public void testClassScannerFiles()
- throws ActivationException, AssemblyException
- {
- SingletonAssembler singleton = new SingletonAssembler()
- {
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- new DefaultUnitOfWorkAssembler().assemble( module );
-
- // Find all classes starting from TestValue, but include only the ones that are named *Value
- findClasses( TestValue.class ).filter( matches( ".*Value" ) )
- .forEach( module::values );
- }
- };
-
- singleton.module().newValueBuilder( TestValue.class );
- singleton.module().newValueBuilder( Test2Value.class );
- }
-
- @Test
- public void testClassScannerJar()
- {
- Assert.assertEquals( 185, findClasses( Test.class ).count() );
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/bootstrap/src/test/java/org/apache/zest/bootstrap/DocumentationSupport.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/DocumentationSupport.java b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/DocumentationSupport.java
deleted file mode 100644
index 2c73588..0000000
--- a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/DocumentationSupport.java
+++ /dev/null
@@ -1,442 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.bootstrap;
-
-import java.util.function.Predicate;
-import org.apache.zest.api.activation.ActivationException;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.service.importer.InstanceImporter;
-import org.apache.zest.api.service.importer.NewObjectImporter;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.ApplicationDescriptor;
-import org.apache.zest.api.structure.Module;
-
-@SuppressWarnings( "ALL" )
-public class DocumentationSupport
-{
-
- public static Predicate<ObjectAssembly> hasMyTypeSpecification = new Predicate<ObjectAssembly>()
- {
-
- public boolean test( ObjectAssembly item )
- {
- return item.types().anyMatch( type -> type.equals(String.class) );
- }
-
- };
-
- public static class objects
- implements Assembler
- {
-
- public static class MyObject {}
-
- // START SNIPPET: objects
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- module.objects( MyObject.class ).visibleIn( Visibility.layer );
- }
- // END SNIPPET: objects
-
- }
-
- public static class transients
- implements Assembler
- {
-
- public static interface MyTransient {}
-
- // START SNIPPET: transients
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- module.transients( MyTransient.class ).visibleIn( Visibility.layer );
- }
- // END SNIPPET: transients
-
- }
-
- public static class values
- implements Assembler
- {
-
- public static interface MyValue {}
-
- // START SNIPPET: values
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- module.values( MyValue.class ).visibleIn( Visibility.layer );
- }
- // END SNIPPET: values
-
- }
-
- public static class entities
- implements Assembler
- {
-
- public static interface MyEntity {}
-
- // START SNIPPET: entities
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- module.entities( MyEntity.class ).visibleIn( Visibility.layer );
- }
- // END SNIPPET: entities
-
- }
-
- public static class services
- implements Assembler
- {
-
- public static interface MyService {}
-
- // START SNIPPET: services
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- module.services( MyService.class ).visibleIn( Visibility.layer );
- }
- // END SNIPPET: services
-
- }
-
- public static class taggedServices
- implements Assembler
- {
-
- public static interface MyService {}
-
- // START SNIPPET: tagged-services
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- module.services( MyService.class ).taggedWith( "foo", "bar" );
- }
- // END SNIPPET: tagged-services
- }
-
- public static class importedServices
- implements Assembler
- {
-
- public static class MyService {}
-
- // START SNIPPET: imported-services
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- module.importedServices( MyService.class ).
- importedBy( InstanceImporter.class ).
- setMetaInfo( new MyService() );
-
- // OR
-
- module.objects( MyService.class );
- module.importedServices( MyService.class ).
- importedBy( NewObjectImporter.class );
- }
- // END SNIPPET: imported-services
- }
-
- public static class defaultPropertyValues
- implements Assembler
- {
-
- public interface MyValue { Property<String> foo(); }
- public interface MyEntity { Property<String> cathedral(); }
-
- // START SNIPPET: properties-defaults
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- module.values( MyValue.class );
- MyValue myValueDefaults = module.forMixin( MyValue.class ).declareDefaults();
- myValueDefaults.foo().set( "bar" );
-
- module.entities( MyEntity.class );
- MyEntity myEntityDefaults = module.forMixin( MyEntity.class ).declareDefaults();
- myEntityDefaults.cathedral().set( "bazar" );
- }
- // END SNIPPET: properties-defaults
- }
-
- public static class singleton
- {
-
- public interface MyService { }
- public interface Stuff { }
-
- void singleton()
- throws ActivationException, AssemblyException
- {
- // START SNIPPET: singleton
- SingletonAssembler assembler = new SingletonAssembler()
- {
-
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- module.services( MyService.class ).identifiedBy( "Foo" );
- module.services( MyService.class ).identifiedBy( "Bar" );
- module.objects( Stuff.class );
- }
-
- };
- Module module = assembler.module();
- Stuff stuff = module.newObject( Stuff.class );
- // END SNIPPET: singleton
- }
-
- }
-
- public static class pancake
- {
-
- public static class LoginAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
- public static class MenuAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
- public static class PerspectivesAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
- public static class ViewsAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
- public static class ReportingAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
- public static class PdfAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
- public static class BookkeepingAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
- public static class CashFlowAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
- public static class BalanceSheetAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
- public static class PricingAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
- public static class ProductAssembler implements Assembler { public void assemble( ModuleAssembly module ) throws AssemblyException { } }
-
- private static Energy4Java zest;
-
- // START SNIPPET: pancake
- public static void main( String[] args )
- throws Exception
- {
- zest = new Energy4Java();
- Assembler[][][] assemblers = new Assembler[][][]{
- { // View Layer
- { // Login Module
- new LoginAssembler()
- // :
- },
- { // Main Workbench Module
- new MenuAssembler(),
- new PerspectivesAssembler(),
- new ViewsAssembler()
- // :
- },
- { // Printing Module
- new ReportingAssembler(),
- new PdfAssembler()
- // :
- }
- },
- { // Application Layer
- { // Accounting Module
- new BookkeepingAssembler(),
- new CashFlowAssembler(),
- new BalanceSheetAssembler()
- // :
- },
- { // Inventory Module
- new PricingAssembler(),
- new ProductAssembler()
- // :
- }
- },
- { // Domain Layer
- // :
- },
- { // Infrastructure Layer
- // :
- }
- };
- ApplicationDescriptor model = newApplication( assemblers );
- Application runtime = model.newInstance( zest.spi() );
- runtime.activate();
- }
-
- private static ApplicationDescriptor newApplication( final Assembler[][][] assemblers )
- throws AssemblyException
- {
- return zest.newApplicationModel( new ApplicationAssembler()
- {
-
- @Override
- public ApplicationAssembly assemble( ApplicationAssemblyFactory appFactory )
- throws AssemblyException
- {
- return appFactory.newApplicationAssembly( assemblers );
- }
-
- } );
- }
- // END SNIPPET: pancake
-
- }
-
- public static class full
- {
-
- public static class CustomerViewComposite{}
- public static class CustomerEditComposite{}
- public static class CustomerListViewComposite{}
- public static class CustomerSearchComposite{}
- public static class CustomerEntity{}
- public static class CountryEntity{}
- public static class AddressValue{}
- public static class LdapAuthenticationAssembler implements Assembler{ public void assemble( ModuleAssembly module ) throws AssemblyException { } }
- public static class ThrinkAuthorizationAssembler implements Assembler{ public void assemble( ModuleAssembly module ) throws AssemblyException { } }
- public static class UserTrackingAuditAssembler implements Assembler{ public void assemble( ModuleAssembly module ) throws AssemblyException { } }
- public static class NeoAssembler implements Assembler{ NeoAssembler( String path ) {} public void assemble( ModuleAssembly module ) throws AssemblyException { } }
-
- // START SNIPPET: full
- private static Energy4Java zest;
-
- private static Application application;
-
- public static void main( String[] args )
- throws Exception
- {
- // Create a Polygene Runtime
- zest = new Energy4Java();
- application = zest.newApplication( new ApplicationAssembler()
- {
-
- @Override
- public ApplicationAssembly assemble( ApplicationAssemblyFactory appFactory )
- throws AssemblyException
- {
- ApplicationAssembly assembly = appFactory.newApplicationAssembly();
- buildAssembly( assembly );
- return assembly;
- }
-
- } );
- // activate the application
- application.activate();
- }
-
- static void buildAssembly( ApplicationAssembly app ) throws AssemblyException
- {
- LayerAssembly webLayer = createWebLayer( app );
- LayerAssembly domainLayer = createDomainLayer( app );
- LayerAssembly persistenceLayer = createInfrastructureLayer( app );
- LayerAssembly authLayer = createAuth2Layer( app );
- LayerAssembly messagingLayer = createMessagingLayer( app );
-
- webLayer.uses( domainLayer );
- domainLayer.uses( authLayer );
- domainLayer.uses( persistenceLayer );
- domainLayer.uses( messagingLayer );
- }
-
- static LayerAssembly createWebLayer( ApplicationAssembly app ) throws AssemblyException
- {
- LayerAssembly layer = app.layer( "web-layer" );
- createCustomerWebModule( layer );
- return layer;
- }
-
- static LayerAssembly createDomainLayer( ApplicationAssembly app ) throws AssemblyException
- {
- LayerAssembly layer = app.layer( "domain-layer" );
- createCustomerDomainModule( layer );
- // :
- // :
- return layer;
- }
-
- static LayerAssembly createInfrastructureLayer( ApplicationAssembly app ) throws AssemblyException
- {
- LayerAssembly layer = app.layer( "infrastructure-layer" );
- createPersistenceModule( layer );
- return layer;
- }
-
- static LayerAssembly createMessagingLayer( ApplicationAssembly app ) throws AssemblyException
- {
- LayerAssembly layer = app.layer( "messaging-layer" );
- createWebServiceModule( layer );
- createMessagingPersistenceModule( layer );
- return layer;
- }
-
- static LayerAssembly createAuth2Layer( ApplicationAssembly application ) throws AssemblyException
- {
- LayerAssembly layer = application.layer( "auth2-layer" );
- createAuthModule( layer );
- return layer;
- }
-
- static void createCustomerWebModule( LayerAssembly layer ) throws AssemblyException
- {
- ModuleAssembly assembly = layer.module( "customer-web-module" );
- assembly.transients( CustomerViewComposite.class, CustomerEditComposite.class,
- CustomerListViewComposite.class, CustomerSearchComposite.class );
- }
-
- static void createCustomerDomainModule( LayerAssembly layer ) throws AssemblyException
- {
- ModuleAssembly assembly = layer.module( "customer-domain-module" );
- assembly.entities( CustomerEntity.class, CountryEntity.class );
- assembly.values( AddressValue.class );
- }
-
- static void createAuthModule( LayerAssembly layer ) throws AssemblyException
- {
- ModuleAssembly assembly = layer.module( "auth-module" );
- new LdapAuthenticationAssembler().assemble( assembly );
- new ThrinkAuthorizationAssembler().assemble( assembly );
- new UserTrackingAuditAssembler().assemble( assembly );
- }
-
- static void createPersistenceModule( LayerAssembly layer ) throws AssemblyException
- {
- ModuleAssembly assembly = layer.module( "persistence-module" );
- // Someone has created an assembler for the Neo EntityStore
- new NeoAssembler( "./neostore" ).assemble( assembly );
- }
-
- // END SNIPPET: full
- private static void createWebServiceModule( LayerAssembly layer ) throws AssemblyException
- {
- }
-
- private static void createMessagingPersistenceModule( LayerAssembly layer ) throws AssemblyException
- {
- }
-
- }
-
-}