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:1127869
Created August 5, 2011 16:06
Decorator example 3
package com.mycompany.springapp.springcdi;
import javax.decorator.Decorator;
import javax.decorator.Delegate;
@Decorator
public class MyServiceSecurityDecorator implements MyService {
@Delegate
private MyService delegate;
@nschlimm
nschlimm / gist:1127871
Created August 5, 2011 16:07
Decorator example 4
package com.mycompany.springapp.springcdi;
import javax.decorator.Decorator;
import javax.decorator.Delegate;
@Decorator
public class MyServiceTransactionDecorator implements MyService{
@Delegate
private MyService delegate;
@nschlimm
nschlimm / gist:1127873
Created August 5, 2011 16:08
Decorator example 5
package com.mycompany.springapp.springcdi;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@ContextConfiguration("/test-decorator-context.xml")
@nschlimm
nschlimm / gist:1127882
Created August 5, 2011 16:12
User Credentials example
import org.springframework.context.annotation.Scope;
@Scope("session")
public class UserCredentials {
...
}
import org.springframework.context.annotation.Scope;
@Scope("singleton")
@nschlimm
nschlimm / gist:1127885
Created August 5, 2011 16:13
User Credentials example CDI scopes
import javax.enterprise.context.SessionScoped;
@SessionScoped
public class UserCredentials implements Serializable {
/**
* Unique ID
*/
private static final long serialVersionUID = 8825296584100263935L;
@nschlimm
nschlimm / gist:1127888
Created August 5, 2011 16:14
Scopes web.xml
<web-app>
...
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
...
</web-app>
@nschlimm
nschlimm / gist:1127892
Created August 5, 2011 16:16
Scopes application.context
<beans>
<context:component-scan base-package="com.mycompany.springapp" scoped-proxy="targetClass"/>
</beans>
@nschlimm
nschlimm / gist:1151458
Created August 17, 2011 12:44
Interceptor application context
<beans>
...
<context:component-scan base-package="com.schlimm.springcdi.interceptor.simple" scoped-proxy="targetClass">
<context:include-filter type="annotation" expression="javax.interceptor.Interceptor" />
</context:component-scan>
<bean class="com.schlimm.springcdi.interceptor.InterceptorAwareBeanFactoryPostProcessor"/>
...
</beans>
@nschlimm
nschlimm / gist:1151678
Created August 17, 2011 14:50
Ordering interceptors
<bean class="com.schlimm.springcdi.interceptor.InterceptorAwareBeanFactoryPostProcessor">
<property name="interceptorOrder">
<list>
<value>com.schlimm.springcdi.interceptor.ct._91_C1.interceptors.TransactionInterceptor</value>
<value>com.schlimm.springcdi.interceptor.ct._92_C1.interceptors.OldSecurityInterceptor</value>
<value>com.schlimm.springcdi.interceptor.ct._92_C1.interceptors.VIPSecurityInterceptor</value>
<value>com.schlimm.springcdi.interceptor.ct._92_C1.interceptors.SecurityInterceptor</value>
</list>
</property>
</bean>
@nschlimm
nschlimm / gist:1206220
Created September 9, 2011 13:34
HTMLDocumentGenerator
public class HTMLDocumentGenerator implements DocumentGenerator, Initialisierbar, Reinitialisierbar, HTMLDocumentGeneratorMBean {
private final ConcurrentHashMap<String, ConcurrentTransformer> transformerCache =
new ConcurrentHashMap<String, ConcurrentTransformer>();
private int concurrentParserThreadCount = 10;
protected Semaphore bouncer;
...
public void createDocument(OutputStream document, Map<String, ?> inputData) throws DocumentGeneratorAusnahme {