datasheets.com EBN.com EDN.com EETimes.com Embedded.com PlanetAnalog.com TechOnline.com  
Events
UBM Tech
UBM Tech

Design Article

Guide to Embedded Systems Architecture - Part 3: Transport layer (UDP) and embedded Java and networking middleware examples

Tammy Noergaard

5/3/2010 2:11 PM EDT

Embedded Java and Networking Middleware Example
Embedded Java and Networking Middleware Example
As introduced in Chapter 2, a JVM can be implemented within a system's middleware and is made up of a class loader, execution engine, and Java API libraries (see Figure 10-17).

Figure 10-17: Internal JVM components

The type of applications in a Java-based design is dependent on the Java APIs provided by the JVM. The functionality provided by these APIs differs according to the Java specification adhered to, such as inclusion of the Real Time Core Specification from the J Consortium, Personal Java (pJava), Embedded Java, Java 2 Micro Edition (J2ME) and The Real Time Specification for Java from Sun Microsystems. Of these standards, pJava 1.1.8 and J2ME's Connected Device Configuration (CDC) standards are typically the standards implemented within larger embedded devices.

PJava 1.1.8 was the predecessor of J2ME CDC, and in the long term may be replaced by CDC altogether. There is a PJava 1.2 specification from Sun, but as mentioned J2ME standards are intended to completely phase out the pJava standards in the embedded industry (by Sun). However, because there are JVMs on the market still supporting pJava 1.1.8, it will be used as a middleware example in this section to demonstrate what networking middleware functionality is implemented via the JVM.

The APIs provided by pJava 1.1.8 are shown in Figure 10-18. In the case of a pJava JVM implemented in the system software layer, these libraries would be included (along with the JVM's loading and execution units) as middleware components.

java.applet
java.awt
java.awt.datatransfer
java.awt.event
java.awt.image
java.beans
java.io
java.lang
java.lang.reflect
java.math
java.net
java.rmi
java.rmi.dgc
java.rmi.registry
java.rmi.server
java.security
java.security.acl
java.security.interfaces
java.sql
java.text
java.util
java.util.zip

Figure 10-18: pJava 1.1.8 APIs [10-4]

In the pJava 1.1.8 specification, networking APIs are provided by the java.net package, shown in Figure 10-19.

    Interfaces
                      ContentHandlerFactory
                      FileNameMap
                      SocketImplFactory
                      URLStreamHandlerFactory

    Classes
                      ContentHandler
                      DatagramPacket
                      DatagramSocket
                      DatagramSocketImpl
                      HttpURLConnection
                      InetAddress
                      MulticastSocket
                      ServerSocket
                      Socket
                      SocketImpl
                      URL
                      URLConnection
                      URLEncoder
                      URLStreamHandler

    Exceptions
                      BindException
                      ConnectException
                      MalformedURLException
                      NoRouteToHostException
                      ProtocolException
                      SocketException
                      UnknownHostException
                      UnknownServiceException


Figure 10-19: java.net package [10-4]

The JVM provides an upper-transport layer API for remote interprocess communication via the client-server model (where the client requests data, etc. from the server). The APIs needed for client and servers are different, but the basis for establishing the network connection via java is the socket (one at the client end and one at the server end). As shown in Figure 10-20, Java sockets use transport layer protocols of middleware networking components, such as TCP/IP discussed in the previous middleware example.

Figure 10-20: Sockets and the JVM

Of the several different types of sockets (raw, sequenced, stream, and datagram, etc.), pJava 1.1.8 JVM provides datagram sockets, in which data messages are read in their entirety at one time, and stream sockets, where data is processed as a continuous stream of characters. JVM datagram sockets rely on the UDP transport layer protocol, while stream sockets use the TCP transport layer protocol. As shown in Figure 10-19, pJava 1.1.8 provides support for the client and server sockets, specifically one class for datagram sockets (called DatagramSocket, used for either client or server), and two classes for client stream sockets (Socket, and MulticastSocket).





Please sign in to post comment

Navigate to related information

Datasheets.com Parts Search

185 million searchable parts
(please enter a part number or hit search to begin)