Eclipse Business 2 Mobile plugin

The Business 2 Mobile plugin from Net Caboodle makes it easy for you to develop MIDP clients for your business services, without the need to write any of your own protocol code. The plugin generates MIDP 'stubs' for your business services and connector code to plug into the Caboodle server.

User guide

Prerequisites

To use the Net Caboodle plugin, you require

Please make sure you have the required software before proceeding with the Net Caboodle installation.

You can run Eclipse with a Java 1.4 or 1.6 JRE, however, JDK 1.5 is required by the plugin and can be set in the plugins preferences

Installation

The Net Caboodle plugin for Eclipse is installed via the Eclipse "Software Updates" option as shown in figure 1 below

If you are already familiar with how to install plugins from Eclipse, then use the URL below and skip to the preferences section.

http://www.netcaboodle.com/eclipse/update

Figure 1: Installing Net Caboodle

Select the "Software Updates -> Find and Install..." menu option in Eclipse.

Now select the "Search for new features to install" option and click the "Next >" button.

On the "Update sites to visit" page, select the "New Remote Site.." button, which will popup a remote site selection dialog box, called "New update site".

Enter a label name, for example, "Net Caboodle" and the remote site URL below

When you click the OK button Eclipse will connect to the Net Caboodle site and add an item to the "Sites to include" list. Select the item that matches the "name" entered in the above dialog.

Click the "Next button" to proceed to the "Search results" page.

In the "Select the features to install" select the "Net Caboodle" item ( or the name you entered in "new update site" dialog) and then click the "Next >" button, where you will be presented with the Net Caboodle license.

To accept the license and proceed with the installation, select "I accept the terms in the license agreements".

You will now be presented with the "install location" page.

To proceed to the final step in the installation process click the "Finish" button, which shows you the dialog box below called "Feature verification"

Finally click the "Install" button to complete the installation process.

Installation via ZIP download

Your firewall may stop you from being able to install the Net Caboodle plugin via the method shown above. An alternative way to install the Net Caboodle plugin is to download the archived site and install the plugin by selecting "New Archived site" (instead of "New Remote site")

Plugin configuration

Having successfully installed the Net Caboodle plugin, you need to configure the plugin to use the Java Development Kit 1.5.

In the Eclipse preferences for "Net Caboodle" you need to make sure that you have selected a Java Development Kit (JDK) 1.5 not just the JRE.

If you skip the above configuration step the plugin will issue warning messages when you try to import a remote service or start the Net Caboodle gateway.

The Net Caboodle plugin has four configurable properties, which you can modify to suit your system/environment.

  • JDK home, which is described in the previous section
  • Gateway host (professional edition only)
    This parameter is used for the OTA provisioning of the your mobile client application.
  • Gateway port
    This is port your mobile clients will use to access your remote services.
  • Internal port
    In the free version of this software, this port is the RMI registry port used by the getting-started "Hello" service.

Enable the Net Caboodle console

Having configured the JDK in the Net Caboodle preferences page, the final step you need to take before using the plugin is to activate the "Net Caboodle console" view. To do this, first select the Eclipse "Show view -> Other" menu option as shown below.

You will now be presented with the "Show view" dialog

Select the "Caboodle console" item and then click the OK button. The Caboodle console will now appear in Eclipse, as shown below

Getting started with the Caboodle plugin

Having successfully installed and configured Net Caboodle, let's now take a look at how to get started with the "Hello" RMI service included with the Net Caboodle distribution.

When you use the Caboodle "Start gateway" menu option, the plugin will also start up the example RMI "Hello" service for you bound on the RMI registry port you entered on the plugin's preference's page. ( the default is port 6060 ).

Follow the steps below to use the Caboodle plugin to generate the code you need to access the example "Hello" RMI service from a MIDP device. Once you are familiar with the steps involved, then it will be easy for you to start writing MIPD code for you existing services.

First Download MIDlet code example and create a new Eclipse ME project that contains the example MIDlet.

Next follow the steps below to create the mobile stubs for the example.

The screenshots below show the "Hello" example using the RMI registry port 6060, however, this is to avoid conflicts with your existing RMI services. The Net Caboodle gateway uses the registry port specified on the plugin's preferences page. ( the default is port 6060 ).

Caboodle plugin menu

The Caboodle plugin has five menu options, which are available when you right-click on a project icon in Eclipse.

  • Start gateway
  • Stop gateway
  • New RMI connector
  • New Bean connector
  • New Jini connector
 
 

To test with the "Hello RMI" example and import the service into a MIDP project you must first use the "start gateway" option.

RMI Connectors

The "New RMI connector" menu option allows you to connect to a running RMI service so the Caboodle plugin can generate the MIDP stubs and connector code required for your MIDlet to use the RMI service via the Net Caboodle gateway.

When you select the "New RMI connector" option from the Caboodle menu, you will be presented with the dialog box as shown below. The "host" and "port" parameters will default to your computer's IP address and the default RMI registry port (1099).

