|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectch.ethz.iks.r_osgi.impl.ChannelEndpointImpl
public final class ChannelEndpointImpl
The endpoint of a network channel encapsulates most of the communication logic like sending of messages, service method invocation, timestamp synchronization, and event delivery.
Endpoints exchange symmetric leases when they are established. These leases contain the statements of supply and demand. The peer states the services it offers and the event topics it is interested in. Whenever one of these statements undergo a change, a lease update has to be sent. Leases expire with the closing of the network channel and the two endpoints.
The network transport of channels is modular and exchangeable. Services can state the supported protocols in their service uri. R-OSGi maintains a list of network channel factories and the protocols they support. Each channel uses exactly one protocol.
When the network channel breaks down, the channel endpoint tries to reconnect and to restore the connection. If this is not possible (for instance, because the other endpoint is not available any more, the endpoint is unregistered.
Field Summary | |
---|---|
protected java.util.Map |
callbacks
the callback register |
protected NetworkChannel |
networkChannel
the channel. |
protected java.util.HashMap |
proxyBundles
map of service uri -> proxy bundle. |
Method Summary | |
---|---|
void |
dispose()
dispose the channel. |
ch.ethz.iks.r_osgi.impl.TimeOffset |
getOffset()
get the temporal offset of a remote peer. |
java.util.Dictionary |
getPresentationProperties(java.lang.String serviceID)
get the attributes for the presentation of the service. |
java.util.Dictionary |
getProperties(java.lang.String serviceID)
get the attributes of a service. |
URI |
getRemoteAddress()
get the channel URI. |
java.lang.Object |
invokeMethod(java.lang.String service,
java.lang.String methodSignature,
java.lang.Object[] args)
invoke a method on the remote host. |
boolean |
isConnected()
|
int |
readStream(short streamID)
read a byte from the input stream on the peer identified by id. |
int |
readStream(short streamID,
byte[] b,
int off,
int len)
read to an array from the input stream on the peer identified by id. |
void |
receivedMessage(RemoteOSGiMessage msg)
process a recieved message. |
java.lang.String |
toString()
|
void |
trackRegistration(java.lang.String serviceID,
org.osgi.framework.ServiceRegistration reg)
track the registration of a proxy service. |
void |
untrackRegistration(java.lang.String serviceID)
untrack the registration of a proxy service. |
void |
writeStream(short streamID,
byte[] b,
int off,
int len)
write bytes from array to output stream on the peer identified by id. |
void |
writeStream(short streamID,
int b)
write a byte to the output stream on the peer identified by id. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected NetworkChannel networkChannel
protected final java.util.Map callbacks
protected final java.util.HashMap proxyBundles
Method Detail |
---|
public void receivedMessage(RemoteOSGiMessage msg)
receivedMessage
in interface ChannelEndpoint
msg
- the received message.ch.ethz.iks.r_osgi.channels.ChannelEndpoint#receivedMessage(ch.ethz.iks.r_osgi.RemoteOSGiMessage)
public java.lang.Object invokeMethod(java.lang.String service, java.lang.String methodSignature, java.lang.Object[] args) throws java.lang.Throwable
invokeMethod
in interface ChannelEndpoint
service
- the service uri.methodSignature
- the method signature.args
- the method parameter.
java.lang.Throwable
- can throw any exception that the original method can throw,
plus RemoteOSGiException.ch.ethz.iks.r_osgi.Remoting#invokeMethod(java.lang.String,
java.lang.String, java.lang.String, java.lang.Object[])
public java.util.Dictionary getProperties(java.lang.String serviceID)
getProperties
in interface ChannelEndpoint
serviceID
- the serviceID of the remote service.
public java.util.Dictionary getPresentationProperties(java.lang.String serviceID)
getPresentationProperties
in interface ChannelEndpoint
serviceID
- the serviceID of the remote service.
public void trackRegistration(java.lang.String serviceID, org.osgi.framework.ServiceRegistration reg)
trackRegistration
in interface ChannelEndpoint
serviceID
- the service ID.reg
- the service registration.public void untrackRegistration(java.lang.String serviceID)
untrackRegistration
in interface ChannelEndpoint
serviceID
- the service ID.public ch.ethz.iks.r_osgi.impl.TimeOffset getOffset() throws RemoteOSGiException
RemoteOSGiException
- in case of network errors.public void dispose()
dispose
in interface ChannelEndpoint
public boolean isConnected()
public java.lang.String toString()
toString
in class java.lang.Object
public int readStream(short streamID) throws java.io.IOException
streamID
- the ID of the stream.
java.io.IOException
- when an IOException occurs.public int readStream(short streamID, byte[] b, int off, int len) throws java.io.IOException
streamID
- the ID of the stream.b
- the array to write the result to.off
- the offset for the destination array.len
- the number of bytes to read.
java.io.IOException
- when an IOException occurs.public void writeStream(short streamID, int b) throws java.io.IOException
streamID
- the ID of the stream.b
- the value.
java.io.IOException
- when an IOException occurs.public void writeStream(short streamID, byte[] b, int off, int len) throws java.io.IOException
streamID
- the ID of the stream.b
- the source array.off
- offset into the source array.len
- number of bytes to copy.
java.io.IOException
- when an IOException occurs.public URI getRemoteAddress()
getRemoteAddress
in interface ChannelEndpoint
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |