|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.buildforge.services.common.api.APIConnection
public abstract class APIConnection
The APIConnection class is responsible for the encoding and decoding of API requests, thereby implementing the line protocol of the services layer. This is a brief summary of that protocol.
Constructor Summary | |
---|---|
APIConnection(IBufferedConnection conn)
Attaches the API protocol to a buffered connection. |
Method Summary | |
---|---|
void |
check()
Checks whether or not this connection has been invalidated due to a violation of the protocol. |
void |
close()
Closes this connection. |
Protocol |
getProtocol()
Returns the protocol that this connection will bind at the time of the first request, or the bound protocol type if one has already been bound. |
APIRequest |
readRequest(boolean isServer)
Runs the request decoder. |
boolean |
setProtocol(Protocol protocol)
Sets the preferred protocol for this connection, if possible. |
void |
writeEntry(java.lang.String key,
java.util.BitSet value)
Write a data entry that is a bit set to the current API request. |
void |
writeEntry(java.lang.String key,
boolean value)
Write a data entry that is a char to the current API request. |
void |
writeEntry(java.lang.String key,
char value)
Write a data entry that is a char to the current API request. |
void |
writeEntry(java.lang.String key,
java.util.Collection<?> value)
Write a data entry that is a Collector to the current API request. |
void |
writeEntry(java.lang.String key,
DBObject value)
Write a data entry that is a DataBase Object (DBO) to the current API request. |
void |
writeEntry(java.lang.String key,
double value)
Write a data entry that is a double to the current API request. |
void |
writeEntry(java.lang.String key,
java.lang.Enum<?> value)
Write a data entry that is an enumerated type to the current API request. |
void |
writeEntry(java.lang.String key,
int value)
Write a data entry that is an int to the current API request. |
void |
writeEntry(java.lang.String key,
long value)
Write a data entry that is a long to the current API request. |
void |
writeEntry(java.lang.String key,
java.util.Map<?,?> value)
Write a data entry that is a map to the current API request. |
void |
writeEntry(java.lang.String key,
java.lang.Number value)
Write a data entry that is a number object to the current API request. |
void |
writeEntry(java.lang.String key,
java.lang.Object obj)
Write a data entry of unknown type to the current API request. |
void |
writeEntry(java.lang.String key,
java.lang.Object[] value)
Write a data entry that is an array to the current API request. |
void |
writeEntry(java.lang.String key,
java.lang.String value)
Write a data entry that is a string to the current API request. |
void |
writeFooter()
Completes an active response, including flushing it to the connection. |
void |
writeHeader(int cmd,
int as)
Begins an active request or response. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public APIConnection(IBufferedConnection conn)
conn
- the buffered connection to wrap with API connection logicMethod Detail |
---|
public void check() throws java.io.IOException
java.io.IOException
- if the connection been invalidatedpublic Protocol getProtocol()
setProtocol(Protocol)
.public boolean setProtocol(Protocol protocol)
protocol
- the protocol that is desired, or null to
revert to the default protocol choice
getProtocol()
may be used to determine which protocol
is being used. Note that false is returned even if
the bound protocol happens to be the same as the requested one.public void close() throws java.io.IOException
java.io.IOException
- if an I/O error occurspublic void writeHeader(int cmd, int as) throws java.io.IOException
cmd
- the command type
java.io.IOException
- if an I/O error occurspublic void writeFooter() throws java.io.IOException, ProtocolException
java.io.IOException
- if an I/O error occurs
ProtocolException
- if no request frame has been startedpublic void writeEntry(java.lang.String key, java.lang.Object obj) throws java.io.IOException
key
- the key to use for this entry. This may only contain
ASCII characters.obj
- the value to assign to the key
java.io.IOException
- if an I/O error occurspublic void writeEntry(java.lang.String key, java.util.BitSet value) throws java.io.IOException
key
- as for writeEntry(String, Object)
value
- the value to assign to the key
java.io.IOException
- if an I/O error occurspublic void writeEntry(java.lang.String key, java.lang.String value) throws java.io.IOException
key
- as for writeEntry(String, Object)
value
- the value to assign to the key
java.io.IOException
- if an I/O error occurspublic void writeEntry(java.lang.String key, java.lang.Number value) throws java.io.IOException
key
- as for writeEntry(String, Object)
value
- the value to assign to the key
java.io.IOException
- if an I/O error occurspublic void writeEntry(java.lang.String key, java.lang.Enum<?> value) throws java.io.IOException
key
- as for writeEntry(String, Object)
value
- the value to assign to the key
java.io.IOException
- if an I/O error occurspublic void writeEntry(java.lang.String key, boolean value) throws java.io.IOException
key
- as for writeEntry(String, Object)
value
- the value to assign to the key
java.io.IOException
- if an I/O error occurspublic void writeEntry(java.lang.String key, char value) throws java.io.IOException
key
- as for writeEntry(String, Object)
value
- the value to assign to the key
java.io.IOException
- if an I/O error occurspublic void writeEntry(java.lang.String key, int value) throws java.io.IOException
key
- as for writeEntry(String, Object)
value
- the value to assign to the key
java.io.IOException
- if an I/O error occurspublic void writeEntry(java.lang.String key, long value) throws java.io.IOException
key
- as for writeEntry(String, Object)
value
- the value to assign to the key
java.io.IOException
- if an I/O error occurspublic void writeEntry(java.lang.String key, double value) throws java.io.IOException
key
- as for writeEntry(String, Object)
value
- the value to assign to the key
java.io.IOException
- if an I/O error occurspublic void writeEntry(java.lang.String key, java.lang.Object[] value) throws java.io.IOException
key
- as for writeEntry(String, Object)
value
- the value to assign to the key
java.io.IOException
- if an I/O error occurspublic void writeEntry(java.lang.String key, java.util.Collection<?> value) throws java.io.IOException
key
- as for writeEntry(String, Object)
value
- the value to assign to the key
java.io.IOException
- if an I/O error occurspublic void writeEntry(java.lang.String key, java.util.Map<?,?> value) throws java.io.IOException
key
- as for writeEntry(String, Object)
value
- the value to assign to the key
java.io.IOException
- if an I/O error occurspublic void writeEntry(java.lang.String key, DBObject value) throws java.io.IOException
key
- as for writeEntry(String, Object)
value
- the value to assign to the key
java.io.IOException
- if an I/O error occurspublic APIRequest readRequest(boolean isServer) throws java.io.IOException, ServiceException
isServer
- true if APIConstants.CTRL_AS
should be accepted, which only the server should ever do.
java.io.IOException
- if the connection is no longer usable because
an I/O error has occurred
ProtocolException
- if the connection is no longer usable
because the communication stream contains data that violate
the protocol
ServiceException
- if any other service-level failure occurs
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |