|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.intel.bluetooth.tcpobex.Connection
public class Connection
This class is Proxy for tcpobex (OBEX over TCP) Connection implementations for IBM J9 support.
You need to configure -Dmicroedition.connection.pkgs=com.intel.bluetooth if not installing bluecove.jar to "%J9_HOME%\lib\jclMidp20\ext\
Your application should not use this class directly.
Constructor Summary | |
---|---|
Connection()
|
Method Summary | |
---|---|
Connection |
acceptAndOpen(ServerRequestHandler handler)
Waits for a transport layer connection to be established and specifies the handler to handle the requests from the client. |
Connection |
acceptAndOpen(ServerRequestHandler handler,
Authenticator auth)
Waits for a transport layer connection to be established and specifies the handler to handle the requests from the client and the Authenticator to use to respond to authentication challenge
and authentication response headers. |
void |
close()
|
HeaderSet |
connect(HeaderSet headers)
Completes an OBEX CONNECT operation. |
HeaderSet |
createHeaderSet()
Creates a javax.obex.HeaderSet object. |
HeaderSet |
delete(HeaderSet headers)
Performs an OBEX DELETE operation. |
HeaderSet |
disconnect(HeaderSet headers)
Completes an OBEX DISCONNECT operation. |
Operation |
get(HeaderSet headers)
Performs an OBEX GET operation. |
long |
getConnectionID()
Retrieves the connection ID that is being used in the present connection. |
ServiceRecord |
getServiceRecord()
|
Operation |
put(HeaderSet headers)
Performs an OBEX PUT operation. |
void |
setAuthenticator(Authenticator auth)
Sets the Authenticator to use with this connection. |
void |
setConnectionID(long id)
Sets the connection ID header to include in the request packets. |
void |
setParameters(String spec,
int access,
boolean timeout)
Passes the parameters from the Connector.open() method to this object. |
Connection |
setParameters2(String spec,
int access,
boolean timeout)
Passes the parameters from the Connector.open() method to this object. |
HeaderSet |
setPath(HeaderSet headers,
boolean backup,
boolean create)
Completes an OBEX SETPATH operation. |
void |
updateServiceRecord(boolean acceptAndOpen)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Connection()
Method Detail |
---|
public void setParameters(String spec, int access, boolean timeout) throws IOException
CreateConnection
setParameters
in interface CreateConnection
spec
- String
The address passed to Connector.open()access
- int
The type of access this Connection is
granted (READ, WRITE, READ_WRITE)timeout
- boolean
A boolean indicating wether or not the
caller to Connector.open() wants timeout
exceptions or not
IOException
- If an error occured opening and configuring
serial port.Connector
public Connection setParameters2(String spec, int access, boolean timeout) throws IOException
CreateConnection
setParameters2
in interface CreateConnection
spec
- String
The address passed to Connector.open()access
- int
The type of access this Connection is
granted (READ, WRITE, READ_WRITE)timeout
- boolean
A boolean indicating wether or not the
caller to Connector.open() wants timeout
exceptions or not
IOException
- If an error occured opening and configuring
serial port.Connector
public void close() throws IOException
close
in interface Connection
IOException
public HeaderSet connect(HeaderSet headers) throws IOException
ClientSession
headers
argument is null
, no headers will be sent in the request.
This method will never return null
.
This method must be called and a successful response code of
OBEX_HTTP_OK
must be received before put()
,
get()
, setPath()
, delete()
,
or disconnect()
may be called. Similarly, after a
successful call to disconnect()
, this method must be
called before calling put()
, get()
,
setPath()
, delete()
, or
disconnect()
.
connect
in interface ClientSession
headers
- the headers to send in the CONNECT request
IOException
- if an error occurred in the transport layer; if the client
is already in an operation; if this method had already
been called with a successful response code of
OBEX_HTTP_OK
and calls to
disconnect()
have not returned a response
code of OBEX_HTTP_OK
; if the headers
defined in headers
exceed the max packet
lengthpublic HeaderSet createHeaderSet()
ClientSession
javax.obex.HeaderSet
object. This object can be
used to define header values in a request.
createHeaderSet
in interface ClientSession
javax.obex.HeaderSet
objectHeaderSet
public HeaderSet delete(HeaderSet headers) throws IOException
ClientSession
null
.
delete
in interface ClientSession
headers
- the header to send in the DELETE request
IOException
- if an error occurred in the transport layer; if the client
is already in an operation; if an OBEX connection does not
exist because connect()
has not been called;
if disconnect()
had been called and a
response code of OBEX_HTTP_OK
was received;
if the headers defined in headers
exceed the
max packet lengthpublic HeaderSet disconnect(HeaderSet headers) throws IOException
ClientSession
headers
argument is null
, no headers will be sent in the request.
This method will end the session. A new session may be started by calling
connect()
. This method will never return
null
.
disconnect
in interface ClientSession
headers
- the header to send in the DISCONNECT request
IOException
- if an error occurred in the transport layer; if the client
is already in an operation; if an OBEX connection does not
exist because connect()
has not been
called; if disconnect()
has been called and
received a response code of OBEX_HTTP_OK
after the last call to connect()
; if the
headers defined in headers
exceed the max
packet lengthpublic Operation get(HeaderSet headers) throws IOException
ClientSession
Operation
object to
continue with the operation. The headers argument may be null. This method will never return
null
.
get
in interface ClientSession
headers
- the OBEX headers to send as part of the initial GET request
IOException
- if an error occurred in the transport layer; if an OBEX
connection does not exist because connect()
has not been called; if disconnect()
had
been called and a response code of
OBEX_HTTP_OK
was received; if
connect()
has not been called; if the
client is already in an operation;Operation
public long getConnectionID()
ClientSession
getConnectionID
in interface ClientSession
public Operation put(HeaderSet headers) throws IOException
ClientSession
Operation
object to
continue with the PUT operation. The headers argument may be null. This method will never return
null
.
put
in interface ClientSession
headers
- the OBEX headers to send in the initial PUT request
IOException
- if an error occurred in the transport layer; if an OBEX
connection does not exist because connect()
has not been called; if disconnect()
had
been called and a response code of
OBEX_HTTP_OK
was received; if
connect()
has not been called; if the
client is already in an operation;Operation
public void setAuthenticator(Authenticator auth)
ClientSession
Authenticator
to use with this connection. The
Authenticator
allows an application to respond to
authentication challenge and authentication response headers. If no
Authenticator
is set, the response to an authentication
challenge or authentication response header is implementation dependent.
setAuthenticator
in interface ClientSession
auth
- the Authenticator
to use for this connectionpublic void setConnectionID(long id)
ClientSession
setConnectionID
in interface ClientSession
id
- the connection ID to usepublic HeaderSet setPath(HeaderSet headers, boolean backup, boolean create) throws IOException
ClientSession
null
.
setPath
in interface ClientSession
headers
- the headers to include in the SETPATH requestbackup
- if true
, instructs the server to back up one
directory before moving to the directory specified in name
(similar to cd .. on PCs); if false
, apply
name
to the current directorycreate
- if true
, instructs the server to create the
directory if it does not exist; if false
,
instruct the server to return an error code if the directory
does not exist
IOException
- if an error occurred in the transport layer; if the client
is already in an operation; if an OBEX connection does not
exist because connect()
has not been called;
if disconnect()
had been called and a
response code of OBEX_HTTP_OK
was received;
if the headers defined in headers
exceed the
max packet lengthpublic Connection acceptAndOpen(ServerRequestHandler handler) throws IOException
SessionNotifier
SessionNotifier
object that
does not have a ServiceRecord
in the SDDB, the
ServiceRecord
for this object will be added to the SDDB.
This method requests the BCC to put the local device in connectable mode
so that it will respond to connection attempts by clients.
The following checks are done to verify that the service record provided
is valid. If any of these checks fail, then a
ServiceRegistrationException
is thrown.
btgoep
service record, must be present in
the ServiceRecord
associated with this notifier.
ServiceRecord
associated with this notifier must not
have changed the RFCOMM server channel number
This method will not ensure that ServiceRecord
associated
with this notifier is a completely valid service record. It is the
responsibility of the application to ensure that the service record
follows all of the applicable syntactic and semantic rules for service
record correctness.
Note : once an application invokes close()
on any SessionNotifier
, L2CAPConnectionNotifier
, or StreamConnectionNotifer
instance, all pending acceptAndOpen()
methods that have been invoked previously on that instance MUST throw
InterruptedIOException
. This mechanism provides an application
with the means to cancel any outstanding acceptAndOpen()
method
calls.
acceptAndOpen
in interface SessionNotifier
handler
- the request handler that will respond to OBEX requests
IOException
- if an error occurs in the transport layerpublic Connection acceptAndOpen(ServerRequestHandler handler, Authenticator auth) throws IOException
SessionNotifier
Authenticator
to use to respond to authentication challenge
and authentication response headers.
SessionNotifier
object that
does not have a ServiceRecord
in the SDDB, the
ServiceRecord
for this object will be added to the SDDB.
This method requests the BCC to put the local device in connectable mode
so that it will respond to connection attempts by clients.
The following checks are done to verify that the service record provided
is valid. If any of these checks fail, then a
ServiceRegistrationException
is thrown.
btgoep
service record, must be present in
the ServiceRecord
associated with this notifier.
ServiceRecord
associated with this notifier must not
have changed the RFCOMM server channel number
This method will not ensure that ServiceRecord
associated
with this notifier is a completely valid service record. It is the
responsibility of the application to ensure that the service record
follows all of the applicable syntactic and semantic rules for service
record correctness.
Note : once an application invokes close()
on any SessionNotifier
, L2CAPConnectionNotifier
, or StreamConnectionNotifer
instance, all pending acceptAndOpen()
methods that have been invoked previously on that instance MUST throw
InterruptedIOException
. This mechanism provides an application
with the means to cancel any outstanding acceptAndOpen()
method
calls.
acceptAndOpen
in interface SessionNotifier
handler
- the request handler that will respond to OBEX requestsauth
- the Authenticator
to use with this connection; if
null
then no Authenticator
will be
used
IOException
- if an error occurs in the transport layerpublic ServiceRecord getServiceRecord()
getServiceRecord
in interface BluetoothConnectionNotifierServiceRecordAccess
public void updateServiceRecord(boolean acceptAndOpen) throws ServiceRegistrationException
updateServiceRecord
in interface BluetoothConnectionNotifierServiceRecordAccess
acceptAndOpen
- wrap validation in ServiceRegistrationException
ServiceRegistrationException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |