142 lines
4.3 KiB
Markdown
142 lines
4.3 KiB
Markdown
# Kiss4web
|
|
|
|
Welcome! Welcome in a world of K.I.S.S.
|
|
|
|
K.I.S.S. = Keep It Simple, Stupid (https://en.wikipedia.org/wiki/KISS_principle).
|
|
|
|
Nowadays, make a Web site involves to use complex and heavy frameworks. Nevertheless, to build a web page and to return it, does not maybe ask so much complexity.
|
|
|
|
Kiss4web is a K.I.S.S. solution for building web applications.
|
|
|
|
Kiss4web builds on:
|
|
|
|
- KissDispatcher: call the good Java Servlet for each HTTP request,
|
|
- Xidyn: a template solution to dynamize HTML sources.
|
|
|
|
## Author
|
|
|
|
Lead developer: Christian Pierre MOMON <christian.momon@devinsy.fr>
|
|
|
|
## License
|
|
|
|
Kiss4web is released under the GNU LGPL license.
|
|
|
|
## Developing environment
|
|
|
|
Kiss4web project uses strictly Eclipse 4.29, Java 17, tomcat 10.1 and Git.
|
|
|
|
|
|
## Build
|
|
|
|
Kiss4web uses Ant and generates a kiss4web-x.y.z folder which contains:
|
|
|
|
- x.jar : full software.
|
|
- x-core.jar : only compiled class without any library.
|
|
- x-core-source.jar : sources.
|
|
|
|
## Dependencies
|
|
|
|
The kiss4web jar requires:
|
|
- commons-io
|
|
- commons-lang3
|
|
- devinsy-strings
|
|
|
|
## Usages
|
|
|
|
```
|
|
B --> FooAppLauncher -------------------------> FooApp
|
|
[ServletContextListener] [Singleton]
|
|
|
|
|
| setMode(Mode.OPEN)
|
|
\ /
|
|
A --> Kiss4webLauncher ----setMode(Mode.OPEN)---> Kiss4web <Mode.APP_INIT>
|
|
[ServletContextListener] [Singleton]
|
|
```
|
|
|
|
KissDispatcher is initialized with Mode.APP_INIT.
|
|
|
|
### Usage A: default
|
|
|
|
The easier way, in case you have no application initialization step. The Kiss4webLauncher set a default log4j2 configuration and set the KissDispatcher to Mode.OPEN state with a default set of hooks.
|
|
|
|
Edit `…/WebContent/WEB-INF/web.xml` :
|
|
```
|
|
<listener>
|
|
<listener-class>fr.devinsy.kiss4web.Kiss4webLauncher</listener-class>
|
|
</listener>
|
|
<servlet>
|
|
<servlet-name>Application dispatcher</servlet-name>
|
|
<servlet-class>fr.devinsy.kiss4web.dispatcher.KissDispatcher</servlet-class>
|
|
<init-param>
|
|
<param-name>webClassesRootPackage</param-name>
|
|
<param-value>website</param-value>
|
|
</init-param>
|
|
<load-on-startup>1</load-on-startup>
|
|
</servlet>
|
|
<servlet-mapping>
|
|
<servlet-name>Application dispatcher</servlet-name>
|
|
<url-pattern>/*</url-pattern>
|
|
</servlet-mapping>
|
|
```
|
|
|
|
You can create …/WebContent/WEB-INF/log4j2.properties:
|
|
```
|
|
# Log configuration
|
|
# #################
|
|
|
|
# priority setting: DEBUG < INFO < WARN < ERROR
|
|
name = Log4j2 Properties Config
|
|
status = ERROR
|
|
dest = err
|
|
|
|
# Logger settings.
|
|
rootLogger.level = INFO
|
|
rootLogger.appenderRefs = a, b
|
|
rootLogger.appenderRef.a.ref = CONSOLE
|
|
rootLogger.appenderRef.b.ref = LOGFILE
|
|
|
|
logger.statoolinfos.name = fr.devinsy.statoolinfos
|
|
logger.statoolinfos.level = INFO
|
|
|
|
logger.xidyn.name = fr.devinsy.xidyn
|
|
logger.xidyn.level = WARN
|
|
|
|
# Appenders settings.
|
|
appenders = CONSOLE, LOGFILE
|
|
|
|
appender.CONSOLE.type = Console
|
|
appender.CONSOLE.name = CONSOLE
|
|
appender.CONSOLE.layout.type = PatternLayout
|
|
appender.CONSOLE.layout.pattern = %d{ISO8601} - FooApp [%-5p] %34.34c.%25M - %m%n
|
|
|
|
appender.LOGFILE.type = File
|
|
appender.LOGFILE.name = LOGFILE
|
|
appender.LOGFILE.filename = /srv/fooapp/rslisi.log
|
|
appender.LOGFILE.layout.type = PatternLayout
|
|
appender.LOGFILE.layout.pattern = %d{ISO8601} - FooApp [%-5p] %34.34c.%25M - %m%n
|
|
```
|
|
|
|
### Usage B: custom init
|
|
|
|
If you want manage an application initialization step, do not use the Kiss4webLauncher as class listener. Create your own FooAppLauncher and make it calls `Kiss4web.instance().setMode(Mode.OPEN)` when the init step is over.
|
|
|
|
|
|
Edit `…/WebContent/WEB-INF/web.xml` :
|
|
```
|
|
<listener>
|
|
<listener-class>org.foo.app.FooAppLauncher</listener-class>
|
|
</listener>
|
|
<servlet>
|
|
<servlet-name>Application dispatcher</servlet-name>
|
|
<servlet-class>fr.devinsy.kiss4web.dispatcher.KissDispatcher</servlet-class>
|
|
<init-param>
|
|
<param-name>webClassesRootPackage</param-name>
|
|
<param-value>website</param-value>
|
|
</init-param>
|
|
<load-on-startup>1</load-on-startup>
|
|
</servlet>
|
|
<servlet-mapping>
|
|
<servlet-name>Application dispatcher</servlet-name>
|
|
<url-pattern>/*</url-pattern>
|
|
</servlet-mapping>
|
|
```
|