Bug 287090 - [context] Are context @Out methods making user's code simpler?
diff --git a/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/internal/context/ContextToObjectLink.java b/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/internal/context/ContextToObjectLink.java
index 46959ad..49be3c2 100644
--- a/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/internal/context/ContextToObjectLink.java
+++ b/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/internal/context/ContextToObjectLink.java
@@ -10,8 +10,6 @@
  *******************************************************************************/
 package org.eclipse.e4.core.services.internal.context;
 
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
 import java.lang.ref.WeakReference;
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
@@ -37,7 +35,6 @@
 	private static final Object[] EMPTY_ARR = new Object[0];
 
 	static class ProcessMethodsResult {
-		List outMethods = new ArrayList();
 		List postConstructMethods = new ArrayList();
 		Set seenMethods = new HashSet();
 
@@ -57,7 +54,6 @@
 	abstract private class Processor {
 
 		protected boolean isSetter;
-		protected boolean shouldProcessOutMethods = false;
 		protected boolean shouldProcessPostConstruct = false;
 		protected Object userObject;
 
@@ -73,10 +69,6 @@
 			// do nothing by default
 		}
 
-		void processOutMethod(Method m, String name) {
-			// do nothing by default
-		}
-
 		void processPostConstructMethod(Method m) {
 			// do nothing by default
 		}
@@ -86,27 +78,11 @@
 		}
 	}
 
-	private static class PropertyChangeListenerImplementation implements PropertyChangeListener {
-		private final String name;
-		private final IEclipseContext outputContext;
-
-		PropertyChangeListenerImplementation(String name, IEclipseContext outputContext) {
-			this.name = name;
-			this.outputContext = outputContext;
-		}
-
-		public void propertyChange(PropertyChangeEvent evt) {
-			outputContext.set(name, evt.getNewValue());
-		}
-	}
-
 	private static final String IN = ".In";//$NON-NLS-1$
 	private static final String INJECT = ".Inject";//$NON-NLS-1$
 	final static private String JAVA_OBJECT = "java.lang.Object"; //$NON-NLS-1$
 	private static final String NAMED = ".Named";//$NON-NLS-1$
 
-	private static final String OUT = ".Out";//$NON-NLS-1$
-
 	private static final String POST_CONSTRUCT = ".PostConstruct";//$NON-NLS-1$
 
 	private static final String PRE_DESTROY = ".PreDestroy";//$NON-NLS-1$
@@ -435,42 +411,6 @@
 				}
 			}
 
-			public void processOutMethod(Method m, final String name) {
-				final EclipseContext outputContext = (EclipseContext) event.getContext().get(
-						IContextConstants.OUTPUTS);
-				if (outputContext == null) {
-					throw new IllegalStateException("No output context available for @Out " + m //$NON-NLS-1$
-							+ " in " + userObject); //$NON-NLS-1$
-				}
-				final Object value;
-				try {
-					if (!m.isAccessible()) {
-						m.setAccessible(true);
-						try {
-							value = m.invoke(userObject, EMPTY_ARR);
-						} finally {
-							m.setAccessible(false);
-						}
-					} else {
-						value = m.invoke(userObject, EMPTY_ARR);
-					}
-					// this has to be done asynchronously, see bug 281659
-					outputContext.schedule(new Runnable() {
-						public void run() {
-							outputContext.set(name, value);
-						}
-					});
-
-					Method addListener = userObject.getClass().getMethod(
-							"addPropertyChangeListener", //$NON-NLS-1$
-							new Class[] { String.class, PropertyChangeListener.class });
-					callMethod(userObject, addListener, new Object[] { name,
-							new PropertyChangeListenerImplementation(name, outputContext) });
-				} catch (Exception ex) {
-					throw new RuntimeException(ex);
-				}
-			}
-
 			void processPostConstructMethod(Method m) {
 				Object[] methodArgs = null;
 				if (m.getParameterTypes().length == 1)
@@ -491,7 +431,6 @@
 				}
 			}
 		};
