diff --git a/li.strolch.tutorialwebapp/.gitignore b/li.strolch.tutorialwebapp/.gitignore new file mode 100644 index 000000000..9f094653a --- /dev/null +++ b/li.strolch.tutorialwebapp/.gitignore @@ -0,0 +1,4 @@ +/.settings +/.classpath +/.project +/target \ No newline at end of file diff --git a/li.strolch.tutorialwebapp/README.md b/li.strolch.tutorialwebapp/README.md new file mode 100644 index 000000000..c80a7a8b8 --- /dev/null +++ b/li.strolch.tutorialwebapp/README.md @@ -0,0 +1,6 @@ +li.strolch.tutorialwbapp +====================== + +[![Build Status](http://jenkins.eitchnet.ch/buildStatus/icon?job=li.strolch.tutorialwebapp)](http://jenkins.eitchnet.ch/view/strolch/job/li.strolch.tutorialwebapp/) + +A simple Strolch tutorial web application diff --git a/li.strolch.tutorialwebapp/pom.xml b/li.strolch.tutorialwebapp/pom.xml new file mode 100644 index 000000000..db4fdef52 --- /dev/null +++ b/li.strolch.tutorialwebapp/pom.xml @@ -0,0 +1,185 @@ + + 4.0.0 + + + li.strolch + li.strolch.parent + 1.0.0-SNAPSHOT + ../li.strolch.parent/pom.xml + + + + UTF-8 + tutorialwebapp + tomcat7.eitchnet.ch + http://appsrv:8080/manager/text + ${warFinalName} + + + li.strolch.tutorialwebapp + li.strolch.tutorialwebapp + Tutorial webapp to show case using Strolch in a servlet container + war + + https://github.com/eitchnet/li.strolch.tutorialwebapp + + 2011 + + + Github Issues + https://github.com/eitchnet/li.strolch.tutorialwebapp/issues + + + + scm:git:https://github.com/eitchnet/li.strolch.tutorialwebapp.git + scm:git:git@github.com:eitch/li.strolch.tutorialwebapp.git + https://github.com/eitchnet/li.strolch.tutorialwebapp + + + + + + 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.tutorialwebapp/src/main/java/li/strolch/tutorialwebapp/StartupListener.java b/li.strolch.tutorialwebapp/src/main/java/li/strolch/tutorialwebapp/StartupListener.java new file mode 100644 index 000000000..2b127e0bf --- /dev/null +++ b/li.strolch.tutorialwebapp/src/main/java/li/strolch/tutorialwebapp/StartupListener.java @@ -0,0 +1,45 @@ +package li.strolch.tutorialwebapp; + +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.tutorialwebapp/src/main/java/li/strolch/tutorialwebapp/postinitializer/PostInitializer.java b/li.strolch.tutorialwebapp/src/main/java/li/strolch/tutorialwebapp/postinitializer/PostInitializer.java new file mode 100644 index 000000000..976b8c774 --- /dev/null +++ b/li.strolch.tutorialwebapp/src/main/java/li/strolch/tutorialwebapp/postinitializer/PostInitializer.java @@ -0,0 +1,42 @@ +/* + * Copyright 2013 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.tutorialwebapp.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() { + + logger.info("Started PostInitializer."); //$NON-NLS-1$ + + super.start(); + } +} diff --git a/li.strolch.tutorialwebapp/src/main/java/li/strolch/tutorialwebapp/web/rest/RestfulApplication.java b/li.strolch.tutorialwebapp/src/main/java/li/strolch/tutorialwebapp/web/rest/RestfulApplication.java new file mode 100644 index 000000000..88d0609f7 --- /dev/null +++ b/li.strolch.tutorialwebapp/src/main/java/li/strolch/tutorialwebapp/web/rest/RestfulApplication.java @@ -0,0 +1,39 @@ +/* + * Copyright 2013 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.tutorialwebapp.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.tutorialwebapp/src/main/non-packaged-resources/ENV.properties b/li.strolch.tutorialwebapp/src/main/non-packaged-resources/ENV.properties new file mode 100644 index 000000000..8212444c1 --- /dev/null +++ b/li.strolch.tutorialwebapp/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.tutorialwebapp/src/main/resources/componentVersion.properties b/li.strolch.tutorialwebapp/src/main/resources/componentVersion.properties new file mode 100644 index 000000000..1f050160f --- /dev/null +++ b/li.strolch.tutorialwebapp/src/main/resources/componentVersion.properties @@ -0,0 +1,6 @@ +groupId=${project.groupId} +artifactId=${project.artifactId} +artifactVersion=${project.version} +scmRevision=r${buildNumber} +scmBranch=${scmBranch} +buildTimestamp=${buildTimestamp} \ No newline at end of file diff --git a/li.strolch.tutorialwebapp/src/main/resources/log4j.xml b/li.strolch.tutorialwebapp/src/main/resources/log4j.xml new file mode 100644 index 000000000..6bb2f5090 --- /dev/null +++ b/li.strolch.tutorialwebapp/src/main/resources/log4j.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/config/PrivilegeConfig.xml b/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/config/PrivilegeConfig.xml new file mode 100644 index 000000000..e264a8929 --- /dev/null +++ b/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/config/PrivilegeConfig.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/config/PrivilegeModel.xml b/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/config/PrivilegeModel.xml new file mode 100644 index 000000000..d320e705f --- /dev/null +++ b/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/config/PrivilegeModel.xml @@ -0,0 +1,91 @@ + + + + + + SYSTEM + + agent + + + + Application + Administrator + ENABLED + en_GB + + PrivilegeAdmin + AppUser + + + + + + + + + Bob + Bernstein + ENABLED + en_GB + + AppUser + + + + + Jill + Johnson + ENABLED + en_GB + + OnlyGreetingServiceRole + + + + + System User + Administrator + SYSTEM + en_GB + + sysAdmin + AppUser + + + + + + + + + + + + true + + + true + + + + + + true + + + true + + + + + + + + + li.strolch.service.test.GreetingService + + + + + \ No newline at end of file diff --git a/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/config/StrolchConfiguration.xml b/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/config/StrolchConfiguration.xml new file mode 100644 index 000000000..b92eba7f4 --- /dev/null +++ b/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/config/StrolchConfiguration.xml @@ -0,0 +1,87 @@ + + + + + StrolchTutorialApp + + 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.tutorialwebapp.postinitializer.PostInitializer + ServiceHandler + + + + + PersistenceHandler + li.strolch.persistence.api.PersistenceHandler + li.strolch.persistence.xml.XmlPersistenceHandler + + true + + + + EnumHandler + li.strolch.runtime.query.enums.EnumHandler + li.strolch.runtime.query.enums.DefaultEnumHandler + RealmHandler + + defaultRealm + Resource/Enumeration/salutations + Resource/Enumeration/sex + Resource/Enumeration/religions + + + + RestfulHandler + li.strolch.rest.RestfulStrolchComponent + li.strolch.rest.RestfulStrolchComponent + SessionHandler + + true + http://localhost:8180 + + + + SessionHandler + li.strolch.rest.StrolchSessionHandler + li.strolch.rest.DefaultStrolchSessionHandler + PrivilegeHandler + + true + + + + diff --git a/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/data/Enums.xml b/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/data/Enums.xml new file mode 100644 index 000000000..eb80fda34 --- /dev/null +++ b/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/data/Enums.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/data/Orders.xml b/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/data/Orders.xml new file mode 100644 index 000000000..55358bcaa --- /dev/null +++ b/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/data/Orders.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/data/Resources.xml b/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/data/Resources.xml new file mode 100644 index 000000000..e6259cb83 --- /dev/null +++ b/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/data/Resources.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/data/StrolchModel.xml b/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/data/StrolchModel.xml new file mode 100644 index 000000000..2d9d4958e --- /dev/null +++ b/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/data/StrolchModel.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/dbStore/.placeholder b/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/dbStore/.placeholder new file mode 100644 index 000000000..e69de29bb diff --git a/li.strolch.tutorialwebapp/src/main/webapp/index.html b/li.strolch.tutorialwebapp/src/main/webapp/index.html new file mode 100644 index 000000000..c39cbc45c --- /dev/null +++ b/li.strolch.tutorialwebapp/src/main/webapp/index.html @@ -0,0 +1,8 @@ + + +Strolch Tutorial + + + Start =) + + \ No newline at end of file diff --git a/li.strolch.tutorialwebapp/src/main/webapp/index.jsp b/li.strolch.tutorialwebapp/src/main/webapp/index.jsp new file mode 100644 index 000000000..c38169bb9 --- /dev/null +++ b/li.strolch.tutorialwebapp/src/main/webapp/index.jsp @@ -0,0 +1,5 @@ + + +

Hello World!

+ +