Class DiffusionServer
java.lang.Object
com.pushtechnology.diffusion.api.server.DiffusionServer
- All Implemented Interfaces:
- EmbeddedDiffusion
Represents an instance of the Diffusion Server.
 
 When a server is instantiated it will attempt to load any XML configuration
 files that it finds on the classpath (or in the specified directory). If no
 XML files are found then the server will be loaded with default (empty)
 configuration and will have to be configured before starting it.
 
 The server may be configured by getting the root configuration using the
 
getConfig() and then configuring any aspects that are required.
 
 Once the server has been started then most aspects of the configuration can
 no longer be changed.
 
 Currently only one instance of the Diffusion Server can ever be instantiated
 in a VM. Once one has been instantiated another can not be. Once a server has
 been stopped it may not be restarted nor another instantiated. These
 restrictions may be removed at a future release.- Since:
- 4.4
- 
Nested Class SummaryNested classes/interfaces inherited from interface com.pushtechnology.diffusion.api.server.EmbeddedDiffusionEmbeddedDiffusion.LifecycleListener, EmbeddedDiffusion.State
- 
Constructor SummaryConstructorsConstructorDescriptionConstructor.DiffusionServer(String propertiesDirectory, boolean embedded) Constructor.DiffusionServer(Properties bootstrapProps) Constructor.DiffusionServer(Properties bootstrapProps, boolean embedded) Constructor.
- 
Method SummaryModifier and TypeMethodDescriptionvoidRegister for lifecycle events.final ServerConfigReturns the root server configuration.booleanbooleanstatic voidThis can be invoked to run free standing.voidDe-Register for lifecycle events.voidstart()Starts the server.voidstop()Stops the server.
- 
Constructor Details- 
DiffusionServerConstructor. Creates a Diffusion Server with default configuration. Equivalent to callingDiffusionServer(Properties)with the system properties.- Throws:
- ConfigException- If the configuration is invalid.
 
- 
DiffusionServerConstructor. Creates a Diffusion Server which loads xml properties from a directory specified by the provided bootstrap properties- Parameters:
- bootstrapProps- The bootstrap properties to be used for configuration
- Throws:
- ConfigException- If the configuration is invalid.
 
- 
DiffusionServerConstructor.- Parameters:
- propertiesDirectory- The properties directory from which xml properties will be loaded. If- null, the default directory will be used.
- embedded- If- true, do not register a JVM shutdown hook, and do not exit the JVM after stopping.
- Throws:
- ConfigException- If the configuration is invalid.
- Since:
- 5.0.0
 
- 
DiffusionServerConstructor. Creates a Diffusion Server which loads xml properties from a directory specified by the provided bootstrap properties- Parameters:
- bootstrapProps- The bootstrap properties to be used for configuration
- embedded- If- true, do not register a JVM shutdown hook, and do not exit the JVM after stopping.
- Throws:
- ConfigException- If the configuration is invalid.
- Since:
- 5.0.0
 
 
- 
- 
Method Details- 
getConfigDescription copied from interface:EmbeddedDiffusionReturns the root server configuration. This may be called before starting the server to configure it or provide further configuration over and above that loaded from any XML properties files found (either on the classpath or the specified directory).- Specified by:
- getConfigin interface- EmbeddedDiffusion
- Returns:
- configuration root
 
- 
isStartedpublic boolean isStarted()- Specified by:
- isStartedin interface- EmbeddedDiffusion
- Returns:
- whether or not the server has started
 
- 
isStoppedpublic boolean isStopped()- Specified by:
- isStoppedin interface- EmbeddedDiffusion
- Returns:
- whether or not the server has stopped
 
- 
startStarts the server. The server may only be started once.- Specified by:
- startin interface- EmbeddedDiffusion
- Throws:
- APIException- if embedded and unable to start; if not embedded (see- DiffusionServer(Properties, boolean)), the JVM will exit
 
- 
stoppublic void stop()Stops the server. If not embedded (seeDiffusionServer(Properties, boolean)), the JVM will exit.- Specified by:
- stopin interface- EmbeddedDiffusion
 
- 
addLifecycleListenerDescription copied from interface:EmbeddedDiffusionRegister for lifecycle events.- Specified by:
- addLifecycleListenerin interface- EmbeddedDiffusion
- Parameters:
- callback- that is called when a state transition occurs.
 
- 
removeLifecycleListenerDescription copied from interface:EmbeddedDiffusionDe-Register for lifecycle events.- Specified by:
- removeLifecycleListenerin interface- EmbeddedDiffusion
- Parameters:
- callback- to be removed.
 
- 
mainThis can be invoked to run free standing.- Parameters:
- args- the first argument may be used to specify the location of the properties directory from which XML property files will be loaded. If not specified then they are loaded from the classpath.
- Throws:
- Throwable- not expected - failures should cause the JVM to exit
 
 
-