I am trying to push data from my services to the browser with gwteventservice, but I am not able to do it from a different service then from MyServiceImpl.java. Here is the situtation: I have service DifferentService.java that reads data from client. Then I have class MyServiceImpl.java, which represents server side of MyService.java (clasic gwt project structure). Finally I have class CallEvent.java which uses addEvent method to send data to a listener (gwteventservice stuff). When I instantiate a CallEvent class within MyServiceImpl.java and call proper method (addEvent) a message is succesfully delivered to a listener. When I call same code from DifferentService.java class nothing happend (no message is delivered to a listener). I think this is a classic situation, when data need to be send from some data provider to a client utilizing gwteventservice. Could you please help me finding a problem? Which solution or approach do you use in such situations? Here are my code snippets used for data delivery.
MsgEvent.java (represents message carrying data - gwteventstuff)
public class MsgEvent implements Event {
public static final Domain SERVER_MESSAGE_DOMAIN = DomainFactory.getDomain("my_domain");
public String message;
public MsgEvent(){}
public MsgEvent(String message) {
this.setMessage(message);
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
CallEvent.java (gwteventstuff)
public class CallEvent extends RemoteEventServiceServlet{
public void SendData(String data){
//create the event
Event theEvent = new MsgEvent("DagaMsg");
//add the event, so clients can receive it
addEvent(MsgEvent.SERVER_MESSAGE_DOMAIN, theEvent);
}
}
DifferentService.java
public class DifferentService{
...
//Reading string data from client
CallEvent ce = new CallEvent();
ce.SendData(stringData); //this code delivers nothing to a listener
...
}
MyServiceImpl.java (gwt stuff)
public class MyServiceImpl extends RemoteEventServiceServlet implements MyService {
public void sendMessage(String message) {
CallEvent ce = new CallEvent();
ce.SendData("Data"); //this code deliver message succesfully to a listener
}
}
web.xml (gwt and gwteventservice stuff)
<web-app>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>My.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>MyService</servlet-name>
<servlet-class>cz.pohanka.my.server.MyServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyService</servlet-name>
<url-pattern>/cz.pohanka.my.My/MyService</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>EventService</servlet-name>
<servlet-class>de.novanic.eventservice.service.EventServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>EventService</servlet-name>
<url-pattern>/cz.pohanka.my.My/gwteventservice</url-pattern>
</servlet-mapping>
</web-app>
I hope I have included everything important. I think that problem could be in web.xml. What do you think. Thank you.
Pavel