Sun Microsystems V2.0 manual Advanced topics, Using library suites

Page 46

Expand each of the first four of these, then select and edit the “Source attachment”. Point this to the relevant source jar as follows:

transducerlib_rt.jar

SDK_INSTALL_DIRECTORY/src/transducerlib_source.jar

multihoplib_rt.jar

SDK_INSTALL_DIRECTORY/src/multihoplib_source.jar

spotlib_common.jar

SDK_INSTALL_DIRECTORY/src/spotlib_source.jar

spotlib_host.jar

SDK_INSTALL_DIRECTORY/src/spotlib_source.jar

You may need to create a new Eclipse classpath variable to do this. After this, you should see source for the Sun SPOT library code as you debug.

Advanced topics

Using library suites

Introduction

The earlier section Deploying and running a sample application shows the process of building user application code into a suite file, deploying that suite file to a Sun SPOT, and executing the application. In fact, each Sun SPOT actually contains three linked suite files:

a bootstrap suite: which contains the base J2ME and CLDC libraries, and other system-level Java classes

a library suite: which contains Sun SPOT-specific library code supplied in this release

an application suite: which contains application code.

For simple application development, the existence of the bootstrap and library suites can be ignored. However, if you develop a substantial body of code that, over time, becomes stable and slow- changing, you can add this code to the library suite. This makes application suites smaller, and hence quicker to build and quicker to deploy. The disadvantage of this is that when the code within the library suite does change, two suites must be re-built and re-deployed, which takes longer.

Alternatively, you may wish to modify the supplied code in the library suite, to experiment with alternatives to system components. In this instance, you might even move code from the library suite to the application suite.

The library suite is constructed from a number of .jar files. The process for building a library suite is as follows:

1.Build any new .jar files containing extensions to the library.

2.Rebuild any of the existing .jar files which you wish to modify

3.Combine the various .jar files into a library suite

4.Deploy the new library suite to your Sun SPOTs

5.Build and deploy applications that use the library suite as usual.

The next section works through an example of adding user code into the library suite.

Adding user code to the library suite

Locate the folder LibraryExtensionSampleCode in the CodeSamples directory. This contains a tiny library extension consisting of a single class adder.Adder, that has a single static method add(int x, int y) that adds two numbers together. In this example, we will rebuild the library suite to include this extension, install it to a Sun SPOT, and then deploy an application that uses our extension without including the Adder class within the application.

46

Image 46
Contents Page Page Contents Http protocol support Introduction Building and deploying Sun Spot applications Deploying and running a sample applicationBuild Successful Total time 3 seconds \MyApplication Ant -Dport=COM2 info Total time 4 seconds \MyApplication Total time 0 seconds \MyApplication Deploying a pre-existing jar Incorporating utility classes into your applicationExcluding files from the compilation Manifest and resourcesOther user properties Built-in properties Using the BasestationOverview Set up Remote operation Base Station configurationIntroduction Connect a Sun Spot base station Take suitable actions during over-the-air downloads Using short names for SPOTsManaging keys and sharing Sun SPOTs BackgroundChanging the owner of a Sun Spot Sharing Sun SPOTsGenerating a new key-pair What is protected?Deploying and running a host application LimitationsIncorporating pre-existing jars into your host application Configuring network featuresYour own host application Mesh routingTrace route Hardware configurations and USB powerLogging Page Threads Overview of an applicationThread priorities Sun Spot device library Sun Spot device librariesDevice Interface Persistent properties Accessing flash memory Overriding the Ieee addressUsart Radio communication library Program Radiogram protocol Client end Server endYou can open server radiogram connections in a similar way Broadcasting Radio properties Turning the receiver off and on Monitoring radio activity Conserving power using deep sleep modeShallow Sleep Activating deep sleep mode Deep SleepDeep sleep behaviour of the standard drivers USB inhibits deep sleepPreconditions for deep sleeping Device Condition to permit deep sleepWriting a device driver Configuring the http protocol Http protocol supportConfiguring projects in an IDE Socket Proxy GUI mode Javadoc/source configuration Classpath configuration Debugging Ant selectapplication Configuring NetBeans as a debug client Configuring Eclipse as a debug clientUsing library suites Advanced topicsWith adderlib as your current directory, execute the command Use the command Using the spot client SpotSerialPortException other exception in serial port comms Persistent system properties ReferenceProperty name Meaning Memory usage Contents of the arm directoryContents of the lib directory Start address Space UseContents of the bin directory preverify.exe Contents of the upgrade directory Contents of the tests directory