Class AbstractMessage
java.lang.Object
zleurtor.scanmanager.model.messages.AbstractMessage
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
CloseConnectionMessage
,HeartBeatMessage
,IAmMessage
,LogLevelErrorMessage
,LogLevelMessage
,LogLevelSuccessMessage
,LogMessage
,OptionsMessage
,ShutdownMessage
,SnapshotErrorMessage
,SnapshotMessage
,SnapshotSuccessMessage
,StreamErrorMessage
,StreamMessage
,UpdateMessage
,WhoAreYouMessage
The super class of all the messages exchanged by the master and the slaves.
- Author:
- Zleurtor
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract AbstractMessage
Set this message values to the ones in the given XML description.byte[]
Serialize this object to an array of bytes (avoid the use of ObjectInputStream because of the presence of the handles that spend a lot of memory).protected abstract String
toXml()
Transform this message to an XML description.static AbstractMessage
unserialize
(byte[] serialized) Unserialize this object from an array of bytes (avoid the use of ObjectInputStream because of the presence of the handles that spend a lot of memory).
-
Field Details
-
DISCOVER
The message to broadcast to all the slaves to discover them.- See Also:
-
STOP
The message to send to stop the slave.- See Also:
-
LOGGER
protected static final org.slf4j.Logger LOGGERA Logger...
-
-
Constructor Details
-
AbstractMessage
protected AbstractMessage()Constructs a new empty message.
-
-
Method Details
-
toXml
protected abstract String toXml() throws ParserConfigurationException, TransformerFactoryConfigurationError, TransformerException, IOExceptionTransform this message to an XML description.- Returns:
- An XML describing this message.
- Throws:
ParserConfigurationException
- If a DocumentBuildercannot be created which satisfies the configuration requested.TransformerFactoryConfigurationError
- Thrown in case of service configuration error or ifthe implementation is not available or cannot be instantiated.TransformerException
- When it is not possible to create a Transformer instance or if an unrecoverable error occurs during the course of the transformation.IOException
- If an I/O error occurs.
-
fromXml
protected abstract AbstractMessage fromXml(String xml) throws SAXException, IOException, ParserConfigurationException, XPathExpressionException Set this message values to the ones in the given XML description.- Parameters:
xml
- The XML containing the values to set in this message.- Returns:
- This message.
- Throws:
SAXException
- If any parse errors occur.IOException
- If any IO errors occur.ParserConfigurationException
- If a DocumentBuildercannot be created which satisfies the configuration requested.XPathExpressionException
- If an XPath expression cannot be evaluated.
-
serialize
public byte[] serialize() throws ParserConfigurationException, TransformerFactoryConfigurationError, TransformerException, IOExceptionSerialize this object to an array of bytes (avoid the use of ObjectInputStream because of the presence of the handles that spend a lot of memory).- Returns:
- An array of bytes that is the serialized form of this message.
- Throws:
ParserConfigurationException
- If a DocumentBuildercannot be created which satisfies the configuration requested.TransformerFactoryConfigurationError
- Thrown in case of service configuration error or ifthe implementation is not available or cannot be instantiated.TransformerException
- When it is not possible to create a Transformer instance or if an unrecoverable error occurs during the course of the transformation.IOException
- If an I/O error occurs.
-
unserialize
public static AbstractMessage unserialize(byte[] serialized) throws XPathExpressionException, SAXException, IOException, ParserConfigurationException, InstantiationException, IllegalAccessException, ClassNotFoundException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException Unserialize this object from an array of bytes (avoid the use of ObjectInputStream because of the presence of the handles that spend a lot of memory).- Parameters:
serialized
- The serialized form of the message to unserialize.- Returns:
- A message object that is the unserialized form of the given byte array.
- Throws:
SAXException
- If any parse errors occur.IOException
- If any IO errors occur.ParserConfigurationException
- If a DocumentBuildercannot be created which satisfies the configuration requested.XPathExpressionException
- If an XPath expression cannot be evaluated.ClassNotFoundException
- If the class cannot be locatedIllegalAccessException
- If the class or its nullary constructor is not accessible.InstantiationException
- If this Class represents an abstract class, an interface, an array class, a primitive type, or void; or if the class has no nullary constructor or if the instantiation fails for some other reason.SecurityException
- If a security manager, s, is present and the caller's class loader is not the same as or an ancestor of the class loader for the current class and invocation of s.checkPackageAccess() denies access to the package of this class.NoSuchMethodException
- If a matching constructor is not found.InvocationTargetException
- If the underlying constructor throws an exception.IllegalArgumentException
- If this Constructor object is enforcing Java language access control and the underlying constructor is inaccessible.
-