[JAVA-13854] Half list moved (#12598)
* [JAVA-13854] added parent module * [JAVA-13854] moved apache-tapestry(submodule) to web-modules(parent) * [JAVA-13854] moved bootique(submodule) to web-modules(parent) * [JAVA-13854] moved dropwizard(submodule) to web-modules(parent) * [JAVA-13854] moved blade(submodule) to web-modules(parent) * [JAVA-13854] moved java-lite(submodule) to web-modules(parent) * [JAVA-13854] moved jooby(submodule) to web-modules(parent) * [JAVA-13854] moved linkrest(submodule) to web-modules(parent) * [JAVA-13854] moved ninja(submodule) to web-modules(parent) * [JAVA-13854] moved ratpack(submodule) to web-modules(parent) * [JAVA-13854] moved resteasy(submodule) to web-modules(parent) * [JAVA-13854] moved restx(submodule) to web-modules(parent) * [JAVA-13854] moved spark-java(submodule) to web-modules(parent) * [JAVA-13854] moved vraptor(submodule) to web-modules(parent) * [JAVA-13854] delete modules that were moved * [JAVA-13854] * [JAVA-13854] * [JAVA-13854] delete ninja submodule + moved raml(submodule) to web-modules(parent) * [JAVA-13854] moved gwt(submodule) to web-modules(parent) * [JAVA-13854] moved jakarta-ee(submodule) to web-modules(parent) * [JAVA-13854] moved javax-servlets(submodule) to web-modules(parent) * [JAVA-13854] moved javax-servlets-2(submodule) to web-modules(parent) * [JAVA-13854] moved jee-7(submodule) to web-modules(parent) * [JAVA-13854] moved play-framework(not a module) to web-modules * [JAVA-13854] fix failing test * [JAVA-13854] moved struts-2(submodule) to web-modules(parent) * [JAVA-13854] moved wicket(submodule) to web-modules(parent) * [JAVA-13854] deleted modules that were moved to web-modules * JAVA-13854 Removed moved modules from the main pom.xml Co-authored-by: panagiotiskakos <panagiotis.kakos@libra-is.com> Co-authored-by: Dhawal Kapil <dhawalkapil@gmail.com>
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
|
||||
version="2.0">
|
||||
|
||||
<!-- Database settings for development -->
|
||||
<persistence-unit name="dev_unit"
|
||||
transaction-type="RESOURCE_LOCAL">
|
||||
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
|
||||
<properties>
|
||||
<property name="hibernate.connection.driver_class" value="org.h2.Driver" />
|
||||
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
|
||||
<property name="hibernate.show_sql" value="true" />
|
||||
<property name="hibernate.format_sql" value="true" />
|
||||
<property name="hibernate.hbm2ddl.auto" value="update" />
|
||||
<property name="hibernate.connection.autocommit" value="true" />
|
||||
|
||||
<!-- Connection Pooling settings -->
|
||||
<property name="hibernate.connection.provider_class" value="org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider" />
|
||||
<property name="hibernate.c3p0.max_size" value="100" />
|
||||
<property name="hibernate.c3p0.min_size" value="0" />
|
||||
<property name="hibernate.c3p0.acquire_increment" value="1" />
|
||||
<property name="hibernate.c3p0.idle_test_period" value="300" />
|
||||
<property name="hibernate.c3p0.max_statements" value="0" />
|
||||
<property name="hibernate.c3p0.timeout" value="100" />
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
</persistence>
|
||||
@@ -0,0 +1,3 @@
|
||||
/* Add additional stylesheets below
|
||||
-------------------------------------------------- */
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package conf;
|
||||
|
||||
import java.util.List;
|
||||
import ninja.Filter;
|
||||
|
||||
public class Filters implements ninja.application.ApplicationFilters {
|
||||
|
||||
@Override
|
||||
public void addFilters(List<Class<? extends Filter>> filters) {
|
||||
// Add your application - wide filters here
|
||||
// filters.add(MyFilter.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package conf;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import services.UserService;
|
||||
import services.UserServiceImpl;
|
||||
|
||||
@Singleton
|
||||
public class Module extends AbstractModule {
|
||||
|
||||
protected void configure() {
|
||||
|
||||
bind(UserService.class).to(UserServiceImpl.class);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package conf;
|
||||
|
||||
import ninja.AssetsController;
|
||||
import ninja.Router;
|
||||
import ninja.application.ApplicationRoutes;
|
||||
import controllers.ApplicationController;
|
||||
|
||||
public class Routes implements ApplicationRoutes {
|
||||
|
||||
@Override
|
||||
public void init(Router router) {
|
||||
|
||||
router.GET().route("/index").with(ApplicationController::index);
|
||||
router.GET().route("/home").with(ApplicationController::home);
|
||||
router.GET().route("/hello").with(ApplicationController::helloWorld);
|
||||
router.GET().route("/userJson").with(ApplicationController::userJson);
|
||||
router.GET().route("/createUser").with(ApplicationController::createUser);
|
||||
router.GET().route("/flash").with(ApplicationController::showFlashMsg);
|
||||
|
||||
router.GET().route("/users").with(ApplicationController::fetchUsers);
|
||||
router.POST().route("/users").with(ApplicationController::insertUser);
|
||||
|
||||
//Assets
|
||||
router.GET().route("/assets/webjars/{fileName: .*}").with(AssetsController::serveWebJars);
|
||||
router.GET().route("/assets/{fileName: .*}").with(AssetsController::serveStatic);
|
||||
|
||||
//Index
|
||||
router.GET().route("/.*").with(ApplicationController::index);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
application.name=baeldung ninja dev application
|
||||
%test.application.name=baeldung ninja test application
|
||||
%prod.application.name=baeldung ninja application
|
||||
|
||||
application.cookie.prefix=NINJA
|
||||
|
||||
application.languages=fr,en
|
||||
|
||||
application.session.expire_time_in_seconds=3600
|
||||
application.session.send_only_if_changed=true
|
||||
application.session.transferred_over_https_only=false
|
||||
|
||||
ninja.port=8000
|
||||
ninja.ssl.port=8001
|
||||
application.secret = fxSjSL9Q017BSL7gBnkyo2Prln7uXaXIT35gotXRIED8c46OSa8s4QdoIQdTsEtj
|
||||
|
||||
# h2 jpa configuration
|
||||
ninja.jpa.persistence_unit_name=dev_unit
|
||||
db.connection.url=jdbc:h2:./devDb
|
||||
db.connection.username=sa
|
||||
db.connection.password=
|
||||
@@ -0,0 +1,2 @@
|
||||
header.home=Home!
|
||||
helloMsg=Hello, welcome to Ninja Framework!
|
||||
@@ -0,0 +1,2 @@
|
||||
header.home=Accueil!
|
||||
helloMsg=Bonjour, bienvenue dans Ninja Framework!
|
||||
@@ -0,0 +1,102 @@
|
||||
package controllers;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.Query;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
import com.google.inject.persist.Transactional;
|
||||
|
||||
import models.User;
|
||||
import ninja.Context;
|
||||
import ninja.Result;
|
||||
import ninja.Results;
|
||||
import ninja.i18n.Lang;
|
||||
import ninja.i18n.Messages;
|
||||
import ninja.jpa.UnitOfWork;
|
||||
import ninja.session.FlashScope;
|
||||
import ninja.validation.JSR303Validation;
|
||||
import ninja.validation.Validation;
|
||||
import services.UserService;
|
||||
|
||||
@Singleton
|
||||
public class ApplicationController {
|
||||
|
||||
@Inject
|
||||
Lang lang;
|
||||
|
||||
@Inject
|
||||
Messages msg;
|
||||
|
||||
private static Log logger = LogFactory.getLog(ApplicationController.class);
|
||||
|
||||
@Inject
|
||||
Provider<EntityManager> entityManagerProvider;
|
||||
|
||||
@Inject
|
||||
UserService userService;
|
||||
|
||||
public Result index() {
|
||||
return Results.html();
|
||||
}
|
||||
|
||||
public Result userJson() {
|
||||
HashMap<String, String> userMap = userService.getUserMap();
|
||||
logger.info(userMap);
|
||||
return Results.json().render(userMap);
|
||||
}
|
||||
|
||||
public Result helloWorld(Context context) {
|
||||
Optional<String> language = Optional.of("fr");
|
||||
String helloMsg = msg.get("helloMsg", language).get();
|
||||
return Results.text().render(helloMsg);
|
||||
}
|
||||
|
||||
public Result showFlashMsg(FlashScope flashScope) {
|
||||
flashScope.success("Success message");
|
||||
flashScope.error("Error message");
|
||||
return Results.redirect("/home");
|
||||
}
|
||||
|
||||
public Result home() {
|
||||
return Results.html();
|
||||
}
|
||||
|
||||
public Result createUser() {
|
||||
return Results.html();
|
||||
}
|
||||
|
||||
@UnitOfWork
|
||||
public Result fetchUsers() {
|
||||
EntityManager entityManager = entityManagerProvider.get();
|
||||
Query q = entityManager.createQuery("SELECT x FROM User x");
|
||||
List<User> users = (List<User>) q.getResultList();
|
||||
return Results.json().render(users);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Result insertUser(FlashScope flashScope, @JSR303Validation User user, Validation validation) {
|
||||
logger.info("Inserting User : " +user);
|
||||
|
||||
if (validation.getViolations().size() > 0) {
|
||||
flashScope.error("Validation Error: User can't be created");
|
||||
} else {
|
||||
EntityManager entityManager = entityManagerProvider.get();
|
||||
entityManager.persist(user);
|
||||
entityManager.flush();
|
||||
flashScope.success("User '" + user + "' is created successfully");
|
||||
}
|
||||
|
||||
return Results.redirect("/home");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../config/ehcache.xsd" updateCheck="false">
|
||||
|
||||
<defaultCache
|
||||
maxElementsInMemory="10000"
|
||||
eternal="false"
|
||||
timeToIdleSeconds="120"
|
||||
timeToLiveSeconds="120"
|
||||
overflowToDisk="false"
|
||||
maxElementsOnDisk="10000000"
|
||||
diskPersistent="false"
|
||||
diskExpiryThreadIntervalSeconds="120"
|
||||
memoryStoreEvictionPolicy="LRU"
|
||||
/>
|
||||
|
||||
</ehcache>
|
||||
@@ -0,0 +1,33 @@
|
||||
<configuration>
|
||||
|
||||
<!-- Uncomment to enable file-based logging with
|
||||
daily (or size exceeding) gzip archival.
|
||||
Also uncomment the "ROLLING" reference in <root>.
|
||||
<appender name="ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>mylog.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<FileNamePattern>mylog.%d{yyyy-MM-dd}.%i.log.gz</FileNamePattern>
|
||||
<MaxHistory>30</MaxHistory>
|
||||
<timeBasedFileNamingAndTriggeringPolicy
|
||||
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>10MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender> -->
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<!-- encoders are assigned the type
|
||||
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="STDOUT" />
|
||||
<!-- <appender-ref ref="ROLLING" /> -->
|
||||
</root>
|
||||
</configuration>
|
||||
@@ -0,0 +1,25 @@
|
||||
package models;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Entity
|
||||
public class User {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||
Long id;
|
||||
|
||||
@NotNull
|
||||
public String firstName;
|
||||
|
||||
public String email;
|
||||
|
||||
public String toString() {
|
||||
return firstName + " : " + email;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package services;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public interface UserService {
|
||||
|
||||
HashMap<String, String> getUserMap();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package services;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class UserServiceImpl implements UserService {
|
||||
|
||||
@Override
|
||||
public HashMap<String, String> getUserMap() {
|
||||
HashMap<String, String> userMap = new HashMap<>();
|
||||
userMap.put("name", "Norman Lewis");
|
||||
userMap.put("email", "norman@email.com");
|
||||
return userMap;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<#import "../layout/defaultLayout.ftl.html" as layout>
|
||||
<@layout.myLayout "Create User">
|
||||
|
||||
<form method="post" action="users">
|
||||
|
||||
First Name : <input type="text" name="firstName"/>
|
||||
<br/>
|
||||
Email : <input type="text" name="email"/>
|
||||
<br/>
|
||||
<input type="submit" value="Create"/>
|
||||
|
||||
</@layout.myLayout>
|
||||
@@ -0,0 +1,9 @@
|
||||
<#import "../layout/defaultLayout.ftl.html" as layout>
|
||||
<@layout.myLayout "Home page">
|
||||
|
||||
|
||||
<h1>${i18n("helloMsg")}</h1>
|
||||
|
||||
<a href="/userJson">User Json</a>
|
||||
|
||||
</@layout.myLayout>
|
||||
@@ -0,0 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Ninja: Index</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>${i18n("helloMsg")}</h1>
|
||||
<a href="/userJson">User Json</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,58 @@
|
||||
<#macro myLayout title="Layout example">
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>${title}</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
|
||||
<!-- Le styles -->
|
||||
<link href="/assets/webjars/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- Optional theme -->
|
||||
<link rel="stylesheet" href="/assets/webjars/bootstrap/3.3.4/css/bootstrap-theme.min.css">
|
||||
|
||||
<!-- Latest compiled and minified JavaScript -->
|
||||
|
||||
<style type="text/css">
|
||||
body {
|
||||
padding-top: 60px;
|
||||
padding-bottom: 40px;
|
||||
}
|
||||
.error-template {padding: 40px 15px;text-align: center;}
|
||||
</style>
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<#include "header.ftl.html"/>
|
||||
|
||||
<#if (flash.error)??>
|
||||
<div class="alert alert-danger">
|
||||
${flash.error}
|
||||
</div>
|
||||
</#if>
|
||||
|
||||
<#if (flash.success)??>
|
||||
<div class="alert alert-success">
|
||||
${flash.success}
|
||||
</div>
|
||||
</#if>
|
||||
|
||||
<#nested/>
|
||||
|
||||
<#include "footer.ftl.html"/>
|
||||
|
||||
</div> <!-- /container -->
|
||||
<script type="text/javascript" src="/assets/webjars/jquery/2.1.3/jquery.js"></script>
|
||||
<script type="text/javascript" src="/assets/webjars/bootstrap/3.3.4/js/bootstrap.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
</#macro>
|
||||
@@ -0,0 +1,5 @@
|
||||
<hr>
|
||||
<footer>
|
||||
Built with <a href="http://www.ninjaframework.org">Ninja framework</a>.
|
||||
</footer>
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="active"><a href="/">${i18n("header.home")}</a></li>
|
||||
<li class=""><a href="/hello">Hello</a></li>
|
||||
<li class=""><a href="/users">List User</a></li>
|
||||
<li class=""><a href="/createUser">Create User</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<!--/.navbar-collapse -->
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,18 @@
|
||||
<#import "../layout/defaultLayout.ftl.html" as layout>
|
||||
<@layout.myLayout "Error. Forbidden.">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="error-template">
|
||||
<h1>
|
||||
Oops!</h1>
|
||||
<h2>
|
||||
403 Forbidden</h2>
|
||||
<div class="error-details">
|
||||
Sorry, an error has occured. Requested page is forbidden!
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</@layout.myLayout>
|
||||
@@ -0,0 +1,18 @@
|
||||
<#import "../layout/defaultLayout.ftl.html" as layout>
|
||||
<@layout.myLayout "Error. Not found.">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="error-template">
|
||||
<h1>
|
||||
Oops!</h1>
|
||||
<h2>
|
||||
404 Not Found</h2>
|
||||
<div class="error-details">
|
||||
Sorry, an error has occured. Requested page not found!
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</@layout.myLayout>
|
||||
Reference in New Issue
Block a user