tomasbilek / gwteventservice

Automatically exported from code.google.com/p/gwteventservice
Other
0 stars 0 forks source link

No way to define a non-standard event service entry point #22

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Creating a servlet-mapping using a non-default url-pattern.

What is the expected output? What do you see instead?

It would be nice (and sort of critical to our project) if end-users could 
configure the service entry point either via web.xml or the inheriting GWT 
module definition file.  Instead, the configuration (defined in a private 
method, no less) forces the endpoint to be based on the module base URL:

    private static EventServiceAsync createEventService() {
        final String theServiceURL = GWT.getModuleBaseURL() + "gwteventservice";
        ServiceDefTarget theServiceEndPoint = (ServiceDefTarget)GWT.create(EventService.class);
        theServiceEndPoint.setServiceEntryPoint(theServiceURL);
        return (EventServiceAsync)theServiceEndPoint;
    }

What version of the product are you using? On what operating system?
gwteventservice 1.1.1 / GWT 2.0.3

Original issue reported on code.google.com by crehb...@gmail.com on 9 Jul 2010 at 7:19

GoogleCodeExporter commented 8 years ago
Hi,

the mapping should only be used internal of GWTEventService and shouldn't be 
called manually from another application. The module base URL should also be 
available in every GWT application. So it shouldn't be necessary to make the 
mapping visible or configurable.

Why could that be a problem in your project?

Regards

Original comment by sven.strohschein@googlemail.com on 10 Jul 2010 at 9:37

GoogleCodeExporter commented 8 years ago
The trouble we're facing is that our RPC services are exposed via a base GWT 
module that is inherited by several other modules.  So we rebase our services 
to use a neutral entry point name, one that isn't tied to the module name at 
all, so that we can use a single web.xml file for all our modules (since all 
the modules have to exist together within the same overall web application).

I understand that within the gwteventservice _coding_ framework that the 
service entry point is sort of abstracted away, but in terms of configuration 
and deployment of the web application we need some level of flexibility there.

Alternatively, if it were possible to expose your service class via a 
ServiceTargetDef implementation we could rebase it without changing your 
underlying code.

Cheers!
- C

Original comment by crehb...@gmail.com on 12 Jul 2010 at 2:19

GoogleCodeExporter commented 8 years ago
Marked as enhancement

Original comment by sven.strohschein@googlemail.com on 23 Oct 2011 at 12:18

GoogleCodeExporter commented 8 years ago
Hi,
This is a problem actually when you build apps using web fragments.
I agree that this is also related to inheritance of of other modules.
In my case have a module with web-fragment and I can't define module name 
there, because I do not know the module name that will use the specific 
web-fragment.

Original comment by szymoncu...@gmail.com on 8 May 2012 at 3:15

GoogleCodeExporter commented 8 years ago
I'm running into the same limitation, when I try to encapsulate my GWT 
application via Phonegap in an Android App. Every GWTEventService related 
functionality stops working.
Here is a more detailed explanation of the problem:
http://blog.daniel-kurka.de/2012/04/gwt-rpc-with-phonegap-revisited.html
In my case a simple exposure via a ServiceTargetDef implementation would solve 
the issue.

Thanks

Original comment by roman.ka...@gmail.com on 2 Jun 2012 at 12:28

GoogleCodeExporter commented 8 years ago
Hi,

Since there does not seem to be a lot of activity around this issue, I had a 
closer look at the GWTEventService source code and found a workaround for my 
situation. I'm creating a GWT application that uses GWTEventService as well as 
MGWT and GWT-Phonegap functionality. It can be executed within desktop & mobile 
browsers. To be able to use the Phonegap functionality I also created an 
Android App which basically only contains the compiled GWT application - so all 
HTML, CSS and Javascript files.

When I start the application within the Android app on a mobile device, I must 
be able to set the entry point of the gwteventservice Servlet. GWT-Phonegap 
provides a utility method for this, but needs access to a ServiceTargetDef.

Since GWTEventService does not provide this, I created my own implementations 
of the DefaultRemoteEventConnector and EventServiceCreator. I used the existing 
code as a basis and made the required modifications to it. I used an existing 
GWT-Phonegap utility class for that. Here is the link to the GWT-Phonegap 
utility class that I'm using:
http://code.google.com/p/gwt-phonegap/source/browse/src/main/java/com/googlecode
/gwtphonegap/client/util/PhonegapUtilImplDevice.java

