samples/xml/contacts/src/main/java/sample/contact/ClientApplication.java
public void invokeContactManager(Authentication authentication, int nrOfCalls) {
		StopWatch stopWatch = new StopWatch(nrOfCalls + " ContactManager call(s)");
		Map<String, ContactManager> contactServices = this.beanFactory.getBeansOfType(
				ContactManager.class, true, true);

		SecurityContextHolder.getContext().setAuthentication(authentication);

		for (Map.Entry<String, ContactManager> entry : contactServices.entrySet()) {
			String beanName = entry.getKey();
			ContactManager remoteContactManager = entry.getValue();
			Object object = this.beanFactory.getBean("&" + beanName);

			try {
				System.out.println("Trying to find setUsername(String) method on: "
						+ object.getClass().getName());

				Method method = object.getClass().getMethod("setUsername",
						new Class[] { String.class });
				System.out.println("Found; Trying to setUsername(String) to "
						+ authentication.getPrincipal());
				method.invoke(object, authentication.getPrincipal());
			}
			catch (NoSuchMethodException ignored) {
				System.out
						.println("This client proxy factory does not have a setUsername(String) method");
			}
			catch (IllegalAccessException ignored) {
				ignored.printStackTrace();
			}
			catch (InvocationTargetException ignored) {
				ignored.printStackTrace();
			}

			try {
				System.out.println("Trying to find setPassword(String) method on: "
						+ object.getClass().getName());

				Method method = object.getClass().getMethod("setPassword",
						new Class[] { String.class });
				method.invoke(object, authentication.getCredentials());
				System.out.println("Found; Trying to setPassword(String) to "
						+ authentication.getCredentials());
			}
			catch (NoSuchMethodException ignored) {
				System.out
						.println("This client proxy factory does not have a setPassword(String) method");
			}
			catch (IllegalAccessException ignored) {
			}
			catch (InvocationTargetException ignored) {
			}

			System.out.println("Calling ContactManager '" + beanName + "'");

			stopWatch.start(beanName);

			List<Contact> contacts = null;

			for (int i = 0; i < nrOfCalls; i++) {
				contacts = remoteContactManager.getAll();
			}

			stopWatch.stop();

			if (contacts.size() != 0) {
				for (Contact contact : contacts) {
					System.out.println("Contact: " + contact);
				}
			}
			else {
				System.out.println("No contacts found which this user has permission to");
			}

			System.out.println();
			System.out.println(stopWatch.prettyPrint());
		}

		SecurityContextHolder.clearContext();
	}
public void invokeContactManager(Authentication authentication, int nrOfCalls) {
		StopWatch stopWatch = new StopWatch(nrOfCalls + " ContactManager call(s)");
		Map<String, ContactManager> contactServices = this.beanFactory.getBeansOfType(
				ContactManager.class, true, true);

		SecurityContextHolder.getContext().setAuthentication(authentication);

		for (Map.Entry<String, ContactManager> entry : contactServices.entrySet()) {
			String beanName = entry.getKey();
			ContactManager remoteContactManager = entry.getValue();
			Object object = this.beanFactory.getBean("&" + beanName);

			try {
				System.out.println("Trying to find setUsername(String) method on: "
						+ object.getClass().getName());

				Method method = object.getClass().getMethod("setUsername",
						new Class[] { String.class });
				System.out.println("Found; Trying to setUsername(String) to "
						+ authentication.getPrincipal());
				method.invoke(object, authentication.getPrincipal());
			}
			catch (NoSuchMethodException ignored) {
				System.out
						.println("This client proxy factory does not have a setUsername(String) method");
			}
			catch (IllegalAccessException ignored) {
				ignored.printStackTrace();
			}
			catch (InvocationTargetException ignored) {
				ignored.printStackTrace();
			}

			try {
				System.out.println("Trying to find setPassword(String) method on: "
						+ object.getClass().getName());

				Method method = object.getClass().getMethod("setPassword",
						new Class[] { String.class });
				method.invoke(object, authentication.getCredentials());
				System.out.println("Found; Trying to setPassword(String) to "
						+ authentication.getCredentials());
			}
			catch (NoSuchMethodException ignored) {
				System.out
						.println("This client proxy factory does not have a setPassword(String) method");
			}
			catch (IllegalAccessException ignored) {
			}
			catch (InvocationTargetException ignored) {
			}

			System.out.println("Calling ContactManager '" + beanName + "'");

			stopWatch.start(beanName);

			List<Contact> contacts = null;

			for (int i = 0; i < nrOfCalls; i++) {
				contacts = remoteContactManager.getAll();
			}

			stopWatch.stop();

			if (contacts.size() != 0) {
				for (Contact contact : contacts) {
					System.out.println("Contact: " + contact);
				}
			}
			else {
				System.out.println("No contacts found which this user has permission to");
			}

			System.out.println();
			System.out.println(stopWatch.prettyPrint());
		}

		SecurityContextHolder.clearContext();
	}
========================================================================================================