Skip to content

Instantly share code, notes, and snippets.

View l-gu's full-sized avatar

Laurent GUERIN l-gu

View GitHub Profile
@l-gu
l-gu / SortWithSpecificComparator.java
Last active December 29, 2015 00:19
Sort a list with a specific Comparator
public static void main(String[] args) {
List<Student> list = new LinkedList<Student>();
int i = 1 ;
list.add(new Student(i++,"John","Wayne"));
list.add(new Student(i++,"Joe","Dalton"));
list.add(new Student(i++,"Bart","Simpson"));
list.add(new Student(i++,"Homer","Simpson"));
list.add(new Student(i++,"Jack","Dalton"));
@l-gu
l-gu / gist:8541031
Created January 21, 2014 14:25
Maven dependencies for Bean Validation 1.1
<dependencies>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
<dependency>
<groupId>junit</groupId>
@l-gu
l-gu / gist:8541041
Created January 21, 2014 14:26
Maven dependencies for Bean Validation 1.0
<dependencies>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
<dependency>
<groupId>junit</groupId>
@l-gu
l-gu / gist:8543836
Last active January 4, 2016 00:49
POM.XML for JPA Hibernate 3.5.6
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>telosys-tools-templates</groupId>
<artifactId>jpa-templates</artifactId>
<version>2.0.5</version>
<build>
<plugins>
@l-gu
l-gu / gist:8580842
Created January 23, 2014 15:46
POM.XML for JPA 2 / Hibernate 4.2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>to.be.defined</groupId>
<artifactId>to.be.defined</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@l-gu
l-gu / MapContent
Last active August 29, 2015 13:55
@SuppressWarnings("unchecked")
protected void logSessionContent(HttpSession session) {
Enumeration<String> enumNames = session.getAttributeNames();
List<String> names = Collections.list(enumNames);
logger.info("Session content (size = " + names.size() + ") : ");
for ( String name : names ) {
logger.info(" . '" + name + "' : " + session.getAttribute(name) );
}
}
@l-gu
l-gu / gist:9188049
Created February 24, 2014 13:05
Map entries
//--- For each entity
for ( Map.Entry<String, EntityInContext> entry : _entities.entrySet() )
{
//String name = entry.getKey() ;
EntityInContext entity = entry.getValue() ;
allEntities.add(entity);
}
@l-gu
l-gu / gist:ed0c8726807e5e8dd83a
Created June 18, 2014 21:22
Database connection in a TelosysTools template
import java.io.File;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.SQLException;
@l-gu
l-gu / pom-xml-jax-rs-jersey
Created July 2, 2015 13:15
pom.xml for jax-rs with jersey
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cours</groupId>
<artifactId>jax-rs</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
@l-gu
l-gu / web-xml-jax-rs-jersey
Created July 2, 2015 13:18
web.xml for JAX-RS with Jersey
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="portail-jaxrs" version="2.5">
<display-name>portail-jaxrs</display-name>
<servlet>
<servlet-name>Jersey REST Service</servlet-name>