Afterwards I was able to specify the gwteventservice entry point with one line 
of code then:
// Special handling for GWTEventService - must be executed before the first 
listener is created
RemoteEventServiceFactory.getInstance().getRemoteEventService(new 
GWTPhoneGapRemoteEventConnector(new 
GWTPhoneGapEventServiceCreator("http://192.168.1.102:8080/com.roksoft.posy.Main/
","gwteventservice")));

I've attached the sources of GWTPhoneGapRemoteEventConnector and 
GWTPhoneGapEventServiceCreator. Maybe they are useful in finding a generic 
solution to the issue. In the meantime it will be possible to use this great 
library within Phonegap as well.

Regards,
8-) Roman

Original comment by roman.ka...@gmail.com on 19 Jun 2012 at 5:26

Attachments:

GoogleCodeExporter commented 8 years ago
Workaround for this issue:

DefaultRemoteEventService ec = 
(DefaultRemoteEventService)RemoteEventServiceFactory.getInstance().getRemoteEven
tService();
ServiceDefTarget asyncInterface = getAsyncInterface(ec);
asyncInterface.setServiceEntryPoint("/events");

private static native ServiceDefTarget 
getAsyncInterface(DefaultRemoteEventService serv)/*-{
   var c = serv.@de.novanic.eventservice.client.event.DefaultRemoteEventService::myRemoteEventConnector;
   return c.@de.novanic.eventservice.client.event.GWTRemoteEventConnector::myEventService;
}-*/;

Original comment by vtl...@gmail.com on 10 Feb 2013 at 8:41

GoogleCodeExporter commented 8 years ago
private static native ServiceDefTarget 
getAsyncInterface(DefaultRemoteEventService serv)/*-{
   var c = serv.@de.novanic.eventservice.client.event.DefaultRemoteEventService::myRemoteEventConnector;
   return c.@de.novanic.eventservice.client.event.GWTRemoteEventConnector::myEventService;
}-*/;

with this workaround i get a error:
Line 106: Referencing field 
'de.novanic.eventservice.client.event.DefaultRemoteEventService.myRemoteEventCon
nector': unable to resolve field

any thoughts?

Original comment by re...@atremmedia.net on 30 Jul 2013 at 10:27

GoogleCodeExporter commented 8 years ago
It's solved.. 
GWT event service 1.2.1 it's:

    private static native ServiceDefTarget getAsyncInterface(DefaultRemoteEventService serv)/*-{
        var c = serv.@de.novanic.eventservice.client.event.RemoteEventServiceAccessor::myRemoteEventConnector;
        return c.@de.novanic.eventservice.client.event.GWTRemoteEventConnector::myEventService;
    }-*/;

Original comment by re...@atremmedia.net on 30 Jul 2013 at 10:40

GoogleCodeExporter commented 8 years ago
Best solutions always come last..
Use multiple url mappings for your modules

   <servlet>
        <servlet-name>EventService</servlet-name>
        <servlet-class>de.novanic.eventservice.service.EventServiceImpl</servlet-class>
        <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>EventService</servlet-name>
        <url-pattern>/Dashboard/gwteventservice/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>EventService</servlet-name>
        <url-pattern>/Logger/gwteventservice/*</url-pattern>
    </servlet-mapping>    
    <servlet-mapping>
        <servlet-name>EventService</servlet-name>
        <url-pattern>/Plugin/gwteventservice/*</url-pattern>
    </servlet-mapping>    
    <servlet-mapping>
        <servlet-name>EventService</servlet-name>
        <url-pattern>/Property/gwteventservice/*</url-pattern>
    </servlet-mapping>    
    <servlet-mapping>
        <servlet-name>EventService</servlet-name>
        <url-pattern>/Task/gwteventservice/*</url-pattern>
    </servlet-mapping>    
    <servlet-mapping>
        <servlet-name>EventService</servlet-name>
        <url-pattern>/Trigger/gwteventservice/*</url-pattern>
    </servlet-mapping>  

Original comment by re...@atremmedia.net on 31 Jul 2013 at 1:09