From 2eaa0b549818be88f31b850db115b690337b2746 Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Tue, 11 Aug 2015 17:59:12 +0200 Subject: [PATCH] [New] Added new project li.strolch.planningwebapp - this project will be a reference implementation for planning use cases --- li.strolch.planningwebapp/.gitignore | 5 + li.strolch.planningwebapp/README.md | 6 + li.strolch.planningwebapp/pom.xml | 160 ++++++++++++++++++ .../planningwebapp/StartupListener.java | 60 +++++++ .../postinitializer/PostInitializer.java | 42 +++++ .../web/rest/RestfulApplication.java | 39 +++++ .../non-packaged-resources/ENV.properties | 1 + .../resources/componentVersion.properties | 6 + .../src/main/resources/log4j.xml | 30 ++++ .../webapp/WEB-INF/config/PrivilegeConfig.xml | 32 ++++ .../webapp/WEB-INF/config/PrivilegeModel.xml | 88 ++++++++++ .../WEB-INF/config/StrolchConfiguration.xml | 75 ++++++++ .../src/main/webapp/WEB-INF/data/Orders.xml | 14 ++ .../main/webapp/WEB-INF/data/Resources.xml | 14 ++ .../main/webapp/WEB-INF/data/StrolchModel.xml | 29 ++++ .../main/webapp/WEB-INF/dbStore/.placeholder | 0 .../src/main/webapp/index.html | 8 + .../src/main/webapp/index.jsp | 5 + pom.xml | 1 + 19 files changed, 615 insertions(+) create mode 100644 li.strolch.planningwebapp/.gitignore create mode 100644 li.strolch.planningwebapp/README.md create mode 100644 li.strolch.planningwebapp/pom.xml create mode 100644 li.strolch.planningwebapp/src/main/java/li/strolch/planningwebapp/StartupListener.java create mode 100644 li.strolch.planningwebapp/src/main/java/li/strolch/planningwebapp/postinitializer/PostInitializer.java create mode 100644 li.strolch.planningwebapp/src/main/java/li/strolch/planningwebapp/web/rest/RestfulApplication.java create mode 100644 li.strolch.planningwebapp/src/main/non-packaged-resources/ENV.properties create mode 100644 li.strolch.planningwebapp/src/main/resources/componentVersion.properties create mode 100644 li.strolch.planningwebapp/src/main/resources/log4j.xml create mode 100644 li.strolch.planningwebapp/src/main/webapp/WEB-INF/config/PrivilegeConfig.xml create mode 100644 li.strolch.planningwebapp/src/main/webapp/WEB-INF/config/PrivilegeModel.xml create mode 100644 li.strolch.planningwebapp/src/main/webapp/WEB-INF/config/StrolchConfiguration.xml create mode 100644 li.strolch.planningwebapp/src/main/webapp/WEB-INF/data/Orders.xml create mode 100644 li.strolch.planningwebapp/src/main/webapp/WEB-INF/data/Resources.xml create mode 100644 li.strolch.planningwebapp/src/main/webapp/WEB-INF/data/StrolchModel.xml create mode 100644 li.strolch.planningwebapp/src/main/webapp/WEB-INF/dbStore/.placeholder create mode 100644 li.strolch.planningwebapp/src/main/webapp/index.html create mode 100644 li.strolch.planningwebapp/src/main/webapp/index.jsp diff --git a/li.strolch.planningwebapp/.gitignore b/li.strolch.planningwebapp/.gitignore new file mode 100644 index 000000000..90dc57c13 --- /dev/null +++ b/li.strolch.planningwebapp/.gitignore @@ -0,0 +1,5 @@ +/.settings +/.classpath +/.project +/target +/target/ diff --git a/li.strolch.planningwebapp/README.md b/li.strolch.planningwebapp/README.md new file mode 100644 index 000000000..0957f544c --- /dev/null +++ b/li.strolch.planningwebapp/README.md @@ -0,0 +1,6 @@ +li.strolch.planningwebapp +====================== + +[![Build Status](http://jenkins.eitchnet.ch/buildStatus/icon?job=li.strolch.planningwebapp)](http://jenkins.eitchnet.ch/view/strolch/job/li.strolch.planningwebapp/) + +A Strolch planning reference web application diff --git a/li.strolch.planningwebapp/pom.xml b/li.strolch.planningwebapp/pom.xml new file mode 100644 index 000000000..65052c388 --- /dev/null +++ b/li.strolch.planningwebapp/pom.xml @@ -0,0 +1,160 @@ + + + 4.0.0 + + + li.strolch + li.strolch.parent + 1.1.0-SNAPSHOT + ../li.strolch.parent/pom.xml + + + + UTF-8 + planningwebapp + tomcat7.eitchnet.ch + http://appsrv:8080/manager/text + ${warFinalName} + + + li.strolch.planningwebapp + li.strolch.planningwebapp + Tutorial webapp to show case using Strolch in a servlet container + war + + https://github.com/eitchnet/li.strolch + + 2011 + + + Github Issues + https://github.com/eitchnet/li.strolch/issues + + + + scm:git:https://github.com/eitchnet/strolch.git + scm:git:git@github.com:eitch/strolch.git + https://github.com/eitchnet/strolch + + + + + + li.strolch + li.strolch.bom + pom + ${project.version} + + + + + + + + li.strolch + li.strolch.bom + pom + + + li.strolch + li.strolch.rest + + + li.strolch + li.strolch.persistence.xml + + + + org.slf4j + slf4j-log4j12 + runtime + + + + + junit + junit + test + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + + ${warFinalName} + + + src/main/resources + true + + **/componentVersion.properties + + + + src/main/resources + false + + **/componentVersion.properties + + + + + + + + org.codehaus.mojo + buildnumber-maven-plugin + + + + org.apache.maven.plugins + maven-war-plugin + + false + ${warFinalName} + + + src/main/non-packaged-resources + WEB-INF + true + + **/ENV.properties + + + + + + + + + org.apache.tomcat.maven + tomcat7-maven-plugin + + ${tomcat7Url} + ${tomcat7ServerId} + /${warFinalName} + + + + + + + + m2e + + + + m2e.version + + + + dev + + + + diff --git a/li.strolch.planningwebapp/src/main/java/li/strolch/planningwebapp/StartupListener.java b/li.strolch.planningwebapp/src/main/java/li/strolch/planningwebapp/StartupListener.java new file mode 100644 index 000000000..c087b61a0 --- /dev/null +++ b/li.strolch.planningwebapp/src/main/java/li/strolch/planningwebapp/StartupListener.java @@ -0,0 +1,60 @@ +/* + * Copyright 2015 Robert von Burg + * + * Licensed 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 li.strolch.planningwebapp; + +import java.io.File; + +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; +import javax.servlet.annotation.WebListener; + +import li.strolch.agent.api.StrolchAgent; +import li.strolch.runtime.configuration.StrolchEnvironment; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@WebListener +@SuppressWarnings("nls") +public class StartupListener implements ServletContextListener { + + private static final Logger logger = LoggerFactory.getLogger(StartupListener.class); + private StrolchAgent agent; + + @Override + public void contextInitialized(ServletContextEvent sce) { + + String realPath = sce.getServletContext().getRealPath("/WEB-INF"); + + File pathF = new File(realPath); + String environment = StrolchEnvironment.getEnvironmentFromEnvProperties(pathF); + logger.info("Starting Agent..."); + this.agent = new StrolchAgent(); + this.agent.setup(environment, pathF); + this.agent.initialize(); + this.agent.start(); + logger.info("Agent started."); + } + + @Override + public void contextDestroyed(ServletContextEvent sce) { + if (this.agent != null) { + this.agent.stop(); + this.agent.destroy(); + } + logger.info("Agent destroyed"); + } +} diff --git a/li.strolch.planningwebapp/src/main/java/li/strolch/planningwebapp/postinitializer/PostInitializer.java b/li.strolch.planningwebapp/src/main/java/li/strolch/planningwebapp/postinitializer/PostInitializer.java new file mode 100644 index 000000000..60c83059b --- /dev/null +++ b/li.strolch.planningwebapp/src/main/java/li/strolch/planningwebapp/postinitializer/PostInitializer.java @@ -0,0 +1,42 @@ +/* + * Copyright 2015 Robert von Burg + * + * Licensed 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 li.strolch.planningwebapp.postinitializer; + +import li.strolch.agent.api.ComponentContainer; +import li.strolch.agent.impl.SimplePostInitializer; + +/** + * @author Robert von Burg + * + */ +public class PostInitializer extends SimplePostInitializer { + + /** + * @param container + * @param componentName + */ + public PostInitializer(ComponentContainer container, String componentName) { + super(container, componentName); + } + + @Override + public void start() throws Exception { + + logger.info("Started PostInitializer."); //$NON-NLS-1$ + + super.start(); + } +} diff --git a/li.strolch.planningwebapp/src/main/java/li/strolch/planningwebapp/web/rest/RestfulApplication.java b/li.strolch.planningwebapp/src/main/java/li/strolch/planningwebapp/web/rest/RestfulApplication.java new file mode 100644 index 000000000..94b90b585 --- /dev/null +++ b/li.strolch.planningwebapp/src/main/java/li/strolch/planningwebapp/web/rest/RestfulApplication.java @@ -0,0 +1,39 @@ +/* + * Copyright 2015 Robert von Burg + * + * Licensed 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 li.strolch.planningwebapp.web.rest; + +import java.util.HashSet; +import java.util.Set; + +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; + +import li.strolch.rest.StrolchRestfulClasses; + +/** + * @author Robert von Burg + */ +@ApplicationPath("rest") +public class RestfulApplication extends Application { + + @Override + public Set> getClasses() { + Set> classes = new HashSet<>(); + classes.addAll(StrolchRestfulClasses.getRestfulClasses()); + classes.addAll(StrolchRestfulClasses.getProviderClasses()); + return classes; + } +} diff --git a/li.strolch.planningwebapp/src/main/non-packaged-resources/ENV.properties b/li.strolch.planningwebapp/src/main/non-packaged-resources/ENV.properties new file mode 100644 index 000000000..8212444c1 --- /dev/null +++ b/li.strolch.planningwebapp/src/main/non-packaged-resources/ENV.properties @@ -0,0 +1 @@ +ENV_STROLCH=${strolch.env} \ No newline at end of file diff --git a/li.strolch.planningwebapp/src/main/resources/componentVersion.properties b/li.strolch.planningwebapp/src/main/resources/componentVersion.properties new file mode 100644 index 000000000..a4594a250 --- /dev/null +++ b/li.strolch.planningwebapp/src/main/resources/componentVersion.properties @@ -0,0 +1,6 @@ +groupId=${project.groupId} +artifactId=${project.artifactId} +artifactVersion=${project.version} +scmRevision=${buildNumber} +scmBranch=${scmBranch} +buildTimestamp=${buildTimestamp} \ No newline at end of file diff --git a/li.strolch.planningwebapp/src/main/resources/log4j.xml b/li.strolch.planningwebapp/src/main/resources/log4j.xml new file mode 100644 index 000000000..6bb2f5090 --- /dev/null +++ b/li.strolch.planningwebapp/src/main/resources/log4j.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/li.strolch.planningwebapp/src/main/webapp/WEB-INF/config/PrivilegeConfig.xml b/li.strolch.planningwebapp/src/main/webapp/WEB-INF/config/PrivilegeConfig.xml new file mode 100644 index 000000000..9f9fde2c0 --- /dev/null +++ b/li.strolch.planningwebapp/src/main/webapp/WEB-INF/config/PrivilegeConfig.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/li.strolch.planningwebapp/src/main/webapp/WEB-INF/config/PrivilegeModel.xml b/li.strolch.planningwebapp/src/main/webapp/WEB-INF/config/PrivilegeModel.xml new file mode 100644 index 000000000..b31ffb4fa --- /dev/null +++ b/li.strolch.planningwebapp/src/main/webapp/WEB-INF/config/PrivilegeModel.xml @@ -0,0 +1,88 @@ + + + + + + SYSTEM + + agent + + + + Application + Administrator + ENABLED + en_GB + + AppUser + + + + + + + + + Bob + Bernstein + ENABLED + en_GB + + AppUser + + + + + Jill + Johnson + ENABLED + en_GB + + OnlyGreetingServiceRole + + + + + System User + Administrator + SYSTEM + en_GB + + sysAdmin + AppUser + + + + + + + + + + li.strolch.agent.impl.StartRealms + + + true + + + + + + true + + + true + + + + + + + + + + + + + + \ No newline at end of file diff --git a/li.strolch.planningwebapp/src/main/webapp/WEB-INF/config/StrolchConfiguration.xml b/li.strolch.planningwebapp/src/main/webapp/WEB-INF/config/StrolchConfiguration.xml new file mode 100644 index 000000000..029791c08 --- /dev/null +++ b/li.strolch.planningwebapp/src/main/webapp/WEB-INF/config/StrolchConfiguration.xml @@ -0,0 +1,75 @@ + + + + + PlanningWebApp + + true + + + + PrivilegeHandler + li.strolch.runtime.privilege.PrivilegeHandler + li.strolch.runtime.privilege.DefaultStrolchPrivilegeHandler + + PrivilegeConfig.xml + + + + RealmHandler + li.strolch.agent.api.RealmHandler + li.strolch.agent.impl.DefaultRealmHandler + PersistenceHandler + PrivilegeHandler + + TRANSIENT + StrolchModel.xml + + + + ServiceHandler + li.strolch.service.api.ServiceHandler + li.strolch.service.api.DefaultServiceHandler + RealmHandler + PrivilegeHandler + + true + + + + PostInitializer + li.strolch.agent.api.PostInitializer + li.strolch.planningwebapp.postinitializer.PostInitializer + ServiceHandler + + + + + PersistenceHandler + li.strolch.persistence.api.PersistenceHandler + li.strolch.persistence.xml.XmlPersistenceHandler + + true + + + + RestfulHandler + li.strolch.rest.RestfulStrolchComponent + li.strolch.rest.RestfulStrolchComponent + SessionHandler + + true + http://localhost:8180 + + + + SessionHandler + li.strolch.rest.StrolchSessionHandler + li.strolch.rest.DefaultStrolchSessionHandler + PrivilegeHandler + + 1 + + + + diff --git a/li.strolch.planningwebapp/src/main/webapp/WEB-INF/data/Orders.xml b/li.strolch.planningwebapp/src/main/webapp/WEB-INF/data/Orders.xml new file mode 100644 index 000000000..55358bcaa --- /dev/null +++ b/li.strolch.planningwebapp/src/main/webapp/WEB-INF/data/Orders.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/li.strolch.planningwebapp/src/main/webapp/WEB-INF/data/Resources.xml b/li.strolch.planningwebapp/src/main/webapp/WEB-INF/data/Resources.xml new file mode 100644 index 000000000..e6259cb83 --- /dev/null +++ b/li.strolch.planningwebapp/src/main/webapp/WEB-INF/data/Resources.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/li.strolch.planningwebapp/src/main/webapp/WEB-INF/data/StrolchModel.xml b/li.strolch.planningwebapp/src/main/webapp/WEB-INF/data/StrolchModel.xml new file mode 100644 index 000000000..2ded8056d --- /dev/null +++ b/li.strolch.planningwebapp/src/main/webapp/WEB-INF/data/StrolchModel.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/li.strolch.planningwebapp/src/main/webapp/WEB-INF/dbStore/.placeholder b/li.strolch.planningwebapp/src/main/webapp/WEB-INF/dbStore/.placeholder new file mode 100644 index 000000000..e69de29bb diff --git a/li.strolch.planningwebapp/src/main/webapp/index.html b/li.strolch.planningwebapp/src/main/webapp/index.html new file mode 100644 index 000000000..4b2d9f0ea --- /dev/null +++ b/li.strolch.planningwebapp/src/main/webapp/index.html @@ -0,0 +1,8 @@ + + +Strolch Planning WebApp + + + Start =) + + \ No newline at end of file diff --git a/li.strolch.planningwebapp/src/main/webapp/index.jsp b/li.strolch.planningwebapp/src/main/webapp/index.jsp new file mode 100644 index 000000000..c38169bb9 --- /dev/null +++ b/li.strolch.planningwebapp/src/main/webapp/index.jsp @@ -0,0 +1,5 @@ + + +

Hello World!

+ + diff --git a/pom.xml b/pom.xml index 7c7771fb4..25de9738a 100644 --- a/pom.xml +++ b/pom.xml @@ -58,5 +58,6 @@ li.strolch.performancetest li.strolch.tutorialapp li.strolch.tutorialwebapp + li.strolch.planningwebapp