Skip to content

Instantly share code, notes, and snippets.

ssh -L 8787:example.com:8787 pete@example.com
ssh -L <localhost-port>:<remote-host-name>:<remote-host-port> <remote-host-user>@<remote-host-name>
@sejersbol
sejersbol / UsingBean.java
Created February 26, 2011 08:48
SomeBean injected using CDI.
...
import javax.inject.Inject;
...
@Inject
private SomeBean someBean;
@sejersbol
sejersbol / ExampleValidator.java
Created February 26, 2011 08:47
A util Validator class method.
...
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
...
public static void myValidator(SomeBean someBean) {
...
ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
Validator validator = validatorFactory.getValidator();
@sejersbol
sejersbol / SomeDto.java
Created February 26, 2011 08:45
Check database constraints on-the-fly.
...
import javax.validation.constraints.Min;
import javax.validation.constraints.Size;
import javax.validation.constraints.NotNull;
@Data
public class SomeDto {
@Min(0)
private int id;
@Size(min=2, max=8)
@sejersbol
sejersbol / SomeDto.java
Created February 26, 2011 08:44
With the Lombok annotation @DaTa this will generate code the shown here.
// Generated by delombok at Mon Feb 14 20:57:05 CET 2011
package com.example;
public class SomeDto {
private int id;
private String firstName;
private String lastName;
@java.lang.SuppressWarnings("all")
public SomeDto() {
@sejersbol
sejersbol / SomeDto.java
Created February 26, 2011 08:43
Simple Lombok annotated DTO.
...
import lombok.Data;
@Data
public class SomeDto {
private int id;
private String firstName;
private String lastName;
}
@sejersbol
sejersbol / pom.xml
Created February 26, 2011 08:33
Transactional SOAP web service Maven POM file.
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>ws</artifactId>
<name>Example Web Service</name>
<packaging>war</packaging>
<version>1.0.0-SNAPSHOT</version>
@sejersbol
sejersbol / web.xml
Created February 26, 2011 08:32
WEB-INF/web.xml file
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<servlet>
<servlet-name>Ws</servlet-name>
<servlet-class>com.example.Ws</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Ws</servlet-name>
@sejersbol
sejersbol / beans.xml
Created February 26, 2011 08:30
Empty beans.xml file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>