Skip to content

Instantly share code, notes, and snippets.

View nschlimm's full-sized avatar
🏠
Working from home

Niklas Schlimm nschlimm

🏠
Working from home
  • TIMOCOM GmbH
  • Cologne, Germany
View GitHub Profile
@nschlimm
nschlimm / gist:1060914
Created July 2, 2011 15:52
Ant build file to run Arquillian test
<project basedir="." default="runtests" name="testng_tests">
<property environment="env" />
<property name="M2_REPO" value="C:/Users/nschlimm/.m2/repository" />
<property name="ECLIPSE_HOME" value="../../../../eclipse-3.6" />
<property name="debuglevel" value="source,lines,vars" />
<property name="target" value="1.6" />
<property name="source" value="1.6" />
<target name="runtests">
<junit printsummary="yes" haltonfailure="yes">
<classpath>
@nschlimm
nschlimm / Complete script
Created July 2, 2011 15:55
Ant build file to run Arquillian test
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- WARNING: Eclipse auto-generated file.
Any modifications will be overwritten.
To include a user specific buildfile here, simply create one in the same
directory with the processing instruction <?eclipse.ant.import?>
as the first entry and export the buildfile again. -->
<project basedir="." default="runtests" name="testng_tests">
<property environment="env" />
<property name="M2_REPO" value="C:/Users/nschlimm/.m2/repository" />
<property name="ECLIPSE_HOME" value="../../../../eclipse-3.6" />
@nschlimm
nschlimm / gist:1060939
Created July 2, 2011 15:56
Ant build file to run Arquillian test
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- WARNING: Eclipse auto-generated file.
Any modifications will be overwritten.
To include a user specific buildfile here, simply create one in the same
directory with the processing instruction <?eclipse.ant.import?>
as the first entry and export the buildfile again. -->
<project basedir="." default="runtests" name="testng_tests">
<property environment="env" />
<property name="M2_REPO" value="C:/Users/nschlimm/.m2/repository" />
<property name="ECLIPSE_HOME" value="../../../../eclipse-3.6" />
@nschlimm
nschlimm / gist:1109076
Created July 27, 2011 10:12
Receive delegate for decorator
public String getRegisteredDelegate(ConfigurableListableBeanFactory beanFactory, DecoratorInfo decoratorInfo) {
DelegateField arbitraryDelegateField = decoratorInfo.getDelegateFields().get(0);
DependencyDescriptor delegateDependencyDescriptor = DecoratorModuleUtils.createRuleBasedDescriptor(arbitraryDelegateField.getDeclaredField(), new Class[] { IgnoreDecoratorAutowiringLogic.class });
List<String> registeredDelegates = new ArrayList<String>();
String[] candidateNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(beanFactory, arbitraryDelegateField.getDeclaredField().getType(), true, false);
for (String candidate : candidateNames) {
BeanDefinition bd = beanFactory.getBeanDefinition(candidate);
// Annotated Bean scanned in the classpath
if (bd instanceof AnnotatedBeanDefinition) {
AnnotatedBeanDefinition abd = (AnnotatedBeanDefinition) bd;
@nschlimm
nschlimm / gist:1115465
Created July 30, 2011 12:14
Spring-CDI decorator application context
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
default-autowire="byName">
<context:component-scan base-package="com.mycompany.springapp.springcdi" scoped-proxy="targetClass">
@nschlimm
nschlimm / gist:1115494
Created July 30, 2011 12:55
DecoratorBeanFactoryPostProcessor main
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
Map<String, Class> decorators = decoratorResolutionStrategy.getRegisteredDecorators(beanFactory);
List<QualifiedDecoratorChain> chains = buildQualifiedDecoratorChains(beanFactory, decorators);
registerAutowireCandidateResolver(beanFactory, chains);
registerDecoratorMetadataBean(beanFactory, chains);
if (PROCESSOR.equals(getMode())) {
((DefaultListableBeanFactory) beanFactory).registerBeanDefinition(DECORATOR_POSTPROCESSOR_NAME, BeanDefinitionBuilder.rootBeanDefinition(DecoratorAwareBeanPostProcessor.class).getBeanDefinition());
if (beanFactory.getBeanNamesForType(DecoratorAwareBeanPostProcessor.class) == null) {
@nschlimm
nschlimm / gist:1115496
Created July 30, 2011 12:57
DecoratorPostProcessor main
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (metaData.isDecoratedBean(beanName)) {
return buildDelegateProxy(bean, beanName);
} else {
return bean;
}
}
@nschlimm
nschlimm / gist:1127845
Created August 5, 2011 15:58
Decorator module dependencies
<dependency>
<groupid>org.springframework</groupid>
<artifactid>spring-context</artifactid>
<version>3.0.5.RELEASE</version>
</dependency>
<dependency>
<groupid>org.springframework</groupid>
<artifactid>org.springframework.aop</artifactid>
<version>3.0.5.RELEASE</version>
@nschlimm
nschlimm / gist:1127852
Created August 5, 2011 16:00
Decorator example 1
package com.mycompany.springapp.springcdi;
public interface MyService {
String sayHello();
}
@nschlimm
nschlimm / gist:1127856
Created August 5, 2011 16:00
Decorator example 2
package com.mycompany.springapp.springcdi;
import org.springframework.stereotype.Component;
@Component
public class MyServiceImpl implements MyService {
public String sayHello() {
return "Hello";
}