Commits

Marcin Grzejszczak  committed 33cfaf1

Initial commit

  • Participants

Comments (0)

Files changed (139)

File AOP/.classpath

+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main"/>
+	<classpathentry kind="src" path="src/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.ajdt.core.ASPECTJRT_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

File AOP/.project

+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>TEST</name>
+	<comment>NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.ajdt.core.ajbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.ajdt.core.ajbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.m2e.core.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.ajdt.ui.ajnature</nature>
+		<nature>org.eclipse.m2e.core.maven2Nature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

File AOP/.settings/org.eclipse.core.resources.prefs

+#Sat Oct 27 14:43:01 CEST 2012
+eclipse.preferences.version=1
+encoding/<project>=UTF-8

File AOP/.settings/org.eclipse.jdt.core.prefs

+#Sat Oct 27 14:43:02 CEST 2012
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6

File AOP/.settings/org.eclipse.m2e.core.prefs

+#Sun Oct 07 20:53:44 CEST 2012
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
+<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/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>pl.grzejszczak.marcin</groupId>
+	<artifactId>aop</artifactId>
+	<version>0.0.1-SNAPSHOT</version>
+
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+		<maven.compiler.source>1.6</maven.compiler.source>
+		<maven.compiler.target>1.6</maven.compiler.target>
+
+		<spring.version>3.1.0.RELEASE</spring.version>
+		<aspectj.version>1.6.11</aspectj.version>
+
+		<!-- Plugin versions -->
+		<aspectj-maven-plugin.version>1.4</aspectj-maven-plugin.version>
+
+	</properties>
+	<repositories>
+		<repository>
+			<id>spring-release</id>
+			<url>http://maven.springframework.org/release</url>
+		</repository>
+		<repository>
+            <id>maven-us-nuxeo</id>
+            <url>https://maven-us.nuxeo.org/nexus/content/groups/public</url>
+        </repository>
+	</repositories>
+
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>4.10</version>
+		</dependency>
+		<!-- Spring -->
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-core</artifactId>
+			<version>${spring.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-beans</artifactId>
+			<version>${spring.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-context</artifactId>
+			<version>${spring.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-aspects</artifactId>
+			<version>${spring.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-aop</artifactId>
+			<version>${spring.version}</version>
+		</dependency>
+		<!-- AspectJ dependencies -->
+		<dependency>
+			<groupId>org.aspectj</groupId>
+			<artifactId>aspectjrt</artifactId>
+			<version>${aspectj.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.aspectj</groupId>
+			<artifactId>aspectjweaver</artifactId>
+			<version>1.6.11</version>
+		</dependency>
+		<dependency><!-- java bytecode processor -->
+			<groupId>javassist</groupId>
+			<artifactId>javassist</artifactId>
+			<version>3.4.GA</version>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-log4j12</artifactId>
+			<version>1.5.2</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-lang</groupId>
+			<artifactId>commons-lang</artifactId>
+			<version>2.6</version>
+		</dependency>
+	</dependencies>
+</project>

File AOP/src/main/pl/grzejszczak/marcin/aop/AopIntegrationTest.java

+package pl.grzejszczak.marcin.aop;
+
+import org.junit.Assert;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import pl.grzejszczak.marcin.aop.service.UserService;
+import pl.grzejszczak.marcin.aop.type.Role;
+import pl.grzejszczak.marcin.aop.ui.SomeComponentForAdmin;
+import pl.grzejszczak.marcin.aop.ui.SomeComponentForGuest;
+import pl.grzejszczak.marcin.aop.ui.SomeComponentForWriter;
+import pl.grzejszczak.marcin.aop.ui.UIFactory;
+import pl.grzejszczak.marcin.aop.user.UserHolder;
+
+public class AopIntegrationTest {
+	public static void main(String[] args) throws Exception {
+		ApplicationContext context = new ClassPathXmlApplicationContext("aopApplicationContext.xml");
+
+		UIFactory uiFactory = context.getBean(UIFactory.class);
+		UserService userService = context.getBean(UserService.class);
+
+		userService.setCurrentUser(new UserHolder(Role.ADMIN));
+		Assert.assertNotNull(uiFactory.createComponent(SomeComponentForAdmin.class));
+		Assert.assertNull(uiFactory.createComponent(SomeComponentForGuest.class));
+		Assert.assertNull(uiFactory.createComponent(SomeComponentForWriter.class));
+
+	}
+}

File AOP/src/main/pl/grzejszczak/marcin/aop/AopTest.java

+package pl.grzejszczak.marcin.aop;
+
+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;
+
+import pl.grzejszczak.marcin.aop.service.UserService;
+import pl.grzejszczak.marcin.aop.type.Role;
+import pl.grzejszczak.marcin.aop.ui.SomeComponentForAdmin;
+import pl.grzejszczak.marcin.aop.ui.SomeComponentForAdminAndGuest;
+import pl.grzejszczak.marcin.aop.ui.SomeComponentForGuest;
+import pl.grzejszczak.marcin.aop.ui.SomeComponentForWriter;
+import pl.grzejszczak.marcin.aop.ui.UIFactory;
+import pl.grzejszczak.marcin.aop.user.UserHolder;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = { "classpath:aopApplicationContext.xml" })
+public class AopTest {
+
+	@Autowired
+	private UIFactory uiFactory;
+
+	@Autowired
+	private UserService userService;
+
+	@Test
+	public void adminTest() throws Exception {
+		userService.setCurrentUser(new UserHolder(Role.ADMIN));
+		Assert.assertNotNull(uiFactory.createComponent(SomeComponentForAdmin.class));
+		Assert.assertNotNull(uiFactory.createComponent(SomeComponentForAdminAndGuest.class));
+		Assert.assertNull(uiFactory.createComponent(SomeComponentForGuest.class));
+		Assert.assertNull(uiFactory.createComponent(SomeComponentForWriter.class));
+	}
+}

File AOP/src/main/pl/grzejszczak/marcin/aop/annotation/SecurityAnnotation.java

+package pl.grzejszczak.marcin.aop.annotation;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+import pl.grzejszczak.marcin.aop.type.Role;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface SecurityAnnotation {
+	Role[] allowedRole();
+}

File AOP/src/main/pl/grzejszczak/marcin/aop/interceptor/SecurityInterceptor.java

+package pl.grzejszczak.marcin.aop.interceptor;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.util.Arrays;
+import java.util.List;
+
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import pl.grzejszczak.marcin.aop.annotation.SecurityAnnotation;
+import pl.grzejszczak.marcin.aop.service.UserService;
+import pl.grzejszczak.marcin.aop.type.Role;
+import pl.grzejszczak.marcin.aop.ui.UIComponent;
+
+@Aspect
+public class SecurityInterceptor {
+	private static final Logger LOGGER = LoggerFactory.getLogger(SecurityInterceptor.class);
+
+	public SecurityInterceptor() {
+		LOGGER.debug("Security Interceptor created");
+	}
+
+	@Autowired
+	private UserService userService;
+
+	@Pointcut("execution(pl.grzejszczak.marcin.aop.ui.UIComponent pl.grzejszczak.marcin.aop.ui.UIFactory.createComponent(..))")
+	private void getComponent(ProceedingJoinPoint thisJoinPoint) {
+	}
+
+	@Around("getComponent(thisJoinPoint)")
+	public UIComponent checkSecurity(ProceedingJoinPoint thisJoinPoint) throws Throwable {
+		LOGGER.info("Intercepting creation of a component");
+
+		Object[] arguments = thisJoinPoint.getArgs();
+		if (arguments.length == 0) {
+			return null;
+		}
+
+		Annotation annotation = checkTheAnnotation(arguments);
+		boolean atrAccessSecurityAnnotationPresent = (annotation != null);
+
+		if (atrAccessSecurityAnnotationPresent) {
+			boolean userHasRole = verifyRole(annotation);
+			if (!userHasRole) {
+				LOGGER.info("Current user doesn't have permission to have this component created");
+				return null;
+			}
+		}
+		LOGGER.info("Current user has required permissions for creating a component");
+		return (UIComponent) thisJoinPoint.proceed();
+	}
+
+	/**
+	 * Basing on the method's argument check if the class is annotataed with
+	 * {@link SecurityAnnotation}
+	 * 
+	 * @param arguments
+	 * @return
+	 */
+	private Annotation checkTheAnnotation(Object[] arguments) {
+		Object concreteClass = arguments[0];
+		LOGGER.info("Argument's class - [{}]", new Object[] { arguments });
+		AnnotatedElement annotatedElement = (AnnotatedElement) concreteClass;
+		Annotation annotation = annotatedElement.getAnnotation(SecurityAnnotation.class);
+		LOGGER.info("Annotation present - [{}]", new Object[] { annotation });
+		return annotation;
+	}
+
+	/**
+	 * The function verifies if the current user has sufficient privilages to
+	 * have the component built
+	 * 
+	 * @param annotation
+	 * @return
+	 */
+	private boolean verifyRole(Annotation annotation) {
+		LOGGER.info("Security annotation is present so checking if the user can use it");
+		SecurityAnnotation annotationRule = (SecurityAnnotation) annotation;
+		List<Role> requiredRolesList = Arrays.asList(annotationRule.allowedRole());
+		Role userRole = userService.getUserRole();
+		boolean userHasRole = requiredRolesList.contains(userRole);
+		return userHasRole;
+	}
+}

File AOP/src/main/pl/grzejszczak/marcin/aop/service/UserService.java

+package pl.grzejszczak.marcin.aop.service;
+
+import pl.grzejszczak.marcin.aop.type.Role;
+import pl.grzejszczak.marcin.aop.user.UserHolder;
+
+public interface UserService {
+	UserHolder getCurrentUser();
+
+	void setCurrentUser(UserHolder userHolder);
+
+	Role getUserRole();
+}

File AOP/src/main/pl/grzejszczak/marcin/aop/service/UserServiceImpl.java

+package pl.grzejszczak.marcin.aop.service;
+
+import org.springframework.stereotype.Service;
+
+import pl.grzejszczak.marcin.aop.type.Role;
+import pl.grzejszczak.marcin.aop.user.UserHolder;
+
+@Service
+public class UserServiceImpl implements UserService {
+	private UserHolder userHolder;
+
+	@Override
+	public UserHolder getCurrentUser() {
+		return userHolder;
+	}
+
+	@Override
+	public void setCurrentUser(UserHolder userHolder) {
+		this.userHolder = userHolder;
+	}
+
+	@Override
+	public Role getUserRole() {
+		if (userHolder == null) {
+			return null;
+		}
+		return userHolder.getUserRole();
+	}
+
+}

File AOP/src/main/pl/grzejszczak/marcin/aop/type/Role.java

+package pl.grzejszczak.marcin.aop.type;
+
+
+public enum Role {
+	ADMIN("ADM"), WRITER("WRT"), GUEST("GST");
+
+	private String name;
+
+	private Role(String name) {
+		this.name = name;
+	}
+
+	public static Role getRoleByName(String name) {
+
+		for (Role role : Role.values()) {
+
+			if (role.name.equals(name)) {
+				return role;
+			}
+		}
+
+		throw new IllegalArgumentException("No such role exists [" + name + "]");
+	}
+
+	public String getName() {
+		return this.name;
+	}
+
+	@Override
+	public String toString() {
+		return name;
+	}
+
+}

File AOP/src/main/pl/grzejszczak/marcin/aop/ui/SomeComponentForAdmin.java

+package pl.grzejszczak.marcin.aop.ui;
+
+import pl.grzejszczak.marcin.aop.annotation.SecurityAnnotation;
+import pl.grzejszczak.marcin.aop.type.Role;
+
+@SecurityAnnotation(allowedRole = { Role.ADMIN })
+public class SomeComponentForAdmin extends UIComponent {
+
+	public SomeComponentForAdmin() {
+		this.componentName = "SomeComponentForAdmin";
+	}
+
+	public static UIComponent getComponent() {
+		return new SomeComponentForAdmin();
+	}
+}

File AOP/src/main/pl/grzejszczak/marcin/aop/ui/SomeComponentForAdminAndGuest.java

+package pl.grzejszczak.marcin.aop.ui;
+
+import pl.grzejszczak.marcin.aop.annotation.SecurityAnnotation;
+import pl.grzejszczak.marcin.aop.type.Role;
+
+@SecurityAnnotation(allowedRole = { Role.ADMIN, Role.GUEST })
+public class SomeComponentForAdminAndGuest extends UIComponent {
+
+	public SomeComponentForAdminAndGuest() {
+		this.componentName = "SomeComponentForAdmin";
+	}
+
+	public static UIComponent getComponent() {
+		return new SomeComponentForAdminAndGuest();
+	}
+}

File AOP/src/main/pl/grzejszczak/marcin/aop/ui/SomeComponentForGuest.java

+package pl.grzejszczak.marcin.aop.ui;
+
+import pl.grzejszczak.marcin.aop.annotation.SecurityAnnotation;
+import pl.grzejszczak.marcin.aop.type.Role;
+
+@SecurityAnnotation(allowedRole = { Role.GUEST })
+public class SomeComponentForGuest extends UIComponent {
+
+	public SomeComponentForGuest() {
+		this.componentName = "SomeComponentForGuest";
+	}
+
+	public static UIComponent getComponent() {
+		return new SomeComponentForGuest();
+	}
+}

File AOP/src/main/pl/grzejszczak/marcin/aop/ui/SomeComponentForWriter.java

+package pl.grzejszczak.marcin.aop.ui;
+
+import pl.grzejszczak.marcin.aop.annotation.SecurityAnnotation;
+import pl.grzejszczak.marcin.aop.type.Role;
+
+@SecurityAnnotation(allowedRole = { Role.WRITER })
+public class SomeComponentForWriter extends UIComponent {
+
+	public SomeComponentForWriter() {
+		this.componentName = "SomeComponentForWriter";
+	}
+
+	public static UIComponent getComponent() {
+		return new SomeComponentForWriter();
+	}
+}

File AOP/src/main/pl/grzejszczak/marcin/aop/ui/UIComponent.java

+package pl.grzejszczak.marcin.aop.ui;
+
+public abstract class UIComponent {
+	protected String componentName;
+
+	protected String getComponentName() {
+		return componentName;
+	}
+
+}

File AOP/src/main/pl/grzejszczak/marcin/aop/ui/UIFactory.java

+package pl.grzejszczak.marcin.aop.ui;
+
+public interface UIFactory {
+	UIComponent createComponent(Class<? extends UIComponent> componentClass) throws Exception;
+}

File AOP/src/main/pl/grzejszczak/marcin/aop/ui/UIFactoryImpl.java

+package pl.grzejszczak.marcin.aop.ui;
+
+import org.apache.commons.lang.NullArgumentException;
+import org.springframework.stereotype.Component;
+
+@Component
+public class UIFactoryImpl implements UIFactory {
+
+	@Override
+	public UIComponent createComponent(Class<? extends UIComponent> componentClass) throws Exception {
+		if (componentClass == null) {
+			throw new NullArgumentException("Provide class for the component");
+		}
+		return (UIComponent) Class.forName(componentClass.getName()).newInstance();
+	}
+
+}

File AOP/src/main/pl/grzejszczak/marcin/aop/user/UserHolder.java

+package pl.grzejszczak.marcin.aop.user;
+
+import pl.grzejszczak.marcin.aop.type.Role;
+
+public class UserHolder {
+	private Role userRole;
+
+	public UserHolder(Role userRole) {
+		this.userRole = userRole;
+	}
+
+	public Role getUserRole() {
+		return userRole;
+	}
+
+	public void setUserRole(Role userRole) {
+		this.userRole = userRole;
+	}
+
+}

File AOP/src/resources/aopApplicationContext.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:context="http://www.springframework.org/schema/context"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns:aop="http://www.springframework.org/schema/aop"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
+        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
+        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
+        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
+
+	<aop:aspectj-autoproxy />
+	<context:annotation-config />
+	<context:component-scan base-package="pl.grzejszczak.marcin.aop">
+		<context:exclude-filter type="annotation" expression="org.aspectj.lang.annotation.Aspect"/>
+	</context:component-scan>
+	<bean class="pl.grzejszczak.marcin.aop.interceptor.SecurityInterceptor" factory-method="aspectOf"/>	
+
+</beans>

File AOP/src/resources/log4j.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+	<!-- Appenders -->
+	<appender name="console" class="org.apache.log4j.ConsoleAppender">
+		<param name="Target" value="System.out" />
+		<layout class="org.apache.log4j.PatternLayout">
+			<param name="ConversionPattern" value="%d %-5p [%t] %c:%L %m%n" />
+		</layout>
+	</appender>
+	
+	<!-- Application Loggers -->
+	<logger name="pl.grzejszczak.marcin">
+		<level value="DEBUG" />
+	</logger>
+	
+	<!-- 3rdparty Loggers -->
+	<logger name="org.springframework.core">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="org.springframework.beans">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="org.springframework.context">
+		<level value="INFO" />
+	</logger>
+
+	<logger name="org.springframework.web">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="org.springframework.security">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="com.juancavallotti.jdto">
+		<level value="WARN" />
+	</logger>
+
+
+	<!-- Root Logger -->
+	<root>
+		<priority value="INFO" />
+		<appender-ref ref="console" />
+	</root>
+	
+</log4j:configuration>

File AOP/target/classes/aopApplicationContext.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:context="http://www.springframework.org/schema/context"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns:aop="http://www.springframework.org/schema/aop"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
+        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
+        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
+        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
+
+	<aop:aspectj-autoproxy />
+	<context:annotation-config />
+	<context:component-scan base-package="pl.grzejszczak.marcin.aop">
+		<context:exclude-filter type="annotation" expression="org.aspectj.lang.annotation.Aspect"/>
+	</context:component-scan>
+	<bean class="pl.grzejszczak.marcin.aop.interceptor.SecurityInterceptor" factory-method="aspectOf"/>	
+
+</beans>

File AOP/target/classes/log4j.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+	<!-- Appenders -->
+	<appender name="console" class="org.apache.log4j.ConsoleAppender">
+		<param name="Target" value="System.out" />
+		<layout class="org.apache.log4j.PatternLayout">
+			<param name="ConversionPattern" value="%d %-5p [%t] %c:%L %m%n" />
+		</layout>
+	</appender>
+	
+	<!-- Application Loggers -->
+	<logger name="pl.grzejszczak.marcin">
+		<level value="DEBUG" />
+	</logger>
+	
+	<!-- 3rdparty Loggers -->
+	<logger name="org.springframework.core">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="org.springframework.beans">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="org.springframework.context">
+		<level value="INFO" />
+	</logger>
+
+	<logger name="org.springframework.web">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="org.springframework.security">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="com.juancavallotti.jdto">
+		<level value="WARN" />
+	</logger>
+
+
+	<!-- Root Logger -->
+	<root>
+		<priority value="INFO" />
+		<appender-ref ref="console" />
+	</root>
+	
+</log4j:configuration>

File AOP/target/classes/pl/grzejszczak/marcin/aop/AopIntegrationTest.class

Binary file added.

File AOP/target/classes/pl/grzejszczak/marcin/aop/AopTest.class

Binary file added.

File AOP/target/classes/pl/grzejszczak/marcin/aop/annotation/SecurityAnnotation.class

Binary file added.

File AOP/target/classes/pl/grzejszczak/marcin/aop/interceptor/SecurityInterceptor.class

Binary file added.

File AOP/target/classes/pl/grzejszczak/marcin/aop/service/UserService.class

Binary file added.

File AOP/target/classes/pl/grzejszczak/marcin/aop/service/UserServiceImpl.class

Binary file added.

File AOP/target/classes/pl/grzejszczak/marcin/aop/type/Role.class

Binary file added.

File AOP/target/classes/pl/grzejszczak/marcin/aop/ui/SomeComponentForAdmin.class

Binary file added.

File AOP/target/classes/pl/grzejszczak/marcin/aop/ui/SomeComponentForAdminAndGuest.class

Binary file added.

File AOP/target/classes/pl/grzejszczak/marcin/aop/ui/SomeComponentForGuest.class

Binary file added.

File AOP/target/classes/pl/grzejszczak/marcin/aop/ui/SomeComponentForWriter.class

Binary file added.

File AOP/target/classes/pl/grzejszczak/marcin/aop/ui/UIComponent.class

Binary file added.

File AOP/target/classes/pl/grzejszczak/marcin/aop/ui/UIFactory.class

Binary file added.

File AOP/target/classes/pl/grzejszczak/marcin/aop/ui/UIFactoryImpl.class

Binary file added.

File AOP/target/classes/pl/grzejszczak/marcin/aop/user/UserHolder.class

Binary file added.

File BeanPostProcessor/.classpath

+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main"/>
+	<classpathentry kind="src" path="src/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.ajdt.core.ASPECTJRT_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

File BeanPostProcessor/.project

+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>TEST</name>
+	<comment>NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.ajdt.core.ajbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.ajdt.core.ajbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.m2e.core.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.ajdt.ui.ajnature</nature>
+		<nature>org.eclipse.m2e.core.maven2Nature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

File BeanPostProcessor/.settings/org.eclipse.core.resources.prefs

+#Sat Oct 27 14:43:01 CEST 2012
+eclipse.preferences.version=1
+encoding/<project>=UTF-8

File BeanPostProcessor/.settings/org.eclipse.jdt.core.prefs

+#Sat Oct 27 14:43:02 CEST 2012
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6

File BeanPostProcessor/.settings/org.eclipse.m2e.core.prefs

+#Sun Oct 07 20:53:44 CEST 2012
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1

File BeanPostProcessor/pom.xml

+<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/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>pl.grzejszczak.marcin</groupId>
+	<artifactId>postprocessor</artifactId>
+	<version>0.0.1-SNAPSHOT</version>
+
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+		<maven.compiler.source>1.6</maven.compiler.source>
+		<maven.compiler.target>1.6</maven.compiler.target>
+
+		<spring.version>3.1.0.RELEASE</spring.version>
+
+	</properties>
+	<repositories>
+		<repository>
+			<id>spring-release</id>
+			<url>http://maven.springframework.org/release</url>
+		</repository>
+	</repositories>
+
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>4.10</version>
+		</dependency>
+		<!-- Spring -->
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-core</artifactId>
+			<version>${spring.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-beans</artifactId>
+			<version>${spring.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-context</artifactId>
+			<version>${spring.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-lang</groupId>
+			<artifactId>commons-lang</artifactId>
+			<version>2.6</version>
+		</dependency>
+		<dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>1.5.2</version>
+        </dependency>
+	</dependencies>
+</project>

File BeanPostProcessor/src/main/pl/grzejszczak/marcin/postprocessor/AbstractBeanPostProcessor.java

+package pl.grzejszczak.marcin.postprocessor;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+
+public abstract class AbstractBeanPostProcessor<T> implements BeanPostProcessor {
+
+	private Class<T> clazz;
+
+	public AbstractBeanPostProcessor(Class<T> clazz) {
+		this.clazz = clazz;
+	}
+
+	@Override
+	public Object postProcessAfterInitialization(Object bean, String name) throws BeansException {
+		checkConditions();
+
+		if (clazz.isAssignableFrom(bean.getClass())) {
+			doAfter();
+		}
+		return bean;
+	}
+
+	@Override
+	public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException {
+		checkConditions();
+
+		if (clazz.isAssignableFrom(bean.getClass())) {
+			doBefore();
+		}
+		return bean;
+	}
+
+	private void checkConditions() {
+		if (clazz == null) {
+			throw new NullPointerException("Provide the interface for the post processor");
+		}
+	}
+
+	public abstract void doBefore();
+
+	public abstract void doAfter();
+
+}

File BeanPostProcessor/src/main/pl/grzejszczak/marcin/postprocessor/SomeOtherService.java

+package pl.grzejszczak.marcin.postprocessor;
+
+public interface SomeOtherService {
+	void methodC();
+
+	void methodD();
+}

File BeanPostProcessor/src/main/pl/grzejszczak/marcin/postprocessor/SomeOtherServiceImpl.java

+package pl.grzejszczak.marcin.postprocessor;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SomeOtherServiceImpl implements SomeOtherService {
+	private static final Logger LOGGER = LoggerFactory.getLogger(SomeOtherServiceImpl.class);
+
+	public SomeOtherServiceImpl() {
+		LOGGER.debug("SomeOtherServiceImpl - I'm created!");
+	}
+
+	private void afterInit() {
+		LOGGER.debug("SomeOtherServiceImpl - After init!");
+	}
+
+	private void destroyMethod() {
+		LOGGER.debug("SomeOtherServiceImpl - Destroy Method!");
+	}
+
+	@Override
+	public void methodC() {
+		LOGGER.debug("SomeOtherServiceImpl - Method C executed");
+	}
+
+	@Override
+	public void methodD() {
+		LOGGER.debug("SomeOtherServiceImpl - Method D executed");
+	}
+
+}

File BeanPostProcessor/src/main/pl/grzejszczak/marcin/postprocessor/SomeService.java

+package pl.grzejszczak.marcin.postprocessor;
+
+public interface SomeService {
+	void methodA();
+
+	void methodB();
+}

File BeanPostProcessor/src/main/pl/grzejszczak/marcin/postprocessor/SomeServiceImpl.java

+package pl.grzejszczak.marcin.postprocessor;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SomeServiceImpl implements SomeService {
+	private static final Logger LOGGER = LoggerFactory.getLogger(SomeServiceImpl.class);
+
+	public SomeServiceImpl() {
+		LOGGER.debug("SomeServiceImpl - I'm created!");
+	}
+
+	private void afterInit() {
+		LOGGER.debug("SomeServiceImpl - After init!");
+	}
+
+	private void destroyMethod() {
+		LOGGER.debug("SomeServiceImpl - Destroy Method!");
+	}
+
+	@Override
+	public void methodA() {
+		LOGGER.debug("SomeServiceImpl - Method A executed");
+	}
+
+	@Override
+	public void methodB() {
+		LOGGER.debug("SomeServiceImpl - Method B executed");
+	}
+
+}

File BeanPostProcessor/src/main/pl/grzejszczak/marcin/postprocessor/SomeServicePostProcessor.java

+package pl.grzejszczak.marcin.postprocessor;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+@Component
+public class SomeServicePostProcessor extends AbstractBeanPostProcessor<SomeService> {
+
+	private static final Logger LOGGER = LoggerFactory.getLogger(SomeServicePostProcessor.class);
+
+	public SomeServicePostProcessor() {
+		super(SomeService.class);
+	}
+
+	@Override
+	public void doBefore() {
+		LOGGER.info("BEFORE it's init method has been executed but AFTER SomeServiceImpl has been instantiated I would like to do sth...");
+	}
+
+	@Override
+	public void doAfter() {
+		LOGGER.info("AFTER SomeServiceImpl has executed its init method I would like to do sth more...");
+	}
+}

File BeanPostProcessor/src/main/pl/grzejszczak/marcin/postprocessor/SpringMain.java

+package pl.grzejszczak.marcin.postprocessor;
+
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class SpringMain {
+
+	public static void main(String[] args) {
+		ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
+		SomeService someService = context.getBean(SomeService.class);
+		someService.methodA();
+		someService.methodB();
+		SomeOtherService someOtherService = context.getBean(SomeOtherService.class);
+		someOtherService.methodC();
+		someOtherService.methodD();
+		context.close();
+	}
+
+}

File BeanPostProcessor/src/resources/applicationContext.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
+
+	<bean class="pl.grzejszczak.marcin.postprocessor.SomeServiceImpl" init-method="afterInit" destroy-method="destroyMethod"/>
+	<bean class="pl.grzejszczak.marcin.postprocessor.SomeOtherServiceImpl" init-method="afterInit" destroy-method="destroyMethod"/>
+	<bean class="pl.grzejszczak.marcin.postprocessor.SomeServicePostProcessor"/>
+
+</beans>

File BeanPostProcessor/src/resources/log4j.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+	<!-- Appenders -->
+	<appender name="console" class="org.apache.log4j.ConsoleAppender">
+		<param name="Target" value="System.out" />
+		<layout class="org.apache.log4j.PatternLayout">
+			<param name="ConversionPattern" value="%d %-5p [%t] %c:%L %m%n" />
+		</layout>
+	</appender>
+	
+	<!-- Application Loggers -->
+	<logger name="pl.grzejszczak.marcin">
+		<level value="DEBUG" />
+	</logger>
+	
+	<!-- 3rdparty Loggers -->
+	<logger name="org.springframework.core">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="org.springframework.beans">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="org.springframework.context">
+		<level value="INFO" />
+	</logger>
+
+	<logger name="org.springframework.web">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="org.springframework.security">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="com.juancavallotti.jdto">
+		<level value="WARN" />
+	</logger>
+
+
+	<!-- Root Logger -->
+	<root>
+		<priority value="INFO" />
+		<appender-ref ref="console" />
+	</root>
+	
+</log4j:configuration>

File BeanPostProcessor/target/classes/applicationContext.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
+
+	<bean class="pl.grzejszczak.marcin.postprocessor.SomeServiceImpl" init-method="afterInit" destroy-method="destroyMethod"/>
+	<bean class="pl.grzejszczak.marcin.postprocessor.SomeOtherServiceImpl" init-method="afterInit" destroy-method="destroyMethod"/>
+	<bean class="pl.grzejszczak.marcin.postprocessor.SomeServicePostProcessor"/>
+
+</beans>

File BeanPostProcessor/target/classes/log4j.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+	<!-- Appenders -->
+	<appender name="console" class="org.apache.log4j.ConsoleAppender">
+		<param name="Target" value="System.out" />
+		<layout class="org.apache.log4j.PatternLayout">
+			<param name="ConversionPattern" value="%d %-5p [%t] %c:%L %m%n" />
+		</layout>
+	</appender>
+	
+	<!-- Application Loggers -->
+	<logger name="pl.grzejszczak.marcin">
+		<level value="DEBUG" />
+	</logger>
+	
+	<!-- 3rdparty Loggers -->
+	<logger name="org.springframework.core">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="org.springframework.beans">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="org.springframework.context">
+		<level value="INFO" />
+	</logger>
+
+	<logger name="org.springframework.web">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="org.springframework.security">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="com.juancavallotti.jdto">
+		<level value="WARN" />
+	</logger>
+
+
+	<!-- Root Logger -->
+	<root>
+		<priority value="INFO" />
+		<appender-ref ref="console" />
+	</root>
+	
+</log4j:configuration>

File BeanPostProcessor/target/classes/pl/grzejszczak/marcin/postprocessor/AbstractBeanPostProcessor.class

Binary file added.

File BeanPostProcessor/target/classes/pl/grzejszczak/marcin/postprocessor/SomeOtherService.class

Binary file added.

File BeanPostProcessor/target/classes/pl/grzejszczak/marcin/postprocessor/SomeOtherServiceImpl.class

Binary file added.

File BeanPostProcessor/target/classes/pl/grzejszczak/marcin/postprocessor/SomeService.class

Binary file added.

File BeanPostProcessor/target/classes/pl/grzejszczak/marcin/postprocessor/SomeServiceImpl.class

Binary file added.

File BeanPostProcessor/target/classes/pl/grzejszczak/marcin/postprocessor/SomeServicePostProcessor.class

Binary file added.

File BeanPostProcessor/target/classes/pl/grzejszczak/marcin/postprocessor/SpringMain.class

Binary file added.

File Mocking - Checking args/.classpath

+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/integration"/>
+	<classpathentry kind="src" path="src/main"/>
+	<classpathentry kind="src" path="src/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.ajdt.core.ASPECTJRT_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

File Mocking - Checking args/.project

+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>TEST</name>
+	<comment>NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.ajdt.core.ajbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.ajdt.core.ajbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.m2e.core.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.ajdt.ui.ajnature</nature>
+		<nature>org.eclipse.m2e.core.maven2Nature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

File Mocking - Checking args/.settings/org.eclipse.core.resources.prefs

+#Sat Oct 27 14:43:01 CEST 2012
+eclipse.preferences.version=1
+encoding/<project>=UTF-8

File Mocking - Checking args/.settings/org.eclipse.jdt.core.prefs

+#Sat Oct 27 14:43:02 CEST 2012
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6

File Mocking - Checking args/.settings/org.eclipse.m2e.core.prefs

+#Sun Oct 07 20:53:44 CEST 2012
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1

File Mocking - Checking args/pom.xml

+<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/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>pl.grzejszczak.marcin</groupId>
+	<artifactId>mockito-argumentcaptor</artifactId>
+	<version>0.0.1-SNAPSHOT</version>
+
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+		<maven.compiler.source>1.6</maven.compiler.source>
+		<maven.compiler.target>1.6</maven.compiler.target>
+	</properties>
+	
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>4.10</version>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-all</artifactId>
+			<version>1.9.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-core</artifactId>
+			<version>1.9.0</version>
+		</dependency>
+		<dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>1.5.2</version>
+        </dependency>
+	</dependencies>
+</project>

File Mocking - Checking args/src/integration/pl/grzejszczak/marcin/ServiceIntegrationTest.java

+package pl.grzejszczak.marcin;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.junit.Assert;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import pl.grzejszczak.marcin.junit.Processable;
+import pl.grzejszczak.marcin.junit.SomeTask;
+import pl.grzejszczak.marcin.junit.invocation.SomePojo;
+
+public class ServiceIntegrationTest {
+
+	private static final Logger LOGGER = LoggerFactory.getLogger(ServiceIntegrationTest.class);
+
+	private ExecutorService executorService = Executors.newCachedThreadPool();
+	private Processable timeConsumingExternalServiceMock = Mockito.mock(Processable.class);
+	private SomeTask someTask = new SomeTask();
+
+	public ServiceIntegrationTest() {
+		initializeMocks();
+	}
+
+	private void initializeMocks() {
+		// Inject the mock to the Task - in any possible way
+		someTask.setTimeConsumingExternalService(timeConsumingExternalServiceMock);
+	}
+
+	public void executeTest() {
+		executorService.execute(someTask);
+
+		final ArgumentCaptor<SomePojo> argumentCaptor = ArgumentCaptor.forClass(SomePojo.class);
+		Mockito.verify(timeConsumingExternalServiceMock).processSomeObject(argumentCaptor.capture());
+		SomePojo somePojo = argumentCaptor.getValue();
+		Assert.assertEquals("name", somePojo.getName());
+		LOGGER.debug("Names are equal");
+		Assert.assertEquals("surname", somePojo.getSurname());
+		LOGGER.debug("Surnames are equal");
+		Assert.assertTrue(1 == somePojo.getIntValue());
+		LOGGER.debug("Ints are equal");
+		Assert.assertTrue(1.0 == somePojo.getDoubleValue());
+		LOGGER.debug("Doubles are equal");
+
+	}
+
+	public static void main(String args[]) {
+		ServiceIntegrationTest integrationTest = new ServiceIntegrationTest();
+		integrationTest.executeTest();
+		System.exit(0);
+	}
+}

File Mocking - Checking args/src/main/pl/grzejszczak/marcin/junit/Processable.java

+package pl.grzejszczak.marcin.junit;
+
+import pl.grzejszczak.marcin.junit.invocation.SomePojo;
+
+public interface Processable {
+	void process();
+
+	void processSomeObject(SomePojo argument);
+}

File Mocking - Checking args/src/main/pl/grzejszczak/marcin/junit/SomeTask.java

+package pl.grzejszczak.marcin.junit;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import pl.grzejszczak.marcin.junit.invocation.SomePojo;
+
+/**
+ * Service that does some things including processing of the external service
+ * 
+ * @author marcin
+ * 
+ */
+public class SomeTask implements Runnable {
+
+	private static final Logger LOGGER = LoggerFactory.getLogger(SomeTask.class);
+
+	// Service is injected via a dependency injection system
+	private Processable timeConsumingExternalService;
+
+	private void methodThatConnectsToExternalServices() {
+		LOGGER.debug("Before processing an object");
+		timeConsumingExternalService.processSomeObject(new SomePojo("name", "surname", 1, 1.0));
+		LOGGER.debug("After processing an object");
+	}
+
+	public void run() {
+		methodThatConnectsToExternalServices();
+	}
+
+	public Processable getTimeConsumingExternalService() {
+		return timeConsumingExternalService;
+	}
+
+	public void setTimeConsumingExternalService(Processable timeConsumingExternalService) {
+		this.timeConsumingExternalService = timeConsumingExternalService;
+	}
+
+}

File Mocking - Checking args/src/main/pl/grzejszczak/marcin/junit/invocation/SomePojo.java

+package pl.grzejszczak.marcin.junit.invocation;
+
+public class SomePojo {
+	private String name;
+	private String surname;
+	private int intValue;
+	private double doubleValue;
+
+	public SomePojo(String name, String surname, int intValue, double doubleValue) {
+		super();
+		this.name = name;
+		this.surname = surname;
+		this.intValue = intValue;
+		this.doubleValue = doubleValue;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public String getSurname() {
+		return surname;
+	}
+
+	public int getIntValue() {
+		return intValue;
+	}
+
+	public double getDoubleValue() {
+		return doubleValue;
+	}
+
+	@Override
+	public String toString() {
+		return "SomePojo [name=" + name + ", surname=" + surname + ", intValue=" + intValue + ", doubleValue=" + doubleValue + "]";
+	}
+
+}

File Mocking - Checking args/src/resources/log4j.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+	<!-- Appenders -->
+	<appender name="console" class="org.apache.log4j.ConsoleAppender">
+		<param name="Target" value="System.out" />
+		<layout class="org.apache.log4j.PatternLayout">
+			<param name="ConversionPattern" value="%d %-5p [%t] %c:%L %m%n" />
+		</layout>
+	</appender>
+	
+	<!-- Application Loggers -->
+	<logger name="pl.grzejszczak.marcin">
+		<level value="DEBUG" />
+	</logger>
+	
+	<!-- 3rdparty Loggers -->
+	<logger name="org.springframework.core">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="org.springframework.beans">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="org.springframework.context">
+		<level value="INFO" />
+	</logger>
+
+	<logger name="org.springframework.web">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="org.springframework.security">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="com.juancavallotti.jdto">
+		<level value="WARN" />
+	</logger>
+
+
+	<!-- Root Logger -->
+	<root>
+		<priority value="INFO" />
+		<appender-ref ref="console" />
+	</root>
+	
+</log4j:configuration>

File Mocking - Checking args/target/classes/log4j.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+	<!-- Appenders -->
+	<appender name="console" class="org.apache.log4j.ConsoleAppender">
+		<param name="Target" value="System.out" />
+		<layout class="org.apache.log4j.PatternLayout">
+			<param name="ConversionPattern" value="%d %-5p [%t] %c:%L %m%n" />
+		</layout>
+	</appender>
+	
+	<!-- Application Loggers -->
+	<logger name="pl.grzejszczak.marcin">
+		<level value="DEBUG" />
+	</logger>
+	
+	<!-- 3rdparty Loggers -->
+	<logger name="org.springframework.core">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="org.springframework.beans">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="org.springframework.context">
+		<level value="INFO" />
+	</logger>
+
+	<logger name="org.springframework.web">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="org.springframework.security">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="com.juancavallotti.jdto">
+		<level value="WARN" />
+	</logger>
+
+
+	<!-- Root Logger -->
+	<root>
+		<priority value="INFO" />
+		<appender-ref ref="console" />
+	</root>
+	
+</log4j:configuration>