http://git-wip-us.apache.org/repos/asf/zest-java/blob/0accd2cf/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/DomainLayerWriter.java ---------------------------------------------------------------------- diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/DomainLayerWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/DomainLayerWriter.java new file mode 100644 index 0000000..f3fe430 --- /dev/null +++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/DomainLayerWriter.java @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.apache.zest.tools.shell.create.project.common; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Map; + +public class DomainLayerWriter +{ + + public void writeClass( Map<String, String> properties ) + throws IOException + { + String rootPackage = properties.get( "root.package" ); + String projectName = properties.get( "project.name" ); + try (PrintWriter pw = createPrinter( properties )) + { + pw.print( "package " ); + pw.print( properties.get( "root.package" ) ); + pw.println( ".bootstrap.domain;" ); + pw.println(); + pw.println( + "import java.util.function.Function;\n" + + "import org.apache.zest.api.structure.Application;\n" + + "import org.apache.zest.api.structure.Module;\n" + + "import org.apache.zest.bootstrap.AssemblyException;\n" + + "import org.apache.zest.bootstrap.LayerAssembly;\n" + + "import org.apache.zest.bootstrap.layered.LayerAssembler;\n" + + "import org.apache.zest.bootstrap.layered.LayeredLayerAssembler;\n" + + "\n" + + "public class DomainLayer extends LayeredLayerAssembler\n" + + " implements LayerAssembler\n" + + "{\n" + + " @Override\n" + + " public LayerAssembly assemble(LayerAssembly layer)\n" + + " throws AssemblyException\n" + + " {\n" + + " createModule( layer, CrudModule.class );\n" + + " createModule( layer, OrderModule.class ); // This is a simple sample that you typically remove.\n" + + " createModule( layer, SecurityModule.class ); // This is a simple sample that you typically remove.\n" + + " return layer;\n" + + " }\n" + + "\n" + + " public static Function<Application, Module> typeFinder()\n" + + " {\n" + + " return application -> application.findModule( \"Domain Layer\", \"Assets Module\" );\n" + + " }\n" + + "}\n" + ); + } + } + + private PrintWriter createPrinter( Map<String, String> properties ) + throws IOException + { + String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/domain/"; + String classname = "DomainLayer"; + File projectDir = new File( properties.get( "project.dir" ) ); + return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ) ); + } +}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/0accd2cf/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/FileConfigurationModuleWriter.java ---------------------------------------------------------------------- diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/FileConfigurationModuleWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/FileConfigurationModuleWriter.java new file mode 100644 index 0000000..dca5052 --- /dev/null +++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/FileConfigurationModuleWriter.java @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.apache.zest.tools.shell.create.project.common; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Map; + +public class FileConfigurationModuleWriter +{ + + public void writeClass( Map<String, String> properties ) + throws IOException + { + String rootPackage = properties.get( "root.package" ); + String projectName = properties.get( "project.name" ); + try (PrintWriter pw = createPrinter( properties )) + { + pw.print( "package " ); + pw.print( properties.get( "root.package" ) ); + pw.println( ".bootstrap.infrastructure;" ); + pw.println(); + pw.println( + "import org.apache.zest.api.common.Visibility;\n" + + "import org.apache.zest.bootstrap.AssemblyException;\n" + + "import org.apache.zest.bootstrap.LayerAssembly;\n" + + "import org.apache.zest.bootstrap.ModuleAssembly;\n" + + "import org.apache.zest.bootstrap.layered.ModuleAssembler;\n" + + "import org.apache.zest.library.fileconfig.FileConfigurationAssembler;\n" + + "\n" + + "public class FileConfigurationModule\n" + + " implements ModuleAssembler\n" + + "{\n" + + " public static String NAME;\n" + + "\n" + + " @Override\n" + + " public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )\n" + + " throws AssemblyException\n" + + " {\n" + + " new FileConfigurationAssembler().visibleIn( Visibility.layer ).assemble( module );\n" + + " return module;\n" + + " }\n" + + "}\n" + ); + } + } + + private PrintWriter createPrinter( Map<String, String> properties ) + throws IOException + { + String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/infrastructure/"; + String classname = "FileConfigurationModule"; + File projectDir = new File( properties.get( "project.dir" ) ); + return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ) ); + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/0accd2cf/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/HardCodedSecurityRepositoryMixinWriter.java ---------------------------------------------------------------------- diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/HardCodedSecurityRepositoryMixinWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/HardCodedSecurityRepositoryMixinWriter.java new file mode 100644 index 0000000..a1e1fb9 --- /dev/null +++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/HardCodedSecurityRepositoryMixinWriter.java @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.apache.zest.tools.shell.create.project.common; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Map; + +public class HardCodedSecurityRepositoryMixinWriter +{ + + public void writeClass( Map<String, String> properties ) + throws IOException + { + String rootPackage = properties.get( "root.package" ); + try (PrintWriter pw = createPrinter( properties )) + { + pw.print( "package " ); + pw.print( properties.get( "root.package" ) ); + pw.println( ".model.security;" ); + pw.println(); + pw.println( + "import java.util.Collections;\n" + + "import java.util.List;\n" + + "import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;\n" + + "\n" + + "public class HardcodedSecurityRepositoryMixin\n" + + " implements SecurityRepository\n" + + "{\n" + + "\n" + + " @Override\n" + + " public boolean verifyPassword( String userName, String password )\n" + + " {\n" + + " if( userName.equals(\"admin\") && password.equals(\"secret\") )" + + " {\n" + + " return true;\n" + + " }\n" + + " if( userName.equals(\"user\") && password.equals(\"123\") )" + + " {\n" + + " return true;\n" + + " }\n" + + " return false;\n" + + " }\n" + + "\n" + + " @UnitOfWorkPropagation\n" + + " public List<String> findRoleNamesOfUser( String name )\n" + + " {\n" + + " if( \"admin\".equals( name ) )\n" + + " {\n" + + " return Collections.singletonList(\"admin\");\n" + + " }\n" + + " return Collections.singletonList(\"user\");\n" + + " }\n" + + "}\n" + ); + } + } + + private PrintWriter createPrinter( Map<String, String> properties ) + throws IOException + { + String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/model/security/"; + String classname = "HardcodedSecurityRepositoryMixin"; + File projectDir = new File( properties.get( "project.dir" ) ); + return new PrintWriter( new FileWriter( new File( projectDir, "model/src/main/java/" + packagename + classname + ".java" ) ) ); + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/0accd2cf/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/IndexingModuleWriter.java ---------------------------------------------------------------------- diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/IndexingModuleWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/IndexingModuleWriter.java new file mode 100644 index 0000000..20790a9 --- /dev/null +++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/IndexingModuleWriter.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.apache.zest.tools.shell.create.project.common; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Map; + +public class IndexingModuleWriter +{ + + public void writeClass( Map<String, String> properties ) + throws IOException + { + String rootPackage = properties.get( "root.package" ); + String projectName = properties.get( "project.name" ); + try (PrintWriter pw = createPrinter( properties )) + { + pw.print( "package " ); + pw.print( properties.get( "root.package" ) ); + pw.println( ".bootstrap.infrastructure;" ); + pw.println(); + pw.println( + "import org.apache.zest.api.common.Visibility;\n" + + "import org.apache.zest.bootstrap.AssemblyException;\n" + + "import org.apache.zest.bootstrap.LayerAssembly;\n" + + "import org.apache.zest.bootstrap.ModuleAssembly;\n" + + "import org.apache.zest.bootstrap.layered.ModuleAssembler;\n" + + "import org.apache.zest.index.rdf.assembly.RdfNativeSesameStoreAssembler;\n" + + "import org.apache.zest.library.rdf.repository.NativeConfiguration;\n" + + "\n" + + "public class IndexingModule\n" + + " implements ModuleAssembler\n" + + "{\n" + + " public static final String NAME = \"Indexing Module\";\n" + + " private final ModuleAssembly configModule;\n" + + "\n" + + " public IndexingModule( ModuleAssembly configModule )\n" + + " {\n" + + " this.configModule = configModule;\n" + + " }\n" + + "\n" + + " @Override\n" + + " public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )\n" + + " throws AssemblyException\n" + + " {\n" + + " module.withDefaultUnitOfWorkFactory();\n" + + "\n" + + " configModule.entities( NativeConfiguration.class ).visibleIn( Visibility.application );\n" + + " new RdfNativeSesameStoreAssembler(Visibility.application, Visibility.module).assemble( module );\n" + + " return module;\n" + + " }\n" + + "}\n" + ); + } + } + + private PrintWriter createPrinter( Map<String, String> properties ) + throws IOException + { + String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/infrastructure/"; + String classname = "IndexingModule"; + File projectDir = new File( properties.get( "project.dir" ) ); + return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ) ); + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/0accd2cf/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/InfrastructureLayerWriter.java ---------------------------------------------------------------------- diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/InfrastructureLayerWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/InfrastructureLayerWriter.java new file mode 100644 index 0000000..9da967f --- /dev/null +++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/InfrastructureLayerWriter.java @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.apache.zest.tools.shell.create.project.common; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Map; + +public class InfrastructureLayerWriter +{ + + public void writeClass( Map<String, String> properties ) + throws IOException + { + String rootPackage = properties.get( "root.package" ); + String projectName = properties.get( "project.name" ); + try (PrintWriter pw = createPrinter( properties )) + { + pw.print( "package " ); + pw.print( properties.get( "root.package" ) ); + pw.println( ".bootstrap.infrastructure;" ); + pw.println(); + pw.println( + "import java.util.function.Function;\n" + + "import org.apache.zest.api.structure.Application;\n" + + "import org.apache.zest.api.structure.Module;\n" + + "import org.apache.zest.bootstrap.AssemblyException;\n" + + "import org.apache.zest.bootstrap.LayerAssembly;\n" + + "import org.apache.zest.bootstrap.ModuleAssembly;\n" + + "import org.apache.zest.bootstrap.layered.LayerAssembler;\n" + + "import org.apache.zest.bootstrap.layered.LayeredLayerAssembler;\n" + + "\n" + + "public class InfrastructureLayer extends LayeredLayerAssembler\n" + + " implements LayerAssembler\n" + + "{\n" + + " public static final String NAME = \"Infrastructure Layer\";\n" + + " private final ModuleAssembly configModule;\n" + + " private final Function<Application, Module> typeFinder;\n" + + "\n" + + " public InfrastructureLayer( ModuleAssembly configModule, Function<Application, Module> typeFinder )\n" + + " {\n" + + " this.configModule = configModule;\n" + + " this.typeFinder = typeFinder;\n" + + " }\n" + + "\n" + + " @Override\n" + + " public LayerAssembly assemble( LayerAssembly layer )\n" + + " throws AssemblyException\n" + + " {\n" + + " createModule( layer, FileConfigurationModule.class );\n" + + "\n" + + " new StorageModule( configModule ).assemble( layer, layer.module( StorageModule.NAME ) );\n" + + " new IndexingModule( configModule ).assemble( layer, layer.module( IndexingModule.NAME ) );\n" + + " new SerializationModule( typeFinder ).assemble( layer, layer.module( SerializationModule.NAME ) );\n" + + "\n" + + " return layer;\n" + + " }\n" + + "}\n" + ); + } + } + + private PrintWriter createPrinter( Map<String, String> properties ) + throws IOException + { + String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/infrastructure/"; + String classname = "InfrastructureLayer"; + File projectDir = new File( properties.get( "project.dir" ) ); + return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ) ); + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/0accd2cf/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderItemWriter.java ---------------------------------------------------------------------- diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderItemWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderItemWriter.java new file mode 100644 index 0000000..28f22b8 --- /dev/null +++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderItemWriter.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.apache.zest.tools.shell.create.project.common; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Map; + +public class OrderItemWriter +{ + + public void writeClass( Map<String, String> properties ) + throws IOException + { + String rootPackage = properties.get( "root.package" ); + String projectName = properties.get( "project.name" ); + try (PrintWriter pw = createPrinter( properties )) + { + pw.print( "package " ); + pw.print( properties.get( "root.package" ) ); + pw.println( ".model.orders;" ); + pw.println(); + pw.println("import java.math.BigDecimal;"); + pw.println("import org.apache.zest.api.entity.Identity;"); + pw.println("import org.apache.zest.api.property.Property;"); + pw.println(); + pw.println( + "public interface OrderItem extends Identity\n" + + "{\n" + + " Property<String> partNumber();\n\n" + + " Property<BigDecimal> unitPrice();\n\n" + + " Property<Integer> units();\n\n" + + " Property<BigDecimal> discount();\n\n" + + "}\n"); + } + } + + private PrintWriter createPrinter( Map<String, String> properties ) + throws IOException + { + String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/model/orders/"; + String classname = "OrderItem"; + File projectDir = new File( properties.get( "project.dir" ) ); + return new PrintWriter( new FileWriter( new File( projectDir, "model/src/main/java/" + packagename + classname + ".java" ) ) ); + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/0accd2cf/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderModuleWriter.java ---------------------------------------------------------------------- diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderModuleWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderModuleWriter.java new file mode 100644 index 0000000..47d22a9 --- /dev/null +++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderModuleWriter.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.apache.zest.tools.shell.create.project.common; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Map; + +import static java.lang.String.format; + +public class OrderModuleWriter +{ + + public void writeClass( Map<String, String> properties ) + throws IOException + { + String rootPackage = properties.get( "root.package" ); + String projectName = properties.get( "project.name" ); + try (PrintWriter pw = createPrinter( properties )) + { + pw.print( "package " ); + pw.print( properties.get( "root.package" ) ); + pw.println( ".bootstrap.domain;" ); + pw.println(); + pw.println( + "import org.apache.zest.api.common.Visibility;\n" + + "import org.apache.zest.bootstrap.AssemblyException;\n" + + "import org.apache.zest.bootstrap.LayerAssembly;\n" + + "import org.apache.zest.bootstrap.ModuleAssembly;\n" + + "import org.apache.zest.bootstrap.layered.ModuleAssembler;"); + pw.println(format("import %s.model.orders.Order;", rootPackage)); + pw.println(format("import %s.model.orders.OrderItem;", rootPackage)); + pw.println(format("import %s.model.orders.Customer;", rootPackage)); + pw.println(); + pw.println( + "public class OrderModule\n" + + " implements ModuleAssembler\n" + + "{\n" + + " public static String NAME;\n" + + "\n" + + " @Override\n" + + " public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )\n" + + " throws AssemblyException\n" + + " {\n" + + " module.values( /* add value types */ );\n" + + " module.entities( Customer.class, Order.class, OrderItem.class );\n" + + " module.services( /* add services */ )\n" + + " .visibleIn( Visibility.layer )\n" + + " .instantiateOnStartup();\n" + + " return module;\n" + + " }\n" + + "}\n" + ); + } + } + + private PrintWriter createPrinter( Map<String, String> properties ) + throws IOException + { + String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/domain/"; + String classname = "OrderModule"; + File projectDir = new File( properties.get( "project.dir" ) ); + return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ) ); + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/0accd2cf/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderWriter.java ---------------------------------------------------------------------- diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderWriter.java new file mode 100644 index 0000000..550f0ec --- /dev/null +++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderWriter.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.apache.zest.tools.shell.create.project.common; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Map; + +public class OrderWriter +{ + + public void writeClass( Map<String, String> properties ) + throws IOException + { + String rootPackage = properties.get( "root.package" ); + String projectName = properties.get( "project.name" ); + try (PrintWriter pw = createPrinter( properties )) + { + pw.print( "package " ); + pw.print( properties.get( "root.package" ) ); + pw.println( ".model.orders;" ); + pw.println(); + pw.println("import java.time.ZonedDateTime;"); + pw.println("import org.apache.zest.api.association.Association;"); + pw.println("import org.apache.zest.api.association.ManyAssociation;"); + pw.println("import org.apache.zest.api.common.Optional;"); + pw.println("import org.apache.zest.api.entity.Identity;"); + pw.println("import org.apache.zest.api.property.Property;"); + pw.println(); + pw.println( + "public interface Order extends Identity\n" + + "{\n" + + " Property<String> orderNumber();\n\n" + + " Property<ZonedDateTime> registered();\n\n" + + " @Optional\n" + + " Property<ZonedDateTime> shipped();\n\n" + + " Association<Customer> customer();\n\n" + + " ManyAssociation<OrderItem> items();\n\n" + + "}\n"); + } + } + + private PrintWriter createPrinter( Map<String, String> properties ) + throws IOException + { + String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/model/orders/"; + String classname = "Order"; + File projectDir = new File( properties.get( "project.dir" ) ); + return new PrintWriter( new FileWriter( new File( projectDir, "model/src/main/java/" + packagename + classname + ".java" ) ) ); + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/0accd2cf/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SecurityModuleWriter.java ---------------------------------------------------------------------- diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SecurityModuleWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SecurityModuleWriter.java new file mode 100644 index 0000000..3f576f1 --- /dev/null +++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SecurityModuleWriter.java @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.apache.zest.tools.shell.create.project.common; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Map; + +import static java.lang.String.format; + +public class SecurityModuleWriter +{ + + public void writeClass( Map<String, String> properties ) + throws IOException + { + String rootPackage = properties.get( "root.package" ); + String projectName = properties.get( "project.name" ); + try (PrintWriter pw = createPrinter( properties )) + { + pw.print( "package " ); + pw.print( properties.get( "root.package" ) ); + pw.println( ".bootstrap.domain;" ); + pw.println(); + pw.println( + "import org.apache.zest.api.common.Visibility;\n" + + "import org.apache.zest.bootstrap.AssemblyException;\n" + + "import org.apache.zest.bootstrap.LayerAssembly;\n" + + "import org.apache.zest.bootstrap.ModuleAssembly;\n" + + "import org.apache.zest.bootstrap.layered.ModuleAssembler;"); + pw.println(format("import %s.model.orders.Order;", rootPackage)); + pw.println(format("import %s.model.orders.OrderItem;", rootPackage)); + pw.println(format("import %s.model.orders.Customer;", rootPackage)); + pw.println(format("import %s.model.security.SecurityRepository;", rootPackage)); + pw.println(format("import %s.model.security.HardcodedSecurityRepositoryMixin;", rootPackage)); + pw.println(); + pw.println( + "public class SecurityModule\n" + + " implements ModuleAssembler\n" + + "{\n" + + " public static String NAME;\n" + + "\n" + + " @Override\n" + + " public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )\n" + + " throws AssemblyException\n" + + " {\n" + + " module.withDefaultUnitOfWorkFactory();\n" + + " module.services( SecurityRepository.class )\n" + + " .withMixins( HardcodedSecurityRepositoryMixin.class )\n" + + " .visibleIn( Visibility.application )\n" + + " .instantiateOnStartup();\n" + + "\n" + + " return module;\n" + + " }\n" + + "}\n" + ); + } + } + + private PrintWriter createPrinter( Map<String, String> properties ) + throws IOException + { + String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/domain/"; + String classname = "SecurityModule"; + File projectDir = new File( properties.get( "project.dir" ) ); + return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ) ); + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/0accd2cf/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SecurityRepositoryWriter.java ---------------------------------------------------------------------- diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SecurityRepositoryWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SecurityRepositoryWriter.java new file mode 100644 index 0000000..989811f --- /dev/null +++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SecurityRepositoryWriter.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.apache.zest.tools.shell.create.project.common; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Map; + +import static java.lang.String.format; + +public class SecurityRepositoryWriter +{ + + public void writeClass( Map<String, String> properties ) + throws IOException + { + String rootPackage = properties.get( "root.package" ); + try (PrintWriter pw = createPrinter( properties )) + { + pw.print( "package " ); + pw.print( properties.get( "root.package" ) ); + pw.println( ".model.security;" ); + pw.println(); + pw.println( + "import java.util.List;\n" + + "import org.apache.zest.api.concern.Concerns;\n" + + "import org.apache.zest.api.unitofwork.concern.UnitOfWorkConcern;\n" + + "import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;\n" + + "\n" + + "@Concerns( UnitOfWorkConcern.class )\n" + + "public interface SecurityRepository\n" + + "{\n" + + " @UnitOfWorkPropagation\n" + + " boolean verifyPassword( String user, String password );\n" + + "\n" + + " @UnitOfWorkPropagation\n" + + " List<String> findRoleNamesOfUser( String name );\n" + + "}\n" + ); + } + } + + private PrintWriter createPrinter( Map<String, String> properties ) + throws IOException + { + String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/model/security/"; + String classname = "SecurityRepository"; + File projectDir = new File( properties.get( "project.dir" ) ); + return new PrintWriter( new FileWriter( new File( projectDir, "model/src/main/java/" + packagename + classname + ".java" ) ) ); + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/0accd2cf/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SerializationModuleWriter.java ---------------------------------------------------------------------- diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SerializationModuleWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SerializationModuleWriter.java new file mode 100644 index 0000000..6dba0de --- /dev/null +++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SerializationModuleWriter.java @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.apache.zest.tools.shell.create.project.common; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Map; + +public class SerializationModuleWriter +{ + + public void writeClass( Map<String, String> properties ) + throws IOException + { + String rootPackage = properties.get( "root.package" ); + String projectName = properties.get( "project.name" ); + try (PrintWriter pw = createPrinter( properties )) + { + pw.print( "package " ); + pw.print( properties.get( "root.package" ) ); + pw.println( ".bootstrap.infrastructure;" ); + pw.println(); + pw.println( + "import java.util.function.Function;\n" + + "import org.apache.zest.api.common.Visibility;\n" + + "import org.apache.zest.api.structure.Application;\n" + + "import org.apache.zest.api.structure.Module;\n" + + "import org.apache.zest.bootstrap.AssemblyException;\n" + + "import org.apache.zest.bootstrap.LayerAssembly;\n" + + "import org.apache.zest.bootstrap.ModuleAssembly;\n" + + "import org.apache.zest.bootstrap.layered.ModuleAssembler;\n" + + "import org.apache.zest.spi.uuid.UuidIdentityGeneratorService;\n" + + "import org.apache.zest.valueserialization.jackson.JacksonValueSerializationAssembler;\n" + + "\n" + + "public class SerializationModule\n" + + " implements ModuleAssembler\n" + + "{\n" + + " public static final String NAME = \"Serialization Module\";\n" + + " private final Function<Application, Module> typeFinder;\n" + + "\n" + + " public SerializationModule( Function<Application, Module> typeFinder )\n" + + " {\n" + + " this.typeFinder = typeFinder;\n" + + " }\n" + + "\n" + + " @Override\n" + + " public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )\n" + + " throws AssemblyException\n" + + " {\n" + + " new JacksonValueSerializationAssembler()\n" + + " .visibleIn( Visibility.application )\n" + + " .withValuesModuleFinder( typeFinder )\n" + + " .assemble( module );\n" + + " module.services( UuidIdentityGeneratorService.class ).visibleIn( Visibility.layer );\n" + + " return module;\n" + + " }\n" + + "}\n" + ); + } + } + + private PrintWriter createPrinter( Map<String, String> properties ) + throws IOException + { + String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/infrastructure/"; + String classname = "SerializationModule"; + File projectDir = new File( properties.get( "project.dir" ) ); + return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ) ); + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/0accd2cf/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SettingsWriter.java ---------------------------------------------------------------------- diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SettingsWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SettingsWriter.java new file mode 100644 index 0000000..ddfa388 --- /dev/null +++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/SettingsWriter.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.apache.zest.tools.shell.create.project.common; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Map; + +public class SettingsWriter +{ + + public void writeClass( Map<String, String> properties ) + throws IOException + { + String rootPackage = properties.get( "root.package" ); + String projectName = properties.get( "project.name" ); + try (PrintWriter pw = createPrinter( properties )) + { + pw.println( + String.format( + "\n" + + "include 'app',\n" + + " 'bootstrap',\n" + + " 'model',\n" + + " 'rest'\n" + + "\n" + + "rootProject.name = \"%s\"\n" + + "\n" + + "validateProject(rootProject, \"\")\n" + + "\n" + + "def validateProject(project, parentName)\n" + + "{\n" + + " assert project.projectDir.isDirectory()\n" + + " if( new File(\"$project.projectDir/src/main/java\").exists() )\n" + + " {\n" + + " assert project.buildFile.isFile()\n" + + " }\n" + + " if( parentName.length() > 0 )\n" + + " println \"Project: \" + project.name\n" + + " project.children.each { child ->\n" + + " validateProject(child, project.name)\n" + + " }\n" + + "}\n" + + "\n", projectName + )); + } + } + + private PrintWriter createPrinter( Map<String, String> properties ) + throws IOException + { + File projectDir = new File( properties.get( "project.dir" ) ); + return new PrintWriter( new FileWriter( new File( projectDir, "settings.gradle" ) ) ); + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/0accd2cf/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/StorageModuleWriter.java ---------------------------------------------------------------------- diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/StorageModuleWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/StorageModuleWriter.java new file mode 100644 index 0000000..c9123a8 --- /dev/null +++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/StorageModuleWriter.java @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.apache.zest.tools.shell.create.project.common; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Map; + +public class StorageModuleWriter +{ + + public void writeClass( Map<String, String> properties ) + throws IOException + { + String rootPackage = properties.get( "root.package" ); + String projectName = properties.get( "project.name" ); + try (PrintWriter pw = createPrinter( properties )) + { + pw.print( "package " ); + pw.print( properties.get( "root.package" ) ); + pw.println( ".bootstrap.infrastructure;" ); + pw.println(); + pw.println( + "import org.apache.zest.api.common.Visibility;\n" + + "import org.apache.zest.bootstrap.AssemblyException;\n" + + "import org.apache.zest.bootstrap.LayerAssembly;\n" + + "import org.apache.zest.bootstrap.ModuleAssembly;\n" + + "import org.apache.zest.bootstrap.layered.ModuleAssembler;\n" + + "import org.apache.zest.entitystore.file.assembly.FileEntityStoreAssembler;\n" + + "\n" + + "public class StorageModule\n" + + " implements ModuleAssembler\n" + + "{\n" + + " public static final String NAME = \"Storage Module\";\n" + + " private final ModuleAssembly configModule;\n" + + "\n" + + " public StorageModule( ModuleAssembly configModule )\n" + + " {\n" + + " this.configModule = configModule;\n" + + " }\n" + + "\n" + + " @Override\n" + + " public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )\n" + + " throws AssemblyException\n" + + " {\n" + + "\n" + + " new FileEntityStoreAssembler()\n" + + " .visibleIn( Visibility.application )\n" + + " .withConfig( configModule, Visibility.application )\n" + + " .identifiedBy( \"filestore\" )\n" + + " .assemble( module );\n" + + " return module;\n" + + " }\n" + + "}\n" + ); + } + } + + private PrintWriter createPrinter( Map<String, String> properties ) + throws IOException + { + String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/infrastructure/"; + String classname = "StorageModule"; + File projectDir = new File( properties.get( "project.dir" ) ); + return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ) ); + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/0accd2cf/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/defaultp/ApplicationWriter.java ---------------------------------------------------------------------- diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/defaultp/ApplicationWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/defaultp/ApplicationWriter.java new file mode 100644 index 0000000..c2cfc4f --- /dev/null +++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/defaultp/ApplicationWriter.java @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ + +package org.apache.zest.tools.shell.create.project.defaultp; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Map; +import org.apache.zest.bootstrap.ApplicationAssembler; +import org.apache.zest.bootstrap.Energy4Java; + +import static java.lang.String.format; + +public class ApplicationWriter +{ + + public void writeClass( Map<String, String> properties ) + throws IOException + { + String rootPackage = properties.get( "root.package" ); + String projectName = properties.get( "project.name" ); + try (PrintWriter pw = createPrinter( properties )) + { + pw.print( "package " ); + pw.print( properties.get( "root.package" ) ); + pw.println( ".app;" ); + pw.println(); + pw.println( "import java.lang.reflect.UndeclaredThrowableException;" ); + pw.println( "import org.apache.zest.api.structure.Application;" ); + pw.println( "import org.apache.zest.api.structure.Module;" ); + pw.println( "import org.apache.zest.bootstrap.AssemblyException;" ); + pw.println( "import org.apache.zest.bootstrap.Energy4Java;" ); + pw.println( "import org.apache.zest.bootstrap.layered.LayeredApplicationAssembler;" ); + pw.println( "import org.apache.zest.library.restlet.ZrestApplication;" ); + pw.println( format( "import %s.bootstrap.%sApplicationAssembler;", rootPackage, projectName ) ); + pw.println( format( "import %s.model.security.SecurityRepository;", rootPackage ) ); + pw.println(); + pw.println( format( "public class %s", projectName ) ); + pw.println( "{\n" ); + pw.println( " private static Energy4Java zest;" ); + pw.println( " private static Application app;" ); + pw.println(); + + pw.println( " private static void registerShutdownHook()" ); + pw.println( " {" ); + pw.println( " Runtime.getRuntime().addShutdownHook( new Thread( new Runnable()\n" + + " {\n" + + " @Override\n" + + " public void run()\n" + + " {\n" + + " try\n" + + " {\n" + + " app.passivate();\n" + + " }\n" + + " catch( Exception e )\n" + + " {\n" + + " System.err.println( \"Clean Shutdown of application failed.\" );\n" + + " e.printStackTrace();\n" + + " }\n" + + " }\n" + + " }, \"Shutdown Hook for Zest\" ) );\n" ); + pw.println( " }\n" ); + pw.println( " public static void main( String[] args )" ); + pw.println( " {" ); + pw.println( " zest = new Energy4Java();" ); + pw.println( format(" app = zest.newApplication( new %sApplicationAssembler() );", projectName) ); + pw.println( " registerShutdownHook();" ); + pw.println( " app.activate();\n" ); + pw.println(); + pw.println( " // Example interfacing" ); + pw.println( " Module securityModule = app.findModule( \"DomainLayer\", \"SecurityModule\" );" ); + pw.println( " SecurityRepository = securityModule.serviceFinder().findService( SecurityRepository.class );" ); + pw.println( " }\n" ); + pw.println( "}" ); + pw.println(); + } + } + + private PrintWriter createPrinter( Map<String, String> properties ) + throws IOException + { + String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/app/"; + String classname = properties.get("project.name"); + File projectDir = new File( properties.get( "project.dir" ) ); + return new PrintWriter( new FileWriter( new File( projectDir, "app/src/main/java/" + packagename + classname + ".java" ) ) ); + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/0accd2cf/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/ApplicationAssemblerWriter.java ---------------------------------------------------------------------- diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/ApplicationAssemblerWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/ApplicationAssemblerWriter.java deleted file mode 100644 index 0cdefc1..0000000 --- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/ApplicationAssemblerWriter.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ - -package org.apache.zest.tools.shell.create.project.restapp; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Map; - -public class ApplicationAssemblerWriter -{ - - public void writeClass( Map<String, String> properties ) - throws IOException - { - String rootPackage = properties.get( "root.package" ); - String projectName = properties.get( "project.name" ); - try (PrintWriter pw = createPrinter( properties )) - { - pw.print( "package " ); - pw.print( properties.get( "root.package" ) ); - pw.println( ".bootstrap;" ); - pw.println(); - pw.println( "import java.io.IOException;" ); - pw.println( "import java.nio.file.Files;" ); - pw.println( "import java.nio.file.Path;" ); - pw.println( "import java.nio.file.Paths;" ); - pw.println( "import java.util.function.Function;" ); - pw.println(); - pw.println( "import org.apache.zest.api.structure.Application;" ); - pw.println( "import org.apache.zest.api.structure.Module;\n" ); - pw.println( "import org.apache.zest.bootstrap.ApplicationAssembly;" ); - pw.println( "import org.apache.zest.bootstrap.AssemblyException;" ); - pw.println( "import org.apache.zest.bootstrap.LayerAssembly;" ); - pw.println( "import org.apache.zest.bootstrap.ModuleAssembly;" ); - pw.println( "import org.apache.zest.bootstrap.layered.LayeredApplicationAssembler;" ); - pw.println(); - pw.println( "import " + rootPackage + ".bootstrap.connectivity.ConnectivityLayer;" ); - pw.println( "import " + rootPackage + ".bootstrap.domain.DomainLayer;" ); - pw.println( "import " + rootPackage + ".bootstrap.config.ConfigurationLayer;" ); - pw.println( "import " + rootPackage + ".bootstrap.infrastructure.InfrastructureLayer;" ); - pw.println(); - pw.print( "public class " ); - pw.print( projectName ); - pw.println( "ApplicationAssembler extends LayeredApplicationAssembler" ); - pw.println( "{" ); - pw.print( " private static final String NAME = \"" ); - pw.print( projectName ); - pw.println( "\";" ); - pw.println( " private static final String VERSION = \"1.0.alpha\";" ); - pw.println(); - pw.print(" public "); - pw.print( projectName ); - pw.println("ApplicationAssembler( Application.Mode mode )"); - pw.println(" throws AssemblyException"); - pw.println(" {"); - pw.println(" super( NAME, VERSION, mode );"); - pw.println(" }"); - pw.println(); - pw.println(" @Override"); - pw.println(" protected void assembleLayers( ApplicationAssembly assembly )"); - pw.println(" throws AssemblyException"); - pw.println(" {"); - pw.println(" LayerAssembly configLayer = createLayer( ConfigurationLayer.class );"); - pw.println(" ModuleAssembly configModule = assemblerOf( ConfigurationLayer.class ).configModule();"); - pw.println(" LayerAssembly domainLayer = createLayer( DomainLayer.class );"); - pw.println(" Function<Application, Module> typeFinder = DomainLayer.typeFinder();"); - pw.println(" LayerAssembly infraLayer = new InfrastructureLayer( configModule, typeFinder ).assemble( assembly.layer( InfrastructureLayer.NAME ) );"); - pw.println(" LayerAssembly connectivityLayer = createLayer( ConnectivityLayer.class );"); - pw.println(" connectivityLayer.uses( domainLayer );"); - pw.println(" domainLayer.uses( infraLayer );"); - pw.println(" infraLayer.uses( configLayer );"); - pw.println(" }"); - pw.println("}"); - } - } - - private PrintWriter createPrinter( Map<String, String> properties ) - throws IOException - { - String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/"; - String classname = properties.get( "project.name" ) + "ApplicationAssembler"; - File projectDir = new File( properties.get( "project.dir" ) ); - return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) )); - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/0accd2cf/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/ConfigLayerWriter.java ---------------------------------------------------------------------- diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/ConfigLayerWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/ConfigLayerWriter.java deleted file mode 100644 index 5b64a4b..0000000 --- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/ConfigLayerWriter.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ - -package org.apache.zest.tools.shell.create.project.restapp; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Map; - -public class ConfigLayerWriter -{ - - public void writeClass( Map<String, String> properties ) - throws IOException - { - String rootPackage = properties.get( "root.package" ); - String projectName = properties.get( "project.name" ); - try (PrintWriter pw = createPrinter( properties )) - { - pw.print( "package " ); - pw.print( properties.get( "root.package" ) ); - pw.println( ".bootstrap.config;" ); - pw.println(); - pw.println( - "import org.apache.zest.bootstrap.AssemblyException;\n" + - "import org.apache.zest.bootstrap.LayerAssembly;\n" + - "import org.apache.zest.bootstrap.ModuleAssembly;\n" + - "import org.apache.zest.bootstrap.layered.LayerAssembler;\n" + - "import org.apache.zest.bootstrap.layered.LayeredLayerAssembler;\n" + - "\n" + - "public class ConfigurationLayer extends LayeredLayerAssembler\n" + - " implements LayerAssembler\n" + - "{\n" + - " public static final String NAME = \"Configuration Layer\";\n" + - " private ModuleAssembly configModule;\n" + - "\n" + - " @Override\n" + - " public LayerAssembly assemble( LayerAssembly layer )\n" + - " throws AssemblyException\n" + - " {\n" + - " configModule = createModule( layer, ConfigModule.class );\n" + - " return layer;\n" + - " }\n" + - "\n" + - " public ModuleAssembly configModule()\n" + - " {\n" + - " return configModule;\n" + - " }\n" + - "}\n" - ); - } - } - - private PrintWriter createPrinter( Map<String, String> properties ) - throws IOException - { - String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/config/"; - String classname = "ConfigurationLayer"; - File projectDir = new File( properties.get( "project.dir" ) ); - return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ) ); - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/0accd2cf/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/ConfigModuleWriter.java ---------------------------------------------------------------------- diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/ConfigModuleWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/ConfigModuleWriter.java deleted file mode 100644 index 7ac15a9..0000000 --- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/ConfigModuleWriter.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ - -package org.apache.zest.tools.shell.create.project.restapp; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Map; - -public class ConfigModuleWriter -{ - - public void writeClass( Map<String, String> properties ) - throws IOException - { - String rootPackage = properties.get( "root.package" ); - String projectName = properties.get( "project.name" ); - try (PrintWriter pw = createPrinter( properties )) - { - pw.print( "package " ); - pw.print( properties.get( "root.package" ) ); - pw.println( ".bootstrap.config;" ); - pw.println(); - pw.println( - "import org.apache.zest.api.common.Visibility;\n" + - "import org.apache.zest.bootstrap.AssemblyException;\n" + - "import org.apache.zest.bootstrap.LayerAssembly;\n" + - "import org.apache.zest.bootstrap.ModuleAssembly;\n" + - "import org.apache.zest.bootstrap.layered.ModuleAssembler;\n" + - "import org.apache.zest.entitystore.memory.MemoryEntityStoreService;\n" + - "import org.apache.zest.spi.uuid.UuidIdentityGeneratorService;\n" + - "import org.apache.zest.valueserialization.jackson.JacksonValueSerializationAssembler;\n" + - "\n" + - "public class ConfigModule\n" + - " implements ModuleAssembler\n" + - "{\n" + - " @Override\n" + - " public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )\n" + - " throws AssemblyException\n" + - " {\n" + - " module.services( MemoryEntityStoreService.class ).visibleIn( Visibility.layer );\n" + - " new JacksonValueSerializationAssembler().visibleIn( Visibility.layer ).assemble( module );\n" + - " module.services( UuidIdentityGeneratorService.class ).visibleIn( Visibility.layer );\n" + - " return module;\n" + - " }\n" + - "}\n"); - } - } - - private PrintWriter createPrinter( Map<String, String> properties ) - throws IOException - { - String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/config/"; - String classname = "ConfigModule"; - File projectDir = new File( properties.get( "project.dir" ) ); - return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ) ); - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/0accd2cf/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/ConnectivityLayerWriter.java ---------------------------------------------------------------------- diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/ConnectivityLayerWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/ConnectivityLayerWriter.java deleted file mode 100644 index 2ae810c..0000000 --- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/ConnectivityLayerWriter.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ - -package org.apache.zest.tools.shell.create.project.restapp; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Map; - -public class ConnectivityLayerWriter -{ - - public void writeClass( Map<String, String> properties ) - throws IOException - { - String rootPackage = properties.get( "root.package" ); - String projectName = properties.get( "project.name" ); - try (PrintWriter pw = createPrinter( properties )) - { - pw.print( "package " ); - pw.print( properties.get( "root.package" ) ); - pw.println( ".bootstrap.connectivity;" ); - pw.println(); - pw.println( - "import org.apache.zest.bootstrap.AssemblyException;\n" + - "import org.apache.zest.bootstrap.LayerAssembly;\n" + - "import org.apache.zest.bootstrap.layered.LayerAssembler;\n" + - "import org.apache.zest.bootstrap.layered.LayeredLayerAssembler;\n" + - "\n" + - "public class ConnectivityLayer extends LayeredLayerAssembler\n" + - " implements LayerAssembler\n" + - "{\n" + - " public static String NAME;\n" + - "\n" + - " @Override\n" + - " public LayerAssembly assemble( LayerAssembly layer )\n" + - " throws AssemblyException\n" + - " {\n" + - " createModule( layer, RestModule.class );\n" + - " return layer;\n" + - " }\n" + - "}\n" - ); - } - } - - private PrintWriter createPrinter( Map<String, String> properties ) - throws IOException - { - String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/connectivity/"; - String classname = "ConnectivityLayer"; - File projectDir = new File( properties.get( "project.dir" ) ); - return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ) ); - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/0accd2cf/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/CrudModuleWriter.java ---------------------------------------------------------------------- diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/CrudModuleWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/CrudModuleWriter.java deleted file mode 100644 index df73ae3..0000000 --- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/CrudModuleWriter.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ - -package org.apache.zest.tools.shell.create.project.restapp; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Map; - -public class CrudModuleWriter -{ - - public void writeClass( Map<String, String> properties ) - throws IOException - { - String rootPackage = properties.get( "root.package" ); - String projectName = properties.get( "project.name" ); - try (PrintWriter pw = createPrinter( properties )) - { - pw.print( "package " ); - pw.print( properties.get( "root.package" ) ); - pw.println( ".bootstrap.domain;" ); - pw.println(); - pw.println( - "import org.apache.zest.bootstrap.AssemblyException;\n" + - "import org.apache.zest.bootstrap.LayerAssembly;\n" + - "import org.apache.zest.bootstrap.ModuleAssembly;\n" + - "import org.apache.zest.bootstrap.layered.ModuleAssembler;\n" + - "import org.apache.zest.library.restlet.assembly.CrudServiceAssembler;\n" + - "\n" + - "public class CrudModule\n" + - " implements ModuleAssembler\n" + - "{\n" + - " @Override\n" + - " public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )\n" + - " throws AssemblyException\n" + - " {\n" + - " module.withDefaultUnitOfWorkFactory();\n" + - " new CrudServiceAssembler().assemble( module );\n" + - " return module;\n" + - " }\n" + - "}\n" - ); - } - } - - private PrintWriter createPrinter( Map<String, String> properties ) - throws IOException - { - String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/domain/"; - String classname = "CrudModule"; - File projectDir = new File( properties.get( "project.dir" ) ); - return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ) ); - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/0accd2cf/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/CustomerWriter.java ---------------------------------------------------------------------- diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/CustomerWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/CustomerWriter.java deleted file mode 100644 index 65a325a..0000000 --- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/CustomerWriter.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ - -package org.apache.zest.tools.shell.create.project.restapp; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Map; - -public class CustomerWriter -{ - - public void writeClass( Map<String, String> properties ) - throws IOException - { - String rootPackage = properties.get( "root.package" ); - String projectName = properties.get( "project.name" ); - try (PrintWriter pw = createPrinter( properties )) - { - pw.print( "package " ); - pw.print( properties.get( "root.package" ) ); - pw.println( ".model.orders;" ); - pw.println(); - pw.println("import java.time.ZonedDateTime;"); - pw.println("import org.apache.zest.api.entity.Identity;"); - pw.println("import org.apache.zest.api.property.Property;"); - pw.println(); - pw.println( - "public interface Customer extends Identity\n" + - "{\n" + - " Property<String> name();\n\n" + - " Property<String> address();\n\n" + - " Property<String> city();\n\n" + - " Property<String> country();\n\n" + - " Property<String> phone();\n\n" + - " Property<ZonedDateTime> registered();\n\n" + - "}\n"); - } - } - - private PrintWriter createPrinter( Map<String, String> properties ) - throws IOException - { - String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/model/orders/"; - String classname = "Customer"; - File projectDir = new File( properties.get( "project.dir" ) ); - return new PrintWriter( new FileWriter( new File( projectDir, "model/src/main/java/" + packagename + classname + ".java" ) ) ); - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/0accd2cf/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/DomainLayerWriter.java ---------------------------------------------------------------------- diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/DomainLayerWriter.java b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/DomainLayerWriter.java deleted file mode 100644 index 3c7b652..0000000 --- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/DomainLayerWriter.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ - -package org.apache.zest.tools.shell.create.project.restapp; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Map; - -public class DomainLayerWriter -{ - - public void writeClass( Map<String, String> properties ) - throws IOException - { - String rootPackage = properties.get( "root.package" ); - String projectName = properties.get( "project.name" ); - try (PrintWriter pw = createPrinter( properties )) - { - pw.print( "package " ); - pw.print( properties.get( "root.package" ) ); - pw.println( ".bootstrap.domain;" ); - pw.println(); - pw.println( - "import java.util.function.Function;\n" + - "import org.apache.zest.api.structure.Application;\n" + - "import org.apache.zest.api.structure.Module;\n" + - "import org.apache.zest.bootstrap.AssemblyException;\n" + - "import org.apache.zest.bootstrap.LayerAssembly;\n" + - "import org.apache.zest.bootstrap.layered.LayerAssembler;\n" + - "import org.apache.zest.bootstrap.layered.LayeredLayerAssembler;\n" + - "\n" + - "public class DomainLayer extends LayeredLayerAssembler\n" + - " implements LayerAssembler\n" + - "{\n" + - " @Override\n" + - " public LayerAssembly assemble(LayerAssembly layer)\n" + - " throws AssemblyException\n" + - " {\n" + - " createModule( layer, CrudModule.class );\n" + - " createModule( layer, OrderModule.class ); // This is a simple sample that you typically remove.\n" + - " createModule( layer, SecurityModule.class ); // This is a simple sample that you typically remove.\n" + - " return layer;\n" + - " }\n" + - "\n" + - " public static Function<Application, Module> typeFinder()\n" + - " {\n" + - " return application -> application.findModule( \"Domain Layer\", \"Assets Module\" );\n" + - " }\n" + - "}\n" - ); - } - } - - private PrintWriter createPrinter( Map<String, String> properties ) - throws IOException - { - String packagename = properties.get( "root.package" ).replaceAll( "\\.", "/" ) + "/bootstrap/domain/"; - String classname = "DomainLayer"; - File projectDir = new File( properties.get( "project.dir" ) ); - return new PrintWriter( new FileWriter( new File( projectDir, "bootstrap/src/main/java/" + packagename + classname + ".java" ) ) ); - } -}
