You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by ni...@apache.org on 2016/08/21 10:53:31 UTC
[2/2] zest-java git commit: ZEST-158 - Adding a project creator based
on Yeoman
ZEST-158 - Adding a project creator based on Yeoman
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/bc55a577
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/bc55a577
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/bc55a577
Branch: refs/heads/develop
Commit: bc55a577d1b1feabfda27280a278adc234e59fa3
Parents: d2e6bb8
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Sun Aug 21 18:52:51 2016 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Sun Aug 21 18:53:23 2016 +0800
----------------------------------------------------------------------
tools/generator-zest/app/index.js | 321 +++++++++++++++++++
.../app/templates/ConfigModule/bootstrap.tmpl | 43 +++
.../templates/ConfigurationLayer/bootstrap.tmpl | 46 +++
.../templates/ConnectivityLayer/bootstrap.tmpl | 41 +++
.../app/templates/CrudModule/bootstrap.tmpl | 39 +++
.../app/templates/DomainLayer/bootstrap.tmpl | 46 +++
.../FileConfigurationModule/bootstrap.tmpl | 41 +++
.../templates/FileStorageModule/bootstrap.tmpl | 53 +++
.../app/templates/Heroes/Hero.tmpl | 28 ++
.../app/templates/Heroes/app.tmpl | 103 ++++++
.../app/templates/Heroes/bootstrap.tmpl | 68 ++++
.../app/templates/Heroes/web.tmpl | 54 ++++
.../Heroes/webapp/app/app.component.css | 34 ++
.../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.ts | 31 ++
.../Heroes/webapp/app/hero-detail.component.css | 36 +++
.../webapp/app/hero-detail.component.html | 16 +
.../Heroes/webapp/app/hero-detail.component.ts | 34 ++
.../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.ts | 39 +++
.../app/templates/Heroes/webapp/app/main.ts | 16 +
.../templates/Heroes/webapp/app/mock-heroes.ts | 21 ++
.../app/templates/Heroes/webapp/index.html | 41 +++
.../app/templates/Heroes/webapp/styles.css | 149 +++++++++
.../InfrastructureLayer/bootstrap.tmpl | 55 ++++
.../JacksonSerializationModule/bootstrap.tmpl | 55 ++++
.../templates/NoCachingModule/bootstrap.tmpl | 46 +++
.../templates/RdfIndexingModule/bootstrap.tmpl | 52 +++
.../HardcodedSecurityRepositoryMixin.tmpl | 54 ++++
.../RestApiModule/SecurityRepository.tmpl | 36 +++
.../templates/RestApiModule/SimpleEnroler.tmpl | 52 +++
.../templates/RestApiModule/SimpleVerifier.tmpl | 46 +++
.../app/templates/RestApiModule/bootstrap.tmpl | 58 ++++
.../HardcodedSecurityRepositoryMixin.tmpl | 51 +++
.../SecurityModule/SecurityRepository.tmpl | 35 ++
.../app/templates/SecurityModule/bootstrap.tmpl | 47 +++
.../app/templates/buildtool/gradle-app.tmpl | 39 +++
.../templates/buildtool/gradle-bootstrap.tmpl | 34 ++
.../app/templates/buildtool/gradle-model.tmpl | 23 ++
.../app/templates/buildtool/gradle-rest.tmpl | 27 ++
.../app/templates/buildtool/gradle-root.tmpl | 44 +++
.../app/templates/buildtool/gradle-wrapper.jar_ | Bin 0 -> 51348 bytes
.../buildtool/gradle-wrapper.properties_ | 24 ++
.../app/templates/buildtool/gradlew-bat.tmpl | 109 +++++++
.../app/templates/buildtool/gradlew.tmpl | 183 +++++++++++
.../app/templates/buildtool/settings.tmpl | 41 +++
tools/generator-zest/package.json | 14 +
52 files changed, 2664 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/index.js
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/index.js b/tools/generator-zest/app/index.js
new file mode 100644
index 0000000..4935e0e
--- /dev/null
+++ b/tools/generator-zest/app/index.js
@@ -0,0 +1,321 @@
+/*
+ * 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.
+ *
+ *
+ */
+
+var generators = require( 'yeoman-generator' );
+
+var zest = {};
+
+module.exports = generators.Base.extend(
+ {
+ // The name `constructor` is important here
+ constructor: function ()
+ {
+ // Calling the super constructor is important so our generator is correctly set up
+ generators.Base.apply( this, arguments );
+
+ // this.option( 'coffee' ); // This method adds support for a `--coffee` flag
+ },
+
+ method1: function ()
+ {
+ console.log( 'method 1 just ran' );
+ },
+ method2: function ()
+ {
+ console.log( 'method 2 just ran' );
+ },
+ prompting: function ()
+ {
+ return this.prompt(
+ [
+ {
+ type: 'input',
+ name: 'name',
+ message: 'Your project name',
+ default: firstUpper( this.appname )
+ },
+ {
+ type: 'input',
+ name: 'packagename',
+ message: 'Java package name',
+ default: this.appname // Default to current folder name
+ },
+ {
+ type: 'list',
+ name: 'entitystore',
+ choices: [
+ 'file',
+ 'geode',
+ 'hazelcast',
+ 'jclouds',
+ 'jdbm',
+ 'leveldb',
+ 'in-memory',
+ 'mongodb',
+ 'preferences',
+ 'redis',
+ 'riak',
+ 'sql'
+ ],
+ message: 'Which entity store do you want to use?'
+ },
+ {
+ type: 'list',
+ name: 'indexing',
+ choices: [
+ 'rdf',
+ 'elasticsearch',
+ 'solr',
+ 'sql'
+ ],
+ message: 'Which caching system do you want to use?'
+ },
+ {
+ type: 'list',
+ name: 'caching',
+ choices: [
+ 'none',
+ 'memcache',
+ 'ehcache'
+ ],
+ message: 'Which serialization system do you want to use?'
+ },
+ {
+ type: 'list',
+ name: 'serialization',
+ choices: [
+ 'jackson',
+ 'stax',
+ 'org.json'
+ ],
+ message: 'Which indexing system do you want to use?'
+ },
+ {
+ type: 'checkbox',
+ name: 'features',
+ choices: [
+ 'rest api',
+ // 'reindexer',
+ // 'metrics',
+ // 'jmx',
+ // 'version migration',
+ 'sample (heroes) web application'
+ ],
+ message: 'Other features?'
+ }
+ ]
+ ).then( function ( answers )
+ {
+ this.log( 'app name', answers.name );
+ this.log( 'Entity Stores:', answers.entitystore );
+ this.log( 'Indexing:', answers.indexing );
+ this.log( 'Caching:', answers.caching );
+ this.log( 'Serialization:', answers.serialization );
+ this.log( 'Features:', answers.features );
+ zest = answers;
+ zest.javaPackageDir = zest.packagename.replace( '.', '/' );
+ zest.singletonApp = false;
+ zest.entitystore = firstUpper( zest.entitystore );
+ zest.indexing = firstUpper( zest.indexing );
+ zest.caching = firstUpper( zest.caching );
+ zest.serialization = firstUpper( zest.serialization );
+ if( hasFeature( 'sample (heroes) web application' ) )
+ {
+ zest.features.push( 'rest api' );
+ }
+ }.bind( this )
+ );
+ },
+
+ writing: function ()
+ {
+ copyZestBootstrap( this, "config", "ConfigurationLayer", !zest.singeltonApp );
+ copyZestBootstrap( this, "infrastructure", "InfrastructureLayer", !zest.singeltonApp );
+ copyZestBootstrap( this, "domain", "DomainLayer", !zest.singeltonApp );
+ copyZestBootstrap( this, "connectivity", "ConnectivityLayer", !zest.singeltonApp );
+
+ copyZestBootstrap( this, "config", "ConfigModule", true );
+
+ copyZestBootstrap( this, "infrastructure", "FileConfigurationModule", true );
+
+ copyZestBootstrap( this, "infrastructure", "FileStorageModule", hasEntityStore( 'File' ) );
+ copyZestBootstrap( this, "infrastructure", "GeodeStorageModule", hasEntityStore( 'Geode' ) );
+ copyZestBootstrap( this, "infrastructure", "HazelcastStorageModule", hasEntityStore( 'Hazelcast' ) );
+ copyZestBootstrap( this, "infrastructure", "JCloudsStorageModule", hasEntityStore( 'Jclouds' ) );
+ copyZestBootstrap( this, "infrastructure", "JdbmStorageModule", hasEntityStore( 'Jdbm' ) );
+ copyZestBootstrap( this, "infrastructure", "LevelDbStorageModule", hasEntityStore( 'Leveldb' ) );
+ copyZestBootstrap( this, "infrastructure", "InMemoryStorageModule", hasEntityStore( 'Memory' ) );
+ copyZestBootstrap( this, "infrastructure", "MongoDbStorageModule", hasEntityStore( 'Mongodb' ) );
+ copyZestBootstrap( this, "infrastructure", "PreferencesStorageModule", hasEntityStore( 'Preferences' ) );
+ copyZestBootstrap( this, "infrastructure", "RedisStorageModule", hasEntityStore( 'Redis' ) );
+ copyZestBootstrap( this, "infrastructure", "RiakStorageModule", hasEntityStore( 'Riak' ) );
+ copyZestBootstrap( this, "infrastructure", "SqlStorageModule", hasEntityStore( 'Sql' ) );
+
+ copyZestBootstrap( this, "infrastructure", "RdfIndexingModule", hasIndexing( 'Rdf' ) );
+ copyZestBootstrap( this, "infrastructure", "ElasticSearchIndexingModule", hasIndexing( 'Elasticsearch' ) );
+ copyZestBootstrap( this, "infrastructure", "SolrIndexingModule", hasIndexing( 'Solr' ) );
+ copyZestBootstrap( this, "infrastructure", "SqlIndexingModule", hasIndexing( 'Sql' ) );
+
+ copyZestBootstrap( this, "infrastructure", "NoCachingModule", hasCaching( 'none' ) );
+ copyZestBootstrap( this, "infrastructure", "MemcacheCachingModule", hasCaching( 'Memcache' ) );
+ copyZestBootstrap( this, "infrastructure", "EhCacheCachingModule", hasCaching( 'Ehcache' ) );
+
+ copyZestBootstrap( this, "infrastructure", "JacksonSerializationModule", hasSerialization( 'Jackson' ) );
+ copyZestBootstrap( this, "infrastructure", "StaxSerializationModule", hasSerialization( 'Stax' ) );
+ copyZestBootstrap( this, "infrastructure", "OrgJsonSerializationModule", hasSerialization( 'Orgjson' ) );
+
+ copyZestBootstrap( this, "connectivity", "RestApiModule", hasFeature( 'rest api' ) );
+ copyZestBootstrap( this, "infrastructure", "ReindexerModule", hasFeature( 'reindexer' ) );
+ copyZestBootstrap( this, "infrastructure", "MetricsModule", hasFeature( 'metrics' ) );
+ copyZestBootstrap( this, "infrastructure", "JmxModule", hasFeature( 'jmx' ) );
+ copyZestBootstrap( this, "infrastructure", "MigrationModule", hasFeature( 'version migration' ) );
+
+ copyZestBootstrap( this, "domain", "CrudModule", true );
+ copyHeroesSampleApp( this );
+ copyZestDomain( this, "security", "RestApiModule", "SecurityRepository", hasFeature( 'rest api' ) );
+
+ copyRestFeature( this, hasFeature( 'rest api' ) );
+
+ this.fs.copyTpl( this.templatePath( 'buildtool/gradle-app.tmpl' ), this.destinationPath( 'app/build.gradle' ), {} );
+ this.fs.copyTpl( this.templatePath( 'buildtool/gradle-bootstrap.tmpl' ), this.destinationPath( 'bootstrap/build.gradle' ), {} );
+ this.fs.copyTpl( this.templatePath( 'buildtool/gradle-model.tmpl' ), this.destinationPath( 'model/build.gradle' ), {} );
+ this.fs.copyTpl( this.templatePath( 'buildtool/gradle-rest.tmpl' ), this.destinationPath( 'rest/build.gradle' ), {} );
+ this.fs.copyTpl( this.templatePath( 'buildtool/gradle-root.tmpl' ), this.destinationPath( 'build.gradle' ), {} );
+ this.fs.copyTpl( this.templatePath( 'buildtool/settings.tmpl' ), this.destinationPath( 'settings.gradle' ), {projectName: zest.name} );
+ this.fs.copyTpl( this.templatePath( 'buildtool/gradlew.tmpl' ), this.destinationPath( 'gradlew' ), {} );
+ this.fs.copyTpl( this.templatePath( 'buildtool/gradlew-bat.tmpl' ), this.destinationPath( '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' ) );
+ }
+ }
+);
+
+function copyZestBootstrap( ctx, layer, moduleName, condition )
+{
+ if( condition )
+ {
+ copyTemplate( ctx,
+ moduleName + '/bootstrap.tmpl',
+ 'bootstrap/src/main/java/' + zest.javaPackageDir + '/bootstrap/' + layer + '/' + moduleName + '.java' );
+ }
+}
+
+function copyZestApp( ctx, name, condition )
+{
+ if( condition )
+ {
+ copyTemplate( ctx,
+ name + '/bootstrap.tmpl',
+ 'bootstrap/src/main/java/' + zest.javaPackageDir + '/bootstrap/' + name + 'ApplicationAssembler.java' );
+
+ copyTemplate( ctx,
+ name + '/app.tmpl',
+ 'app/src/main/java/' + zest.javaPackageDir + '/app/' + name + '.java' );
+
+ copyTemplate( ctx,
+ name + '/webapp/',
+ 'app/src/main/webapp/' );
+ }
+}
+
+function copyZestDomain( ctx, model, module, clazz, condition )
+{
+ if( condition )
+ {
+ copyTemplate( ctx,
+ module + '/' + clazz + '.tmpl',
+ 'model/src/main/java/' + zest.javaPackageDir + '/model/' + model + '/' + clazz + '.java' );
+ }
+}
+
+function copyRestFeature( ctx, condition )
+{
+ if( condition )
+ {
+ copyZestBootstrap( ctx, "domain", "SecurityModule", true );
+
+ copyTemplate( ctx,
+ 'RestApiModule/SimpleEnroler.tmpl',
+ 'rest/src/main/java/' + zest.javaPackageDir + '/rest/security/SimpleEnroler.java' );
+
+ copyTemplate( ctx,
+ 'RestApiModule/SimpleVerifier.tmpl',
+ 'rest/src/main/java/' + zest.javaPackageDir + '/rest/security/SimpleVerifier.java' );
+
+ copyTemplate( ctx,
+ 'RestApiModule/HardcodedSecurityRepositoryMixin.tmpl',
+ 'model/src/main/java/' + zest.javaPackageDir + '/model/security/HardcodedSecurityRepositoryMixin.java' );
+ }
+}
+
+function copyHeroesSampleApp( ctx )
+{
+ copyZestDomain( ctx, "heroes", "Heroes", "Hero", hasFeature( 'sample (heroes) web application' ) );
+ copyZestApp( 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: zest.packagename,
+ hasFeature: hasFeature,
+ hasEntityStore: hasEntityStore,
+ hasIndexing: hasIndexing,
+ hasCaching: hasCaching,
+ zest: zest
+ }
+ );
+}
+
+function hasEntityStore( esType )
+{
+ return zest.entitystore === esType;
+}
+
+function hasIndexing( indexingType )
+{
+ return zest.indexing === indexingType;
+}
+
+function hasCaching( cachingType )
+{
+ return zest.caching === cachingType;
+}
+
+function hasSerialization( serializer )
+{
+ return zest.serialization === serializer;
+}
+
+function hasFeature( feature )
+{
+ return zest.features.indexOf( feature ) >= 0;
+}
+
+function firstUpper( text )
+{
+ return text.charAt( 0 ).toUpperCase() + text.substring( 1 );
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/ConfigModule/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/ConfigModule/bootstrap.tmpl b/tools/generator-zest/app/templates/ConfigModule/bootstrap.tmpl
new file mode 100644
index 0000000..cbad162
--- /dev/null
+++ b/tools/generator-zest/app/templates/ConfigModule/bootstrap.tmpl
@@ -0,0 +1,43 @@
+<%#
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+-%>
+package <%= packageName %>.bootstrap.config;
+
+import org.apache.zest.api.common.Visibility;
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.bootstrap.layered.ModuleAssembler;
+import org.apache.zest.entitystore.memory.MemoryEntityStoreService;
+import org.apache.zest.spi.uuid.UuidIdentityGeneratorService;
+import org.apache.zest.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 );
+ module.services( UuidIdentityGeneratorService.class ).visibleIn( Visibility.layer );
+ return module;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/ConfigurationLayer/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/ConfigurationLayer/bootstrap.tmpl b/tools/generator-zest/app/templates/ConfigurationLayer/bootstrap.tmpl
new file mode 100644
index 0000000..fd6cad0
--- /dev/null
+++ b/tools/generator-zest/app/templates/ConfigurationLayer/bootstrap.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 %>.bootstrap.config;
+
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.bootstrap.layered.LayerAssembler;
+import org.apache.zest.bootstrap.layered.LayeredLayerAssembler;
+
+public class ConfigurationLayer extends LayeredLayerAssembler
+ implements LayerAssembler
+{
+ public static String NAME;
+ private ModuleAssembly configModule;
+
+ @Override
+ public LayerAssembly assemble( LayerAssembly layer )
+ throws AssemblyException
+ {
+ configModule = createModule( layer, ConfigModule.class );
+ return layer;
+ }
+
+ public ModuleAssembly configModule()
+ {
+ return configModule;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/ConnectivityLayer/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/ConnectivityLayer/bootstrap.tmpl b/tools/generator-zest/app/templates/ConnectivityLayer/bootstrap.tmpl
new file mode 100644
index 0000000..88bfeea
--- /dev/null
+++ b/tools/generator-zest/app/templates/ConnectivityLayer/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.connectivity;
+
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.layered.LayerAssembler;
+import org.apache.zest.bootstrap.layered.LayeredLayerAssembler;
+
+public class ConnectivityLayer extends LayeredLayerAssembler
+ implements LayerAssembler
+{
+ public static String NAME;
+
+ @Override
+ public LayerAssembly assemble( LayerAssembly layer )
+ throws AssemblyException
+ {
+<% if( hasFeature('rest api') ) { %>
+ createModule( layer, RestApiModule.class );
+<% } -%>
+ return layer;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/CrudModule/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/CrudModule/bootstrap.tmpl b/tools/generator-zest/app/templates/CrudModule/bootstrap.tmpl
new file mode 100644
index 0000000..4db1a06
--- /dev/null
+++ b/tools/generator-zest/app/templates/CrudModule/bootstrap.tmpl
@@ -0,0 +1,39 @@
+<%#
+ * 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.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.bootstrap.layered.ModuleAssembler;
+import org.apache.zest.library.restlet.assembly.CrudServiceAssembler;
+
+public class CrudModule
+ implements ModuleAssembler
+{
+ @Override
+ public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+ throws AssemblyException
+ {
+ module.withDefaultUnitOfWorkFactory();
+ new CrudServiceAssembler().assemble( module );
+ return module;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/DomainLayer/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/DomainLayer/bootstrap.tmpl b/tools/generator-zest/app/templates/DomainLayer/bootstrap.tmpl
new file mode 100644
index 0000000..1d8afe2
--- /dev/null
+++ b/tools/generator-zest/app/templates/DomainLayer/bootstrap.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 %>.bootstrap.domain;
+
+import java.util.function.Function;
+import org.apache.zest.api.structure.Application;
+import org.apache.zest.api.structure.Module;
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.layered.LayerAssembler;
+import org.apache.zest.bootstrap.layered.LayeredLayerAssembler;
+
+public class DomainLayer extends LayeredLayerAssembler
+ implements LayerAssembler
+{
+ @Override
+ public LayerAssembly assemble(LayerAssembly layer)
+ throws AssemblyException
+ {
+ createModule( layer, CrudModule.class );
+ createModule( layer, SecurityModule.class );
+ return layer;
+ }
+
+ public static Function<Application, Module> typeFinder()
+ {
+ return application -> application.findModule( "Domain Layer", "Assets Module" );
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/FileConfigurationModule/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/FileConfigurationModule/bootstrap.tmpl b/tools/generator-zest/app/templates/FileConfigurationModule/bootstrap.tmpl
new file mode 100644
index 0000000..4bb1d37
--- /dev/null
+++ b/tools/generator-zest/app/templates/FileConfigurationModule/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.infrastructure;
+
+import org.apache.zest.api.common.Visibility;
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.bootstrap.layered.ModuleAssembler;
+import org.apache.zest.library.fileconfig.FileConfigurationAssembler;
+
+public class FileConfigurationModule
+ implements ModuleAssembler
+{
+ public static String NAME;
+
+ @Override
+ public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+ throws AssemblyException
+ {
+ new FileConfigurationAssembler().visibleIn( Visibility.layer ).assemble( module );
+ return module;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/FileStorageModule/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/FileStorageModule/bootstrap.tmpl b/tools/generator-zest/app/templates/FileStorageModule/bootstrap.tmpl
new file mode 100644
index 0000000..0f71243
--- /dev/null
+++ b/tools/generator-zest/app/templates/FileStorageModule/bootstrap.tmpl
@@ -0,0 +1,53 @@
+<%#
+ * 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.zest.api.common.Visibility;
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.bootstrap.layered.ModuleAssembler;
+import org.apache.zest.entitystore.file.assembly.FileEntityStoreAssembler;
+
+public class FileStorageModule
+ implements ModuleAssembler
+{
+ public static final String NAME = "File Storage Module";
+ private final ModuleAssembly configModule;
+
+ public FileStorageModule( ModuleAssembly configModule )
+ {
+ this.configModule = configModule;
+ }
+
+ @Override
+ public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+ throws AssemblyException
+ {
+ module.withDefaultUnitOfWorkFactory();
+
+ new FileEntityStoreAssembler()
+ .visibleIn( Visibility.application )
+ .withConfig( configModule, Visibility.application )
+ .identifiedBy( "filestore" )
+ .assemble( module );
+ return module;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/Heroes/Hero.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/Heroes/Hero.tmpl b/tools/generator-zest/app/templates/Heroes/Hero.tmpl
new file mode 100644
index 0000000..f0b3f2e
--- /dev/null
+++ b/tools/generator-zest/app/templates/Heroes/Hero.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.heroes;
+
+import org.apache.zest.api.entity.Identity;
+import org.apache.zest.api.property.Property;
+
+public interface Hero extends Identity
+{
+ Property<String> name();
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/Heroes/app.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/Heroes/app.tmpl b/tools/generator-zest/app/templates/Heroes/app.tmpl
new file mode 100644
index 0000000..f3771bc
--- /dev/null
+++ b/tools/generator-zest/app/templates/Heroes/app.tmpl
@@ -0,0 +1,103 @@
+<%#
+ * 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 %>.app;
+
+import java.lang.reflect.UndeclaredThrowableException;
+import org.apache.zest.api.structure.Application;
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.layered.LayeredApplicationAssembler;
+import org.apache.zest.library.restlet.ZrestApplication;
+import org.restlet.Context;
+import org.restlet.routing.Filter;
+import org.restlet.routing.Router;
+import org.restlet.security.Enroler;
+import org.restlet.security.Verifier;
+
+import <%= packageName %>.bootstrap.HeroesApplicationAssembler;
+import <%= packageName %>.bootstrap.connectivity.ConnectivityLayer;
+import <%= packageName %>.bootstrap.connectivity.RestApiModule;
+import <%= packageName %>.model.heroes.Hero;
+import <%= packageName %>.rest.security.SimpleEnroler;
+import <%= packageName %>.rest.security.SimpleVerifier;
+
+public class Heroes extends ZrestApplication
+{
+
+ public Heroes( Context context )
+ throws AssemblyException
+ {
+ super( context );
+ }
+
+ @Override
+ protected void addRoutes( Router router )
+ {
+ addResourcePath( "heroes", Hero.class, "/" );
+ }
+
+ @Override
+ protected LayeredApplicationAssembler createApplicationAssembler( String mode )
+ throws AssemblyException
+ {
+ if( mode != null )
+ {
+ return new HeroesApplicationAssembler( Application.Mode.valueOf( mode ) );
+ }
+ return new HeroesApplicationAssembler( Application.Mode.production );
+ }
+
+ @Override
+ protected Verifier createVerifier()
+ {
+ return newObject( SimpleVerifier.class );
+ }
+
+ @Override
+ protected Enroler createEnroler()
+ {
+ return newObject( SimpleEnroler.class, this );
+ }
+
+ @Override
+ protected String getConnectivityLayer()
+ {
+ return ConnectivityLayer.NAME;
+ }
+
+ @Override
+ protected String getConnectivityModule()
+ {
+ return RestApiModule.NAME;
+ }
+
+ private <T> T newObject( Class<T> type, Object... uses )
+ {
+ try
+ {
+ T instamce = type.newInstance();
+ objectFactory.injectTo( instamce, uses );
+ return instamce;
+ }
+ catch( Exception e )
+ {
+ throw new UndeclaredThrowableException( e );
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/Heroes/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/Heroes/bootstrap.tmpl b/tools/generator-zest/app/templates/Heroes/bootstrap.tmpl
new file mode 100644
index 0000000..4baa1f2
--- /dev/null
+++ b/tools/generator-zest/app/templates/Heroes/bootstrap.tmpl
@@ -0,0 +1,68 @@
+<%#
+ * 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;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.function.Function;
+
+import org.apache.zest.api.structure.Application;
+import org.apache.zest.api.structure.Module;
+
+import org.apache.zest.bootstrap.ApplicationAssembly;
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.bootstrap.layered.LayeredApplicationAssembler;
+
+import <%= packageName %>.bootstrap.connectivity.ConnectivityLayer;
+import <%= packageName %>.bootstrap.domain.DomainLayer;
+import <%= packageName %>.bootstrap.config.ConfigurationLayer;
+import <%= packageName %>.bootstrap.infrastructure.InfrastructureLayer;
+
+public class HeroesApplicationAssembler extends LayeredApplicationAssembler
+{
+ private static final String NAME = "Heroes";
+ private static final String VERSION = "1.0.alpha";
+
+ public HeroesApplicationAssembler( Application.Mode mode )
+ throws AssemblyException
+ {
+ super( NAME, VERSION, mode );
+ }
+
+ @Override
+ protected void assembleLayers( ApplicationAssembly assembly )
+ throws AssemblyException
+ {
+ LayerAssembly configLayer = createLayer( ConfigurationLayer.class );
+ ModuleAssembly configModule = assemblerOf( ConfigurationLayer.class ).configModule();
+ LayerAssembly domainLayer = createLayer( DomainLayer.class );
+ Function<Application, Module> typeFinder = DomainLayer.typeFinder();
+ LayerAssembly infraLayer = new InfrastructureLayer( configModule, typeFinder ).assemble( assembly.layer( InfrastructureLayer.NAME ) );
+ LayerAssembly connectivityLayer = createLayer( ConnectivityLayer.class );
+ connectivityLayer.uses( domainLayer );
+ domainLayer.uses( infraLayer );
+ infraLayer.uses( configLayer );
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/Heroes/web.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/Heroes/web.tmpl b/tools/generator-zest/app/templates/Heroes/web.tmpl
new file mode 100644
index 0000000..eb26db5
--- /dev/null
+++ b/tools/generator-zest/app/templates/Heroes/web.tmpl
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<%#
+ ~ 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.
+ ~
+ ~
+%>
+<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><%= zest.name %></display-name>
+
+
+ <servlet>
+ <servlet-name>Restlet</servlet-name>
+ <servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
+ <init-param>
+ <param-name>org.apache.zest.runtime.mode</param-name>
+ <param-value>development</param-value>
+ </init-param>
+ <init-param>
+ <!-- Application class name -->
+ <param-name>org.restlet.application</param-name>
+ <param-value><%= packageName %>.app.Heroes</param-value>
+ </init-param>
+ <init-param>
+ <!-- Protocols to be bound to-->
+ <param-name>org.restlet.clients</param-name>
+ <param-value>HTTP HTTPS</param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Restlet</servlet-name>
+ <url-pattern>/api/1/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/Heroes/webapp/app/app.component.css
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/Heroes/webapp/app/app.component.css b/tools/generator-zest/app/templates/Heroes/webapp/app/app.component.css
new file mode 100755
index 0000000..cb651f5
--- /dev/null
+++ b/tools/generator-zest/app/templates/Heroes/webapp/app/app.component.css
@@ -0,0 +1,34 @@
+nav a {
+ padding: 5px 10px;
+ text-decoration: none;
+ margin-top: 10px;
+ display: inline-block;
+ background-color: #eee;
+ border-radius: 4px;
+}
+nav a:visited, a:link {
+ color: #607D8B;
+}
+nav a:hover {
+ color: #039be5;
+ background-color: #CFD8DC;
+}
+nav a.router-link-active {
+ color: #039be5;
+}
+h1 {
+ font-size: 1.2em;
+ color: #999;
+ margin-bottom: 0;
+}
+h2 {
+ font-size: 2em;
+ margin-top: 0;
+ padding-top: 0;
+}
+
+/*
+Copyright 2016 Google Inc. All Rights Reserved.
+Use of this source code is governed by an MIT-style license that
+can be found in the LICENSE file at http://angular.io/license
+*/
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/Heroes/webapp/app/app.component.ts
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/Heroes/webapp/app/app.component.ts b/tools/generator-zest/app/templates/Heroes/webapp/app/app.component.ts
new file mode 100755
index 0000000..222874b
--- /dev/null
+++ b/tools/generator-zest/app/templates/Heroes/webapp/app/app.component.ts
@@ -0,0 +1,37 @@
+import {Component} from 'angular2/core';
+import {RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';
+import {HeroesComponent} from './heroes.component';
+import {HeroDetailComponent} from './hero-detail.component';
+import {DashboardComponent} from './dashboard.component';
+import {HeroService} from './hero.service';
+
+@Component({
+ selector: 'my-app',
+ template: `
+ <h1>{{title}}</h1>
+ <nav>
+ <a [routerLink]="['Dashboard']">Dashboard</a>
+ <a [routerLink]="['Heroes']">Heroes</a>
+ </nav>
+ <router-outlet></router-outlet>
+ `,
+ styleUrls: ['app/app.component.css'],
+ directives: [ROUTER_DIRECTIVES],
+ providers: [HeroService]
+})
+@RouteConfig([
+ // {path: '/', redirectTo: ['Dashboard'] },
+ {path: '/dashboard', name: 'Dashboard', component: DashboardComponent, useAsDefault: true},
+ {path: '/heroes', name: 'Heroes', component: HeroesComponent},
+ {path: '/detail/:id', name: 'HeroDetail', component: HeroDetailComponent}
+])
+export class AppComponent {
+ title = 'Tour of Heroes';
+}
+
+
+/*
+Copyright 2016 Google Inc. All Rights Reserved.
+Use of this source code is governed by an MIT-style license that
+can be found in the LICENSE file at http://angular.io/license
+*/
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/Heroes/webapp/app/dashboard.component.css
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/Heroes/webapp/app/dashboard.component.css b/tools/generator-zest/app/templates/Heroes/webapp/app/dashboard.component.css
new file mode 100755
index 0000000..b9d3215
--- /dev/null
+++ b/tools/generator-zest/app/templates/Heroes/webapp/app/dashboard.component.css
@@ -0,0 +1,67 @@
+[class*='col-'] {
+ float: left;
+}
+*, *:after, *:before {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+h3 {
+ text-align: center; margin-bottom: 0;
+}
+[class*='col-'] {
+ padding-right: 20px;
+ padding-bottom: 20px;
+}
+[class*='col-']:last-of-type {
+ padding-right: 0;
+}
+.grid {
+ margin: 0;
+}
+.col-1-4 {
+ width: 25%;
+}
+.module {
+ padding: 20px;
+ text-align: center;
+ color: #eee;
+ max-height: 120px;
+ min-width: 120px;
+ background-color: #607D8B;
+ border-radius: 2px;
+}
+h4 {
+ position: relative;
+}
+.module:hover {
+ background-color: #EEE;
+ cursor: pointer;
+ color: #607d8b;
+}
+.grid-pad {
+ padding: 10px 0;
+}
+.grid-pad > [class*='col-']:last-of-type {
+ padding-right: 20px;
+}
+@media (max-width: 600px) {
+ .module {
+ font-size: 10px;
+ max-height: 75px; }
+}
+@media (max-width: 1024px) {
+ .grid {
+ margin: 0;
+ }
+ .module {
+ min-width: 60px;
+ }
+}
+
+
+/*
+Copyright 2016 Google Inc. All Rights Reserved.
+Use of this source code is governed by an MIT-style license that
+can be found in the LICENSE file at http://angular.io/license
+*/
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/Heroes/webapp/app/dashboard.component.html
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/Heroes/webapp/app/dashboard.component.html b/tools/generator-zest/app/templates/Heroes/webapp/app/dashboard.component.html
new file mode 100755
index 0000000..3fc7517
--- /dev/null
+++ b/tools/generator-zest/app/templates/Heroes/webapp/app/dashboard.component.html
@@ -0,0 +1,15 @@
+<h3>Top Heroes</h3>
+<div class="grid grid-pad">
+ <div *ngFor="#hero of heroes" class="col-1-4" (click)="gotoDetail(hero)">
+ <div class="module hero">
+ <h4>{{hero.name}}</h4>
+ </div>
+ </div>
+</div>
+
+
+<!--
+Copyright 2016 Google Inc. All Rights Reserved.
+Use of this source code is governed by an MIT-style license that
+can be found in the LICENSE file at http://angular.io/license
+-->
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/Heroes/webapp/app/dashboard.component.ts
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/Heroes/webapp/app/dashboard.component.ts b/tools/generator-zest/app/templates/Heroes/webapp/app/dashboard.component.ts
new file mode 100755
index 0000000..c8160d1
--- /dev/null
+++ b/tools/generator-zest/app/templates/Heroes/webapp/app/dashboard.component.ts
@@ -0,0 +1,31 @@
+import {Component, OnInit} from 'angular2/core';
+import {Router} from 'angular2/router';
+import {Hero} from './hero';
+import {HeroService} from './hero.service';
+
+@Component({
+ selector: 'my-dashboard',
+ templateUrl: 'app/dashboard.component.html',
+ styleUrls: ['app/dashboard.component.css']
+})
+export class DashboardComponent implements OnInit {
+ heroes: Hero[] = [];
+
+ constructor(private _heroService: HeroService, private _router: Router) { }
+
+ ngOnInit() {
+ this._heroService.getHeroes().then(heroes => this.heroes = heroes.slice(1,5));
+ }
+
+ gotoDetail(hero: Hero) {
+ let link = ['HeroDetail', { id: hero.id }];
+ this._router.navigate(link);
+ }
+}
+
+
+/*
+Copyright 2016 Google Inc. All Rights Reserved.
+Use of this source code is governed by an MIT-style license that
+can be found in the LICENSE file at http://angular.io/license
+*/
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/Heroes/webapp/app/hero-detail.component.css
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/Heroes/webapp/app/hero-detail.component.css b/tools/generator-zest/app/templates/Heroes/webapp/app/hero-detail.component.css
new file mode 100755
index 0000000..2a0e285
--- /dev/null
+++ b/tools/generator-zest/app/templates/Heroes/webapp/app/hero-detail.component.css
@@ -0,0 +1,36 @@
+label {
+ display: inline-block;
+ width: 3em;
+ margin: .5em 0;
+ color: #607D8B;
+ font-weight: bold;
+}
+input {
+ height: 2em;
+ font-size: 1em;
+ padding-left: .4em;
+}
+button {
+ margin-top: 20px;
+ font-family: Arial;
+ background-color: #eee;
+ border: none;
+ padding: 5px 10px;
+ border-radius: 4px;
+ cursor: pointer; cursor: hand;
+}
+button:hover {
+ background-color: #cfd8dc;
+}
+button:disabled {
+ background-color: #eee;
+ color: #ccc;
+ cursor: auto;
+}
+
+
+/*
+Copyright 2016 Google Inc. All Rights Reserved.
+Use of this source code is governed by an MIT-style license that
+can be found in the LICENSE file at http://angular.io/license
+*/
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/Heroes/webapp/app/hero-detail.component.html
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/Heroes/webapp/app/hero-detail.component.html b/tools/generator-zest/app/templates/Heroes/webapp/app/hero-detail.component.html
new file mode 100755
index 0000000..1e85e75
--- /dev/null
+++ b/tools/generator-zest/app/templates/Heroes/webapp/app/hero-detail.component.html
@@ -0,0 +1,16 @@
+<div *ngIf="hero">
+ <h2>{{hero.name}} details!</h2>
+ <div>
+ <label>id: </label>{{hero.id}}</div>
+ <div>
+ <label>name: </label>
+ <input [(ngModel)]="hero.name" placeholder="name"/>
+ </div>
+ <button (click)="goBack()">Back</button>
+</div>
+
+<!--
+Copyright 2016 Google Inc. All Rights Reserved.
+Use of this source code is governed by an MIT-style license that
+can be found in the LICENSE file at http://angular.io/license
+-->
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/Heroes/webapp/app/hero-detail.component.ts
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/Heroes/webapp/app/hero-detail.component.ts b/tools/generator-zest/app/templates/Heroes/webapp/app/hero-detail.component.ts
new file mode 100755
index 0000000..0181847
--- /dev/null
+++ b/tools/generator-zest/app/templates/Heroes/webapp/app/hero-detail.component.ts
@@ -0,0 +1,34 @@
+import {Component, OnInit} from 'angular2/core';
+import {RouteParams} from 'angular2/router';
+
+import {Hero} from './hero';
+import {HeroService} from './hero.service';
+
+@Component({
+ selector: 'my-hero-detail',
+ templateUrl: 'app/hero-detail.component.html',
+ styleUrls: ['app/hero-detail.component.css']
+})
+export class HeroDetailComponent implements OnInit {
+ hero: Hero;
+
+ constructor(private _heroService: HeroService,
+ private _routeParams: RouteParams) {
+ }
+
+ ngOnInit() {
+ let id = +this._routeParams.get('id');
+ this._heroService.getHero(id).then(hero => this.hero = hero);
+ }
+
+ goBack() {
+ window.history.back();
+ }
+}
+
+
+/*
+Copyright 2016 Google Inc. All Rights Reserved.
+Use of this source code is governed by an MIT-style license that
+can be found in the LICENSE file at http://angular.io/license
+*/
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/Heroes/webapp/app/hero.service.ts
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/Heroes/webapp/app/hero.service.ts b/tools/generator-zest/app/templates/Heroes/webapp/app/hero.service.ts
new file mode 100755
index 0000000..aee78a1
--- /dev/null
+++ b/tools/generator-zest/app/templates/Heroes/webapp/app/hero.service.ts
@@ -0,0 +1,22 @@
+import {Injectable} from 'angular2/core';
+import {HEROES} from './mock-heroes';
+
+@Injectable()
+export class HeroService {
+ getHeroes() {
+ return Promise.resolve(HEROES);
+ }
+
+ getHero(id: number) {
+ return Promise.resolve(HEROES).then(
+ heroes => heroes.filter(hero => hero.id === id)[0]
+ );
+ }
+}
+
+
+/*
+Copyright 2016 Google Inc. All Rights Reserved.
+Use of this source code is governed by an MIT-style license that
+can be found in the LICENSE file at http://angular.io/license
+*/
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/Heroes/webapp/app/hero.ts
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/Heroes/webapp/app/hero.ts b/tools/generator-zest/app/templates/Heroes/webapp/app/hero.ts
new file mode 100755
index 0000000..812726c
--- /dev/null
+++ b/tools/generator-zest/app/templates/Heroes/webapp/app/hero.ts
@@ -0,0 +1,11 @@
+export class Hero {
+ id: number;
+ name: string;
+}
+
+
+/*
+Copyright 2016 Google Inc. All Rights Reserved.
+Use of this source code is governed by an MIT-style license that
+can be found in the LICENSE file at http://angular.io/license
+*/
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/Heroes/webapp/app/heroes.component.css
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/Heroes/webapp/app/heroes.component.css b/tools/generator-zest/app/templates/Heroes/webapp/app/heroes.component.css
new file mode 100755
index 0000000..98e7ecc
--- /dev/null
+++ b/tools/generator-zest/app/templates/Heroes/webapp/app/heroes.component.css
@@ -0,0 +1,66 @@
+.selected {
+ background-color: #CFD8DC !important;
+ color: white;
+}
+.heroes {
+ margin: 0 0 2em 0;
+ list-style-type: none;
+ padding: 0;
+ width: 15em;
+}
+.heroes li {
+ cursor: pointer;
+ position: relative;
+ left: 0;
+ background-color: #EEE;
+ margin: .5em;
+ padding: .3em 0;
+ height: 1.6em;
+ border-radius: 4px;
+}
+.heroes li:hover {
+ color: #607D8B;
+ background-color: #DDD;
+ left: .1em;
+}
+.heroes li.selected:hover {
+ background-color: #BBD8DC !important;
+ color: white;
+}
+.heroes .text {
+ position: relative;
+ top: -3px;
+}
+.heroes .badge {
+ display: inline-block;
+ font-size: small;
+ color: white;
+ padding: 0.8em 0.7em 0 0.7em;
+ background-color: #607D8B;
+ line-height: 1em;
+ position: relative;
+ left: -1px;
+ top: -4px;
+ height: 1.8em;
+ margin-right: .8em;
+ border-radius: 4px 0 0 4px;
+}
+button {
+ font-family: Arial;
+ background-color: #eee;
+ border: none;
+ padding: 5px 10px;
+ border-radius: 4px;
+ cursor: pointer;
+ cursor: hand;
+}
+button:hover {
+ background-color: #cfd8dc;
+}
+
+
+/*
+Copyright 2016 Google Inc. All Rights Reserved.
+Use of this source code is governed by an MIT-style license that
+can be found in the LICENSE file at http://angular.io/license
+*/
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/Heroes/webapp/app/heroes.component.html
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/Heroes/webapp/app/heroes.component.html b/tools/generator-zest/app/templates/Heroes/webapp/app/heroes.component.html
new file mode 100755
index 0000000..0688e6a
--- /dev/null
+++ b/tools/generator-zest/app/templates/Heroes/webapp/app/heroes.component.html
@@ -0,0 +1,21 @@
+<div>
+ <h2>My Heroes</h2>
+ <ul class="heroes">
+ <li *ngFor="#hero of heroes"
+ [class.selected]="hero === selectedHero"
+ (click)="onSelect(hero)">
+ <span class="badge">{{hero.id}}</span> {{hero.name}}
+ </li>
+ </ul>
+ <div *ngIf="selectedHero">
+ <h2>{{selectedHero.name | uppercase}} is my hero</h2>
+ <button (click)="gotoDetail()">View Details</button>
+ </div>
+</div>
+
+
+<!--
+Copyright 2016 Google Inc. All Rights Reserved.
+Use of this source code is governed by an MIT-style license that
+can be found in the LICENSE file at http://angular.io/license
+-->
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/Heroes/webapp/app/heroes.component.ts
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/Heroes/webapp/app/heroes.component.ts b/tools/generator-zest/app/templates/Heroes/webapp/app/heroes.component.ts
new file mode 100755
index 0000000..0002025
--- /dev/null
+++ b/tools/generator-zest/app/templates/Heroes/webapp/app/heroes.component.ts
@@ -0,0 +1,39 @@
+import {Component, OnInit} from 'angular2/core';
+import {Router} from 'angular2/router';
+import {HeroService} from './hero.service';
+import {HeroDetailComponent} from './hero-detail.component';
+import {Hero} from './hero';
+
+@Component({
+ selector: 'my-heroes',
+ templateUrl: 'app/heroes.component.html',
+ styleUrls: ['app/heroes.component.css'],
+ directives: [HeroDetailComponent]
+})
+export class HeroesComponent implements OnInit {
+ heroes: Hero[];
+ selectedHero: Hero;
+
+ constructor(private _heroService: HeroService, private _router: Router) { }
+
+ getHeroes() {
+ this._heroService.getHeroes().then(heroes => this.heroes = heroes);
+ }
+
+ gotoDetail() {
+ this._router.navigate(['HeroDetail', { id: this.selectedHero.id }]);
+ }
+
+ ngOnInit() {
+ this.getHeroes();
+ }
+
+ onSelect(hero: Hero) { this.selectedHero = hero; }
+}
+
+
+/*
+Copyright 2016 Google Inc. All Rights Reserved.
+Use of this source code is governed by an MIT-style license that
+can be found in the LICENSE file at http://angular.io/license
+*/
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/Heroes/webapp/app/main.ts
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/Heroes/webapp/app/main.ts b/tools/generator-zest/app/templates/Heroes/webapp/app/main.ts
new file mode 100755
index 0000000..95e2d0b
--- /dev/null
+++ b/tools/generator-zest/app/templates/Heroes/webapp/app/main.ts
@@ -0,0 +1,16 @@
+import {bootstrap} from 'angular2/platform/browser';
+import {ROUTER_PROVIDERS} from 'angular2/router';
+import {HeroService} from './hero.service';
+import {AppComponent} from './app.component';
+
+bootstrap(AppComponent, [
+ ROUTER_PROVIDERS,
+ HeroService
+]);
+
+
+/*
+Copyright 2016 Google Inc. All Rights Reserved.
+Use of this source code is governed by an MIT-style license that
+can be found in the LICENSE file at http://angular.io/license
+*/
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/Heroes/webapp/app/mock-heroes.ts
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/Heroes/webapp/app/mock-heroes.ts b/tools/generator-zest/app/templates/Heroes/webapp/app/mock-heroes.ts
new file mode 100755
index 0000000..673cf53
--- /dev/null
+++ b/tools/generator-zest/app/templates/Heroes/webapp/app/mock-heroes.ts
@@ -0,0 +1,21 @@
+import { Hero } from './hero';
+
+export var HEROES: Hero[] = [
+ {"id": 11, "name": "Mr. Nice"},
+ {"id": 12, "name": "Narco"},
+ {"id": 13, "name": "Bombasto"},
+ {"id": 14, "name": "Celeritas"},
+ {"id": 15, "name": "Magneta"},
+ {"id": 16, "name": "RubberMan"},
+ {"id": 17, "name": "Dynama"},
+ {"id": 18, "name": "Dr IQ"},
+ {"id": 19, "name": "Magma"},
+ {"id": 20, "name": "Tornado"}
+];
+
+
+/*
+Copyright 2016 Google Inc. All Rights Reserved.
+Use of this source code is governed by an MIT-style license that
+can be found in the LICENSE file at http://angular.io/license
+*/
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/Heroes/webapp/index.html
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/Heroes/webapp/index.html b/tools/generator-zest/app/templates/Heroes/webapp/index.html
new file mode 100755
index 0000000..753dd48
--- /dev/null
+++ b/tools/generator-zest/app/templates/Heroes/webapp/index.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script>document.write('<base href="' + document.location + '" />');</script>
+ <title>Angular 2 Tour of Heroes</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel="stylesheet" href="styles.css">
+
+ <!-- IE required polyfills, in this exact order -->
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.35.0/es6-shim.min.js"></script>
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.26/system-polyfills.js"></script>
+ <script src="https://npmcdn.com/angular2@2.0.0-beta.15/es6/dev/src/testing/shims_for_IE.js"></script>
+
+ <script src="https://code.angularjs.org/2.0.0-beta.15/angular2-polyfills.js"></script>
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.26/system.js"></script>
+ <script src="https://npmcdn.com/typescript@1.8.10/lib/typescript.js"></script>
+ <script src="https://code.angularjs.org/2.0.0-beta.15/Rx.js"></script>
+ <script src="https://code.angularjs.org/2.0.0-beta.15/angular2.dev.js"></script>
+ <script src="https://code.angularjs.org/2.0.0-beta.15/router.dev.js"></script>
+ <script>
+ System.config({
+ transpiler: 'typescript',
+ typescriptOptions: { emitDecoratorMetadata: true },
+ packages: {'app': {defaultExtension: 'ts'}}
+ });
+ System.import('app/main')
+ .then(null, console.error.bind(console));
+ </script>
+ </head>
+
+ <body>
+ <my-app>Loading...</my-app>
+ </body>
+</html>
+
+
+<!--
+Copyright 2016 Google Inc. All Rights Reserved.
+Use of this source code is governed by an MIT-style license that
+can be found in the LICENSE file at http://angular.io/license
+-->
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/Heroes/webapp/styles.css
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/Heroes/webapp/styles.css b/tools/generator-zest/app/templates/Heroes/webapp/styles.css
new file mode 100755
index 0000000..1774fd6
--- /dev/null
+++ b/tools/generator-zest/app/templates/Heroes/webapp/styles.css
@@ -0,0 +1,149 @@
+/* Master Styles */
+h1 {
+ color: #369;
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 250%;
+}
+h2, h3 {
+ color: #444;
+ font-family: Arial, Helvetica, sans-serif;
+ font-weight: lighter;
+}
+body {
+ margin: 2em;
+}
+body, input[text], button {
+ color: #888;
+ font-family: Cambria, Georgia;
+}
+a {
+ cursor: pointer;
+ cursor: hand;
+}
+button {
+ font-family: Arial;
+ background-color: #eee;
+ border: none;
+ padding: 5px 10px;
+ border-radius: 4px;
+ cursor: pointer;
+ cursor: hand;
+}
+button:hover {
+ background-color: #cfd8dc;
+}
+button:disabled {
+ background-color: #eee;
+ color: #aaa;
+ cursor: auto;
+}
+
+/* Navigation link styles */
+nav a {
+ padding: 5px 10px;
+ text-decoration: none;
+ margin-top: 10px;
+ display: inline-block;
+ background-color: #eee;
+ border-radius: 4px;
+}
+nav a:visited, a:link {
+ color: #607D8B;
+}
+nav a:hover {
+ color: #039be5;
+ background-color: #CFD8DC;
+}
+nav a.router-link-active {
+ color: #039be5;
+}
+
+/* items class */
+.items {
+ margin: 0 0 2em 0;
+ list-style-type: none;
+ padding: 0;
+ width: 24em;
+}
+.items li {
+ cursor: pointer;
+ position: relative;
+ left: 0;
+ background-color: #EEE;
+ margin: .5em;
+ padding: .3em 0;
+ height: 1.6em;
+ border-radius: 4px;
+}
+.items li:hover {
+ color: #607D8B;
+ background-color: #DDD;
+ left: .1em;
+}
+.items li.selected:hover {
+ background-color: #BBD8DC;
+ color: white;
+}
+.items .text {
+ position: relative;
+ top: -3px;
+}
+.items {
+ margin: 0 0 2em 0;
+ list-style-type: none;
+ padding: 0;
+ width: 24em;
+}
+.items li {
+ cursor: pointer;
+ position: relative;
+ left: 0;
+ background-color: #EEE;
+ margin: .5em;
+ padding: .3em 0;
+ height: 1.6em;
+ border-radius: 4px;
+}
+.items li:hover {
+ color: #607D8B;
+ background-color: #DDD;
+ left: .1em;
+}
+.items li.selected {
+ background-color: #CFD8DC;
+ color: white;
+}
+
+.items li.selected:hover {
+ background-color: #BBD8DC;
+}
+.items .text {
+ position: relative;
+ top: -3px;
+}
+.items .badge {
+ display: inline-block;
+ font-size: small;
+ color: white;
+ padding: 0.8em 0.7em 0 0.7em;
+ background-color: #607D8B;
+ line-height: 1em;
+ position: relative;
+ left: -1px;
+ top: -4px;
+ height: 1.8em;
+ margin-right: .8em;
+ border-radius: 4px 0 0 4px;
+}
+
+/* everywhere else */
+* {
+ font-family: Arial, Helvetica, sans-serif;
+}
+
+
+/*
+Copyright 2016 Google Inc. All Rights Reserved.
+Use of this source code is governed by an MIT-style license that
+can be found in the LICENSE file at http://angular.io/license
+*/
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/InfrastructureLayer/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/InfrastructureLayer/bootstrap.tmpl b/tools/generator-zest/app/templates/InfrastructureLayer/bootstrap.tmpl
new file mode 100644
index 0000000..61d4def
--- /dev/null
+++ b/tools/generator-zest/app/templates/InfrastructureLayer/bootstrap.tmpl
@@ -0,0 +1,55 @@
+<%#
+ * 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 java.util.function.Function;
+import org.apache.zest.api.structure.Application;
+import org.apache.zest.api.structure.Module;
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.bootstrap.layered.LayerAssembler;
+import org.apache.zest.bootstrap.layered.LayeredLayerAssembler;
+
+public class InfrastructureLayer extends LayeredLayerAssembler
+ implements LayerAssembler
+{
+ public static final String NAME = "Infrastructure Layer";
+ private final ModuleAssembly configModule;
+ private final Function<Application, Module> typeFinder;
+
+ public InfrastructureLayer( ModuleAssembly configModule, Function<Application, Module> typeFinder )
+ {
+ this.configModule = configModule;
+ this.typeFinder = typeFinder;
+ }
+
+ @Override
+ public LayerAssembly assemble( LayerAssembly layer )
+ throws AssemblyException
+ {
+ createModule( layer, FileConfigurationModule.class );
+
+ new <%= zest.entitystore %>StorageModule( configModule ).assemble( layer, layer.module( <%= zest.entitystore %>StorageModule.NAME ) );
+ new <%= zest.indexing %>IndexingModule( configModule ).assemble( layer, layer.module( <%= zest.indexing %>IndexingModule.NAME ) );
+ new <%= zest.serialization %>SerializationModule( typeFinder ).assemble( layer, layer.module( <%= zest.serialization %>SerializationModule.NAME ) );
+ return layer;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/JacksonSerializationModule/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/JacksonSerializationModule/bootstrap.tmpl b/tools/generator-zest/app/templates/JacksonSerializationModule/bootstrap.tmpl
new file mode 100644
index 0000000..1210cde
--- /dev/null
+++ b/tools/generator-zest/app/templates/JacksonSerializationModule/bootstrap.tmpl
@@ -0,0 +1,55 @@
+<%#
+ * 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 java.util.function.Function;
+import org.apache.zest.api.common.Visibility;
+import org.apache.zest.api.structure.Application;
+import org.apache.zest.api.structure.Module;
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.bootstrap.layered.ModuleAssembler;
+import org.apache.zest.spi.uuid.UuidIdentityGeneratorService;
+import org.apache.zest.valueserialization.jackson.JacksonValueSerializationAssembler;
+
+public class JacksonSerializationModule
+ implements ModuleAssembler
+{
+ public static final String NAME = "Jackson Serialization Module";
+ private final Function<Application, Module> typeFinder;
+
+ public JacksonSerializationModule( Function<Application, Module> typeFinder )
+ {
+ this.typeFinder = typeFinder;
+ }
+
+ @Override
+ public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+ throws AssemblyException
+ {
+ new JacksonValueSerializationAssembler()
+ .visibleIn( Visibility.application )
+ .withValuesModuleFinder( typeFinder )
+ .assemble( module );
+ module.services( UuidIdentityGeneratorService.class ).visibleIn( Visibility.layer );
+ return module;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/NoCachingModule/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/NoCachingModule/bootstrap.tmpl b/tools/generator-zest/app/templates/NoCachingModule/bootstrap.tmpl
new file mode 100644
index 0000000..895af43
--- /dev/null
+++ b/tools/generator-zest/app/templates/NoCachingModule/bootstrap.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 %>.bootstrap.infrastructure;
+
+import org.apache.zest.api.common.Visibility;
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.bootstrap.layered.ModuleAssembler;
+import org.apache.zest.entitystore.file.assembly.FileEntityStoreAssembler;
+
+public class NoCachingModule
+ implements ModuleAssembler
+{
+ public static final String NAME = "No Caching Module";
+ private final ModuleAssembly configModule;
+
+ public NoCachingModule( ModuleAssembly configModule )
+ {
+ this.configModule = configModule;
+ }
+
+ @Override
+ public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
+ throws AssemblyException
+ {
+ return module;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/RdfIndexingModule/bootstrap.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/RdfIndexingModule/bootstrap.tmpl b/tools/generator-zest/app/templates/RdfIndexingModule/bootstrap.tmpl
new file mode 100644
index 0000000..dd37698
--- /dev/null
+++ b/tools/generator-zest/app/templates/RdfIndexingModule/bootstrap.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 %>.bootstrap.infrastructure;
+
+import org.apache.zest.api.common.Visibility;
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.bootstrap.layered.ModuleAssembler;
+import org.apache.zest.index.rdf.assembly.RdfNativeSesameStoreAssembler;
+import org.apache.zest.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
+ {
+ module.withDefaultUnitOfWorkFactory();
+
+ 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/zest-java/blob/bc55a577/tools/generator-zest/app/templates/RestApiModule/HardcodedSecurityRepositoryMixin.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/RestApiModule/HardcodedSecurityRepositoryMixin.tmpl b/tools/generator-zest/app/templates/RestApiModule/HardcodedSecurityRepositoryMixin.tmpl
new file mode 100644
index 0000000..ffa13a9
--- /dev/null
+++ b/tools/generator-zest/app/templates/RestApiModule/HardcodedSecurityRepositoryMixin.tmpl
@@ -0,0 +1,54 @@
+<%#
+ * 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.zest.api.unitofwork.concern.UnitOfWorkPropagation;
+
+public class HardcodedSecurityRepositoryMixin
+ implements SecurityRepository
+{
+
+ @Override
+ public boolean verifyPassword( String userName, String password )
+ {
+ 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/zest-java/blob/bc55a577/tools/generator-zest/app/templates/RestApiModule/SecurityRepository.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/RestApiModule/SecurityRepository.tmpl b/tools/generator-zest/app/templates/RestApiModule/SecurityRepository.tmpl
new file mode 100644
index 0000000..be799ee
--- /dev/null
+++ b/tools/generator-zest/app/templates/RestApiModule/SecurityRepository.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.security;
+
+import java.util.List;
+import org.apache.zest.api.concern.Concerns;
+import org.apache.zest.api.unitofwork.concern.UnitOfWorkConcern;
+import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;
+
+@Concerns( UnitOfWorkConcern.class )
+public interface SecurityRepository
+{
+ @UnitOfWorkPropagation
+ boolean verifyPassword( String user, String password );
+
+ @UnitOfWorkPropagation
+ List<String> findRoleNamesOfUser( String name );
+}
+
http://git-wip-us.apache.org/repos/asf/zest-java/blob/bc55a577/tools/generator-zest/app/templates/RestApiModule/SimpleEnroler.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/RestApiModule/SimpleEnroler.tmpl b/tools/generator-zest/app/templates/RestApiModule/SimpleEnroler.tmpl
new file mode 100644
index 0000000..f3268ea
--- /dev/null
+++ b/tools/generator-zest/app/templates/RestApiModule/SimpleEnroler.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.zest.api.injection.scope.Service;
+import org.apache.zest.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 SimpleEnroler
+ 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/zest-java/blob/bc55a577/tools/generator-zest/app/templates/RestApiModule/SimpleVerifier.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-zest/app/templates/RestApiModule/SimpleVerifier.tmpl b/tools/generator-zest/app/templates/RestApiModule/SimpleVerifier.tmpl
new file mode 100644
index 0000000..dda1796
--- /dev/null
+++ b/tools/generator-zest/app/templates/RestApiModule/SimpleVerifier.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.zest.api.injection.scope.Service;
+import org.restlet.security.SecretVerifier;
+import org.restlet.security.Verifier;
+import <%= packageName %>.model.security.SecurityRepository;
+
+public class SimpleVerifier 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;
+ }
+}