Class org.as2lib.io.conn.local.server.LocalServer

org.as2lib.core.BasicClass
   +--org.as2lib.io.conn.local.server.LocalServer

Implemented Interfaces

Server

Description

LocalServer acts as a composite for many services that are all combined in one domain.

Example: var server:LocalServer = new LocalServer("local.as2lib.org"); server.putService("myServiceOne", new MyServiceOne()); server.putService("myServiceTwo", new MyServiceTwo()); server.run();

Method Index

new LocalServer()

addService(), getHost(), getServerRegistry(), getService(), isRunning(), putService(), removeService(), run(), setServerRegistry(), stop()

Inherited from BasicClass

toString()

Constructor Detail

LocalServer

public function LocalServer(host:String)

Constructs a new LocalServer instance.

Parameters

hostthe name of this server

Throws

IllegalArgumentExceptionif the passed-in host is null, undefined or an empty string

Method Detail

getServerRegistry

public function getServerRegistry(Void):ServerRegistry

Returns the currently used server registry.

This is either the server registry set via setServerRegistry or the default registry returned by the LocalConfig.getServerRegistry method.

Return

the currently used server registry

setServerRegistry

public function setServerRegistry(serverRegistry:ServerRegistry):Void

Sets a new server registry.

If serverRegistry is null or undefined the getServerRegistry method will return the default server registry.

Parameters

serverRegistrythe new server registry

run

public function run(Void):Void

Runs this server.

This involves registering itself at the server registry and running all added services with this host.

If this server is already running a restart will be made. This means it will be stopped and run again.

Specified By

run() in org.as2lib.io.conn.core.server.Server

stop

public function stop(Void):Void

Stops this server.

This involves stopping all services and removing itself from the server registry.

Specified By

stop() in org.as2lib.io.conn.core.server.Server

putService

public function putService(path:String, service):ServerServiceProxy

Puts the passed-in service to the passed-in path on this server.

service and path are wrapped in a ServerServiceProxy instance.

Parameters

paththat path to the service on the host
servicethe service to make locally available

Return

the newly created server service proxy that wraps service and path

Throws

IllegalArgumentExceptionif the passed-in path is null, undefined or an empty string or if the passed-in service is null or undefined

Specified By

putService() in org.as2lib.io.conn.core.server.Server

addService

public function addService(serviceProxy:ServerServiceProxy):Void

Adds the passed-in serviceProxy to this service.

If this server is running, the serviceProxy will be run immediately too.

Parameters

serviceProxythe proxy that wraps the actual service

Throws

IllegalArgumentExceptionif the passed-in serviceProxy is null or undefined or if the path of the passed-in serviceProxy is null, undefined or an empty string or if the path of the passed-in serviceProxy is already in use

Specified By

addService() in org.as2lib.io.conn.core.server.Server

removeService

public function removeService(path:String):ServerServiceProxy

Removes the service registered wiht the passed-in path.

If the service is running it will be stopped.

null will be returned if:

  • The passed-in path is null or an empty string.
  • There is no registered service with the passed-in path.

Parameters

paththe path of the service to remove

Return

the removed server service proxy wrapping the actual service

Specified By

removeService() in org.as2lib.io.conn.core.server.Server

getService

public function getService(path:String):ServerServiceProxy

Returns the service registered with the passed-in path.

null will be returned if:

  • The passed-in path is null or an empty string.
  • There is no service registered with the passed-in path.

Parameters

paththe path of the service to return

Return

the server service proxy wrapping the actual service

Specified By

getService() in org.as2lib.io.conn.core.server.Server

isRunning

public function isRunning(Void):Boolean

Returns whether this server is running.

This server is by default not running. It runs as soon as you call the run method. And stops when you call the method.

Return

true if this server is running else false

Specified By

isRunning() in org.as2lib.io.conn.core.server.Server

getHost

public function getHost(Void):String

Returns the host of this server.

Return

this host of this server

Specified By

getHost() in org.as2lib.io.conn.core.server.Server