Skip to content

Instantly share code, notes, and snippets.

View cmadsen's full-sized avatar

Carsten Madsen cmadsen

  • NAVICON A/S
  • Denmark
View GitHub Profile
@cmadsen
cmadsen / TestDisruptor.java
Last active August 12, 2019 09:39
Disruptor consumer invocation issue
package camel.routing.test;
import static java.util.concurrent.TimeUnit.*;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.*;
import javax.annotation.PostConstruct;
import org.apache.camel.CamelContext;
import org.apache.camel.ConsumerTemplate;
package dk.navicon.openmap.geotools;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.Transparency;
import java.awt.geom.Point2D;
import java.awt.image.BufferedImage;
import java.io.File;
@cmadsen
cmadsen / EurekaPropertySourceLocator.java
Last active February 3, 2016 16:53
EurekaPropertySourceLocator
@Configuration
public class EurekaPropertySourceLocator implements PropertySourceLocator {
private static final Logger log = LoggerFactory
.getLogger(EurekaPropertySourceLocator.class);
@Override
public PropertySource<?> locate(Environment env) {
try {
String eurekaUrl = env.getProperty(
@cmadsen
cmadsen / gist:5037405
Last active March 22, 2021 17:08
Use CGLIB proxy to capture method calls and use that to do reflection instead of using strings for reflection. Example here uses this method to create google guava functions and predicates for std POJO method calls. Inspired by [Funcito](http://code.google.com/p/funcito/wiki/CodeGenerationAndProxies)
import java.lang.reflect.Method;
import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
public class ReflectionMethodInterceptor implements MethodInterceptor {