Skip to content

Instantly share code, notes, and snippets.

@Dierk
Created July 16, 2013 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dierk/6008721 to your computer and use it in GitHub Desktop.
Save Dierk/6008721 to your computer and use it in GitHub Desktop.
/** An in-memory client connector without any asynchronous calls such that * technologies like GWT, Vaadin, or ULC can use it savely on the server side * without leaving the request thread. */
/*
* Copyright 2012-2013 Canoo Engineering AG.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opendolphin.core.client.comm
import groovy.transform.InheritConstructors
import groovy.util.logging.Log
import org.opendolphin.core.client.ClientDolphin
import org.opendolphin.core.comm.Command
/** An in-memory client connector without any asynchronous calls such that
* technologies like GWT, Vaadin, or ULC can use it savely on the server side
* without leaving the request thread.
*/
@Log @InheritConstructors
class SynchronousInMemoryClientConnector extends InMemoryClientConnector {
def serverConnector // must be injected since the class is only available in a "combined" context
SynchronousInMemoryClientConnector(ClientDolphin clientDolphin) {
super(clientDolphin)
}
protected void startCommandProcessing() {
/* do nothing! */
}
@Override
void send(Command command, OnFinishedHandler callback = null) {
def answer = transmit([command])
processResults(answer, [ new CommandAndHandler(command: command, handler: callback) ] )
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment