Change request. Please, help!

The process porting of
vaaclipse
to vaadin 7 has started. There are some implementation features in vaadin 7 that do impossible correct execution vaaclipse runtime. Very little changes is required (just pressing Alt+Shift+M in Eclipse) to help us. I can use java agent to hack your classes in runtime or use patched version of vaadin, but such addition works is not desirable.

Vaaclipse needs ability to execute some internal code after ANY client request. The old communication way using variables call changeVariables method in handleBurst method of AbstractCommunicationManager. Vaaclipse uses own communcation manager that override this method for executing internal code after all user code complete:


public class VaadinOSGiCommunicationManager extends CommunicationManager implements VaadinExecutorService {
	protected void changeVariables(Object source, final VariableOwner owner,
            Map<String, Object> m) {
		super.changeVariables(source, owner, m);

		exec();
	}

	private synchronized void exec() {
		Runnable runnable;
		while ((runnable = runnables.poll()) != null) {
			try {
				runnable.run();
				Object key = runnable2Key.remove(runnable);
				keys.remove(key);
			} catch (Throwable e) {
				e.printStackTrace();
			}
		}
       //.......
      }
}

But currently only legacy code uses variables. PPC is used instead of variables, so vaaclipse need ability to execute own code after each client RPC. This is a pice of handleBurst method:

if (invocation instanceof ServerRpcMethodInvocation) {
                    try {
                        ServerRpcManager.applyInvocation(connector,
                                (ServerRpcMethodInvocation) invocation);
                    } catch (RpcInvocationException e) {
                        handleConnectorRelatedException(connector, e);
                    }
                } else {

                    // All code below is for legacy variable changes
                    LegacyChangeVariablesInvocation legacyInvocation = (LegacyChangeVariablesInvocation) invocation;
                    Map<String, Object> changes = legacyInvocation
                            .getVariableChanges();
                    try {
                        if (connector instanceof VariableOwner) {
                            changeVariables(source, (VariableOwner) connector,
                                    changes);
                        } else {
                            throw new IllegalStateException(
                                    "Received legacy variable change for "
                                            + connector.getClass().getName()
                                            + " ("
                                            + connector.getConnectorId()
                                            + ") which is not a VariableOwner. The client-side connector sent these legacy varaibles: "
                                            + changes.keySet());
                        }
                    } catch (Exception e) {
                        handleConnectorRelatedException(connector, e);
                    }
                }

So, we need extract the code


try {
    ServerRpcManager.applyInvocation(connector,
    (ServerRpcMethodInvocation) invocation);
} catch (RpcInvocationException e) {
    handleConnectorRelatedException(connector, e);
}

in a separate protected method applyInvocation. If that will be done, applyInvocation will be ovverided in vaaclipse communcation manager, so any runnables can be executed after user code execution.

For now the method handleBurst itselft can be overriden (also required to copy the referenced private methods or call them using reflection). But for future the best way to extract the code for procedure invocation as shown above.