public class ManagedServer extends Object implements org.osgi.service.cm.ManagedService, org.osgi.util.tracker.ServiceTrackerCustomizer<Resource,Resource>, ServerEndpointRegistry
ServerInterface instance that can be configured using the OSGi
Configuration Admin service.
The service understands all network configuration properties defined
by NetworkConfigDefaults.
In particular, it uses the following properties to determine which endpoints the managed server
should listen on:
EndpointFactory provided via the constructor must support the creation of secure endpoints.
Resource instances being added to the OSGi service registry
and automatically adds them to the managed Californium ServerInterface instance.| Constructor and Description |
|---|
ManagedServer(org.osgi.framework.BundleContext bundleContext,
EndpointFactory endpointFactory)
Sets all required collaborators.
|
ManagedServer(org.osgi.framework.BundleContext bundleContext,
ch.ethz.inf.vs.californium.osgi.ServerInterfaceFactory serverFactory,
EndpointFactory endpointFactory)
Sets all required collaborators.
|
| Modifier and Type | Method and Description |
|---|---|
Resource |
addingService(org.osgi.framework.ServiceReference<Resource> reference)
Adds a Californium
Resource to the managed Californium Server. |
Endpoint |
getEndpoint(InetSocketAddress address)
Gets the endpoint bound to a particular address.
|
Endpoint |
getEndpoint(int port)
Gets the endpoint bound to a particular port.
|
void |
modifiedService(org.osgi.framework.ServiceReference<Resource> reference,
Resource service)
Does nothing as the Californium server does not need to be informed about
updated service registration properties of a
Resource. |
void |
removedService(org.osgi.framework.ServiceReference<Resource> reference,
Resource service)
Removes a Californium
Resource from the managed Californium Server. |
void |
stop()
Stops and destroys the managed server instance.
|
void |
updated(Dictionary<String,?> properties)
Updates the configuration properties of the wrapped Californium server.
|
public ManagedServer(org.osgi.framework.BundleContext bundleContext,
EndpointFactory endpointFactory)
ManagedServer(BundleContext, EndpointFactory)
with null as the server factory.bundleContext - the bundle context to be used for tracking ResourcesendpointFactory - the factory to use for creating endpoints for the managed
serverNullPointerException - if any of the parameters is nullpublic ManagedServer(org.osgi.framework.BundleContext bundleContext,
ch.ethz.inf.vs.californium.osgi.ServerInterfaceFactory serverFactory,
EndpointFactory endpointFactory)
bundleContext - the bundle context to be used for tracking ResourcesserverFactory - the factory to use for creating new server instancesendpointFactory - the factory to use for creating endpoints for the managed
serverNullPointerException - if the bundle context is nullpublic void updated(Dictionary<String,?> properties) throws org.osgi.service.cm.ConfigurationException
updated in interface org.osgi.service.cm.ManagedServiceproperties - the properties to set on the serverorg.osgi.service.cm.ConfigurationExceptionpublic void stop()
BundleActivator that registered
this managed service when the bundle is stopped.public Resource addingService(org.osgi.framework.ServiceReference<Resource> reference)
Resource to the managed Californium Server.
This method is invoked automatically by the ServiceTracker whenever
a Resource is added to the OSGi service registry.public void removedService(org.osgi.framework.ServiceReference<Resource> reference, Resource service)
Resource from the managed Californium Server.
This method is invoked automatically by the ServiceTracker whenever
a Resource is removed from the OSGi service registry.public void modifiedService(org.osgi.framework.ServiceReference<Resource> reference, Resource service)
Resource.public Endpoint getEndpoint(InetSocketAddress address)
ServerEndpointRegistrygetEndpoint in interface ServerEndpointRegistryaddress - the addressnull if none of the
server's endpoints is bound to the given addresspublic Endpoint getEndpoint(int port)
ServerEndpointRegistrygetEndpoint in interface ServerEndpointRegistryport - the portnull if none of the
server's endpoints is bound to the given port on any of its
network interfacesCopyright © 2014 Institute for Pervasive Computing, ETH Zurich. All rights reserved.