Skip to content

Instantly share code, notes, and snippets.

@arey
arey / ClearAttachmentsOutInterceptor.java
Created February 20, 2014 17:29
CXF interceptor fixing memory leak by removing attachments
import org.apache.cxf.binding.soap.SoapMessage;
import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
import org.apache.cxf.endpoint.ClientImpl;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.phase.Phase;
/**
* Fix CXF memory leak by removing attachments once the SOAP message was sent.
*/
public class ClearAttachmentsOutInterceptor extends AbstractSoapInterceptor {
@arey
arey / pom-jasmine.xml
Created March 4, 2014 09:10
jasmine-maven-plugin configuration testing JavaScript code of a Java web app with Jasmine
<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.javaetmoi.samples</groupId>
<version>1.0-SNAPSHOT</version>
<artifactId>jasmine-test-webapp</artifactId>
<name>JavaEtMoi Samples :: ${project.artifactId} - ${project.packaging}</name>
<packaging>war</packaging>
<description>Maven configuration to test JavaScript code of a Java web app with Jasmine et PhantomJS</description>
<inceptionYear>2014</inceptionYear>
@arey
arey / NopScanner.java
Created April 9, 2014 19:56
No-operation Hibernate Scanner
package com.javaetmoi.core.persistence.hibernate;
import java.util.Collections;
import java.util.Set;
import org.hibernate.jpa.boot.archive.internal.StandardArchiveDescriptorFactory;
import org.hibernate.jpa.boot.scan.spi.AbstractScannerImpl;
import org.hibernate.jpa.boot.scan.spi.ScanOptions;
import org.hibernate.jpa.boot.scan.spi.ScanResult;
import org.hibernate.jpa.boot.spi.ClassDescriptor;
@arey
arey / angular-from-scratch.html
Last active August 29, 2015 14:00
HTML et JavaScript basé sur le hand's on labs "AngularJS from scratch : comprendre Angular en le re-faisant de zéro" de Devoxx France 2014
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>AngularJS from scratch</title>
</head>
<body class="container text-center">
<h1 class="page-header" ng-bind="labs.titre">AngularJS from scratch</h1>
<input type="text" ng-model="labs.titre"/>
@arey
arey / ViewStateExtractor.java
Created May 24, 2012 18:24
Extracteur JMeter d'identifiant du view state JSF à l’aide d'une regex
import java.util.HashSet;
import java.util.Set;
import org.apache.jmeter.extractor.RegexExtractor;
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
import org.apache.jmeter.testelement.TestElement;
import com.javaetmoi.tests.jmeter.TestElementProcessor;
import com.javaetmoi.tests.jmeter.TestElementTree;
@arey
arey / pom-maven-replace-arobase.xml
Created July 16, 2012 18:38
Configuration maven permettant d'utiliser des délimiteurs de filtre maven sur plusieurs caractères
<build>
<!-- Filtres les fichiers de ressources -->
<resources>
<resource>
<directory>target/generated-resources</directory>
<!-- Utilise les délimiteurs par défaut ${*} et @ -->
<filtering>true</filtering>
</resource>
</resources>
<filters>
@arey
arey / jboss-app.xml
Created January 4, 2013 11:07
Fichier META-INF\jboss-app.xml d'un EAR permettant d'isoler le classloader de JBoss.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-app PUBLIC
"-//JBoss//DTD Java EE Application 5.0//EN"
"http://www.jboss.org/j2ee/dtd/jboss-app_5_0.dtd">
<jboss-app>
<loader-repository>com.javaetmoi:archive=monapplication-ear
<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
</loader-repository>
</jboss-app>
@arey
arey / pom-ear-jboss.xml
Created January 4, 2013 11:12
Configuration du plugin maven-ear-plugin générant e fichier jboss-app.xml avec isolation du classloader de l'EAR.
<!-- Generation du classPath dans le Manifest de l'EAR, paramétrage du classloader -->
<!-- et recopie centralisée des JARs des WARs dans le répertoire lib -->
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<version>5</version>
<defaultJavaBundleDir>lib/</defaultJavaBundleDir>
<applicationXml>${project.build.directory}/application.xml</applicationXml>
<archive>
<manifest>
@arey
arey / TransactionAwareDestination.java
Created September 5, 2013 17:05
A DbSetup destination which wraps a DataSource and gets its connection from a JDBC DataSource, adding awareness of Spring-managed transactions.
package com.javametmoi.test.dbsetup;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;
@arey
arey / TestSpringDbSetup.java
Created September 6, 2013 06:14
Test case mixing both the DbSetup and the Spring frameworks
package com.javametmoi.test.dbsetup;
import static com.ninja_squad.dbsetup.Operations.insertInto;
import static com.ninja_squad.dbsetup.Operations.sequenceOf;
import static org.junit.Assert.assertEquals;
import java.sql.SQLException;
import javax.sql.DataSource;