Hi!
I've made it :)
I am using the utils in the gwt-widgets (
http://gwt-widget.sourceforge.net/, mainly the gwt-sl) project, this way I can
deploy everything in a .war and maintain the default layout suggested by gwt (which allows me to use the Cypal Studio
plugin for eclipse and Spring Plugin for Eclipse without manual edition of the .settings/*.xml eclipse files).
The example eclipse project attached implements a simple service which returns the current's user EID. The final result
is a simple html page with a button wich shows an alert dialog box with the user's eid when clicked.
Basically I followed the normal GWT procedure to create a service (UserManagerService), then in the web.xml file I use:
<!-- Sakai request filter -->
<filter>
<filter-name>sakai.request</filter-name>
<filter-class>org.sakaiproject.util.RequestFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>sakai.request</filter-name>
<servlet-name>spring.rpc</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
<servlet>
<servlet-name>spring.rpc</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring.rpc</servlet-name>
<url-pattern>/UserManagerService</url-pattern>
</servlet-mapping>
<!-- Sakai listeners -->
<listener>
<listener-class>
org.sakaiproject.util.ToolListener
</listener-class>
</listener>
<listener>
<listener-class>
org.sakaiproject.util.ContextLoaderListener
</listener-class>
</listener>
Notice the spring.rpc, this servlet will be mapped to "/UserManagerService". The service is not declared here, it will
be declared in a mapping to a POJO that implements the service. This POJO is initialized in spring.rpc-servlet.xml
(spring conf.) which follows:
<bean id="UserManagerPOJO"
class="pt.ipb.sakai.usermanager.server.UserManagerPOJO">
<property name="userDirectoryService" ref="org.sakaiproject.user.api.UserDirectoryService"/>
</bean>
<bean id="RPCUserManagerPOJO"
class="org.gwtwidgets.server.spring.GWTRPCServiceExporter">
<property name="service" ref="UserManagerPOJO" />
<property name="serviceInterfaces">
<value>pt.ipb.sakai.usermanager.client.UserManagerService</value>
</property>
</bean>
<bean
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<map>
<entry key="/UserManagerService" value-ref="RPCUserManagerPOJO" />
</map>
</property>
</bean>
And that's it!
The attached .zip contains only the source code and gwt-widgets...jar files, you need to inspect the build.xml (yes I am
using ant :P) to resolve dependencies, i have put the most important properties on the top of the file. With luck you
will only need to change this:
<!-- GWT Related -->
<property name="gwt.home.dir" value="/home/ellobo/lib/gwt" />
<property name="gwt.output.dir" value="${build.dir}/gwtOutput" />
<property name="gwt.app.name" value="pt.ipb.sakai.usermanager.UserManager" />
<property name="gwt.public.dir" value="${src.dir}/pt/ipb/sakai/usermanager/public/" />
<property name="gwt.dev.jar" value="${gwt.home.dir}/gwt-dev-linux.jar" />
<!-- Tomcat -->
<property name="tomcat.admin.user" value="...."/>
<property name="tomcat.admin.password" value="..."/>
<property name="tomcat.url" value="
http://localhost:8080/manager"/>
To build and deploy the project to you tomcat server, just issue the command:
ant clean war+gwt deploy-tomcat
(or "ant clean war+gwt undeploy-tomcat deploy-tomcat" if the project is already there)
Good Luck,
Regards,
--
Luís Filipe Lobo
PS: My original project layout was:
.
|-- WebContent
| |-- META-INF
| | `-- MANIFEST.MF
| |-- WEB-INF
| | |-- applicationContext.xml
| | |-- lib
| | | `-- gwt-sl-0.1.4e.jar
| | |-- spring.rpc-servlet.xml
| | `-- web.xml
| `-- tools
| `-- sakai.usermanager.xml
|-- build.xml
|-- etc
| `-- proj.version
|-- include
| `-- gwt-widgets-0.0.8.jar
|-- include-sakai
| |-- commons-beanutils-1.7.0.jar
| |-- commons-codec-1.3.jar
| |-- commons-digester-1.6.jar
| |-- commons-logging.jar
| |-- commons-validator-1.3.1.jar
| |-- sakai-chat-impl-M2.jar
| |-- sakai-courier-util-M2.jar
| |-- sakai-db-storage-M2.jar
| |-- sakai-entity-api-M2.jar
| |-- sakai-entity-util-M2.jar
| |-- sakai-event-util-M2.jar
| |-- sakai-jsf-app-M2.jar
| |-- sakai-jsf-tool-M2.jar
| |-- sakai-jsf-widgets-M2.jar
| |-- sakai-jsf-widgets-sun-M2.jar
| |-- sakai-mergedlist-util-M2.jar
| |-- sakai-message-impl-M2.jar
| |-- sakai-presence-util-M2.jar
| |-- sakai-user-api-M2.jar
| |-- sakai-util-M2.jar
| |-- sakai-velocity-tool-M2.jar
| |-- spring-webmvc.jar
| `-- spring.jar
`-- src
`-- pt
`-- ipb
`-- sakai
`-- usermanager
|-- UserManager.gwt.xml
|-- client
| |-- UserManager.java
| |-- UserManagerService.java
| `-- UserManagerServiceAsync.java
|-- public
| `-- UserManager.html
`-- server
`-- UserManagerPOJO.java
[see attachment: "IPBUserManager.zip", size: 225970 bytes]
Attachments:
IPBUserManager.zip
https://collab.sakaiproject.org/access/content/attachment/70b83be0-e412-4461-80d1-efa409dcf719/IPBUserManager.zip----------------------
This automatic notification message was sent by Sakai Collab (
https://collab.sakaiproject.org/portal) from the DG: Development (a.k.a. sakai-dev) site.
You can modify how you receive notifications at My Workspace > Preferences.