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 2017/03/11 01:44:13 UTC

[3/3] polygene-java git commit: Restructuring of the yeoman generator, to make it more easy to work with and demand naming in extensions to be unified.

Restructuring of the yeoman generator, to make it more easy to work with and demand naming in extensions to be unified.


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

Branch: refs/heads/develop
Commit: a7bdc40862e9a9865bd660bedb9aa91791915b5a
Parents: 46e26e6
Author: niclas <ni...@spicter.com>
Authored: Sat Mar 11 09:00:54 2017 +0800
Committer: niclas <ni...@spicter.com>
Committed: Sat Mar 11 09:44:05 2017 +0800

----------------------------------------------------------------------
 .../ElasticSearchIndexingAssembler.java         |  26 ++
 libraries/shiro-core/src/docs/shiro.txt         |   4 +
 tools/generator-polygene/app/index.js           | 325 ++++++-------------
 .../app/templates/CodahaleModule/bootstrap.tmpl |  50 ---
 .../app/templates/ConfigModule/bootstrap.tmpl   |  41 ---
 .../ConfigModule/bootstrap.tmpl                 |  41 +++
 .../ConfigurationLayer/ConfigModule/module.js   |   8 +
 .../app/templates/ConfigurationLayer/layer.js   |  10 +
 .../RestApiModule/DefaultEnroler.tmpl           |  52 +++
 .../RestApiModule/DefaultVerifier.tmpl          |  46 +++
 .../RestApiModule/NullEnroler.tmpl              |  32 ++
 .../RestApiModule/NullVerifier.tmpl             |  34 ++
 .../RestApiModule/bootstrap.tmpl                |  56 ++++
 .../ConnectivityLayer/RestApiModule/module.js   |  25 ++
 .../app/templates/ConnectivityLayer/layer.js    |  10 +
 .../app/templates/CrudModule/bootstrap.tmpl     |  38 ---
 .../DomainLayer/CrudModule/bootstrap.tmpl       |  38 +++
 .../templates/DomainLayer/CrudModule/module.js  |   9 +
 .../DomainLayer/DomainModule/Crud.tmpl          |  41 +++
 .../DomainLayer/DomainModule/Entity.tmpl        |  41 +++
 .../DomainLayer/DomainModule/Object.tmpl        |  33 ++
 .../DomainLayer/DomainModule/Service.tmpl       |  36 ++
 .../DomainLayer/DomainModule/Value.tmpl         |  41 +++
 .../DomainLayer/DomainModule/bootstrap.tmpl     |  87 +++++
 .../DomainLayer/DomainModule/module.js          |  42 +++
 .../SecurityModule/CryptoConfiguration.tmpl     |  37 +++
 .../SecurityModule/CryptoException.tmpl         |  28 ++
 .../SecurityModule/CryptoService.tmpl           | 106 ++++++
 .../EncryptedStringPropertyConcern.tmpl         |  41 +++
 ...ntityStoreBackedSecurityRepositoryMixin.tmpl |  60 ++++
 .../DomainLayer/SecurityModule/Group.tmpl       |  41 +++
 .../SecurityModule/RealmService.tmpl            |  48 +++
 .../SecurityModule/SecurityRepository.tmpl      |  63 ++++
 .../DomainLayer/SecurityModule/User.tmpl        |  51 +++
 .../DomainLayer/SecurityModule/bootstrap.tmpl   |  53 +++
 .../DomainLayer/SecurityModule/module.js        |  28 ++
 .../app/templates/DomainLayer/bootstrap.tmpl    |   4 +-
 .../app/templates/DomainLayer/layer.js          |  10 +
 .../app/templates/DomainModule/Crud.tmpl        |  41 ---
 .../app/templates/DomainModule/Entity.tmpl      |  41 ---
 .../app/templates/DomainModule/Object.tmpl      |  33 --
 .../app/templates/DomainModule/Service.tmpl     |  36 --
 .../app/templates/DomainModule/Value.tmpl       |  41 ---
 .../app/templates/DomainModule/bootstrap.tmpl   |  85 -----
 .../FileConfigurationModule/bootstrap.tmpl      |  41 ---
 .../app/templates/Heroes/Hero.tmpl              |  28 --
 .../app/templates/Heroes/app.tmpl               | 103 ------
 .../app/templates/Heroes/bootstrap.tmpl         |  63 ----
 .../app/templates/Heroes/web.tmpl               |  54 ---
 .../Heroes/webapp/app/app.component.css         |  34 --
 .../Heroes/webapp/app/app.component.js          |  41 ---
 .../Heroes/webapp/app/app.component.js.map      |   1 -
 .../Heroes/webapp/app/app.component.ts          |  37 ---
 .../Heroes/webapp/app/dashboard.component.css   |  67 ----
 .../Heroes/webapp/app/dashboard.component.html  |  15 -
 .../Heroes/webapp/app/dashboard.component.js    |  38 ---
 .../webapp/app/dashboard.component.js.map       |   1 -
 .../Heroes/webapp/app/dashboard.component.ts    |  31 --
 .../Heroes/webapp/app/hero-detail.component.css |  36 --
 .../webapp/app/hero-detail.component.html       |  16 -
 .../Heroes/webapp/app/hero-detail.component.js  |  37 ---
 .../webapp/app/hero-detail.component.js.map     |   1 -
 .../Heroes/webapp/app/hero-detail.component.ts  |  34 --
 .../app/templates/Heroes/webapp/app/hero.js     |  13 -
 .../app/templates/Heroes/webapp/app/hero.js.map |   1 -
 .../templates/Heroes/webapp/app/hero.service.js |  30 --
 .../Heroes/webapp/app/hero.service.js.map       |   1 -
 .../templates/Heroes/webapp/app/hero.service.ts |  22 --
 .../app/templates/Heroes/webapp/app/hero.ts     |  11 -
 .../Heroes/webapp/app/heroes.component.css      |  66 ----
 .../Heroes/webapp/app/heroes.component.html     |  21 --
 .../Heroes/webapp/app/heroes.component.js       |  42 ---
 .../Heroes/webapp/app/heroes.component.js.map   |   1 -
 .../Heroes/webapp/app/heroes.component.ts       |  39 ---
 .../app/templates/Heroes/webapp/app/main.js     |  15 -
 .../app/templates/Heroes/webapp/app/main.js.map |   1 -
 .../app/templates/Heroes/webapp/app/main.ts     |  16 -
 .../templates/Heroes/webapp/app/mock-heroes.js  |  19 --
 .../Heroes/webapp/app/mock-heroes.js.map        |   1 -
 .../templates/Heroes/webapp/app/mock-heroes.ts  |  21 --
 .../app/templates/Heroes/webapp/index.html      |  41 ---
 .../app/templates/Heroes/webapp/styles.css      | 149 ---------
 .../CachingModule/bootstrap.tmpl                |  51 +++
 .../InfrastructureLayer/CachingModule/module.js |  11 +
 .../FileConfigurationModule/bootstrap.tmpl      |  41 +++
 .../FileConfigurationModule/module.js           |   8 +
 .../IndexingModule/bootstrap.tmpl               |  52 +++
 .../IndexingModule/module.js                    |   8 +
 .../MetricsModule/bootstrap.tmpl                |  48 +++
 .../InfrastructureLayer/MetricsModule/module.js |  10 +
 .../SerializationModule/bootstrap.tmpl          |  43 +++
 .../SerializationModule/module.js               |   8 +
 .../StorageModule/bootstrap.tmpl                |  51 +++
 .../InfrastructureLayer/StorageModule/module.js |   8 +
 .../InfrastructureLayer/bootstrap.tmpl          |   9 +-
 .../app/templates/InfrastructureLayer/layer.js  |  10 +
 .../JacksonSerializationModule/bootstrap.tmpl   |  43 ---
 .../templates/NoCachingModule/bootstrap.tmpl    |  46 ---
 .../templates/RdfIndexingModule/bootstrap.tmpl  |  50 ---
 .../HardcodedSecurityRepositoryMixin.tmpl       |  54 ---
 .../RestApiModule/SecurityRepository.tmpl       |  36 --
 .../templates/RestApiModule/SimpleEnroler.tmpl  |  52 ---
 .../templates/RestApiModule/SimpleVerifier.tmpl |  46 ---
 .../app/templates/RestApiModule/bootstrap.tmpl  |  56 ----
 .../SecurityModule/SecurityRepository.tmpl      |  35 --
 .../app/templates/SecurityModule/bootstrap.tmpl |  46 ---
 .../templates/SolrIndexingModule/bootstrap.tmpl |  49 ---
 .../app/templates/StorageModule/bootstrap.tmpl  |  51 ---
 .../app/templates/buildtool/build.js            |  22 ++
 .../templates/buildtool/gradle-bootstrap.tmpl   |   8 +
 .../app/templates/buildtool/settings.tmpl       |   2 +-
 111 files changed, 1768 insertions(+), 2387 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/extensions/indexing-elasticsearch/src/main/java/org/apache/polygene/index/elasticsearch/assembly/ElasticSearchIndexingAssembler.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/main/java/org/apache/polygene/index/elasticsearch/assembly/ElasticSearchIndexingAssembler.java b/extensions/indexing-elasticsearch/src/main/java/org/apache/polygene/index/elasticsearch/assembly/ElasticSearchIndexingAssembler.java