You need to change these fields to the correct values to match the RMI URL of your running services.

For the "Hello RMI" example you need to enter the default port, which is 6060

 

Use the RMI example to learn how to use the Net Caboodle plugin.

Once you are familiar with the concepts, try out the POJO (Plain Old Java Object) example

There are three text fields you need to either modify or complete to construct an RMI lookup URL, for example, rmi://myhost:1099/MyService

  • Host
    This is the IP address or host name of the computer where the RMI service is running. By default this is set to your local host's IP address.
  • Port
    This is the port the RMI registry is running on. By default this is set to 1099
  • Lookup name
    This is the name you have registered with the RMI registry when you started the service

Connect

Having entered the three lookup parameters, click the "Connect" button.

Make sure your RMI server has a correctly configured and exported codebase - see our FAQ pages for more details if you don't know what this means.

Whilst the connection is occurring you will see the following message in the dialog box.

If network/connection problems are encountered these will be displayed in the Net Caboodle console.

Whereas when the connection succeeds, then you will see a list of the interfaces implemented by the RMI service, as shown if the figure below.

Select the interface you want to use and then click the OK button.

The Caboodle plugin will then attempt to generate the stubs required for the MIDP client, as shown in the figure below.

The Caboodle console will issue you with warnings for methods/classes that are not compatible for MIDP 1.0 conversion. See the section below on MIDP compatibility.

When conversion is complete, take a look in the Caboodle console window for the basic code required to use the converted service.

If you have Downloaded MIDlet code example and created an Eclipse ME project, the mobile stubs should now have been generated and your project ready is to run!

Generated code library

On successful completion of the above process, the Net Caboodle plugin will have configured your MIDP project with the generated codes JAR file, so you can immediately start writing and test code against the RMI service.

Trying out the Hello Example

Having the followed the above steps you need to check that the Net Caboodle gateway is running.

If you haven't already started the gateway, right click on your Eclipse project's icon and select "Caboodle -> Start gateway". The Caboodle console will display information about the server's status and the RMI registry port the "Hello example" service has been started on ( the default is port 6060 )

Earlier we mentioned that the code code required to use a converted service will be displayed in the Caboodle console. In the case of the Hello example, here's what you need to do; add the import statement, plus a field that holds the MIDP service's proxy instance.

The Hello example illustrates three types of service methods.

  • Service returning a primitive/Java type (String)
  • Service returning a user-defined type ( called ServiceInfo )
  • Service receiving the user-defined type ServiceInfo

The figure below show the basic code to test the Hello example

Code generation patterns & rules

Net Caboodle converts RMI (and other Java service types) using the following rules/patterns.

CLDC 1.0 compatible types

Due to the restrictions of the Connected Limited Device Configuration (CLDC), not all services are candidates for being accessed from a MIDP device. However, by using Net Caboodle it is possible to create Beans to act as mediators between existing services and MIDP clients.

CLDC 1.0 types supported by Net Caboodle.

  • Primitives types, excluding double and float
  • Number wrapper classes excluding Double and Float
  • java.util.Date and java.util.Calendar
  • java.util.Vector

Note that ONLY single dimension arrays are supported for the above types in this release -- Use Vectors instead of arrays for user-defined types

User-defined classes that are used as parameters or return types MUST have a public no-args constructor and provide matching field accessors in the form of "getters" and "setters".

User-defined classes embedded as fields are NOT supported this version of the software.

Class pattern matching and conversion

The selected service interface class name and package are maintained during conversion, for example, if we take the RMI Hello example interface

com.nc.example.Hello

The generated MIDP code will have the same fully qualified class name.

Any user-defined class types used by the service interface class, will also be converted into the same package. For example, if we had a class called com.nc.service.ServiceInfo, which was returned from the "Hello" service, the converted class, would be placed in the sample package as the MIDP service interface (e.g, com.nc.example).

MIDP lookup of services

For each converted service Net Caboodle will generate a lookup factory using the following naming conventions.

<service_package><service_interface>Factory 

e.g com.nc.exmple.HelloFactory

To access the MIDP service proxy there are two overloaded methods

<service_interface>Factory.getService();
<service_interface>Factory.getService(String gatewayHost,int gatewayPort);

e.g

//use default gateway
Hello service=HelloFactory.getService();

//explicitly use the gateway "janeway:8080"
Hello service=HelloFactory.getService("janeway",8080);

Jini and POJO Connectors

The Net Caboodle plugin for Eclipse allows you to select a remote service, either via lookup or by directly selecting the JAR file that contains your business service's interface. The plugin then creates a JAR file containing all the connector code and stubs, for you to link into your Eclipse MIDP project. As you add/remove methods from you business services, the plugin can be used to regenerate the JAR file.

Version 2.x of the Net Caboodle plugin for Eclipse supports the following service types.

  • RMI
  • Jini
  • User-defined beans

