Java Reference
In-Depth Information
While the example in Listing 12-1 passes only the URL to open , you can also specify
an access mode (one of Connector.READ , Connector.WRITE , or Connector.READ_WRITE ), indi-
cating the access mode for the resulting connection. If you supply an access mode, you
can also indicate that your application wants to receive time-outs when using the con-
nection if they're provided by the specific protocol.
You're probably familiar with the notion of a URL, but because URLs play a key role
in the creation of connections, it's worth reviewing their semantics. Using the GCF, URLs
describe both the kind of connection as well as the location to which the connection
instance should connect. The syntax of a URL is described in RFCs 1738 and 2396; a URL
is a single string that looks like this:
scheme://user:password@host:port/path;parameters
where
• The scheme specifies the protocol used for the connection, such as HTTP.
• The user specifies an optional username required when accessing the connection.
• The password specifies an optional password required when accessing the
connection.
• The host is the fully qualified domain name or other address of the remote end
of the connection.
• The port specifies an optional port to be used on the remote end of the
connection.
• The path is a path to the remote end of the connection, whose interpretation and
format may vary depending on the scheme . The path may include one or more
parameters modifying the connection .
Under the hood, the implementation of Connector uses the scheme you specify in a
URL to determine the kind of Connection it should instantiate and return. Java ME and the
various RFCs for extending the communication capabilities of Java ME have defined sev-
eral different schemes. Table 12-1 provides a list of common schemes, the protocol, the
returned Connection subclass, and in which JSR the scheme was introduced to the Java
ME platform.
 
Search WWH ::




Custom Search