polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [05/35] polygene-java git commit: Current snapshot for Paul (others) to take a close look if he wants.
Date Sun, 28 May 2017 16:10:25 GMT
Current snapshot for Paul (others) to take a close look if he wants.

Signed-off-by: niclas <niclas@hedhman.org>


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/a9de6c65
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/a9de6c65
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/a9de6c65

Branch: refs/heads/develop
Commit: a9de6c653137b986bb02d1d897f3f1520a217d24
Parents: f510c1e
Author: niclas <niclas@hedhman.org>
Authored: Sun May 21 22:38:16 2017 +0800
Committer: niclas <niclas@hedhman.org>
Committed: Sun May 21 22:38:16 2017 +0800

----------------------------------------------------------------------
 .../layered/LayeredLayerAssembler.java          |  11 +-
 .../test/model/assembly/AccessLayer.java        |   9 +-
 extensions/entitystore-cassandra/build.gradle   |   1 +
 .../CassandraEntityStoreConfiguration.java      |   2 +
 .../entitystore/cassandra/ClusterBuilder.java   |  18 +-
 libraries/constraints/build.gradle              |   2 +-
 .../constraints/HostPortListConstraint.java     |   9 +-
 .../constraints/HostPortListConstraintTest.java |   8 +
 .../library/http/SecureJettyConfiguration.java  |   2 +-
 .../restlet/PolygeneRestApplication.java        |  84 ++-----
 .../PolygeneRestApplicationLauncher.java        |  85 +++++++
 .../library/shiro/web/ShiroFilterService.java   |   5 +-
 .../shiro/web/assembly/HttpShiroAssembler.java  |  23 +-
 tools/generator-polygene/app/index.js           |   1 +
 .../application.java.tmpl                       |  83 +++++++
 .../CommandLineApplication/bootstrap.tmpl       |  49 ++++
 .../HttpServerModule/bootstrap.tmpl             |  94 +++++++
 .../HttpServerModule/module.js                  |  29 +++
 .../RestApiModule/DefaultEnroler.tmpl           |   7 +-
 .../templates/ConnectivityLayer/bootstrap.tmpl  |   3 +-
 .../DomainLayer/DomainModule/Crud.tmpl          |   5 +-
 .../DomainLayer/DomainModule/Entity.tmpl        |   5 +-
 .../DomainLayer/JmxModule/bootstrap.tmpl        |   4 +-
 .../DomainLayer/SecurityModule/bootstrap.tmpl   |  20 --
 .../IndexingModule/bootstrap.tmpl               |   2 +-
 .../MetricsModule/bootstrap.tmpl                |   7 -
 .../StorageModule/bootstrap.tmpl                |   2 +-
 .../DevelopmentKeyManagement.java.tmpl          | 243 +++++++++++++++++++
 .../RestAPIApplication/Launcher.java.tmpl       |  66 +++++
 .../app/templates/RestAPIApplication/app.js     |  22 +-
 .../RestAPIApplication/application.java.tmpl    |  86 +++++++
 .../templates/RestAPIApplication/bootstrap.tmpl |  56 +++++
 .../RestAPIApplication/web-shiro.ini.tmpl       |  44 ++++
 .../templates/RestAPIApplication/web.xml.tmpl   |  46 ----
 .../CommandLineModule/bootstrap.tmpl            |   2 +-
 .../app/templates/buildtool/gradle-app.tmpl     |  22 +-
 .../templates/buildtool/gradle-bootstrap.tmpl   |  36 +--
 .../app/templates/buildtool/gradle-root.tmpl    |   1 +
 38 files changed, 977 insertions(+), 217 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/layered/LayeredLayerAssembler.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/layered/LayeredLayerAssembler.java b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/layered/LayeredLayerAssembler.java
