Created
July 16, 2013 13:33
-
-
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. */
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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