To work with Jini services rather than RMI-based services, download the Inca X Jini plugn for Eclipse

User-defined beans can be used to write your own bridging code, for example, you might have service implementations other than RMI or Jini, such as CORBA or JMS. By creating a Java interface/adapter for these applications or services the Caboodle server can then make them available as services for your MIDP clients.

User-defined beans can also be used to write "adapters" for existing services, which have methods and parameters that are incompatible with CLDC 1.0.

The Caboodle gateway acts as a container for user-define connector beans and loads them in memory the first time a mobile client tries to access the connector. A user-defined connector bean must have a public no-args constructor with public methods defined for the functionality you want to expose to your mobile clients.

Jini Service connectors and User-defined beans

Both Jini service and user-defined beans (POJOs) can be imported by selecting the JAR file that contains the service's interface class as shown below. Having selected a JAR file the import dialog will display a list of interface classes (or beans) contained in the JAR file.

Having selected a JAR file the Jini or Beans import dialog will display a list of interface classes contained in the JAR file.

Select the service or bean interface and then click the OK button. The Caboodle plugin will generate all the connector code, just as it does for a RMI service import.

Hello POJO example

Earlier you saw how to use the Net Caboodle plugin to connect to the example Hello RMI service. In many cases it is easier just to write a POJO (Plain Old Java Object) connector, as illustrated with the Mobile Messaging Example.

Below is a Hello POJO connector.

public class HelloPOJO{
	//required constructor
	public HelloPOJO(){}


	//say hello method
	public String sayHello(){
		return "Hello from a POJO";
	}
}

To use a POJO connector bean, simply create a JAR file containing the required class files and the use the "New Bean connector" menu option to generate the mobile stubs, just like you did for the RMI example above.

Gateway deployment

The gateway deployment options allow you to develop and build your Net Caboodle gateway instance within Eclipse and then export the gateway configuration directly to the file system. Having exported the Gateway instance, you can then run the gateway outside of Eclispe and make the Gateway accessible for live Over the Air OTA usage.

Deployment options

  • Deploy Bean to Gateway - Caboodle popup menu
    Use this option to update the gateway with any POJO/Bean services that have been updated. Please note that if you change the methods in your POJOs, then you will need to re-generate the mobile stubs, which also updates the the Gateway.
  • Deploy MIDlet to Gateway - Caboodle popup menu
    Use this option to deploy a MIDlet to the Gateway. Having been deployed your MIDlet it will be configured for OTA provisioning by the Gateway.
  • Deploy Gateway instance - Caboodle main menu
    Exports the current Gateway configuration to the file system, so you can run the Gateway independently of Eclipse.

    Before exporting (deploying) the gateway you will need to
    1. Makes ure you have tested and deployed your MIDlets to the Gateway.
    2. Configure the gateway to use your exteneral Intenet address or hostname-- this is address that you will enter on your phone to download your MIDlets (OTA). To do this, open the gateway's preferences dialog and change the Gateway Host value to either your exteneral Internet IP address or hostname.
    3. Change the default Gateway Port from 8205 to a different port which is available and either accessible through your firewall or can be accessed via your router's configuration.
    4. Save the configuration changes and STOP the gateway from Eclipse if it is running.
    5. Use the "Deploy Gateway" menu option and select the directory to deploy the gateway to.

    Having configured, exported and started the gateway, you should next test that you can access the Gateway from your mobile phone - to do this use one of the OTA provisioning URL from the gateway console. If you phone cannot connect to the gateway, check your firewall and router settings.

Developer license & Gateway license

The Net Caboodle Business 2 Mobile plugin for Eclipse is available as a free 30 trial.
When your trial expires you can purchase a developer license to reactivate the software.

Please note: A developer license permits you to write and test your services and mobile applications using the Business 2 Mobile plugin and exported gateway instances, which are restricted to a maximum of 5 concurrent connections.

A Developer License does not permit you to use the Net Caboodle gateway for any other purposes other than developing and testing. To deploy the Net Caboodle Gateway for any other purpose requires a separate Gateway license, details of which can be obtained by contacting sales.

If you have any questions or comments about using the Net Caboodle Business 2 Mobile plugin for Eclipse, then please contact us

Different packs and Plugable servers

With Net Caboodle Professional, you can install and use additional server and client-side development packs to hook in your own authentication code and to interact with the Net Caboodle Transaction Manager.

More code examples

FAQs | Location pack | Security pack | Transaction Pack | Gateway | Windows Mobile® 5.0 connector pack

Copyright notice

The information within this document remains the sole property of Net Caboodle - www.netcaboodle.com

No part of this document may be copied or reproduced in any form or by any means, and the information
contained within it is not to be communicated to a third party, without the prior written consent of
Net Caboodle. All trademarks remain the property of their respective owners. NetCaboodle, Caboodle server
and Raven are all trademarks of Net Caboodle.