Where does the @TunnelToServer annotation belong to? [message #1728508] |
Tue, 05 April 2016 02:19  |
Eclipse User |
|
|
|
The question could be summarized like this:
Quote:Should the @TunnelToServer be added:
* to the interface: com.company.example.helloworld.shared.helloworld.IHelloWorldService
* to the implementation in the server: com.company.example.helloworld.server.helloworld.HelloWorldService
When the classes are created by the Scout SDK (new Form for example), the interface is annotated with the interface.
----
When you create an application having the client and the server deployed in the same application. See (org.eclipse.scout.contacts.all.app.dev for an example), the ServerSession is only created when the server class is annotated with @TunnelToServer. I had the problem that the HelloWorldServer was throwing a NullPointerException on this line:
ServerSession.get().getUserId()
because "ServerSession.get()" was null.
As far I could debug it, this is because of the implementation of BridgeToServerBeanDecorationFactory#decorate(..) that checks if bean.getBeanAnnotation(TunnelToServer.class) is not null.
I have tried to create here an "helloworld.all.app.dev" and the only solution was to move the annotation from the interface to the class.
Code is on GitHub: https://github.com/jmini/scout-helloworld
----
By the way, I think I will add it later to the architecture document, but if you are interested to create a "<your-app>.all.app.dev", you simply need to create a new project similar to your "<your-app>.ui.html.app.dev" with those dependencies:
* org.eclipse.scout.dev.jetty (like in the "<your-app>.ui.html.app.dev")
* org.eclipse.scout.rt.serverbridge (this on is important)
* <your-app>.ui.html (like in the "<your-app>.ui.html.app.dev")
* helloworld.server (the same dendencies as the one you have in "<your-app>.server.app.dev")
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04138 seconds