Playing with J2ME

Posted by – October 11, 2007

After some years away from mobile world I finally back with mobile development, I’ve been working on a application that solves some server management tasks like start/stop services, this application consists of two parts, a webservice written in Groovy and the J2ME client. The J2ME client can call webservice methods that will execute these management tasks, like a remote control.

I used GroovySOAP on webserver side, with GroovySOAP I could write the webserver used to publish the webservice and the webservice itself, the scripts for both modules (webserver and webservice) are described below:

ManagementServer.groovy

1
2
3
4
import groovy.net.soap.SoapServer
def server = new SoapServer("localhost", 8888)
server.setNode("ManagementService")
server.start()

ManagementService.groovy

1
2
3
4
5
6
7
8
9
10
11
12
13
public class ManagementService {
    String call(String command, String serviceName) {
    if(command == "restart") {
        "net stop ${serviceName}".execute();
        Process process = "net start ${serviceName}".execute();
        return process.text;
    }
    else if(command == "start" || command == "stop") {
        Process process = "net ${command} ${serviceName}".execute();
        return process.text;
    }
    }
}

The J2ME client code can be found by clicking here.

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>