new file mode 100644
index 0000000..d13e790
--- /dev/null
+++ b/extensions/indexing-elasticsearch/src/main/java/org/apache/polygene/index/elasticsearch/assembly/ElasticSearchIndexingAssembler.java
@@ -0,0 +1,26 @@
+/*
+ *  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.index.elasticsearch.assembly;
+
+/**
+ * This is a dummy Assembler to support the Yeoman Polygene Generator, which require naming conventions for
+ * the systems that it supports.
+ */
+public class ElasticSearchIndexingAssembler extends ESFilesystemIndexQueryAssembler
+{
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/libraries/shiro-core/src/docs/shiro.txt
----------------------------------------------------------------------
diff --git a/libraries/shiro-core/src/docs/shiro.txt b/libraries/shiro-core/src/docs/shiro.txt
index 38c826f..fd35a05 100644
--- a/libraries/shiro-core/src/docs/shiro.txt
+++ b/libraries/shiro-core/src/docs/shiro.txt
@@ -242,3 +242,7 @@ contribute.
 == Logging ==
 
 All code from this library use the `org.apache.polygene.library.shiro` logger.
+
+
+
+

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/tools/generator-polygene/app/index.js
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/index.js b/tools/generator-polygene/app/index.js
index 7ab5505..a13be9d 100644
--- a/tools/generator-polygene/app/index.js
+++ b/tools/generator-polygene/app/index.js
@@ -21,6 +21,7 @@
 var generators = require('yeoman-generator');
 var fs = require('fs');
 
+
 var polygene = {};
 
 module.exports = generators.Base.extend(
@@ -43,21 +44,9 @@ module.exports = generators.Base.extend(
                 polygene.entitystore = polygene.entitystore ? polygene.entitystore : null;
                 polygene.caching = polygene.caching ? polygene.caching : null;
                 polygene.serialization = polygene.serialization ? polygene.serialization : null;
-                console.log(JSON.stringify(polygene,null,4));
-            }
-            else {
-                polygene = {
-                    name: firstUpper(this.appname),
-                    packageName: "com.acme." + this.appname,
-                    singletonApp: false,
-                    entitystore: null,
-                    indexing: null,
-                    serialization: null,
-                    caching: null,
-                    features: ['rest api'],
-                    modules: {}
-                };
+                console.log(JSON.stringify(polygene, null, 4));
             }
+            assignFunctions(polygene);
         },
 
         prompting: function () {
@@ -71,13 +60,13 @@ module.exports = generators.Base.extend(
                             type: 'input',
                             name: 'name',
                             message: 'Your project name',
-                            default: polygene.name
+                            default: polygene.name ? polygene.name : firstUpper(this.appname)
                         },
                         {
                             type: 'input',
                             name: 'packageName',
                             message: 'Java package name',
-                            default: polygene.packageName
+                            default: polygene.packageName ? polygene.packageName : "com.acme"
                         },
                         {
                             type: 'list',
@@ -102,7 +91,7 @@ module.exports = generators.Base.extend(
                                 'SQLite'
                             ],
                             message: 'Which entity store do you want to use?',
-                            default: polygene.entitystore
+                            default: polygene.entitystore ? polygene.entitystore : "Memory"
                         },
                         {
                             type: 'list',
@@ -113,17 +102,19 @@ module.exports = generators.Base.extend(
                                 'Solr',
                                 'SQL'
                             ],
-                            message: 'Which indexing system do you want to use?'
+                            message: 'Which indexing system do you want to use?',
+                            default: polygene.indexing ? polygene.indexing : "Rdf"
                         },
                         {
                             type: 'list',
                             name: 'caching',
                             choices: [
-                                'none',
-                                'memcache',
-                                'ehcache'
+                                'None',
+                                'Memcache',
+                                'EhCache'
                             ],
-                            message: 'Which caching system do you want to use?'
+                            message: 'Which caching system do you want to use?',
+                            default: polygene.caching ? polygene.caching : "None"
                         },
                         {
                             type: 'list',
@@ -133,27 +124,40 @@ module.exports = generators.Base.extend(
                                 // 'Johnzon',
                                 'Stax'
                             ],
-                            message: 'Which serialization system do you want to use?'
+                            message: 'Which serialization system do you want to use?',
+                            default: polygene.serialization ? polygene.serialization : "Jackson"
                         },
                         {
                             type: 'list',
                             name: 'metrics',
                             choices: [
-                                'none',
-                                'codahale'
+                                'None',
+                                'Codahale'
                             ],
-                            message: 'Which metrics capturing system do you want to use?'
+                            message: 'Which metrics capturing system do you want to use?',
+                            default: polygene.metrics ? polygene.metrics : "None"
                         },
                         {
                             type: 'checkbox',
                             name: 'features',
                             choices: [
-                                'rest api',
-                                // 'jmx',
-                                // 'version migration',
-                                'sample (heroes) web application'
+                                'rest api'
+                                , 'security'
+                                // ,'version migration'
+                                // ,'logging'
+                                // ,'jmx'
+                                // ,'circuit breakers'
+                                // ,'file transactions'
+                                // ,'spring integration'
+                                // ,'servlet deployment'
+                                // ,'osgi support'
+                                // ,'alarms'
+                                // ,'scheduling'
+                                // ,'groovy mixins'
+                                // ,'javascript mixins'
                             ],
-                            message: 'Other features?'
+                            message: 'Other features?',
+                            default: polygene.features ? polygene.features : []
                         }
                     ]
                 ).then(function (answers) {
@@ -170,73 +174,26 @@ module.exports = generators.Base.extend(
                         polygene.serialization = answers.serialization;
                         polygene.metrics = answers.metrics;
                         polygene.packageName = answers.packageName;
-                        answers.features.forEach(function (f) {
-                            polygene.features.push(f);
-                        });
+                        polygene.features = answers.features;
                         polygene.javaPackageDir = polygene.javaPackageDir ? polygene.javaPackageDir : polygene.packageName.replace(/[.]/g, '/');
                         polygene.singletonApp = false;
-                        if (hasFeature('sample (heroes) web application')) {
-                            polygene.features.push('rest api');
-                        }
                     }.bind(this)
                 );
             }
         },
 
         writing: function () {
-            copyPolygeneBootstrap(this, "config", "ConfigurationLayer", !polygene.singeltonApp);
-            copyPolygeneBootstrap(this, "infrastructure", "InfrastructureLayer", !polygene.singeltonApp);
-            copyPolygeneBootstrap(this, "domain", "DomainLayer", !polygene.singeltonApp);
-            copyPolygeneBootstrap(this, "connectivity", "ConnectivityLayer", !polygene.singeltonApp);
-
-            copyPolygeneBootstrap(this, "config", "ConfigModule", true);
-
-            copyPolygeneBootstrap(this, "infrastructure", "FileConfigurationModule", true);
-
-            copyEntityStore(this, polygene.entitystore);
-
-            copyPolygeneBootstrap(this, "infrastructure", "RdfIndexingModule", hasIndexing('Rdf'));
-            copyPolygeneBootstrap(this, "infrastructure", "ElasticSearchIndexingModule", hasIndexing('Elasticsearch'));
-            copyPolygeneBootstrap(this, "infrastructure", "SolrIndexingModule", hasIndexing('Solr'));
-            copyPolygeneBootstrap(this, "infrastructure", "SqlIndexingModule", hasIndexing('Sql'));
-
-            copyPolygeneBootstrap(this, "infrastructure", "NoCachingModule", hasCaching('none'));
-            copyPolygeneBootstrap(this, "infrastructure", "MemcacheCachingModule", hasCaching('Memcache'));
-            copyPolygeneBootstrap(this, "infrastructure", "EhCacheCachingModule", hasCaching('Ehcache'));
-
-            copyPolygeneBootstrap(this, "infrastructure", "JacksonSerializationModule", hasSerialization('Jackson'));
-            copyPolygeneBootstrap(this, "infrastructure", "StaxSerializationModule", hasSerialization('Stax'));
-            copyPolygeneBootstrap(this, "infrastructure", "OrgJsonSerializationModule", hasSerialization('Orgjson'));
-
-            copyPolygeneBootstrap(this, "connectivity", "RestApiModule", hasFeature('rest api'));
-            copyPolygeneBootstrap(this, "infrastructure", "ReindexerModule", hasFeature('reindexer'));
-            copyPolygeneBootstrap(this, "infrastructure", "MetricsModule", hasFeature('metrics'));
-            copyPolygeneBootstrap(this, "infrastructure", "JmxModule", hasFeature('jmx'));
-            copyPolygeneBootstrap(this, "infrastructure", "MigrationModule", hasFeature('version migration'));
-
-            copyPolygeneBootstrap(this, "domain", "CrudModule", true);
-            var ctx = this;
-            Object.keys(polygene.modules).forEach(function (moduleName, index) {
-                copyPolygeneDomainModule(ctx, moduleName, polygene.modules[moduleName]);
+            polygene.ctx = this;
+            fs.readdir(__dirname + "/templates", function (err, files) {
+                files.forEach(function (directory) {
+                    if (directory.endsWith("Layer")) {
+                        var layer = require(__dirname + '/templates/' + directory + '/layer.js');
+                        layer.write(polygene);
+                    }
+                });
             });
-            copyPolygeneBootstrap(this, "domain", "CrudModule", hasFeature('rest api'));
-            // copyPolygeneBootstrap(this, "domain", "SecurityModule", true);
-            copyHeroesSampleApp(this);
-            copyPolygeneDomain(this, "security", "RestApiModule", "SecurityRepository", hasFeature('rest api'));
-
-            copyRestFeature(this, hasFeature('rest api'));
-
-            copyTemplate(this, 'buildtool/gradle-app.tmpl', 'app/build.gradle');
-            copyTemplate(this, 'buildtool/gradle-bootstrap.tmpl', 'bootstrap/build.gradle');
-            copyTemplate(this, 'buildtool/gradle-model.tmpl', 'model/build.gradle');
-            copyTemplate(this, 'buildtool/gradle-rest.tmpl', 'rest/build.gradle');
-            copyTemplate(this, 'buildtool/gradle-root.tmpl', 'build.gradle');
-            copyTemplate(this, 'buildtool/settings.tmpl', 'settings.gradle');
-            copyTemplate(this, 'buildtool/gradlew.tmpl', 'gradlew');
-            copyTemplate(this, 'buildtool/gradlew-bat.tmpl', 'gradlew.bat');
-            this.fs.copy(this.templatePath('buildtool/gradle-wrapper.jar_'), this.destinationPath('gradle/wrapper/gradle-wrapper.jar'));
-            this.fs.copy(this.templatePath('buildtool/gradle-wrapper.properties_'), this.destinationPath('gradle/wrapper/gradle-wrapper.properties'));
-
+            var buildToolChain = require(__dirname + '/templates/buildtool/build.js');
+            buildToolChain.write(polygene);
             if (this.options.export != null) {
                 exportModel(this, "exported-model.json");
             }
@@ -244,142 +201,6 @@ module.exports = generators.Base.extend(
     }
 );
 
-function copyPolygeneBootstrap(ctx, layer, moduleName, condition) {
-    if (condition) {
-        copyTemplate(ctx,
-            moduleName + '/bootstrap.tmpl',
-            'bootstrap/src/main/java/' + polygene.javaPackageDir + '/bootstrap/' + layer + '/' + moduleName + '.java');
-    }
-}
-
-function copyEntityStore(ctx, entityStoreName) {
-    copyTemplate(ctx,
-        'StorageModule/bootstrap.tmpl',
-        'bootstrap/src/main/java/' + polygene.javaPackageDir + '/bootstrap/infrastructure/' + entityStoreName + 'StorageModule.java');
-}
-
-function copyPolygeneApp(ctx, name, condition) {
-    if (condition) {
-        copyTemplate(ctx,
-            name + '/bootstrap.tmpl',
-            'bootstrap/src/main/java/' + polygene.javaPackageDir + '/bootstrap/' + name + 'ApplicationAssembler.java');
-
-        copyTemplate(ctx,
-            name + '/app.tmpl',
-            'app/src/main/java/' + polygene.javaPackageDir + '/app/' + name + '.java');
-
-        copyTemplate(ctx,
-            name + '/webapp/',
-            'app/src/main/webapp/');
-    }
-}
-
-function copyPolygeneDomain(ctx, model, module, clazz, condition) {
-    if (condition) {
-        copyTemplate(ctx,
-            module + '/' + clazz + '.tmpl',
-            'model/src/main/java/' + polygene.javaPackageDir + '/model/' + model + '/' + clazz + '.java');
-    }
-}
-
-function copyPolygeneDomainModule(ctx, moduleName, moduleDef) {
-    var clazz = firstUpper(moduleName) + "Module";
-    polygene.current = moduleDef;
-    polygene.current.name = moduleName;
-    copyTemplate(ctx,
-        'DomainModule/bootstrap.tmpl',
-        'bootstrap/src/main/java/' + polygene.javaPackageDir + '/bootstrap/domain/' + clazz + '.java');
-    for (var idx1 in moduleDef.cruds) {
-        if (moduleDef.cruds.hasOwnProperty(idx1)) {
-            polygene.current.clazz = moduleDef.cruds[idx1];
-            copyTemplate(ctx,
-                'DomainModule/Crud.tmpl',
-                'model/src/main/java/' + polygene.javaPackageDir + '/model/' + moduleName + '/' + moduleDef.cruds[idx1].name + '.java');
-        }
-    }
-    for (var idx2 in moduleDef.values) {
-        if (moduleDef.values.hasOwnProperty(idx2)) {
-            polygene.current.clazz = moduleDef.values[idx2];
-            copyTemplate(ctx,
-                'DomainModule/Value.tmpl',
-                'model/src/main/java/' + polygene.javaPackageDir + '/model/' + moduleName + '/' + moduleDef.values[idx2].name + '.java');
-        }
-    }
-    for (var idx3 in moduleDef.entities) {
-        if (moduleDef.entities.hasOwnProperty(idx3)) {
-            polygene.current.clazz = moduleDef.entities[idx2];
-            copyTemplate(ctx,
-                'DomainModule/Entity.tmpl',
-                'model/src/main/java/' + polygene.javaPackageDir + '/model/' + moduleName + '/' + moduleDef.entities[idx3].name + '.java');
-        }
-    }
-    for (var idx4 in moduleDef.transients) {
-        if (moduleDef.transients.hasOwnProperty(idx4)) {
-            polygene.current.clazz = moduleDef.transients[idx3];
-            copyTemplate(ctx,
-                'DomainModule/Transient.tmpl',
-                'model/src/main/java/' + polygene.javaPackageDir + '/model/' + moduleName + '/' + moduleDef.transients[idx4].name + '.java');
-        }
-    }
-    for (var idx5 in moduleDef.objects) {
-        if (moduleDef.objects.hasOwnProperty(idx5)) {
-            polygene.current.clazz = moduleDef.objects[idx5];
-            copyTemplate(ctx,
-                'DomainModule/Object.tmpl',
-                'model/src/main/java/' + polygene.javaPackageDir + '/model/' + moduleName + '/' + moduleDef.objects[idx5].name + '.java');
-        }
-    }
-    for (var idx6 in moduleDef.services) {
-        if (moduleDef.services.hasOwnProperty(idx6)) {
-            polygene.current.clazz = moduleDef.services[idx6];
-            copyTemplate(ctx,
-                'DomainModule/Service.tmpl',
-                'model/src/main/java/' + polygene.javaPackageDir + '/model/' + moduleName + '/' + moduleDef.services[idx6].name + '.java');
-        }
-    }
-}
-
-function copyRestFeature(ctx, condition) {
-    if (condition) {
-        copyPolygeneBootstrap(ctx, "domain", "SecurityModule", true);
-
-        copyTemplate(ctx,
-            'RestApiModule/SimpleEnroler.tmpl',
-            'rest/src/main/java/' + polygene.javaPackageDir + '/rest/security/SimpleEnroler.java');
-
-        copyTemplate(ctx,
-            'RestApiModule/SimpleVerifier.tmpl',
-            'rest/src/main/java/' + polygene.javaPackageDir + '/rest/security/SimpleVerifier.java');
-
-        copyTemplate(ctx,
-            'RestApiModule/HardcodedSecurityRepositoryMixin.tmpl',
-            'model/src/main/java/' + polygene.javaPackageDir + '/model/security/HardcodedSecurityRepositoryMixin.java');
-    }
-}
-
-function copyHeroesSampleApp(ctx) {
-    copyPolygeneDomain(ctx, "heroes", "Heroes", "Hero", hasFeature('sample (heroes) web application'));
-    copyPolygeneApp(ctx, "Heroes", hasFeature('sample (heroes) web application'));
-    copyTemplate(ctx,
-        'Heroes/web.tmpl',
-        'app/src/main/webapp/WEB-INF/web.xml');
-}
-
-function copyTemplate(ctx, from, to) {
-    ctx.fs.copyTpl(
-        ctx.templatePath(from),
-        ctx.destinationPath(to),
-        {
-            packageName: polygene.packageName,
-            hasFeature: hasFeature,
-            hasEntityStore: hasEntityStore,
-            hasIndexing: hasIndexing,
-            hasCaching: hasCaching,
-            firstUpper: firstUpper,
-            polygene: polygene
-        }
-    );
-}
 
 function hasEntityStore(esType) {
     return polygene.entitystore === esType;
@@ -413,3 +234,57 @@ function exportModel(ctx, filename) {
     delete polygene.current;
     return fs.writeFileSync(filename, JSON.stringify(polygene, null, 4) + "\n", 'utf8');
 }
+
+function assignFunctions(polygene) {
+
+    polygene.hasFeature = function (feature) {
+        console.log(polygene.features);
+        return polygene.features.indexOf(feature) >= 0;
+    };
+
+    polygene.copyTemplate = function (ctx, from, to) {
+        ctx.fs.copyTpl(
+            ctx.templatePath(from),
+            ctx.destinationPath(to),
+            {
+                packageName: polygene.packageName,
+                hasFeature: hasFeature,
+                hasEntityStore: hasEntityStore,
+                hasIndexing: hasIndexing,
+                hasCaching: hasCaching,
+                firstUpper: firstUpper,
+                polygene: polygene
+            }
+        );
+    };
+
+    polygene.copyPolygeneBootstrap = function (ctx, layer, moduleName, condition) {
+        if (condition) {
+            copyTemplate(ctx,
+                moduleName + '/bootstrap.tmpl',
+                'bootstrap/src/main/java/' + polygene.javaPackageDir + '/bootstrap/' + layer + '/' + moduleName + '.java');
+        }
+    };
+
+    polygene.copyEntityStore = function (ctx, entityStoreName) {
+        copyTemplate(ctx,
+            'StorageModule/bootstrap.tmpl',
+            'bootstrap/src/main/java/' + polygene.javaPackageDir + '/bootstrap/infrastructure/' + entityStoreName + 'StorageModule.java');
+    };
+
+    polygene.copyModules = function (dirname) {
+        fs.readdir(dirname, function (err, files) {
+            if (files !== undefined) {
+                files.forEach(function (directory) {
+                    if (directory.endsWith("Module")) {
+                        var module = require(dirname + "/" + directory + '/module.js');
+                        module.write(polygene);
+                    }
+                });
+            }
+        });
+    };
+    polygene.firstUpper = function (text) {
+        return text.charAt(0).toUpperCase() + text.substring(1);
+    };
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/tools/generator-polygene/app/templates/CodahaleModule/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/CodahaleModule/bootstrap.tmpl b/tools/generator-polygene/app/templates/CodahaleModule/bootstrap.tmpl
deleted file mode 100644
index ec826a2..0000000
--- a/tools/generator-polygene/app/templates/CodahaleModule/bootstrap.tmpl
+++ /dev/null
@@ -1,50 +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 <%= 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;
-import org.apache.polygene.bootstrap.layered.ModuleAssembler;
-import org.apache.polygene.metrics.codehale.assembly.CodahaleMetricsAssembler;
-import org.apache.polygene.library.rdf.repository.NativeConfiguration;
-
-public class RdfIndexingModule
-    implements ModuleAssembler
-{
-    public static final String NAME = "Rdf Indexing Module";
-    private final ModuleAssembly configModule;
-
-    public RdfIndexingModule( ModuleAssembly configModule )
-    {
-        this.configModule = configModule;
-    }
-
-    @Override
-    public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
-        throws AssemblyException
-    {
-        configModule.entities( NativeConfiguration.class ).visibleIn( Visibility.application );
-        new RdfNativeSesameStoreAssembler(Visibility.application, Visibility.module).assemble( module );
-        return module;
-    }
-}
-

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/tools/generator-polygene/app/templates/ConfigModule/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/ConfigModule/bootstrap.tmpl b/tools/generator-polygene/app/templates/ConfigModule/bootstrap.tmpl
deleted file mode 100644
index b152d3a..0000000
--- a/tools/generator-polygene/app/templates/ConfigModule/bootstrap.tmpl
+++ /dev/null
@@ -1,41 +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 <%= packageName %>.bootstrap.config;
-
-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.valueserialization.jackson.JacksonValueSerializationAssembler;
-
-public class ConfigModule
-    implements ModuleAssembler
-{
-    @Override
-    public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
-        throws AssemblyException
-    {
-        module.services( MemoryEntityStoreService.class ).visibleIn( Visibility.layer );
-        new JacksonValueSerializationAssembler().visibleIn( Visibility.layer ).assemble( module );
-        return module;
-    }
-}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/tools/generator-polygene/app/templates/ConfigurationLayer/ConfigModule/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/ConfigurationLayer/ConfigModule/bootstrap.tmpl b/tools/generator-polygene/app/templates/ConfigurationLayer/ConfigModule/bootstrap.tmpl
new file mode 100644
index 0000000..b152d3a
--- /dev/null
+++ b/tools/generator-polygene/app/templates/ConfigurationLayer/ConfigModule/bootstrap.tmpl
@@ -0,0 +1,41 @@
+<%#
+ *  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 <%= packageName %>.bootstrap.config;
+
+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.valueserialization.jackson.JacksonValueSerializationAssembler;
+
+public class ConfigModule
+    implements ModuleAssembler
+{
+    @Override
+    public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+        throws AssemblyException
+    {
+        module.services( MemoryEntityStoreService.class ).visibleIn( Visibility.layer );
+        new JacksonValueSerializationAssembler().visibleIn( Visibility.layer ).assemble( module );
+        return module;
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/tools/generator-polygene/app/templates/ConfigurationLayer/ConfigModule/module.js
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/ConfigurationLayer/ConfigModule/module.js b/tools/generator-polygene/app/templates/ConfigurationLayer/ConfigModule/module.js
new file mode 100644
index 0000000..690f715
--- /dev/null
+++ b/tools/generator-polygene/app/templates/ConfigurationLayer/ConfigModule/module.js
@@ -0,0 +1,8 @@
+module.exports = {
+
+    write: function (p) {
+        p.copyTemplate(p.ctx,
+            'ConfigurationLayer/ConfigModule/bootstrap.tmpl',
+            'bootstrap/src/main/java/' + p.javaPackageDir + '/bootstrap/config/ConfigModule.java');
+    }
+};

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/tools/generator-polygene/app/templates/ConfigurationLayer/layer.js
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/ConfigurationLayer/layer.js b/tools/generator-polygene/app/templates/ConfigurationLayer/layer.js
new file mode 100644
index 0000000..06a3e31
--- /dev/null
+++ b/tools/generator-polygene/app/templates/ConfigurationLayer/layer.js
@@ -0,0 +1,10 @@
+
+module.exports = {
+
+    write: function (p) {
+        p.copyTemplate(p.ctx,
+            'ConfigurationLayer/bootstrap.tmpl',
+            'bootstrap/src/main/java/' + p.javaPackageDir + '/bootstrap/config/ConfigurationLayer.java');
+        p.copyModules(__dirname );
+    }
+};

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/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
new file mode 100644
index 0000000..c469137
--- /dev/null
+++ b/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/DefaultEnroler.tmpl
@@ -0,0 +1,52 @@
+<%#
+ *  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 <%= packageName %>.rest.security;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.polygene.api.injection.scope.Service;
+import org.apache.polygene.api.injection.scope.Uses;
+import org.restlet.Application;
+import org.restlet.data.ClientInfo;
+import org.restlet.security.Enroler;
+import org.restlet.security.Role;
+import <%= packageName %>.model.security.SecurityRepository;
+
+
+public class DefaultEnroler
+    implements Enroler
+{
+    @Service
+    private SecurityRepository repository;
+
+    @Uses
+    private Application application;
+
+    @Override
+    public void enrole( ClientInfo clientInfo )
+    {
+        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 ) );
+        clientInfo.setRoles( restletRoles );
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/DefaultVerifier.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/DefaultVerifier.tmpl b/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/DefaultVerifier.tmpl
new file mode 100644
index 0000000..256b39d
--- /dev/null
+++ b/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/DefaultVerifier.tmpl
@@ -0,0 +1,46 @@
+<%#
+ *  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 <%= packageName %>.rest.security;
+
+import org.apache.polygene.api.injection.scope.Service;
+import org.restlet.security.SecretVerifier;
+import org.restlet.security.Verifier;
+import <%= packageName %>.model.security.SecurityRepository;
+
+public class DefaultVerifier extends SecretVerifier
+    implements Verifier
+{
+    @Service
+    private SecurityRepository repository;
+
+    @Override
+    public int verify( String user, char[] secret )
+    {
+        if( user == null || secret == null )
+        {
+            return RESULT_UNKNOWN;
+        }
+        if( repository.verifyPassword( user, String.valueOf( secret ) ) )
+        {
+            return RESULT_VALID;
+        }
+        return RESULT_INVALID;
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/NullEnroler.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/NullEnroler.tmpl b/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/NullEnroler.tmpl
new file mode 100644
index 0000000..8076289
--- /dev/null
+++ b/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/NullEnroler.tmpl
@@ -0,0 +1,32 @@
+<%#
+ *  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 <%= packageName %>.rest.security;
+
+import org.restlet.data.ClientInfo;
+import org.restlet.security.Enroler;
+
+public class NullEnroler
+    implements Enroler
+{
+    @Override
+    public void enrole( ClientInfo clientInfo )
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/NullVerifier.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/NullVerifier.tmpl b/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/NullVerifier.tmpl
new file mode 100644
index 0000000..e7af254
--- /dev/null
+++ b/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/NullVerifier.tmpl
@@ -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 <%= packageName %>.rest.security;
+
+import org.restlet.security.SecretVerifier;
+import org.restlet.security.Verifier;
+
+public class NullVerifier extends SecretVerifier
+    implements Verifier
+{
+
+    @Override
+    public int verify( String user, char[] secret )
+    {
+        return RESULT_VALID;
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/bootstrap.tmpl b/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/bootstrap.tmpl
new file mode 100644
index 0000000..d2ad313
--- /dev/null
+++ b/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/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 <%= packageName %>.bootstrap.connectivity;
+
+<% if( hasFeature('security') ) { %>
+import <%= packageName %>.rest.security.DefaultEnroler;
+import <%= packageName %>.rest.security.DefaultVerifier;
+<% } else { %>
+import <%= packageName %>.rest.security.NullEnroler;
+import <%= packageName %>.rest.security.NullVerifier;
+<% } %>
+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.restlet.assembly.RestletCrudConnectivityAssembler;
+import org.apache.polygene.library.restlet.resource.EntryPoint;
+
+public class RestApiModule
+    implements ModuleAssembler
+{
+    public static String NAME;
+
+    @Override
+    public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+        throws AssemblyException
+    {
+<% if( hasFeature('security') ) { %>
+        module.objects( DefaultVerifier.class, DefaultEnroler.class);
+<% } else {%>
+        module.objects( NullVerifier.class, NullEnroler.class);
+<% } %>
+        new RestletCrudConnectivityAssembler().assemble( module );
+        module.values( EntryPoint.class );
+        module.values( /* add value types */   );
+        module.services(  /* add services */  );
+        return module;
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/module.js
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/module.js b/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/module.js
new file mode 100644
index 0000000..8524da3
--- /dev/null
+++ b/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/module.js
@@ -0,0 +1,25 @@
+
+module.exports = {
+
+    write: function (p) {
+        if (p.hasFeature("rest api")) {
+            p.copyTemplate(p.ctx,
+                'ConnectivityLayer/RestApiModule/bootstrap.tmpl',
+                'bootstrap/src/main/java/' + p.javaPackageDir + '/bootstrap/connectivity/RestApiModule.java');
+            if (p.hasFeature("security")) {
+                copyFile(p, "DefaultEnroler");
+                copyFile(p, "DefaultVerifier");
+            }
+            else {
+                copyFile(p, "NullEnroler");
+                copyFile(p, "NullVerifier");
+            }
+        }
+    }
+};
+
+function copyFile(p, clazz) {
+    p.copyTemplate(p.ctx,
+        'ConnectivityLayer/RestApiModule/' + clazz + '.tmpl',
+        'rest/src/main/java/' + p.javaPackageDir + '/rest/security/' + clazz + '.java');
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/tools/generator-polygene/app/templates/ConnectivityLayer/layer.js
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/ConnectivityLayer/layer.js b/tools/generator-polygene/app/templates/ConnectivityLayer/layer.js
new file mode 100644
index 0000000..6a0e9b3
--- /dev/null
+++ b/tools/generator-polygene/app/templates/ConnectivityLayer/layer.js
@@ -0,0 +1,10 @@
+
+module.exports = {
+
+    write: function (p) {
+        p.copyTemplate(p.ctx,
+            'ConnectivityLayer/bootstrap.tmpl',
+            'bootstrap/src/main/java/' + p.javaPackageDir + '/bootstrap/connectivity/ConnectivityLayer.java');
+        p.copyModules(__dirname );
+    }
+};

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/tools/generator-polygene/app/templates/CrudModule/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/CrudModule/bootstrap.tmpl b/tools/generator-polygene/app/templates/CrudModule/bootstrap.tmpl
deleted file mode 100644
index 0877723..0000000
--- a/tools/generator-polygene/app/templates/CrudModule/bootstrap.tmpl
+++ /dev/null
@@ -1,38 +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 <%= packageName %>.bootstrap.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;
-import org.apache.polygene.library.restlet.assembly.CrudServiceAssembler;
-
-public class CrudModule
-    implements ModuleAssembler
-{
-    @Override
-    public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
-        throws AssemblyException
-    {
-        new CrudServiceAssembler().assemble( module );
-        return module;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/tools/generator-polygene/app/templates/DomainLayer/CrudModule/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/DomainLayer/CrudModule/bootstrap.tmpl b/tools/generator-polygene/app/templates/DomainLayer/CrudModule/bootstrap.tmpl
new file mode 100644
index 0000000..0877723
--- /dev/null
+++ b/tools/generator-polygene/app/templates/DomainLayer/CrudModule/bootstrap.tmpl
@@ -0,0 +1,38 @@
+<%#
+ *  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 <%= packageName %>.bootstrap.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;
+import org.apache.polygene.library.restlet.assembly.CrudServiceAssembler;
+
+public class CrudModule
+    implements ModuleAssembler
+{
+    @Override
+    public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+        throws AssemblyException
+    {
+        new CrudServiceAssembler().assemble( module );
+        return module;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/tools/generator-polygene/app/templates/DomainLayer/CrudModule/module.js
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/DomainLayer/CrudModule/module.js b/tools/generator-polygene/app/templates/DomainLayer/CrudModule/module.js
new file mode 100644
index 0000000..acc509a
--- /dev/null
+++ b/tools/generator-polygene/app/templates/DomainLayer/CrudModule/module.js
@@ -0,0 +1,9 @@
+
+module.exports = {
+
+    write: function (p) {
+        p.copyTemplate(p.ctx,
+            'DomainLayer/CrudModule/bootstrap.tmpl',
+            'bootstrap/src/main/java/' + p.javaPackageDir + '/bootstrap/domain/CrudModule.java');
+    }
+};

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/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
new file mode 100644
index 0000000..95eed76
--- /dev/null
+++ b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Crud.tmpl
@@ -0,0 +1,41 @@
+<%#
+ *  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 <%= packageName %>.model.<%= polygene.current.name %>;
+
+import org.apache.polygene.api.injection.scope.This;
+import org.apache.polygene.api.mixin.Mixins;
+import org.apache.polygene.api.property.Property;
+
+@Mixins( { <%= polygene.current.clazz.name %>.Mixin.class } )
+public interface <%= polygene.current.clazz.name %>
+{
+    interface State
+    {
+        Property<String> name();     // Sample hidden property
+    }
+
+    class Mixin
+        implements <%= polygene.current.clazz.name %>
+    {
+        @This
+        private State state;        // Sample reference to hidden property
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/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
new file mode 100644
index 0000000..95eed76
--- /dev/null
+++ b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Entity.tmpl
@@ -0,0 +1,41 @@
+<%#
+ *  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 <%= packageName %>.model.<%= polygene.current.name %>;
+
+import org.apache.polygene.api.injection.scope.This;
+import org.apache.polygene.api.mixin.Mixins;
+import org.apache.polygene.api.property.Property;
+
+@Mixins( { <%= polygene.current.clazz.name %>.Mixin.class } )
+public interface <%= polygene.current.clazz.name %>
+{
+    interface State
+    {
+        Property<String> name();     // Sample hidden property
+    }
+
+    class Mixin
+        implements <%= polygene.current.clazz.name %>
+    {
+        @This
+        private State state;        // Sample reference to hidden property
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Object.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Object.tmpl b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Object.tmpl
new file mode 100644
index 0000000..27d6119
--- /dev/null
+++ b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Object.tmpl
@@ -0,0 +1,33 @@
+<%#
+ *  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 <%= packageName %>.model.<%= polygene.current.name %>;
+
+import org.apache.polygene.api.injection.scope.This
+import org.apache.polygene.api.mixin.Mixins;
+
+public class <%= polygene.current.clazz.name %>
+{
+    @Uses
+    private String name;   // Sample @Uses injection
+
+    @Structure
+    private ValueBuilderFactory vbf;  // Sample @Structure injection
+
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Service.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Service.tmpl b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Service.tmpl
new file mode 100644
index 0000000..0edefdc
--- /dev/null
+++ b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Service.tmpl
@@ -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 <%= packageName %>.model.<%= polygene.current.name %>;
+
+import org.apache.polygene.api.injection.scope.Structure;
+import org.apache.polygene.api.mixin.Mixins;
+import org.apache.polygene.api.value.ValueBuilderFactory;
+
+@Mixins( { <%= polygene.current.clazz.name %>.Mixin.class } )
+public interface <%= polygene.current.clazz.name %>
+{
+    class Mixin
+        implements <%= polygene.current.clazz.name %>
+    {
+        @Structure
+        private ValueBuilderFactory vbf;
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Value.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Value.tmpl b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Value.tmpl
new file mode 100644
index 0000000..60e117d
--- /dev/null
+++ b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Value.tmpl
@@ -0,0 +1,41 @@
+<%#
+ *  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 <%= packageName %>.model.<%= polygene.current.name %>;
+
+import org.apache.polygene.api.injection.scope.This
+import org.apache.polygene.api.mixin.Mixins;
+import org.apache.polygene.api.property.Property;
+
+@Mixins( { <%= polygene.current.clazz.name %>.Mixin.class } )
+public interface <%= polygene.current.clazz.name %>
+{
+    interface State
+    {
+        Property<String> name();     // Sample hidden property
+    }
+
+    class Mixin
+        implements <%= polygene.current.clazz.name %>
+    {
+        @This
+        private State state;        // Sample reference to hidden property
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/tools/generator-polygene/app/templates/DomainLayer/DomainModule/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/bootstrap.tmpl b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/bootstrap.tmpl
new file mode 100644
index 0000000..cbab067
--- /dev/null
+++ b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/bootstrap.tmpl
@@ -0,0 +1,87 @@
+<%#
+ *  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 <%= packageName %>.bootstrap.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;
+<% for( var idx in polygene.current.cruds) { %>
+<%= "import " + packageName + ".model." + polygene.current.name + "." + polygene.current.cruds[idx].name + ";" %>
+<% } %>
+<% for( var idx in polygene.current.values) { %><%= "import " + packageName + ".model." + polygene.current.name + "." + polygene.current.values[idx].name + ";" %><% } %>
+<% for( var idx in polygene.current.entities) { %><%= "import " + packageName + ".model." + polygene.current.name + "." + polygene.current.entities[idx].name + ";" %><% } %>
+<% for( var idx in polygene.current.transients) { %><%= "import " + packageName + ".model." + polygene.current.name + "." + polygene.current.transients[idx].name + ";" %><% } %>
+<% for( var idx in polygene.current.objects) { %><%= "import " + packageName + ".model." + polygene.current.name + "." + polygene.current.objects[idx].name + ";" %><% } %>
+<% for( var idx in polygene.current.services) { %><%= "import " + packageName + ".model." + polygene.current.name + "." + polygene.current.services[idx].name + ";" %><% } %>
+
+import static org.apache.polygene.api.common.Visibility.layer;
+import static org.apache.polygene.api.common.Visibility.application;
+
+public class <%- firstUpper(polygene.current.name) %>Module
+    implements ModuleAssembler
+{
+    @Override
+    public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+        throws AssemblyException
+    {
+<% if( polygene.current.cruds ) { %>
+  <% for( var value in polygene.current.cruds ) { %>
+    <% var crud1 = polygene.current.cruds[value]; %>
+    module.values(<%-  crud1.name + ".class" %>)<% if( crud1.visibility ) {%><%-".visibleIn(" + crud1.visibility +")"%><% } %>;
+  <% } %>
+  <% for( var value in polygene.current.cruds ) { %>
+    <% var crud2 = polygene.current.cruds[value]; %>
+        module.entities(<%= crud2.name + ".class" %>)<% if( crud2.visibility ) {%><%-".visibleIn(" + crud2.visibility +")"%><% } %>;
+  <% } %>
+<% } %>
+<% if( polygene.current.values ) { %>
+  <% for( var value in polygene.current.values ) { %>
+    <% var v = polygene.current.current[value]; %>
+        module.values(<%= v.name + ".class" %>)<% if( v.visibility ) {%><%-".visibleIn(" + v.visibility +")"%><% } %>;
+  <% } %>
+<% } %>
+<% if( polygene.current.entities ) { %>
+  <% for( var value in polygene.current.entities ) { %>
+    <% var entity = polygene.current.entities[value]; %>
+        module.values(<%= entity.name + ".class" %>)<% if( entity.visibility ) {%><%-".visibleIn(" + entity.visibility +")"%><% } %>;
+  <% } %>
+<% } %>
+<% if( polygene.current.transients ) { %>
+  <% for( var value in polygene.current.transients ) { %>
+    <% var trans = polygene.current.transients[value]; %>
+        module.values(<%= trans.name + ".class" %>)<% if( trans.visibility ) {%><%-".visibleIn(" + trans.visibility +")"%><% } %>;
+  <% } %>
+<% } %>
+<% if( polygene.current.objects ) { %>
+  <% for( var value in polygene.current.objects ) { %>
+    <% var obj = polygene.current.objects[value]; %>
+        module.values(<%= obj.name + ".class" %>)<% if( obj.visibility ) {%><%-".visibleIn(" + obj.visibility +")"%><% } %>;
+  <% } %>
+<% } %>
+<% if( polygene.current.services ) { %>
+  <% for( var value in polygene.current.services ) { %>
+    <% var service = polygene.current.services[value]; %>
+        module.values(<%= service.name + ".class" %>)<% if( service.visibility ) {%><%-".visibleIn(" + service.visibility +")"%><% } %>;
+  <% } %>
+<% } %>
+        return module;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/tools/generator-polygene/app/templates/DomainLayer/DomainModule/module.js
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/module.js b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/module.js
new file mode 100644
index 0000000..2ceeaa5
--- /dev/null
+++ b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/module.js
@@ -0,0 +1,42 @@
+module.exports = {
+
+    write: function (p) {
+
+        Object.keys(p.modules).forEach(function (moduleName, index) {
+            copyPolygeneDomainModule(p, moduleName, p.modules[moduleName])
+        });
+    }
+
+};
+
+function copyFile(p, module, clazz) {
+    p.copyTemplate(p.ctx,
+        p.firstUpper(module) + 'Module/' + clazz + '.tmpl',
+        'model/src/main/java/' + p.javaPackageDir + '/model/' + module + '/' + clazz + '.java');
+}
+
+function copyPolygeneDomainModule(p, moduleName, moduleDef) {
+    p.current = moduleDef;
+    p.current.name = moduleName;
+    var clazz = p.firstUpper(moduleName) + "Module";
+    p.copyTemplate(p.ctx,
+        'DomainLayer/DomainModule/bootstrap.tmpl',
+        'bootstrap/src/main/java/' + p.javaPackageDir + '/bootstrap/domain/' + clazz + '.java');
+    copyComposites(p, moduleDef.cruds, "Crud");
+    copyComposites(p, moduleDef.entities, "Entity");
+    copyComposites(p, moduleDef.values, "Value");
+    copyComposites(p, moduleDef.transients, "Transient");
+    copyComposites(p, moduleDef.objects, "Object");
+    copyComposites(p, moduleDef.services, "Service");
+}
+
+function copyComposites(p, composites, type) {
+    for (var idx in composites) {
+        if (composites.hasOwnProperty(idx)) {
+            p.current.clazz = composites[idx];
+            p.copyTemplate(p.ctx,
+                'DomainLayer/DomainModule/' + type + '.tmpl',
+                'model/src/main/java/' + p.javaPackageDir + '/model/' + p.current.name  + '/' + p.current.clazz.name + '.java');
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/CryptoConfiguration.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/CryptoConfiguration.tmpl b/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/CryptoConfiguration.tmpl
new file mode 100644
index 0000000..89883a2
--- /dev/null
+++ b/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/CryptoConfiguration.tmpl
@@ -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 <%= packageName %>.model.security;
+
+import org.apache.polygene.api.property.Property;
+import org.apache.polygene.api.common.Optional;
+
+public class CryptoConfiguration
+{
+    @Optional
+    Property<String> digestAlgorithm();
+
+    @Optional
+    Property<String> digestAlgorithm();
+
+    Property<String> secret1();
+
+    Property<String> secret2();
+
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/CryptoException.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/CryptoException.tmpl b/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/CryptoException.tmpl
new file mode 100644
index 0000000..00ec8f8
--- /dev/null
+++ b/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/CryptoException.tmpl
@@ -0,0 +1,28 @@
+<%#
+ *  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 <%= packageName %>.model.security;
+
+public class CryptoException extends RuntimeException
+{
+    public CryptoException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/CryptoService.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/CryptoService.tmpl b/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/CryptoService.tmpl
new file mode 100644
index 0000000..4bc72c2
--- /dev/null
+++ b/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/CryptoService.tmpl
@@ -0,0 +1,106 @@
+<%#
+ *  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 <%= packageName %>.model.security;
+
+import java.security.MessageDigest;
+import java.crypto.Cipher;
+import java.crypto.spec.IvParameterSpec;
+import java.crypto.spec.SecretKeySpec;
+
+import org.apache.polygene.api.mixin.Mixins;
+import org.apache.polygene.api.property.Property;
+
+@Mixins( { CryptoService.Mixin.class } )
+public interface CryptoService
+{
+    String encrypt( String clear );
+
+    String decrypt( String encrypted );
+
+    class CryptoMixin
+        implements CryptoService
+    {
+        private byte[] keyBytes;
+        private byte[] ivBytes;
+        private Cipher cipher;
+        private MessageDigest digest;
+
+        public CryptoMixin(Configuration<CryptoConfiguration> configuration)
+            throws Exception
+        {
+            CryptoConfiguration config = configuration.configuration().get();
+            String digestAlgorithm = config.digestAlgorithm().get();
+            if( digestAlgorithm == null )
+                digestAlgorithm = "SHA-1";
+            digest = MessageDigest.getInstance(  );
+            byte[] keyBytes = hashed( config.secret1().get() );
+            byte[] ivBytes = hashed( config.secret2().get() );
+
+            SecretKeySpec key = new SecretKeySpec(keyBytes, "DES");
+            IvParameterSpec ivSpec = new IvParameterSpec(ivBytes);
+
+            String encryptionAlgorithm = config.encryptionAlgorithm().get();
+            if( encryptionAlgorithm == null )
+                encryptionAlgorithm = "AES";
+            cipher = Cipher.getInstance( encryptionAlgorithm );
+        }
+
+        public String encrypt( String clear )
+            throws CryptoException
+        {
+            try
+            {
+                cipher.init(Cipher.ENCRYPT_MODE, key, ivSpec);
+
+                byte[] input = clear.getBytes();
+                byte[] encrypted= new byte[cipher.getOutputSize(input.length)];
+                int enc_len = cipher.update(input, 0, input.length, encrypted, 0);
+                enc_len += cipher.doFinal(encrypted, enc_len);
+                return new String( encrypted, 0, enc_len );
+
+            } catch( Exception e ) {
+                throw new CryptoException( "Unable to encrypt.", e );
+            }
+        }
+
+        public String decrypt( String encryptedString )
+            throws CryptoException
+        {
+            try
+            {
+                cipher.init(Cipher.DECRYPT_MODE, key, ivSpec);
+
+                byte[] encrypted = encryptedString.getBytes();
+                byte[] decrypted = new byte[cipher.getOutputSize(enc_len)];
+                int dec_len = cipher.update(encrypted, 0, enc_len, decrypted, 0);
+                dec_len += cipher.doFinal(decrypted, dec_len);
+                return new String( decrypted, 0, dec_len );
+            } catch( Exception e ) {
+                throw new CryptoException( "Unable to decrypt.", e );
+            }
+        }
+
+        private byte[] hashed( String data )
+        {
+            digest.reset();
+            return digest.digest( data.getBytes() );
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/EncryptedStringPropertyConcern.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/EncryptedStringPropertyConcern.tmpl b/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/EncryptedStringPropertyConcern.tmpl
new file mode 100644
index 0000000..4083a39
--- /dev/null
+++ b/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/EncryptedStringPropertyConcern.tmpl
@@ -0,0 +1,41 @@
+<%#
+ *  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 <%= packageName %>.model.security;
+
+import org.apache.polygene.api.concern.ConcernOf;
+import org.apache.polygene.api.property.Property;
+import org.apache.polygene.api.injection.scope.Service;
+
+public class EncryptedStringPropertyConcern extends ConcernOf<Property<String>>
+    implements Property<String>
+{
+    @Service
+    private CryptoService crypto;
+
+    public String get() {
+        String value = next.get();
+        return crypto.decrypt( value );
+    }
+
+    public void set( String value ) {
+        String encrypted = crypto.encrypt( value );
+        next.set( value );
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/EntityStoreBackedSecurityRepositoryMixin.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/EntityStoreBackedSecurityRepositoryMixin.tmpl b/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/EntityStoreBackedSecurityRepositoryMixin.tmpl
new file mode 100644
index 0000000..56c4a5c
--- /dev/null
+++ b/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/EntityStoreBackedSecurityRepositoryMixin.tmpl
@@ -0,0 +1,60 @@
+<%#
+ *  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 <%= packageName %>.model.security;
+
+import java.util.Collections;
+import java.util.List;
+import org.apache.polygene.api.unitofwork.concern.UnitOfWorkPropagation;
+
+public class EntityStoreBackedSecurityRepositoryMixin
+    implements SecurityRepository
+{
+    @Structure
+    private UnitOfWorkFactory uowf;
+
+    @Override
+    @UnitOfWorkPropagation
+    public boolean verifyPassword( String userName, String password )
+    {
+        Identity identity = new StringIdentity("User-" + userName );
+        User user = uow.currentUnitOfWork(User.class, identity );
+
+        if( userName.equals("admin") && password.equals("secret") )
+        {
+            return true;
+        }
+        if( userName.equals("user") && password.equals("123") )
+        {
+            return true;
+        }
+        return false;
+    }
+
+    @UnitOfWorkPropagation
+    public List<String> findRoleNamesOfUser( String name )
+    {
+        if( "admin".equals( name ) )
+        {
+            return Collections.singletonList("admin");
+        }
+        return Collections.singletonList("user");
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/a7bdc408/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/Group.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/Group.tmpl b/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/Group.tmpl
new file mode 100644
index 0000000..eb83232
--- /dev/null
+++ b/tools/generator-polygene/app/templates/DomainLayer/SecurityModule/Group.tmpl
@@ -0,0 +1,41 @@
+<%#
+ *  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 <%= packageName %>.model.security;
+
+import org.apache.polygene.api.injection.scope.This
+import org.apache.polygene.api.mixin.Mixins;
+import org.apache.polygene.api.property.Property;
+
+@Mixins( { Group.Mixin } )
+public interface Group
+{
+    interface State
+    {
+        Property<String> password();
+    }
+
+    class Mixin
+        implements Group
+    {
+        @This
+        private State state;        // Sample reference to hidden property
+
+    }
+}