index 9783de5..e9a2c23 100644
--- a/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/layered/LayeredLayerAssembler.java
+++ b/core/bootstrap/src/main/java/org/apache/polygene/bootstrap/layered/LayeredLayerAssembler.java
@@ -33,8 +33,9 @@ public abstract class LayeredLayerAssembler
     {
         try
         {
-            ModuleAssembler moduleAssembler = instantiateAssembler( layer, moduleAssemblerClass );
             String moduleName = createModuleName( moduleAssemblerClass );
+            ModuleAssembly moduleAssembly = layer.module( moduleName );
+            ModuleAssembler moduleAssembler = instantiateModuleAssembler( moduleAssembly, moduleAssemblerClass );
             LayeredApplicationAssembler.setNameIfPresent( moduleAssemblerClass, moduleName );
             ModuleAssembly module = layer.module( moduleName );
             assemblers.put( moduleAssemblerClass, moduleAssembler );
@@ -61,9 +62,9 @@ public abstract class LayeredLayerAssembler
         return moduleName;
     }
 
-    protected ModuleAssembler instantiateAssembler( LayerAssembly layer,
-                                                  Class<? extends ModuleAssembler> modulerAssemblerClass
-    )
+    protected ModuleAssembler instantiateModuleAssembler( ModuleAssembly module,
+                                                          Class<? extends ModuleAssembler> modulerAssemblerClass
+                                                        )
         throws InstantiationException, IllegalAccessException, java.lang.reflect.InvocationTargetException, NoSuchMethodException
     {
         ModuleAssembler moduleAssembler;
@@ -71,7 +72,7 @@ public abstract class LayeredLayerAssembler
         {
             Constructor<? extends ModuleAssembler> assemblyConstructor = modulerAssemblerClass.getDeclaredConstructor( ModuleAssembly.class );
             assemblyConstructor.setAccessible( true );
-            moduleAssembler = assemblyConstructor.newInstance( layer );
+            moduleAssembler = assemblyConstructor.newInstance( module );
         }
         catch( NoSuchMethodException e )
         {

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/core/testsupport/src/main/java/org/apache/polygene/test/model/assembly/AccessLayer.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/model/assembly/AccessLayer.java b/core/testsupport/src/main/java/org/apache/polygene/test/model/assembly/AccessLayer.java
index 045b621..7095dc9 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/model/assembly/AccessLayer.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/model/assembly/AccessLayer.java
@@ -23,6 +23,7 @@ package org.apache.polygene.test.model.assembly;
 import java.lang.reflect.InvocationTargetException;
 import org.apache.polygene.bootstrap.AssemblyException;
 import org.apache.polygene.bootstrap.LayerAssembly;
+import org.apache.polygene.bootstrap.ModuleAssembly;
 import org.apache.polygene.bootstrap.layered.LayeredLayerAssembler;
 import org.apache.polygene.bootstrap.layered.ModuleAssembler;
 
@@ -48,9 +49,9 @@ class AccessLayer extends LayeredLayerAssembler
     }
 
     @Override
-    protected ModuleAssembler instantiateAssembler( LayerAssembly layer,
-                                                    Class<? extends ModuleAssembler> moduleAssemblerClass
-    )
+    protected ModuleAssembler instantiateModuleAssembler( ModuleAssembly module,
+                                                          Class<? extends ModuleAssembler> moduleAssemblerClass
+                                                        )
         throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
     {
         if( moduleAssemblerClass.equals(TestExecutionModule.class))
@@ -59,7 +60,7 @@ class AccessLayer extends LayeredLayerAssembler
         }
         else
         {
-            return super.instantiateAssembler( layer, moduleAssemblerClass );
+            return super.instantiateModuleAssembler( module, moduleAssemblerClass );
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/extensions/entitystore-cassandra/build.gradle
----------------------------------------------------------------------
diff --git a/extensions/entitystore-cassandra/build.gradle b/extensions/entitystore-cassandra/build.gradle
index b1f32a8..343b9f9 100644
--- a/extensions/entitystore-cassandra/build.gradle
+++ b/extensions/entitystore-cassandra/build.gradle
@@ -27,6 +27,7 @@ jar { manifest { name = "Apache Polygene™ Extension - EntityStore - Cassandra"
 dependencies {
   api polygene.core.bootstrap
   api libraries.cassandra_client
+  api polygene.library( 'constraints' )
 
   implementation polygene.library( 'locking' )
   implementation libraries.jackson_mapper

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreConfiguration.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreConfiguration.java b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreConfiguration.java
index ca257e8..e52a0d4 100644
--- a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreConfiguration.java
+++ b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraEntityStoreConfiguration.java
@@ -22,6 +22,7 @@ package org.apache.polygene.entitystore.cassandra;
 import org.apache.polygene.api.common.Optional;
 import org.apache.polygene.api.common.UseDefaults;
 import org.apache.polygene.api.property.Property;
+import org.apache.polygene.library.constraints.annotation.HostPortList;
 
 // START SNIPPET: config
 public interface CassandraEntityStoreConfiguration
@@ -39,6 +40,7 @@ public interface CassandraEntityStoreConfiguration
      * @return A comma or space separated list of hostnames (and port) to use to connect to the Cassandra cluster.
      */
     @Optional
+    @HostPortList
     Property<String> hostnames();
 
     /** The name of the cluster to connect to.

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/ClusterBuilder.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/ClusterBuilder.java b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/ClusterBuilder.java
index 0aced37..53986cc 100644
--- a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/ClusterBuilder.java
+++ b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/ClusterBuilder.java
@@ -31,7 +31,7 @@ public interface ClusterBuilder
 {
     String DEFAULT_HOST_PORT = "localhost:9042";
 
-    Cluster build(CassandraEntityStoreConfiguration config);
+    Cluster build( CassandraEntityStoreConfiguration config );
 
     class DefaultBuilder
         implements ClusterBuilder
@@ -48,9 +48,9 @@ public interface ClusterBuilder
             Cluster.Builder builder =
                 Cluster.builder()
                        .withClusterName( clusterName )
-                       .addContactPointsWithPorts(connectionPoints)
+                       .addContactPointsWithPorts( connectionPoints )
                        .withCredentials( username(), password() );
-            builder = customConfiguration(builder);
+            builder = customConfiguration( builder );
             return builder.build();
         }
 
@@ -77,13 +77,13 @@ public interface ClusterBuilder
         protected Collection<InetSocketAddress> cassandraConnectionPoints()
         {
             String hostnames = hostnames();
-            return Arrays.stream( hostnames.split( "(,| )" ) )
+            return Arrays.stream( hostnames.split( "[ ,]" ) )
                          .map( text ->
-                        {
-                            String[] strings = text.split( ":" );
-                            return new InetSocketAddress( strings[ 0 ], Integer.parseInt( strings[ 1 ] ) );
-                        }
-                      )
+                               {
+                                   String[] strings = text.split( ":" );
+                                   return new InetSocketAddress( strings[ 0 ], Integer.parseInt( strings[ 1 ] ) );
+                               }
+                             )
                          .collect( Collectors.toList() );
         }
 

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/libraries/constraints/build.gradle
----------------------------------------------------------------------
diff --git a/libraries/constraints/build.gradle b/libraries/constraints/build.gradle
index 2aff446..84e52b2 100644
--- a/libraries/constraints/build.gradle
+++ b/libraries/constraints/build.gradle
@@ -27,7 +27,7 @@ jar { manifest { name = "Apache Polygene™ Library - Constraints"}}
 dependencies {
   api polygene.core.bootstrap
 
-  implementation libraries.commons_validator
+  api libraries.commons_validator
 
   runtimeOnly polygene.core.runtime
 

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/libraries/constraints/src/main/java/org/apache/polygene/library/constraints/HostPortListConstraint.java
----------------------------------------------------------------------
diff --git a/libraries/constraints/src/main/java/org/apache/polygene/library/constraints/HostPortListConstraint.java b/libraries/constraints/src/main/java/org/apache/polygene/library/constraints/HostPortListConstraint.java
index 6e81da4..c878c0f 100644
--- a/libraries/constraints/src/main/java/org/apache/polygene/library/constraints/HostPortListConstraint.java
+++ b/libraries/constraints/src/main/java/org/apache/polygene/library/constraints/HostPortListConstraint.java
@@ -19,11 +19,12 @@
  */
 package org.apache.polygene.library.constraints;
 
-import java.util.Arrays;
 import org.apache.commons.validator.routines.UrlValidator;
 import org.apache.polygene.api.constraint.Constraint;
 import org.apache.polygene.library.constraints.annotation.HostPortList;
 
+import static java.util.Arrays.stream;
+
 /**
  * Implement @HostPortList constraint.
  */
@@ -35,9 +36,9 @@ public class HostPortListConstraint
     @Override
     public boolean isValid( HostPortList annotation, String value )
     {
-        return Arrays.stream( value.split( "[ ,]" ) )
-                     .map( this::prefixProtocol )
-                     .allMatch( VALIDATOR::isValid );
+        return stream( value.split( "[ ,]" ) )
+            .map( this::prefixProtocol )
+            .allMatch( VALIDATOR::isValid );
     }
 
     private String prefixProtocol( String value )

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/HostPortListConstraintTest.java
----------------------------------------------------------------------
diff --git a/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/HostPortListConstraintTest.java b/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/HostPortListConstraintTest.java
index 82edd11..3e6ce38 100644
--- a/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/HostPortListConstraintTest.java
+++ b/libraries/constraints/src/test/java/org/apache/polygene/library/constraints/HostPortListConstraintTest.java
@@ -72,6 +72,14 @@ public class HostPortListConstraintTest extends AbstractPolygeneTest
     }
 
     @Test
+    public void givenValidListOfOneHostPortWhenSettingPropertyExpectSuccess()
+        throws Exception
+    {
+        SomeValue someValue = transientBuilderFactory.newTransient( SomeValue.class );
+        someValue.hostPort().set( "localhost:32775" );
+    }
+
+    @Test
     public void givenValidListHostPortWhenSettingPropertyExpectSuccess()
         throws Exception
     {

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/libraries/http/src/main/java/org/apache/polygene/library/http/SecureJettyConfiguration.java
----------------------------------------------------------------------
diff --git a/libraries/http/src/main/java/org/apache/polygene/library/http/SecureJettyConfiguration.java b/libraries/http/src/main/java/org/apache/polygene/library/http/SecureJettyConfiguration.java
index a75e296..64192a3 100644
--- a/libraries/http/src/main/java/org/apache/polygene/library/http/SecureJettyConfiguration.java
+++ b/libraries/http/src/main/java/org/apache/polygene/library/http/SecureJettyConfiguration.java
@@ -34,7 +34,7 @@ import org.apache.polygene.library.constraints.annotation.OneOf;
  */
 // START SNIPPET: configssl
 public interface SecureJettyConfiguration
-        extends JettyConfiguration
+    extends JettyConfiguration
 {
 
     /**

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/PolygeneRestApplication.java
----------------------------------------------------------------------
diff --git a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/PolygeneRestApplication.java b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/PolygeneRestApplication.java
index 4df326f..d3f33d4 100644
--- a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/PolygeneRestApplication.java
+++ b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/PolygeneRestApplication.java
@@ -19,17 +19,11 @@
  */
 package org.apache.polygene.library.restlet;
 
-import java.util.logging.Level;
-import org.apache.polygene.api.composite.TransientBuilderFactory;
+import java.io.PrintStream;
 import org.apache.polygene.api.identity.HasIdentity;
+import org.apache.polygene.api.injection.scope.Structure;
 import org.apache.polygene.api.object.ObjectFactory;
-import org.apache.polygene.api.service.ServiceFinder;
 import org.apache.polygene.api.structure.Application;
-import org.apache.polygene.api.structure.Module;
-import org.apache.polygene.api.unitofwork.UnitOfWorkFactory;
-import org.apache.polygene.api.value.ValueBuilderFactory;
-import org.apache.polygene.bootstrap.AssemblyException;
-import org.apache.polygene.bootstrap.layered.LayeredApplicationAssembler;
 import org.apache.polygene.library.restlet.crud.EntityListResource;
 import org.apache.polygene.library.restlet.crud.EntityResource;
 import org.apache.polygene.library.restlet.resource.CreationResource;
@@ -55,65 +49,39 @@ import org.restlet.util.Series;
 /**
  * This class is generic enough to be promoted to Polygene's Restlet Library
  */
+@SuppressWarnings( { "WeakerAccess", "unused" } )
 public abstract class PolygeneRestApplication extends org.restlet.Application
 {
-    protected org.apache.polygene.api.structure.Application polygeneApplication;
-    protected ServiceFinder serviceFinder;
+    @Structure
+    protected Application polygeneApplication;
+
+    @Structure
     protected ObjectFactory objectFactory;
-    protected TransientBuilderFactory transientBuilderFactory;
-    protected UnitOfWorkFactory unitOfWorkFactory;
-    protected ValueBuilderFactory valueBuilderFactory;
 
-    private Router router;
+    protected Router router;
 
-    public PolygeneRestApplication( Context context )
-        throws AssemblyException
+    protected PolygeneRestApplication( Context context )
     {
         super( context );
+        setName( polygeneApplication.name() );
     }
 
-    protected void printRoutes()
+    protected void printRoutes( PrintStream out )
     {
-        router.getRoutes().forEach(
-            route -> System.out.println( route.toString() ) );
+        router.getRoutes()
+              .stream()
+              .map( Object::toString )
+              .forEach( out::println );
     }
 
-    protected abstract LayeredApplicationAssembler createApplicationAssembler( String mode )
-        throws AssemblyException;
-
     @Override
     public synchronized void start()
         throws Exception
     {
         Series<Parameter> parameters = getContext().getParameters();
         String mode = parameters.getFirstValue( "org.apache.polygene.runtime.mode" );
-        createApplication( mode );
-        polygeneApplication.activate();
-        Module module = polygeneApplication.findModule( getConnectivityLayer(), getConnectivityModule() );
-        serviceFinder = module;
-        objectFactory = module;
-        transientBuilderFactory = module;
-        unitOfWorkFactory = module.unitOfWorkFactory();
-        valueBuilderFactory = module;
         super.start();
-    }
-
-    private void createApplication( String mode )
-    {
-        try
-        {
-            LayeredApplicationAssembler assembler = createApplicationAssembler(mode);
-            assembler.initialize();
-            polygeneApplication = assembler.application();
-            setName( polygeneApplication.name() );
-        }
-        catch( Throwable e )
-        {
-            e.printStackTrace();
-            getLogger().log( Level.SEVERE, "Unable to start Polygene application.", e );
-            throw new InternalError( "Unable to start Polygene application.", e );
-        }
-        getLogger().info( "RestApplication successfully created." );
+        getLogger().info( "RestApplication successfully started." );
     }
 
     @Override
@@ -121,7 +89,7 @@ public abstract class PolygeneRestApplication extends org.restlet.Application
         throws Exception
     {
         super.stop();
-        polygeneApplication.passivate();
+        getLogger().info( "RestApplication successfully stopped." );
     }
 
     @Override
@@ -139,7 +107,7 @@ public abstract class PolygeneRestApplication extends org.restlet.Application
         addRoutes( router );
         router.attach( "/", newPolygeneRestlet( EntryPointResource.class, EntryPoint.class ) );
 
-        ChallengeAuthenticator guard = new ChallengeAuthenticator( context, ChallengeScheme.HTTP_BASIC, "Storm Clouds" );
+        ChallengeAuthenticator guard = new ChallengeAuthenticator( context, ChallengeScheme.HTTP_BASIC, getName() + " Realm" );
 
         Verifier verifier = createVerifier();
         if( verifier != null )
@@ -198,16 +166,12 @@ public abstract class PolygeneRestApplication extends org.restlet.Application
         return null;
     }
 
-    protected abstract String getConnectivityLayer();
-
-    protected abstract String getConnectivityModule();
-
     protected abstract void addRoutes( Router router );
 
     protected void addResourcePath( String name,
                                     Class<? extends HasIdentity> type,
                                     String basePath
-    )
+                                  )
     {
         addResourcePath( name, type, basePath, true, true );
     }
@@ -217,7 +181,7 @@ public abstract class PolygeneRestApplication extends org.restlet.Application
                                     String basePath,
                                     boolean createLink,
                                     boolean rootRoute
-    )
+                                  )
     {
         if( createLink )
         {
@@ -232,21 +196,19 @@ public abstract class PolygeneRestApplication extends org.restlet.Application
         router.attach( basePath + name + "/{id}/{invoke}", newPolygeneRestlet( EntityResource.class, type ) );
     }
 
-    private <K extends HasIdentity, T extends ServerResource<K>> Restlet newPolygeneRestlet(Class<T> resourceClass,
-                                                                                        Class<K> entityClass
-    )
+    private <K extends HasIdentity, T extends ServerResource<K>> Restlet newPolygeneRestlet( Class<T> resourceClass, Class<K> entityClass )
     {
 
         @SuppressWarnings( "unchecked" )
         ResourceFactory<K, T> factory = objectFactory.newObject( DefaultResourceFactoryImpl.class,
                                                                  resourceClass, router
-        );
+                                                               );
         PolygeneConverter converter = new PolygeneConverter( objectFactory );
         return objectFactory.newObject( PolygeneEntityRestlet.class,
                                         factory,
                                         router,
                                         entityClass,
                                         converter
-        );
+                                      );
     }
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/PolygeneRestApplicationLauncher.java
----------------------------------------------------------------------
diff --git a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/PolygeneRestApplicationLauncher.java b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/PolygeneRestApplicationLauncher.java
new file mode 100644
index 0000000..69d2759
--- /dev/null
+++ b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/PolygeneRestApplicationLauncher.java
@@ -0,0 +1,85 @@
+package org.apache.polygene.library.restlet;
+
+import org.apache.polygene.api.activation.ActivationException;
+import org.apache.polygene.api.activation.PassivationException;
+import org.apache.polygene.api.composite.TransientBuilderFactory;
+import org.apache.polygene.api.object.ObjectFactory;
+import org.apache.polygene.api.service.ServiceFinder;
+import org.apache.polygene.api.structure.Application;
+import org.apache.polygene.api.structure.Module;
+import org.apache.polygene.api.unitofwork.UnitOfWorkFactory;
+import org.apache.polygene.api.value.ValueBuilderFactory;
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.layered.LayeredApplicationAssembler;
+
+@SuppressWarnings( "WeakerAccess" )
+public abstract class PolygeneRestApplicationLauncher
+{
+    protected org.apache.polygene.api.structure.Application polygeneApplication;
+    protected ServiceFinder serviceFinder;
+    protected ObjectFactory objectFactory;
+    protected TransientBuilderFactory transientBuilderFactory;
+    protected UnitOfWorkFactory unitOfWorkFactory;
+    protected ValueBuilderFactory valueBuilderFactory;
+    protected Module entryModule;
+
+    protected void initialize()
+        throws ActivationException
+    {
+        polygeneApplication = createApplication();
+        activateApplication();
+        entryModule = polygeneApplication.findModule( entryLayer(), entryModule() );
+        serviceFinder = entryModule;
+        objectFactory = entryModule;
+        transientBuilderFactory = entryModule;
+        unitOfWorkFactory = entryModule.unitOfWorkFactory();
+        valueBuilderFactory = entryModule;
+    }
+
+    protected abstract String entryLayer();
+
+    protected abstract String entryModule();
+
+    protected void activateApplication()
+        throws ActivationException
+    {
+        polygeneApplication.activate();
+    }
+
+    protected Application createApplication()
+    {
+        try
+        {
+            LayeredApplicationAssembler assembler = createApplicationAssembler();
+            assembler.initialize();
+            return assembler.application();
+        }
+        catch( Throwable e )
+        {
+            throw new RuntimeException( "Unable to start Polygene application.", e );
+        }
+    }
+
+    protected abstract LayeredApplicationAssembler createApplicationAssembler()
+        throws AssemblyException;
+
+    protected void installShutdownHook()
+    {
+        Runtime.getRuntime().addShutdownHook( new Thread( this::shutdown ) );
+    }
+
+    protected void shutdown()
+    {
+        try
+        {
+            if( polygeneApplication != null )
+            {
+                polygeneApplication.passivate();
+            }
+        }
+        catch( PassivationException e )
+        {
+            throw new RuntimeException( "Unable to shut down cleanly.", e );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/libraries/shiro-web/src/main/java/org/apache/polygene/library/shiro/web/ShiroFilterService.java
----------------------------------------------------------------------
diff --git a/libraries/shiro-web/src/main/java/org/apache/polygene/library/shiro/web/ShiroFilterService.java b/libraries/shiro-web/src/main/java/org/apache/polygene/library/shiro/web/ShiroFilterService.java
index 698bcaa..b8b822a 100644
--- a/libraries/shiro-web/src/main/java/org/apache/polygene/library/shiro/web/ShiroFilterService.java
+++ b/libraries/shiro-web/src/main/java/org/apache/polygene/library/shiro/web/ShiroFilterService.java
@@ -20,11 +20,10 @@
 package org.apache.polygene.library.shiro.web;
 
 import javax.servlet.Filter;
-import org.apache.shiro.web.servlet.ShiroFilter;
 import org.apache.polygene.api.mixin.Mixins;
+import org.apache.shiro.web.servlet.ShiroFilter;
 
 @Mixins( ShiroFilter.class )
-public interface ShiroFilterService
-        extends Filter
+public interface ShiroFilterService extends Filter
 {
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/libraries/shiro-web/src/main/java/org/apache/polygene/library/shiro/web/assembly/HttpShiroAssembler.java
----------------------------------------------------------------------
diff --git a/libraries/shiro-web/src/main/java/org/apache/polygene/library/shiro/web/assembly/HttpShiroAssembler.java b/libraries/shiro-web/src/main/java/org/apache/polygene/library/shiro/web/assembly/HttpShiroAssembler.java
index 0c0a5e0..94677ec 100644
--- a/libraries/shiro-web/src/main/java/org/apache/polygene/library/shiro/web/assembly/HttpShiroAssembler.java
+++ b/libraries/shiro-web/src/main/java/org/apache/polygene/library/shiro/web/assembly/HttpShiroAssembler.java
@@ -36,26 +36,27 @@ import static org.apache.polygene.library.http.Servlets.addFilters;
 import static org.apache.polygene.library.http.Servlets.filter;
 import static org.apache.polygene.library.http.Servlets.listen;
 
-public class HttpShiroAssembler
-    extends Assemblers.Config<HttpShiroAssembler>
+public class HttpShiroAssembler extends Assemblers.Config<HttpShiroAssembler>
 {
     @Override
     public void assemble( ModuleAssembly module )
         throws AssemblyException
     {
-        addContextListeners( listen().
-            with( EnvironmentLoaderService.class ) ).
-            to( module );
+        addContextListeners(
+            listen().with( EnvironmentLoaderService.class ) )
+            .to( module );
 
-        addFilters( filter( "/*" ).
-            through( ShiroFilterService.class ).
-            on( REQUEST, FORWARD, INCLUDE, ERROR, ASYNC ) ).
-            to( module );
+        addFilters(
+            filter( "/*" )
+                .through( ShiroFilterService.class )
+                .on( REQUEST, FORWARD, INCLUDE, ERROR, ASYNC ) )
+            .to( module );
 
         if( hasConfig() )
         {
-            configModule().entities( ShiroIniConfiguration.class ).
-                visibleIn( configVisibility() );
+            configModule()
+                .entities( ShiroIniConfiguration.class )
+                .visibleIn( configVisibility() );
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/tools/generator-polygene/app/index.js
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/index.js b/tools/generator-polygene/app/index.js
index e106698..a0531cf 100644
--- a/tools/generator-polygene/app/index.js
+++ b/tools/generator-polygene/app/index.js
@@ -28,6 +28,7 @@ var polygene = {};
 module.exports = generators.Base.extend(
     {
         constructor: function () {
+            console.log("WARNING!!!  This is BETA quality and likely to change drastically over time.");
             generators.Base.apply(this, arguments);
 
             this.option('import-model', {

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/tools/generator-polygene/app/templates/CommandLineApplication/application.java.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/CommandLineApplication/application.java.tmpl b/tools/generator-polygene/app/templates/CommandLineApplication/application.java.tmpl
new file mode 100644
index 0000000..3218593
--- /dev/null
+++ b/tools/generator-polygene/app/templates/CommandLineApplication/application.java.tmpl
@@ -0,0 +1,83 @@
+<%#
+ *  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 <%= polygene.packageName %>.app;
+
+import org.apache.polygene.api.structure.Application;
+import org.apache.polygene.bootstrap.layered.LayeredApplicationAssembler;
+
+import <%= polygene.packageName %>.bootstrap.<%= polygene.name %>Application;
+
+public class <%= polygene.name %>CommandLineApplication
+{
+    protected Application application;
+
+    private static final String NAME = "<%= polygene.name %>";
+    private static final String VERSION = "0.1";
+
+    public <%= polygene.name %>CommandLineApplication(String mode)
+        throws AssemblyException
+    {
+        createApplication(mode);
+    }
+
+    @Override
+    protected LayeredApplicationAssembler createApplicationAssembler( String mode )
+        throws AssemblyException
+    {
+        return new <%= polygene.name %>Application( NAME, VERSION, Application.Mode.valueOf( mode ));
+    }
+
+    private void createApplication( String mode )
+    {
+        try
+        {
+            LayeredApplicationAssembler assembler = createApplicationAssembler( mode );
+            assembler.initialize();
+            polygeneApplication = assembler.application();
+            setName( polygeneApplication.name() );
+        }
+        catch( Throwable e )
+        {
+            getLogger().log( Level.SEVERE, "Unable to start Polygene application.", e );
+            throw new InternalError( "Unable to start Polygene application.", e );
+        }
+    }
+
+    @Override
+    public void start()
+        throws Exception
+    {
+        application.activate();
+    }
+
+    @Override
+    public void stop()
+        throws Exception
+    {
+        application.passivate();
+    }
+
+    public static void main( String[] args )
+    {
+        <%= polygene.name %>CommandLineApplication app = new <%= polygene.name %>CommandLineApplication("development");
+        Runtime.getRuntime().addShutdownHook( new Thread( () -> app.stop() ) );
+        app.start();
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/tools/generator-polygene/app/templates/CommandLineApplication/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/CommandLineApplication/bootstrap.tmpl b/tools/generator-polygene/app/templates/CommandLineApplication/bootstrap.tmpl
new file mode 100644
index 0000000..8abe510
--- /dev/null
+++ b/tools/generator-polygene/app/templates/CommandLineApplication/bootstrap.tmpl
@@ -0,0 +1,49 @@
+<%#
+ *  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 <%= polygene.packageName %>.bootstrap;
+
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.ApplicationAssembly;
+import org.apache.polygene.bootstrap.LayerAssembly;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.bootstrap.layered.LayeredApplicationAssembler;
+
+public class <%= polygene.name %>Application extends LayeredApplicationAssembler
+{
+    public <%= polygene.name %>Application( String name, String version, Application.Mode mode )
+        throws AssemblyException
+    {
+        super( name, version, mode );
+    }
+
+    @Override
+    protected void assembleLayers( ApplicationAssembly assembly )
+        throws AssemblyException
+    {
+        LayerAssembly config = this.createLayer( ConfigurationLayer.class );
+        ModuleAssembly configModule = assemblerOf( ConfigurationLayer.class ).configModule();
+        LayerAssembly infra = new InfrastructureLayer(configModule).assemble( assembly.layer( InfrastructureLayer.NAME ) );
+        LayerAssembly domain = this.createLayer( DomainLayer.class );
+        LayerAssembly ui = this.createLayer( UserInterfaceLayer.class );
+        ui.uses( domain );
+        domain.uses( infra );
+        infra.uses( config );
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/tools/generator-polygene/app/templates/ConnectivityLayer/HttpServerModule/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/ConnectivityLayer/HttpServerModule/bootstrap.tmpl b/tools/generator-polygene/app/templates/ConnectivityLayer/HttpServerModule/bootstrap.tmpl
new file mode 100644
index 0000000..719e567
--- /dev/null
+++ b/tools/generator-polygene/app/templates/ConnectivityLayer/HttpServerModule/bootstrap.tmpl
@@ -0,0 +1,94 @@
+<%#
+ *  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 <%= polygene.packageName %>.bootstrap.connectivity;
+
+import java.io.File;
+import java.util.HashMap;
+import javax.servlet.Servlet;
+<% if( hasFeature('security') ) { %>
+import org.apache.polygene.library.http.SecureJettyConfiguration;
+import org.apache.polygene.library.http.SecureJettyServiceAssembler;
+import org.apache.polygene.library.shiro.web.assembly.HttpShiroAssembler;
+import org.apache.polygene.library.shiro.ini.ShiroIniConfiguration;
+<% } else { %>
+import org.apache.polygene.library.http.JettyConfiguration;
+import org.apache.polygene.library.http.JettyServiceAssembler;
+<% } %>
+import org.apache.polygene.api.common.Visibility;
+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;
+import org.restlet.ext.servlet.ServerServlet;
+
+import <%= polygene.packageName %>.rest.<%= polygene.name %>RestApplication;
+
+import static org.apache.polygene.library.http.Servlets.addServlets;
+import static org.apache.polygene.library.http.Servlets.serve;
+
+public class HttpServerModule
+    implements ModuleAssembler
+{<% if( hasFeature('security') ) { %>
+    private static final int DEFAULT_PORT = 8443;
+    public static final String KS_PASSWORD = "1234";  // TODO: Secure the key stores
+    public static final String SERVER_KEYSTORE_FILENAME = "security/<%= polygene.name.toLowerCase() %>-app.key";
+    public static final String SERVER_KEYSTORE_TYPE = "JCEKS";
+    public static final String TRUSTSTORE_FILENAME = "security/<%= polygene.name.toLowerCase() %>-app.key";
+    public static final String TRUSTSTORE_TYPE = "JCEKS";
+<% } else {
+%>    protected static final int DEFAULT_PORT = 8080;
+<% } %>
+    public static String NAME = "HTTP Server Module";
+
+    @Override
+    public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+        throws AssemblyException
+    {
+<% if( hasFeature('security') ) {
+%>        new HttpShiroAssembler()
+            .withConfig( module, Visibility.module );
+        module.forMixin( ShiroIniConfiguration.class ).declareDefaults().iniResourcePath().set("web-shiro.ini");
+        new SecureJettyServiceAssembler()
+            .withConfig( module, Visibility.layer )
+            .visibleIn( Visibility.layer )
+            .assemble( module );
+
+        module.services( Servlet.class ).withMixins( ServerServlet.class );
+
+        SecureJettyConfiguration defaults = module.forMixin( SecureJettyConfiguration.class ).declareDefaults();
+        defaults.keystorePath().set( new File( SERVER_KEYSTORE_FILENAME ).getAbsolutePath() );
+        defaults.keystoreType().set( "JCEKS" );
+        defaults.keystorePassword().set( KS_PASSWORD );
+        defaults.truststorePath().set( new File( TRUSTSTORE_FILENAME ).getAbsolutePath() );
+        defaults.truststoreType().set( TRUSTSTORE_TYPE );
+        defaults.truststorePassword().set( KS_PASSWORD );
+        defaults.wantClientAuth().set( Boolean.FALSE );
+<% } else {
+%>        new JettyServiceAssembler().assemble( module );
+        JettyConfiguration defaults = module.forMixin( JettyConfiguration.class ).declareDefaults();
+<% } %>
+        defaults.hostName().set( System.getProperty( "<%= polygene.name.toLowerCase() %>.http.servername", "127.0.0.1" ));
+        defaults.port().set( DEFAULT_PORT );
+        HashMap<String, String> initParams = new HashMap<>();
+        initParams.put("org.restlet.application", <%= polygene.name %>RestApplication.class.getName() );
+        addServlets( serve( "/" ).with(Servlet.class ).withInitParams( initParams ) ).to( module );
+        return module;
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/tools/generator-polygene/app/templates/ConnectivityLayer/HttpServerModule/module.js
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/ConnectivityLayer/HttpServerModule/module.js b/tools/generator-polygene/app/templates/ConnectivityLayer/HttpServerModule/module.js
new file mode 100644
index 0000000..4d9835a
--- /dev/null
+++ b/tools/generator-polygene/app/templates/ConnectivityLayer/HttpServerModule/module.js
@@ -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.
+ */
+
+module.exports = {
+
+    write: function (p) {
+        if (p.applicationtype === 'Rest API') {
+            p.copyTemplate(p.ctx,
+                'ConnectivityLayer/HttpServerModule/bootstrap.tmpl',
+                'bootstrap/src/main/java/' + p.javaPackageDir + '/bootstrap/connectivity/HttpServerModule.java');
+        }
+    }
+};
+

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/DefaultEnroler.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/DefaultEnroler.tmpl b/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/DefaultEnroler.tmpl
index 31d4588..806e006 100644
--- a/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/DefaultEnroler.tmpl
+++ b/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/DefaultEnroler.tmpl
@@ -19,8 +19,8 @@
 %>
 package <%= polygene.packageName %>.rest.security;
 
-import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 import org.apache.polygene.api.injection.scope.Service;
 import org.apache.polygene.api.injection.scope.Uses;
 import org.restlet.Application;
@@ -45,8 +45,9 @@ public class DefaultEnroler
         org.restlet.security.User user = clientInfo.getUser();
         String name = user.getName();
         List<String> roleList = repository.findRoleNamesOfUser( name );
-        List<Role> restletRoles = new ArrayList<>();
-        roleList.stream().map( roleName -> Role.get( application, roleName ) );
+        List<Role> restletRoles = roleList.stream()
+                                          .map( roleName -> Role.get( application, roleName ) )
+                                          .collect( Collectors.toList() );
         clientInfo.setRoles( restletRoles );
     }
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/tools/generator-polygene/app/templates/ConnectivityLayer/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/ConnectivityLayer/bootstrap.tmpl b/tools/generator-polygene/app/templates/ConnectivityLayer/bootstrap.tmpl
index 5623b6f..325f3ea 100644
--- a/tools/generator-polygene/app/templates/ConnectivityLayer/bootstrap.tmpl
+++ b/tools/generator-polygene/app/templates/ConnectivityLayer/bootstrap.tmpl
@@ -27,13 +27,14 @@ import org.apache.polygene.bootstrap.layered.LayeredLayerAssembler;
 public class ConnectivityLayer extends LayeredLayerAssembler
     implements LayerAssembler
 {
-    public static String NAME;
+    public static String NAME = "Connectivity Layer";
 
     @Override
     public LayerAssembly assemble( LayerAssembly layer )
         throws AssemblyException
     {
         createModule( layer, RestApiModule.class );
+        createModule( layer, HttpServerModule.class );
         return layer;
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Crud.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Crud.tmpl b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Crud.tmpl
index 60d7528..51e508d 100644
--- a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Crud.tmpl
+++ b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Crud.tmpl
@@ -19,6 +19,7 @@
 -%>
 package <%= polygene.packageName %>.model.<%= polygene.current.name %>;
 
+import org.apache.polygene.api.identity.HasIdentity;
 import org.apache.polygene.api.injection.scope.This;
 import org.apache.polygene.api.mixin.Mixins;
 <%
@@ -31,7 +32,7 @@ for( var imp in polygene.current.imported ) {
 } %>
 
 @Mixins( { <%= polygene.current.clazz.name %>.Mixin.class } )
-public interface <%= polygene.current.clazz.name %>
+public interface <%= polygene.current.clazz.name %> extends HasIdentity
 {
     interface State
     {
@@ -40,7 +41,7 @@ public interface <%= polygene.current.clazz.name %>
 <% }
 %>    }
 
-    class Mixin
+    abstract class Mixin
         implements <%= polygene.current.clazz.name %>
     {
         @This

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Entity.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Entity.tmpl b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Entity.tmpl
index 60d7528..51e508d 100644
--- a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Entity.tmpl
+++ b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Entity.tmpl
@@ -19,6 +19,7 @@
 -%>
 package <%= polygene.packageName %>.model.<%= polygene.current.name %>;
 
+import org.apache.polygene.api.identity.HasIdentity;
 import org.apache.polygene.api.injection.scope.This;
 import org.apache.polygene.api.mixin.Mixins;
 <%
@@ -31,7 +32,7 @@ for( var imp in polygene.current.imported ) {
 } %>
 
 @Mixins( { <%= polygene.current.clazz.name %>.Mixin.class } )
-public interface <%= polygene.current.clazz.name %>
+public interface <%= polygene.current.clazz.name %> extends HasIdentity
 {
     interface State
     {
@@ -40,7 +41,7 @@ public interface <%= polygene.current.clazz.name %>
 <% }
 %>    }
 
-    class Mixin
+    abstract class Mixin
         implements <%= polygene.current.clazz.name %>
     {
         @This

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/tools/generator-polygene/app/templates/DomainLayer/JmxModule/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/DomainLayer/JmxModule/bootstrap.tmpl b/tools/generator-polygene/app/templates/DomainLayer/JmxModule/bootstrap.tmpl
index e0f3ade..8a9a96f 100644
--- a/tools/generator-polygene/app/templates/DomainLayer/JmxModule/bootstrap.tmpl
+++ b/tools/generator-polygene/app/templates/DomainLayer/JmxModule/bootstrap.tmpl
@@ -17,14 +17,12 @@
  *
  *
 -%>
-package <%= polygene.packageName %>.bootstrap.config;
+package <%= polygene.packageName %>.bootstrap.domain;
 
-import org.apache.polygene.api.common.Visibility;
 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;
-import org.apache.polygene.entitystore.memory.MemoryEntityStoreService;
 import org.apache.polygene.library.jmx.JMXAssembler;
 import org.apache.polygene.library.jmx.JMXConnectorService;
 import org.apache.polygene.library.jmx.JMXConnectorConfiguration;

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/bootstrap.tmpl b/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/bootstrap.tmpl
index e60c563..5f420a0 100644
--- a/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/bootstrap.tmpl
+++ b/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/bootstrap.tmpl
@@ -24,11 +24,6 @@ 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;
-import org.apache.polygene.library.shiro.assembly.PasswordDomainAssembler;
-import org.apache.polygene.library.shiro.assembly.PermissionsDomainAssembler;
-import org.apache.polygene.library.shiro.assembly.StandaloneShiroAssembler;
-import org.apache.polygene.library.shiro.ini.ShiroIniConfiguration;
-import <%= polygene.packageName %>.model.security.RealmService;
 import <%= polygene.packageName %>.model.security.SecurityRepository;
 import <%= polygene.packageName %>.model.security.User;
 import <%= polygene.packageName %>.model.security.UserFactory;
@@ -46,21 +41,6 @@ public class SecurityModule
             .visibleIn( Visibility.application )
             .instantiateOnStartup();
 
-        new StandaloneShiroAssembler()
-            .withConfig( module, Visibility.layer )
-            .assemble( module );
-        module.services( RealmService.class );
-
-        module.forMixin( ShiroIniConfiguration.class )
-            .declareDefaults()
-            .iniResourcePath().set( "classpath:standalone-shiro.ini" );
-
-        new PasswordDomainAssembler()
-            .withConfig( module, Visibility.layer )
-            .assemble( module );
-
-        new PermissionsDomainAssembler().assemble( module );
-
         module.entities( User.class );
         module.services( UserFactory.class );
 

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/tools/generator-polygene/app/templates/InfrastructureLayer/IndexingModule/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/InfrastructureLayer/IndexingModule/bootstrap.tmpl b/tools/generator-polygene/app/templates/InfrastructureLayer/IndexingModule/bootstrap.tmpl
index 6648c9f..0b050aa 100644
--- a/tools/generator-polygene/app/templates/InfrastructureLayer/IndexingModule/bootstrap.tmpl
+++ b/tools/generator-polygene/app/templates/InfrastructureLayer/IndexingModule/bootstrap.tmpl
@@ -32,7 +32,7 @@ public class <%- polygene.indexing %>IndexingModule
     public static final String NAME = "<%- polygene.indexing %> Indexing Module";
     private final ModuleAssembly configModule;
 
-    public <%- polygene.indexing %>IndexingModule( ModuleAssembly configModule )
+    <%- polygene.indexing %>IndexingModule( ModuleAssembly configModule )
     {
         this.configModule = configModule;
     }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/tools/generator-polygene/app/templates/InfrastructureLayer/MetricsModule/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/InfrastructureLayer/MetricsModule/bootstrap.tmpl b/tools/generator-polygene/app/templates/InfrastructureLayer/MetricsModule/bootstrap.tmpl
index d06c9cc..12d55f2 100644
--- a/tools/generator-polygene/app/templates/InfrastructureLayer/MetricsModule/bootstrap.tmpl
+++ b/tools/generator-polygene/app/templates/InfrastructureLayer/MetricsModule/bootstrap.tmpl
@@ -19,7 +19,6 @@
 -%>
 package <%= polygene.packageName %>.bootstrap.infrastructure;
 
-import org.apache.polygene.api.common.Visibility;
 import org.apache.polygene.bootstrap.AssemblyException;
 import org.apache.polygene.bootstrap.LayerAssembly;
 import org.apache.polygene.bootstrap.ModuleAssembly;
@@ -30,12 +29,6 @@ public class <%- polygene.metrics %>MetricsModule
     implements ModuleAssembler
 {
     public static final String NAME = "<%- polygene.metrics %> Metrics Module";
-    private final ModuleAssembly configModule;
-
-    public <%- polygene.metrics %>MetricsModule( ModuleAssembly configModule )
-    {
-        this.configModule = configModule;
-    }
 
     @Override
     public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/tools/generator-polygene/app/templates/InfrastructureLayer/StorageModule/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/InfrastructureLayer/StorageModule/bootstrap.tmpl b/tools/generator-polygene/app/templates/InfrastructureLayer/StorageModule/bootstrap.tmpl
index 1583636..151dfab 100644
--- a/tools/generator-polygene/app/templates/InfrastructureLayer/StorageModule/bootstrap.tmpl
+++ b/tools/generator-polygene/app/templates/InfrastructureLayer/StorageModule/bootstrap.tmpl
@@ -32,7 +32,7 @@ public class <%- polygene.entitystore %>StorageModule
     public static final String NAME = "<%- polygene.entitystore %> Storage Module";
     private final ModuleAssembly configModule;
 
-    public <%- polygene.entitystore %>StorageModule( ModuleAssembly configModule )
+    <%- polygene.entitystore %>StorageModule( ModuleAssembly configModule )
     {
         this.configModule = configModule;
     }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/tools/generator-polygene/app/templates/RestAPIApplication/DevelopmentKeyManagement.java.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/RestAPIApplication/DevelopmentKeyManagement.java.tmpl b/tools/generator-polygene/app/templates/RestAPIApplication/DevelopmentKeyManagement.java.tmpl
new file mode 100644
index 0000000..d82eec5
--- /dev/null
+++ b/tools/generator-polygene/app/templates/RestAPIApplication/DevelopmentKeyManagement.java.tmpl
@@ -0,0 +1,243 @@
+<%#
+ *  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 <%= polygene.packageName %>.app;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.math.BigInteger;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.Provider;
+import java.security.PublicKey;
+import java.security.Security;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.X509Certificate;
+import java.util.Date;
+import javax.net.ssl.KeyManagerFactory;
+import javax.security.auth.x500.X500Principal;
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.bouncycastle.asn1.ASN1ObjectIdentifier;
+import org.bouncycastle.asn1.x500.X500Name;
+import org.bouncycastle.asn1.x509.BasicConstraints;
+import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter;
+import org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder;
+import org.bouncycastle.jce.X509KeyUsage;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.bouncycastle.openssl.jcajce.JcaPEMWriter;
+import org.bouncycastle.operator.ContentSigner;
+import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
+import org.bouncycastle.pkcs.PKCS10CertificationRequest;
+import org.bouncycastle.pkcs.PKCS10CertificationRequestBuilder;
+import org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequestBuilder;
+
+import static <%= polygene.packageName %>.bootstrap.connectivity.HttpServerModule.*;
+
+/**
+ * This class creates self-signed SSL certificate into the security/ directory.
+ * <p>
+ * NOTE: This is for use in development only. For production setup, please use better tooling.
+ * </p>
+ */
+class DevelopmentKeyManagement
+{
+    private static final String COMMON_NAME = "<%= polygene.packageName %>";
+    private static final int RSA_KEY_LEN = 4096;
+
+    static void initializeKeyStore()
+    {
+        @SuppressWarnings( "unused" )
+        KeyStore trustStore = loadKeyStore( new File(TRUSTSTORE_FILENAME), TRUSTSTORE_TYPE, KS_PASSWORD );
+
+        KeyStore keyStore = loadKeyStore( new File(SERVER_KEYSTORE_FILENAME), SERVER_KEYSTORE_TYPE, KS_PASSWORD );
+        initializeKeyManager( keyStore, KS_PASSWORD );
+        createKeyStoreData( keyStore );
+    }
+
+    private static KeyStore loadKeyStore( File keyFile, String type, String password )
+    {
+        if( !keyFile.exists() )
+        {
+            return createKeyStore(keyFile, type, password);
+        }
+        try( FileInputStream fis = new FileInputStream( keyFile ) )
+        {
+            KeyStore ks = KeyStore.getInstance( type );
+            char[] pwd = password.toCharArray();
+            ks.load( fis, pwd );
+            return ks;
+        }
+        catch( Exception e )
+        {
+            throw new AssemblyException( "Unable to create keystore.", e );
+        }
+    }
+
+    @SuppressWarnings( "ResultOfMethodCallIgnored" )
+    private static KeyStore createKeyStore( File keyFile, String type, String password )
+        throws AssemblyException
+    {
+        if( !keyFile.getParentFile().exists() )
+        {
+            keyFile.getParentFile().mkdirs();
+        }
+        try( FileOutputStream fos = new FileOutputStream( keyFile ) )
+        {
+            KeyStore ks = KeyStore.getInstance( type );
+            char[] pwd = password.toCharArray();
+            ks.load( null, pwd );
+            ks.store( fos, pwd );
+            return ks;
+        }
+        catch( Exception e )
+        {
+            throw new AssemblyException( "Unable to create keystore.", e );
+        }
+    }
+
+    private static void initializeKeyManager( KeyStore keyStore, String password )
+    {
+        try
+        {
+            KeyManagerFactory kmf = KeyManagerFactory.getInstance( KeyManagerFactory.getDefaultAlgorithm() );
+            kmf.init( keyStore, password.toCharArray() );
+        }
+        catch( NoSuchAlgorithmException | KeyStoreException | UnrecoverableKeyException e )
+        {
+            throw new AssemblyException( "Unable to initialize KeyManager.", e );
+        }
+    }
+
+    private static void createKeyStoreData( KeyStore keyStore )
+    {
+        try
+        {
+            if( keyStore.getCertificate( COMMON_NAME ) != null )
+            {
+                return;
+            }
+            KeyPair keyPair = generateKeyPair();
+            X509Certificate certificate = selfSignedCertificate( keyPair, COMMON_NAME, 30 );
+            keyStore.setCertificateEntry( COMMON_NAME, certificate );
+
+            System.out.println("Created Self-signed certificated:");
+            System.out.println(convertCertificateToPEM( certificate ));
+        }
+        catch( KeyStoreException e )
+        {
+            throw new AssemblyException( "Unable to store certificate in keystore.", e );
+        }
+    }
+
+    private static KeyPair generateKeyPair()
+    {
+        try
+        {
+            KeyPairGenerator keyGen = KeyPairGenerator.getInstance( "RSA" );
+            keyGen.initialize( RSA_KEY_LEN );
+            return keyGen.generateKeyPair();
+        }
+        catch( NoSuchAlgorithmException e )
+        {
+            throw new AssemblyException( "RSA encryption is not available on this system.", e );
+        }
+    }
+
+    @SuppressWarnings( "unused" )
+    private static PKCS10CertificationRequest generateCSR( KeyPair pair, String subjectDN )
+    {
+        try
+        {
+            X500Principal subject = new X500Principal( "CN=" + subjectDN );
+            PublicKey publicKey = pair.getPublic();
+            PKCS10CertificationRequestBuilder p10Builder = new JcaPKCS10CertificationRequestBuilder( subject, publicKey );
+            JcaContentSignerBuilder csBuilder = new JcaContentSignerBuilder( "SHA256withRSA" );
+            ContentSigner signer = csBuilder.build( pair.getPrivate() );
+            return p10Builder.build( signer );
+        }
+        catch( Exception e )
+        {
+            throw new AssemblyException( "Unable to generate Certificate Signing Request", e );
+        }
+    }
+
+    private static String convertCertificateToPEM( X509Certificate signedCertificate )
+    {
+        try( StringWriter signedCertificatePEMDataStringWriter = new StringWriter() )
+        {
+            JcaPEMWriter pemWriter = new JcaPEMWriter( signedCertificatePEMDataStringWriter );
+            pemWriter.writeObject( signedCertificate );
+            pemWriter.close();
+            return signedCertificatePEMDataStringWriter.toString();
+        }
+        catch( IOException e )
+        {
+            throw new AssemblyException( "Unable to convert certificate to PEM string.", e );
+        }
+    }
+
+    private static X509Certificate selfSignedCertificate( KeyPair keyPair, String subjectDN, @SuppressWarnings( "SameParameterValue" ) int days )
+    {
+        try
+        {
+            Provider bcProvider = new BouncyCastleProvider();
+            Security.addProvider( bcProvider );
+
+            long now = System.currentTimeMillis();
+            Date startDate = new Date( now );
+            Date endDate = new Date( now + days * 25 * 3_600_000L );
+
+            X500Name dnName = new X500Name( "CN=" + subjectDN );
+            BigInteger certSerialNumber = new BigInteger( Long.toString( now ) );
+            String signatureAlgorithm = "SHA256WithRSA"; // <-- Use appropriate signature algorithm based on your keyPair algorithm.
+            ContentSigner contentSigner = new JcaContentSignerBuilder( signatureAlgorithm ).build( keyPair.getPrivate() );
+            JcaX509v3CertificateBuilder certBuilder =
+                new JcaX509v3CertificateBuilder( dnName, certSerialNumber, startDate, endDate, dnName, keyPair.getPublic() );
+
+            // Basic Constraints
+            certBuilder.addExtension(
+                new ASN1ObjectIdentifier( "2.5.29.19" ),
+                true,
+                new BasicConstraints( true ) ); // Basic Constraints is usually marked as critical.
+
+            // Key Usage constraints
+            certBuilder.addExtension(
+                new ASN1ObjectIdentifier( "2.5.29.15" ),
+                true,
+                new X509KeyUsage(
+                    X509KeyUsage.digitalSignature |
+                    X509KeyUsage.keyCertSign |
+                    X509KeyUsage.nonRepudiation |
+                    X509KeyUsage.keyEncipherment |
+                    X509KeyUsage.dataEncipherment ) );
+
+            return new JcaX509CertificateConverter().setProvider( bcProvider ).getCertificate( certBuilder.build( contentSigner ) );
+        }
+        catch( Exception e )
+        {
+            throw new AssemblyException( "Unable to self-sign certificate.", e );
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/tools/generator-polygene/app/templates/RestAPIApplication/Launcher.java.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/RestAPIApplication/Launcher.java.tmpl b/tools/generator-polygene/app/templates/RestAPIApplication/Launcher.java.tmpl
new file mode 100644
index 0000000..c6c5707
--- /dev/null
+++ b/tools/generator-polygene/app/templates/RestAPIApplication/Launcher.java.tmpl
@@ -0,0 +1,66 @@
+<%#
+ *  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 <%= polygene.packageName %>.app;
+
+import <%= polygene.packageName %>.bootstrap.<%= polygene.name %>ApplicationAssembler;
+import <%= polygene.packageName %>.bootstrap.connectivity.ConnectivityLayer;
+import <%= polygene.packageName %>.bootstrap.connectivity.RestApiModule;
+
+import org.apache.polygene.api.structure.Application;
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.layered.LayeredApplicationAssembler;
+import org.apache.polygene.library.restlet.PolygeneRestApplicationLauncher;
+
+public class <%= polygene.name %>Launcher extends PolygeneRestApplicationLauncher
+{
+    private static final String name = "<%= polygene.name %>";
+    private static final String version = "0.1";
+    private Application.Mode mode = Application.Mode.development;
+
+    public static void main( String[] args )
+        throws Exception
+    {
+        <%= polygene.name %>Launcher app = new <%= polygene.name %>Launcher();
+        app.installShutdownHook();
+        app.initialize();
+    }
+
+    protected LayeredApplicationAssembler createApplicationAssembler()
+        throws AssemblyException
+    {
+<% if( polygene.hasFeature( 'security' ) ) {
+%>        if( mode == Application.Mode.development )
+        {
+            DevelopmentKeyManagement.initializeKeyStore();
+        }
+<% }
+%>        return new <%= polygene.name %>ApplicationAssembler( name, version, mode );
+    }
+
+    protected String entryLayer()
+    {
+        return ConnectivityLayer.NAME;
+    }
+
+    protected String entryModule()
+    {
+        return RestApiModule.NAME;
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/tools/generator-polygene/app/templates/RestAPIApplication/app.js
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/RestAPIApplication/app.js b/tools/generator-polygene/app/templates/RestAPIApplication/app.js
index 80380c7..e231d11 100644
--- a/tools/generator-polygene/app/templates/RestAPIApplication/app.js
+++ b/tools/generator-polygene/app/templates/RestAPIApplication/app.js
@@ -25,8 +25,25 @@ module.exports = {
         copyLayer(p, "Connectivity");
 
         p.copyTemplate(p.ctx,
-            'RestAPIApplication/web.xml.tmpl',
-            'app/src/main/webapp/WEB-INF/web.xml');
+            'RestAPIApplication/application.java.tmpl',
+            'rest/src/main/java/' + p.javaPackageDir + '/rest/' + p.name + 'RestApplication.java');
+
+        p.copyTemplate(p.ctx,
+            'RestAPIApplication/Launcher.java.tmpl',
+            'app/src/main/java/' + p.javaPackageDir + '/app/' + p.name + 'Launcher.java');
+
+        if (p.hasFeature('security')) {
+            p.copyTemplate(p.ctx,
+                'RestAPIApplication/DevelopmentKeyManagement.java.tmpl',
+                'app/src/main/java/' + p.javaPackageDir + '/app/DevelopmentKeyManagement.java');
+            p.copyTemplate(p.ctx,
+                'RestAPIApplication/web-shiro.ini.tmpl',
+                'app/src/main/resources/web-shiro.ini');
+        }
+
+        p.copyTemplate(p.ctx,
+            'RestAPIApplication/bootstrap.tmpl',
+            'bootstrap/src/main/java/' + p.javaPackageDir + '/bootstrap/' + p.name + 'ApplicationAssembler.java');
     }
 };
 
@@ -34,3 +51,4 @@ function copyLayer(p, layerName) {
     var layer = require(__dirname + '/../' + layerName + 'Layer/layer.js');
     layer.write(p);
 }
+

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/tools/generator-polygene/app/templates/RestAPIApplication/application.java.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/RestAPIApplication/application.java.tmpl b/tools/generator-polygene/app/templates/RestAPIApplication/application.java.tmpl
new file mode 100644
index 0000000..1a74136
--- /dev/null
+++ b/tools/generator-polygene/app/templates/RestAPIApplication/application.java.tmpl
@@ -0,0 +1,86 @@
+<%#
+ *  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 <%= polygene.packageName %>.rest;
+
+import org.apache.polygene.library.restlet.PolygeneRestApplication;
+import org.restlet.Context;
+import org.restlet.routing.Router;
+import org.restlet.security.Enroler;
+import org.restlet.security.Verifier;
+
+<%
+for( var moduleName in polygene.modules) {
+    var module = polygene.modules[moduleName];
+    for( var idx2 in module.cruds ) {
+        var crud = module.cruds[idx2];
+%>import <%= polygene.packageName %>.model.<%= moduleName %>.<%= crud.name %>;
+<%
+    }
+}%>
+<% if( hasFeature('security') ) { %>
+import <%= polygene.packageName %>.rest.security.DefaultEnroler;
+import <%= polygene.packageName %>.rest.security.DefaultVerifier;
+<% } else { %>
+import <%= polygene.packageName %>.rest.security.NullEnroler;
+import <%= polygene.packageName %>.rest.security.NullVerifier;
+<% } %>
+public class <%= polygene.name %>RestApplication extends PolygeneRestApplication
+{
+    private static final String BASEPATH = "/<%= polygene.name.toLowerCase() %>/";
+
+    public <%= polygene.name %>RestApplication( Context context )
+    {
+        super( context );
+    }
+
+    @Override
+    protected void addRoutes( Router router )
+    {
+<%
+for( var moduleName in polygene.modules) {
+    var module = polygene.modules[moduleName];
+    for( var idx2 in module.cruds ) {
+        var crud = module.cruds[idx2];
+%>        addResourcePath( "<%= crud.name.toLowerCase() %>", <%= crud.name %>.class, BASEPATH );
+<%
+    }
+}
+%>        System.out.println( "REST API defined;" );
+        printRoutes( System.out );
+    }
+
+    protected Verifier createVerifier()
+    {
+<% if( hasFeature('security') ) {
+%>        return objectFactory.newObject(DefaultVerifier.class, this);
+<% } else {
+%>        return objectFactory.newObject(NullVerifier.class, this);
+<% }
+%>    }
+
+    protected Enroler createEnroler()
+    {
+<% if( hasFeature('security') ) {
+%>        return objectFactory.newObject(DefaultEnroler.class, this);
+<% } else {
+%>        return objectFactory.newObject(NullEnroler.class, this);
+<% }
+%>    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/tools/generator-polygene/app/templates/RestAPIApplication/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/RestAPIApplication/bootstrap.tmpl b/tools/generator-polygene/app/templates/RestAPIApplication/bootstrap.tmpl
new file mode 100644
index 0000000..f8e247a
--- /dev/null
+++ b/tools/generator-polygene/app/templates/RestAPIApplication/bootstrap.tmpl
@@ -0,0 +1,56 @@
+<%#
+ *  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 <%= polygene.packageName %>.bootstrap;
+
+import org.apache.polygene.api.structure.Application;
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.ApplicationAssembly;
+import org.apache.polygene.bootstrap.LayerAssembly;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.bootstrap.layered.LayeredApplicationAssembler;
+
+import <%= polygene.packageName %>.bootstrap.connectivity.ConnectivityLayer;
+import <%= polygene.packageName %>.bootstrap.config.ConfigurationLayer;
+import <%= polygene.packageName %>.bootstrap.domain.DomainLayer;
+import <%= polygene.packageName %>.bootstrap.infrastructure.InfrastructureLayer;
+
+public class <%= polygene.name %>ApplicationAssembler extends LayeredApplicationAssembler
+{
+    public <%= polygene.name %>ApplicationAssembler( String name, String version, Application.Mode mode )
+        throws AssemblyException
+    {
+        super( name, version, mode );
+    }
+
+    @Override
+    protected void assembleLayers( ApplicationAssembly assembly )
+        throws AssemblyException
+    {
+        LayerAssembly config = this.createLayer( ConfigurationLayer.class );
+        ModuleAssembly configModule = assemblerOf( ConfigurationLayer.class ).configModule();
+        LayerAssembly infra = new InfrastructureLayer(configModule).assemble( assembly.layer( InfrastructureLayer.NAME ) );
+        LayerAssembly domain = this.createLayer( DomainLayer.class );
+        LayerAssembly connect = this.createLayer( ConnectivityLayer.class );
+        connect.uses( domain );
+        connect.uses( infra );
+        domain.uses( infra );
+        infra.uses( config );
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/tools/generator-polygene/app/templates/RestAPIApplication/web-shiro.ini.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/RestAPIApplication/web-shiro.ini.tmpl b/tools/generator-polygene/app/templates/RestAPIApplication/web-shiro.ini.tmpl
new file mode 100644
index 0000000..7ebfeb3
--- /dev/null
+++ b/tools/generator-polygene/app/templates/RestAPIApplication/web-shiro.ini.tmpl
@@ -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.
+
+# =============================================================================
+# Tutorial INI configuration
+#
+# Usernames/passwords are based on the classic Mel Brooks' film "Spaceballs" :)
+# =============================================================================
+
+# -----------------------------------------------------------------------------
+# Users and their (optional) assigned roles
+# username = password, role1, role2, ..., roleN
+# -----------------------------------------------------------------------------
+[users]
+root = secret, admin
+guest = guest, guest
+presidentskroob = 12345, president
+darkhelmet = ludicrousspeed, darklord, schwartz
+lonestarr = vespa, goodguy, schwartz
+
+# -----------------------------------------------------------------------------
+# Roles with assigned permissions
+# roleName = perm1, perm2, ..., permN
+# -----------------------------------------------------------------------------
+[roles]
+admin = *
+schwartz = lightsaber:*
+goodguy = winnebago:drive:eagle5
+
+[urls]
+/ = authcBasic
+/** = authcBasic

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/tools/generator-polygene/app/templates/RestAPIApplication/web.xml.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/RestAPIApplication/web.xml.tmpl b/tools/generator-polygene/app/templates/RestAPIApplication/web.xml.tmpl
deleted file mode 100644
index bdc6301..0000000
--- a/tools/generator-polygene/app/templates/RestAPIApplication/web.xml.tmpl
+++ /dev/null
@@ -1,46 +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.
-  ~
-  ~
-%><?xml version="1.0" encoding="UTF-8"?>
-<web-app xmlns="http://java.sun.com/xml/ns/javaee"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
-         version="2.5">
-
-    <display-name><%= polygene.name %></display-name>
-<% if( polygene.hasFeature( "security" )) { %>
-    <listener>
-        <listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
-    </listener>
-<% } %>
-<% if( polygene.hasFeature( "security" ) ) { %>
-    <filter>
-        <filter-name>ShiroFilter</filter-name>
-        <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
-    </filter>
-<% } %>
-<% if( polygene.hasFeature( "security" ) ) { %>
-    <!-- Filter all web requests.  This filter mapping is typically declared
-        before all others to ensure any other filters are secured as well: -->
-    <filter-mapping>
-        <filter-name>ShiroFilter</filter-name>
-        <url-pattern>/*</url-pattern>
-    </filter-mapping>
-<% } %>
-
-</web-app>

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/tools/generator-polygene/app/templates/UserInterfaceLayer/CommandLineModule/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/UserInterfaceLayer/CommandLineModule/bootstrap.tmpl b/tools/generator-polygene/app/templates/UserInterfaceLayer/CommandLineModule/bootstrap.tmpl
index eb158c8..244cc2c 100644
--- a/tools/generator-polygene/app/templates/UserInterfaceLayer/CommandLineModule/bootstrap.tmpl
+++ b/tools/generator-polygene/app/templates/UserInterfaceLayer/CommandLineModule/bootstrap.tmpl
@@ -32,7 +32,7 @@ public class CommandLineModule
     public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
         throws AssemblyException
     {
-        // AUTO-GENERATION not supported yet.
+        // AUTO-GENERATION not fully supported yet.
         return module;
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a9de6c65/tools/generator-polygene/app/templates/buildtool/gradle-app.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/buildtool/gradle-app.tmpl b/tools/generator-polygene/app/templates/buildtool/gradle-app.tmpl
index 623ee78..6a830e6 100644
--- a/tools/generator-polygene/app/templates/buildtool/gradle-app.tmpl
+++ b/tools/generator-polygene/app/templates/buildtool/gradle-app.tmpl
@@ -18,25 +18,25 @@
  *
 -%>
 
-plugins {
-  id 'war'
-  id "org.akhikhl.gretty" version "1.4.0"
-}
-
 dependencies {
   compile project( ":bootstrap" )
   compile project( ":model" )
 <% if( polygene.applicationtype === 'Rest API' ) {
 %>  compile project( ":rest" )<% } %>
-
-  compile "org.apache.polygene.core:org.apache.polygene.core.spi:$polygeneVersion"
+<% if( hasFeature( 'security' ) ) {
+%>  compile "org.apache.polygene.libraries:org.apache.polygene.library.shiro-web:$polygeneVersion"
+<% }
+%>  compile "org.apache.polygene.core:org.apache.polygene.core.spi:$polygeneVersion"
   compile "org.apache.polygene.core:org.apache.polygene.core.bootstrap:$polygeneVersion"
-  compile "org.apache.polygene.libraries:org.apache.polygene.library.servlet:$polygeneVersion"
 <% if( polygene.applicationtype === 'Rest API' ) {
-%>  compile "javax.servlet:servlet-api:2.5"
-  compile "org.restlet.jee:org.restlet:2.3.4"<% } %>
+%>  compile "org.restlet.jee:org.restlet:2.3.4"
+  compile "javax.servlet:servlet-api:2.5"<% } %>
 
   runtime "org.apache.polygene.core:org.apache.polygene.core.runtime:$polygeneVersion"
   runtime "org.restlet.jee:org.restlet.ext.servlet:2.3.4"
-
+  runtime "org.apache.johnzon:johnzon-core:1.1.0"
+  runtime "org.apache.johnzon:johnzon-mapper:1.1.0"
+  runtime "org.apache.geronimo.specs:geronimo-json_1.1_spec:1.0"
+  runtime "ch.qos.logback:logback-classic:1.2.3"
+  runtime "ch.qos.logback:logback-core:1.2.3"
 }


Mime
View raw message