Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Thomas Darimont thomasdarimont

🏠
Working from home
View GitHub Profile
View 1_SpringJunit4RunnerRuleTests.java
package de.jugsaar.meeting8.testing.junit.poc;
import org.junit.Assert;
import org.junit.ClassRule;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
@thomasdarimont
thomasdarimont / FalseSharingDemo.cs
Last active Aug 29, 2015
C# FalseSharingEffects
View FalseSharingDemo.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ConcurrencyExamples
{
View ConfigSettingValue.java
package de.tutorials.training.springconfig;
import java.io.Serializable;
import lombok.Data;
@Data
public class ConfigSettingValue implements Serializable {
private static final long serialVersionUID = 1L;
View DependencyOverrideExampleTests.java
import static org.mockito.Mockito.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Spy;
import org.mockito.runners.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
public class DependencyOverrideExampleTests {
@thomasdarimont
thomasdarimont / Application.java
Last active Aug 29, 2015
This gist demonstrates the PoC for the upcoming support for dynamic binding of SpEL expression in string based and derived queries.
View Application.java
package demo;
import java.util.List;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
View ReflectiveDefaultMethodCallExample.java
package de.tutorials.training;
import org.springframework.core.env.SystemEnvironmentPropertySource;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
/**
* [USER=136855]@author[/USER] Thomas Darimont
View expressionsInDerivedQueries.md

Initially we also had support for SpEL Expression parameters in query derivation but we decided to leave it out for now, since we had some concerns whether having SpEL expressions in user code is a good idea.

Configure SpEL expression as a bean

@Bean
Expression currentUserEmailAdress(){
	return new SpelExpressionParser().parseExpression("principal?.emailAddress");
}
@thomasdarimont
thomasdarimont / JPAProposal.md
Last active Aug 29, 2015
Add support for EL expressions in JPA-QL and native queries.
View JPAProposal.md

Add support for EL expressions in JPA-QL and native queries.

This proposal suggests adding support using [EL expressions] (http://docs.oracle.com/javaee/7/tutorial/doc/jsf-el002.htm) in JPA query strings. With this one could define query string templates and dynamic parameter bindings based on EL (Expression Language).

  • Immediate evaluation (via ${...}) could be used to statically alter the query string in cases where the user wants to statically generate a fixed part of a query. This could be used to add query fragments or adjust the name of tables or columns / fields.

  • Deferred evaluation (via #{...}) could be used to dynamically compute a parameter value in cases where the user

View StringBasedMongoQuery.java
/*
* Copyright 2011-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@thomasdarimont
thomasdarimont / publicStreamMethods.cypher
Created Jul 22, 2014
List all publicly available Methods in JDK 8 that return a Stream with the help of http://jqassistant.org, I wasn't aware of ZipFile.stream() and JarFile.stream() :)
View publicStreamMethods.cypher
match (t:Type)-[:DECLARES]->(m:Method)-[:RETURNS]->(rt:Type)
where rt.fqn = "java.util.stream.Stream" and t.visibility = 'public' and m.visibility = 'public'
return distinct(t.fqn+"."+m.name) as fqmn
You can’t perform that action at this time.