Repository: polygene-java Updated Branches: refs/heads/develop ed4cca574 -> cfd38626c
Introducing another level of questions and consequences, the 'applicationm type'. Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/ab83f189 Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/ab83f189 Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/ab83f189 Branch: refs/heads/develop Commit: ab83f189725082cdb476d149f4ee41a69d378f52 Parents: 01949a6 Author: niclas <[email protected]> Authored: Tue Mar 14 07:16:26 2017 +0800 Committer: niclas <[email protected]> Committed: Tue Mar 14 07:16:26 2017 +0800 ---------------------------------------------------------------------- tools/generator-polygene/app/index.js | 20 ++------- .../app/templates/CommandLineApplication/app.js | 14 ++++++ .../RestApiModule/web.xml.tmpl | 46 -------------------- .../InfrastructureLayer/CachingModule/module.js | 1 + .../app/templates/RestAPIApplication/app.js | 19 ++++++++ .../templates/RestAPIApplication/web.xml.tmpl | 46 ++++++++++++++++++++ .../CommandLineModule/module.js | 12 +++++ .../templates/UserInterfaceLayer/bootstrap.tmpl | 41 +++++++++++++++++ .../app/templates/UserInterfaceLayer/layer.js | 10 +++++ .../app/templates/buildtool/gradle-app.tmpl | 9 ++-- .../app/templates/buildtool/settings.tmpl | 7 ++- 11 files changed, 156 insertions(+), 69 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/polygene-java/blob/ab83f189/tools/generator-polygene/app/index.js ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/index.js b/tools/generator-polygene/app/index.js index b1a12c1..30186f4 100644 --- a/tools/generator-polygene/app/index.js +++ b/tools/generator-polygene/app/index.js @@ -67,7 +67,6 @@ module.exports = generators.Base.extend( polygene.caching = polygene.caching ? polygene.caching : null; polygene.serialization = polygene.serialization ? polygene.serialization : null; } - assignFunctions(polygene); }, prompting: function () { @@ -198,30 +197,17 @@ module.exports = generators.Base.extend( this.log('Serialization:', answers.serialization); this.log('Features:', answers.features); polygene = answers; - // polygene.name = answers.name; - // polygene.entitystore = answers.entitystore; - // polygene.indexing = answers.indexing; - // polygene.caching = answers.caching; - // polygene.serialization = answers.serialization; - // polygene.metrics = answers.metrics; - // polygene.packageName = answers.packageName; - // polygene.features = answers.features; }.bind(this) ); } }, writing: function () { + assignFunctions(polygene); polygene.javaPackageDir = polygene.packageName.replace(/[.]/g, '/'); 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); - } - }); - }); + var app = require(__dirname + '/templates/' + polygene.applicationtype.replace(/ /g, '') + 'Application/app.js'); + app.write(polygene); var buildToolChain = require(__dirname + '/templates/buildtool/build.js'); buildToolChain.write(polygene); if (this.options.export) { http://git-wip-us.apache.org/repos/asf/polygene-java/blob/ab83f189/tools/generator-polygene/app/templates/CommandLineApplication/app.js ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/CommandLineApplication/app.js b/tools/generator-polygene/app/templates/CommandLineApplication/app.js new file mode 100644 index 0000000..83648f6 --- /dev/null +++ b/tools/generator-polygene/app/templates/CommandLineApplication/app.js @@ -0,0 +1,14 @@ +module.exports = { + + write: function (p) { + copyLayer("Configuration"); + copyLayer("Infrastructure"); + copyLayer("Domain"); + copyLayer("UserInterface"); + } +}; + +function copyLayer(layerName) { + var layer = require(__dirname + '/../' + layerName + 'Layer/layer.js'); + layer.write(polygene); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/ab83f189/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/web.xml.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/web.xml.tmpl b/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/web.xml.tmpl deleted file mode 100644 index d650933..0000000 --- a/tools/generator-polygene/app/templates/ConnectivityLayer/RestApiModule/web.xml.tmpl +++ /dev/null @@ -1,46 +0,0 @@ -<%# - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you under the Apache License, Version 2.0 (the - ~ "License"); you may not use this file except in compliance - ~ with the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ limitations under the License. - ~ - ~ -%><?xml version="1.0" encoding="UTF-8"?> -<web-app xmlns="http://java.sun.com/xml/ns/javaee" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" - version="2.5"> - - <display-name><%= polygene.name %></display-name> -<% if( polygene.hasFeature( "security" ) { %> - <listener> - <listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class> - </listener> -<% } %> -<% if( polygene.hasFeature( "security" ) { %> - <filter> - <filter-name>ShiroFilter</filter-name> - <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class> - </filter> -<% } %> -<% if( polygene.hasFeature( "security" ) { %> - <-- Filter all web requests. This filter mapping is typically declared - before all others to ensure any other filters are secured as well: --> - <filter-mapping> - <filter-name>ShiroFilter</filter-name> - <url-pattern>/*</url-pattern> - </filter-mapping> -<% } %> - -</web-app> http://git-wip-us.apache.org/repos/asf/polygene-java/blob/ab83f189/tools/generator-polygene/app/templates/InfrastructureLayer/CachingModule/module.js ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/InfrastructureLayer/CachingModule/module.js b/tools/generator-polygene/app/templates/InfrastructureLayer/CachingModule/module.js index 474899c..fdc99b0 100644 --- a/tools/generator-polygene/app/templates/InfrastructureLayer/CachingModule/module.js +++ b/tools/generator-polygene/app/templates/InfrastructureLayer/CachingModule/module.js @@ -1,3 +1,4 @@ + module.exports = { write: function (p) { http://git-wip-us.apache.org/repos/asf/polygene-java/blob/ab83f189/tools/generator-polygene/app/templates/RestAPIApplication/app.js ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/RestAPIApplication/app.js b/tools/generator-polygene/app/templates/RestAPIApplication/app.js new file mode 100644 index 0000000..0972b82 --- /dev/null +++ b/tools/generator-polygene/app/templates/RestAPIApplication/app.js @@ -0,0 +1,19 @@ + +module.exports = { + + write: function (p) { + copyLayer(p, "Configuration"); + copyLayer(p, "Infrastructure"); + copyLayer(p, "Domain"); + copyLayer(p, "Connectivity"); + + p.copyTemplate(p.ctx, + 'RestAPIApplication/web.xml.tmpl', + 'app/src/main/web/WEB-INF/web.xml'); + } +}; + +function copyLayer( p, layerName ) { + var layer = require(__dirname + '/../' + layerName + 'Layer/layer.js'); + layer.write(p); +} http://git-wip-us.apache.org/repos/asf/polygene-java/blob/ab83f189/tools/generator-polygene/app/templates/RestAPIApplication/web.xml.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/RestAPIApplication/web.xml.tmpl b/tools/generator-polygene/app/templates/RestAPIApplication/web.xml.tmpl new file mode 100644 index 0000000..d650933 --- /dev/null +++ b/tools/generator-polygene/app/templates/RestAPIApplication/web.xml.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. + ~ + ~ +%><?xml version="1.0" encoding="UTF-8"?> +<web-app xmlns="http://java.sun.com/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" + version="2.5"> + + <display-name><%= polygene.name %></display-name> +<% if( polygene.hasFeature( "security" ) { %> + <listener> + <listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class> + </listener> +<% } %> +<% if( polygene.hasFeature( "security" ) { %> + <filter> + <filter-name>ShiroFilter</filter-name> + <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class> + </filter> +<% } %> +<% if( polygene.hasFeature( "security" ) { %> + <-- Filter all web requests. This filter mapping is typically declared + before all others to ensure any other filters are secured as well: --> + <filter-mapping> + <filter-name>ShiroFilter</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> +<% } %> + +</web-app> http://git-wip-us.apache.org/repos/asf/polygene-java/blob/ab83f189/tools/generator-polygene/app/templates/UserInterfaceLayer/CommandLineModule/module.js ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/UserInterfaceLayer/CommandLineModule/module.js b/tools/generator-polygene/app/templates/UserInterfaceLayer/CommandLineModule/module.js new file mode 100644 index 0000000..3ae88a3 --- /dev/null +++ b/tools/generator-polygene/app/templates/UserInterfaceLayer/CommandLineModule/module.js @@ -0,0 +1,12 @@ + +module.exports = { + + write: function (p) { + if (p.applicationtype === 'Command Line') { + // NOT SUPPORTED YET!!! + // p.copyTemplate(p.ctx, + // 'UserInterfaceLayer/CommandLineModule/bootstrap.tmpl', + // 'bootstrap/src/main/java/' + p.javaPackageDir + '/bootstrap/ui/CommandLineModule.java'); + } + } +}; http://git-wip-us.apache.org/repos/asf/polygene-java/blob/ab83f189/tools/generator-polygene/app/templates/UserInterfaceLayer/bootstrap.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/UserInterfaceLayer/bootstrap.tmpl b/tools/generator-polygene/app/templates/UserInterfaceLayer/bootstrap.tmpl new file mode 100644 index 0000000..dbbbb1b --- /dev/null +++ b/tools/generator-polygene/app/templates/UserInterfaceLayer/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 <%= polygene.packageName %>.bootstrap.ui; + +import org.apache.polygene.bootstrap.AssemblyException; +import org.apache.polygene.bootstrap.LayerAssembly; +import org.apache.polygene.bootstrap.layered.LayerAssembler; +import org.apache.polygene.bootstrap.layered.LayeredLayerAssembler; + +public class UserInterfaceLayer extends LayeredLayerAssembler + implements LayerAssembler +{ + public static String NAME; + + @Override + public LayerAssembly assemble( LayerAssembly layer ) + throws AssemblyException + { +<% if( polygene.applicationtype === 'Rest API' ) { %> + createModule( layer, CommandLineModule.class ); +<% } -%> + return layer; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/polygene-java/blob/ab83f189/tools/generator-polygene/app/templates/UserInterfaceLayer/layer.js ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/UserInterfaceLayer/layer.js b/tools/generator-polygene/app/templates/UserInterfaceLayer/layer.js new file mode 100644 index 0000000..c060f63 --- /dev/null +++ b/tools/generator-polygene/app/templates/UserInterfaceLayer/layer.js @@ -0,0 +1,10 @@ + +module.exports = { + + write: function (p) { + p.copyTemplate(p.ctx, + 'UserInterfaceLayer/bootstrap.tmpl', + 'bootstrap/src/main/java/' + p.javaPackageDir + '/bootstrap/ui/UserInterfaceLayer.java'); + p.copyModules(__dirname ); + } +}; http://git-wip-us.apache.org/repos/asf/polygene-java/blob/ab83f189/tools/generator-polygene/app/templates/buildtool/gradle-app.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/buildtool/gradle-app.tmpl b/tools/generator-polygene/app/templates/buildtool/gradle-app.tmpl index 880a5e5..623ee78 100644 --- a/tools/generator-polygene/app/templates/buildtool/gradle-app.tmpl +++ b/tools/generator-polygene/app/templates/buildtool/gradle-app.tmpl @@ -26,14 +26,15 @@ plugins { dependencies { compile project( ":bootstrap" ) compile project( ":model" ) - compile project( ":rest" ) +<% if( polygene.applicationtype === 'Rest API' ) { +%> compile project( ":rest" )<% } %> compile "org.apache.polygene.core:org.apache.polygene.core.spi:$polygeneVersion" compile "org.apache.polygene.core:org.apache.polygene.core.bootstrap:$polygeneVersion" compile "org.apache.polygene.libraries:org.apache.polygene.library.servlet:$polygeneVersion" - - compile "javax.servlet:servlet-api:2.5" - compile "org.restlet.jee:org.restlet:2.3.4" +<% if( polygene.applicationtype === 'Rest API' ) { +%> compile "javax.servlet:servlet-api:2.5" + compile "org.restlet.jee:org.restlet:2.3.4"<% } %> runtime "org.apache.polygene.core:org.apache.polygene.core.runtime:$polygeneVersion" runtime "org.restlet.jee:org.restlet.ext.servlet:2.3.4" http://git-wip-us.apache.org/repos/asf/polygene-java/blob/ab83f189/tools/generator-polygene/app/templates/buildtool/settings.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/buildtool/settings.tmpl b/tools/generator-polygene/app/templates/buildtool/settings.tmpl index 2d8e164..9576305 100644 --- a/tools/generator-polygene/app/templates/buildtool/settings.tmpl +++ b/tools/generator-polygene/app/templates/buildtool/settings.tmpl @@ -18,9 +18,12 @@ * -%> include 'app', - 'bootstrap', + 'bootstrap',<% +if( polygene.applicationtype === 'Rest API' ) { %> 'model', - 'rest' + 'rest'<% } else { %> + 'model' +<% } %> rootProject.name = '<%= polygene.name %>'
