Tuesday, June 15, 2010

RESTful on Google App Engine in 5

 RESTful on Google App Engine in 5

Quick prototyping and publishing is very useful in developing RESTful services.  It's essential that consumers can access and experiment with a service while it's being developed.  The Google App Engine (GAE) platform is free at the entry level, and provides sufficient capabilities to deploy RESTful applications with a public URI.

Prepare the Environment
  1. Obtain a free GAE account by visiting: appengine.google.com.
  2. From the "My Applications" view on the appengine page, create a new application ID.
  3. Install the Eclipse plugin .
Creating & Deploying a RESTful App on GAE
  1. In Eclipse, create a new web application (File / New / Web Application Project), notice the Google logo next to this option.
  2. Modify the appengine-web.xml file to reflect your new application ID:

  3. Create a package for your REST classes

  4. Update web.xml with the following:

  5.     <servlet>


  6. Download JAXB 2.1 ; note that 2.2 does not run on GAE at this time; unpack the file or, if your systems is unix-based, run:

    java -jar JAXB2_20081030.jar

  7. Download the JAX-RS reference implementation (jersey), and unpack.

  8. Place the JAXB and JAX-RS jars in the Eclipse project under /war/WEB-INF/lib.  Also, add the jars to the Java build path of the project.

  9. package zpylx.restful.action;

    import javax.ws.rs.GET;
    import javax.ws.rs.Path;
    import javax.ws.rs.Produces;

    public class MapActivities {

    public String getItems() {
    return "restful web service example";

  10. Create RESTful classes, e.g.: Deploy to app engine from Eclipse, by clicking on the "Deploy App Engine Project" icon in the toolbar (installed by the GAE plugin).

  11. The application, based on the configuration above, would be accessible from this URI:  your-app-id.appspot.com/rest/activitieslist

  12. Manage application versions and view logs from the admin dashbord: appengine.google.com/dashboard?&app_id=your-app-id

example link: http://zhoupengylx.appspot.com/rest/activitieslist

Thursday, June 3, 2010

Seamless Java RDP client

(I had done this two years ago and posted on my personal website. I never thought someone still sent email to me for this, even ask for source code. I think maybe more people want to know it. Posting on blogger is absolutely much popular than on my personal website).

It is built base on properJavaRDP, which is an open source Java RDP client for Windows Terminal Services. The idea of "seamless" is come from rdesktop, which is a open source RDP client on unix platform. "seamless" can make remote running application looks like running locally. I upgrad properJavaRDP code from AWT to Swing, and add the functionality to handle "seamless" message in a special rdp vchannel.

 new update(2010.06): support window 2008 now (solve problem of “wrong modulus size! expected64+8got:264”)

new update(2010.06.17): support seamless mode applet

Seamless Java RDP client

It is a general Java RDP client for Windows Terminal Services with "seamless" feature. It is built base on properJavaRDP.

Product details

To use seamless feature, you need seamlessRDP server extension. A SeamlessRDP server extension is available to support integration of individual applications with the client desktop. Precompiled binaries are available from Cendio (If you want Connetion sharing feature, you have to get patch from http://www.fontis.com.au/rdesktop). My contribution is updated properJavaRDP code from AWT to Swing, and add the functionality to handle "seamless" message in a special rdp vchannel. jdk1.6.0-10 is needed, since shaping jframe is a new feature of jdk1.6.0-10.

To download the client jar file: javaRDP16-1.1.jar. A usage document is here:HowTo.

I also write a Adito extension: adito-application-seamlessjavardp.zip. Just for you convenience, i upload service side exe package here:seamlessrdp_server.zip.

(05/12/2009) Recently, i got chance to take a look at "rdesktop session connection-sharing" from http://www.fontis.com.au/rdesktop. It is a very interesting feature which can save TS session. I think it is good to port this feature to my seamless JavaRDPClient. It took me one day to do this. I have updated all above link with the new update. Welcome you to try this cool feature.

"Connection sharing - allows a single rdesktop connection to launch multiple applications. When run in seamless mode, rdesktop creates and listens on a control socket. A new option allows rdesktop to be run in slave mode, which notifies the master rdesktop instance of a new command to be run and then exits. The master instance sends a client-to-server message to the SeamlessRDP server component, which runs the new command".

see the difference of "seamless rdp" from normal rdp client with following screenshot:

1. nornal properJavaRdp client: ie and notepad is running on a remote server. you can see there is always a "frame" around the remote application.(My OS is english version XP, remote server is a chinese version windows 2003)

2. Seamless rdp client: ie and notepad is running on a remote server. you can are running like "local" application. (My OS is english version XP, remote server is a chinese version windows 2003)

The usage:

First, On windows as server

download seamlessrdp_server.zip and upzip it to C:\seamlessrdp

Then, on client side (windows or unix support jdk1.6u10),

Run the pure seamless client:

c:\>java -jar JavaRDP16-1.1.jar -u administrator -p 111111 -fs -s "C:\seamlessrdp\seamlessrdpshell.exe C:\Program Files\Internet Explorer\iexplore.exe"

Run as seamless client with Connection-sharing feature:

1. start the firt client :

c:\>java -jar JavaRDP16-1.1.jar -u administrator -p 111111 -fm -s "C:\seamlessrdp\seamlessrdpshell.exe C:\Program Files\Internet Explorer\iexplore.exe"

2. start more client but share the same connection with above one:

c:\>java -jar JavaRDP16-1.1.jar -fc -s "C:\Program Files\Internet Explorer\iexplore.exe"


How to run as applet:  

(take a look at exampleHtml to be aware of how to fill the params.)

First, the JavaRDP16-1.1.jar should be signed, and make sure it is in the right directory. I wrote a html(javaRdpApplet.html) and “sign.bat” in case you do not know how to sign and run the RDP jar.

Step by step:

1. create self certification and sign the jar package. In “sign.bat”, there are four commands to be executed:

keytool -genkey -dname "cn=BeanSoft Studio, ou=Java Software, o=BeanSoft Studio, c=China" -alias beansoft -keypass beansoft -storepass beansoft -validity 365 -keystore .\beansoft

keytool -list -keystore .\beansoft -storepass beansoft

keytool -export -keystore .\beansoft -storepass beansoft -file beansoft.cer -alias beansoft

jarsigner -verbose -keystore .\beansoft javaRDP16-1.1.jar beansoft

If you already have your certification file, you may just need to run the command in last line.

Before running sign.bat, the file list is as below:


2. run the sign.bat, you will get a window as below, input your password, in my case, it is “beansoft”.


3. Now, you got file list should like:


Notice that the size of javaRDP16-1.1.jar is bigger than original one. (in my testing, it is from 352KB to 374KB). It is becase it is signed. “jarsigner” add some file to META-INF.

4. Now you can try javaRdpApplet.html with IE explorer. I got message like below and it work well if you input correct IP address.


Wednesday, June 2, 2010

Flex tips


1. fileReference.load undefined - wrong SDK:

1061: Call to a possibly undefined method load through a reference with static type flash.net:FileReference


in Flex Bulider 3/4:
Project > Properties > Flex compiler
Change "HTML wrapper" --> "Require Flash Player version" from 9.x.x to 10.x.x where x is some numbers (In my case, I just change 9.0.124 to 10.0.0)