-		processor.shouldProcessOutMethods = true;
 		processor.shouldProcessPostConstruct = true;
 		processClassHierarchy(event.getArguments()[0], processor);
 
@@ -648,25 +587,6 @@
 				processor.processPostConstructMethod(m);
 			}
 		}
-		if (!processor.shouldProcessOutMethods)
-			return;
-		for (Iterator it = processMethodsResult.outMethods.iterator(); it.hasNext();) {
-			Method m = (Method) it.next();
-			String name = m.getName();
-			if (name.startsWith("get") && name.length() > 3) { //$NON-NLS-1$
-				name = name.substring(3);
-				char firstChar = name.charAt(0);
-				if (Character.isUpperCase(firstChar)) {
-					firstChar = Character.toLowerCase(firstChar);
-					if (name.length() == 1) {
-						name = Character.toString(firstChar);
-					} else {
-						name = Character.toString(firstChar) + name.substring(1);
-					}
-				}
-			}
-			processor.processOutMethod(m, name);
-		}
 	}
 
 	/**
@@ -849,10 +769,6 @@
 								&& annotationName.endsWith(POST_CONSTRUCT)) {
 							inject = false;
 							result.postConstructMethods.add(method);
-						} else if (processor.shouldProcessOutMethods
-								&& annotationName.endsWith(OUT)) {
-							inject = false;
-							result.outMethods.add(method);
 						}
 					} catch (Exception ex) {
 						logWarning(method, ex);
diff --git a/tests/org.eclipse.e4.core.tests.services/src/org/eclipse/e4/core/services/internal/context/ContextInjectionTest.java b/tests/org.eclipse.e4.core.tests.services/src/org/eclipse/e4/core/services/internal/context/ContextInjectionTest.java
index 537c985..c00828f 100644
--- a/tests/org.eclipse.e4.core.tests.services/src/org/eclipse/e4/core/services/internal/context/ContextInjectionTest.java
+++ b/tests/org.eclipse.e4.core.tests.services/src/org/eclipse/e4/core/services/internal/context/ContextInjectionTest.java
@@ -10,14 +10,12 @@
  *******************************************************************************/
 package org.eclipse.e4.core.services.internal.context;
 
-import java.beans.PropertyChangeListener;
 import junit.framework.AssertionFailedError;
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 import org.eclipse.e4.core.services.IDisposable;
 import org.eclipse.e4.core.services.annotations.In;
-import org.eclipse.e4.core.services.annotations.Out;
 import org.eclipse.e4.core.services.annotations.PostConstruct;
 import org.eclipse.e4.core.services.context.EclipseContextFactory;
 import org.eclipse.e4.core.services.context.IEclipseContext;
@@ -197,40 +195,6 @@
 		assertEquals(1, userObject.overriddenPreDestroyCount);
 	}
 
-	public void testOutMethod() {
-		class Injected extends ObjectSuperClass {
-			private String input;
-
-			@SuppressWarnings("unused")
-			@In
-			private void setInput(String input) {
-				this.input = input;
-
-			}
-
-			@SuppressWarnings("unused")
-			@Out
-			private String getOutput() {
-				return input;
-			}
-
-			public void addPropertyChangeListener(String propertyName,
-					PropertyChangeListener listener) {
-			}
-		}
-		IEclipseContext parent = EclipseContextFactory.create();
-		IEclipseContext context = EclipseContextFactory.create(parent, null);
-		IEclipseContext outputContent = EclipseContextFactory.create();
-		context.set("outputs", outputContent);
-		parent.set("OverriddenMethod", new Object());
-		parent.set("StringViaMethod", "oldValue");
-		context.set("input", "Hello");
-		Injected object = new Injected();
-		ContextInjectionFactory.inject(object, context);
-		assertEquals("Hello", outputContent.get("output"));
-		parent.set("StringViaMethod", "value");
-	}
-
 	/**
 	 * Tests basic context injection
 	 */