Crossfire JXClient, Trunk
Public Member Functions | Static Public Member Functions | Static Public Attributes | Package Attributes | Static Private Member Functions | Static Private Attributes | List of all members
com.sun.jmx.examples.scandir.config.XmlConfigUtils Class Reference
Collaboration diagram for com.sun.jmx.examples.scandir.config.XmlConfigUtils:
Collaboration graph

Public Member Functions

synchronized ScanManagerConfig readFromFile () throws IOException
 
synchronized void writeToFile (ScanManagerConfig bean) throws IOException
 
 XmlConfigUtils (String file)
 

Static Public Member Functions

static File createNewXmlFile (String basename) throws IOException
 
static ScanManagerConfig read (File f) throws JAXBException
 
static String toString (Object bean)
 
static void write (ResultRecord bean, OutputStream os, boolean fragment) throws JAXBException
 
static void write (ScanManagerConfig bean, OutputStream os, boolean fragment) throws JAXBException
 
static DirectoryScannerConfig xmlClone (DirectoryScannerConfig bean)
 
static ScanManagerConfig xmlClone (ScanManagerConfig bean)
 

Static Public Attributes

static final String NAMESPACE
 

Package Attributes

final String file
 

Static Private Member Functions

static File commit (String basename, File tmpFile) throws IOException
 
static Object copy (Object bean)
 
static Marshaller createMarshaller () throws JAXBException
 
static Unmarshaller createUnmarshaller () throws JAXBException
 
static synchronized JAXBContext getContext () throws JAXBException
 
static File newXmlTmpFile (String basename) throws IOException
 
static void writeXml (Object bean, OutputStream os, boolean fragment) throws JAXBException
 

Static Private Attributes

static JAXBContext context
 
static final Logger LOG
 

Detailed Description

The class XmlConfigUtils is used to deal with XML serialization and XML files.

Author
Sun Microsystems, 2006 - All rights reserved.

Definition at line 62 of file XmlConfigUtils.java.

Constructor & Destructor Documentation

◆ XmlConfigUtils()

com.sun.jmx.examples.scandir.config.XmlConfigUtils.XmlConfigUtils ( String  file)

Creates a new instance of XmlConfigUtils.

Parameters
fileThe file name of the XML file in which an instance of this object will read and write XML data.

Definition at line 89 of file XmlConfigUtils.java.

References com.sun.jmx.examples.scandir.config.XmlConfigUtils.file.

Member Function Documentation

◆ commit()

static File com.sun.jmx.examples.scandir.config.XmlConfigUtils.commit ( String  basename,
File  tmpFile 
) throws IOException
staticprivate

◆ copy()

static Object com.sun.jmx.examples.scandir.config.XmlConfigUtils.copy ( Object  bean)
staticprivate

Creates an XML clone of the given bean.

In other words, this method XML-serializes the given bean, and XML-deserializes a copy of that bean.

Exceptions
IllegalArgumentExceptionif the bean class is not known by the underlying XML binding context.
Returns
A deep-clone of the given bean.

Definition at line 180 of file XmlConfigUtils.java.

References com.sun.jmx.examples.scandir.config.XmlConfigUtils.createMarshaller(), and com.sun.jmx.examples.scandir.config.XmlConfigUtils.createUnmarshaller().

Referenced by com.sun.jmx.examples.scandir.config.XmlConfigUtils.xmlClone().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createMarshaller()

static Marshaller com.sun.jmx.examples.scandir.config.XmlConfigUtils.createMarshaller ( ) throws JAXBException
staticprivate

◆ createNewXmlFile()

static File com.sun.jmx.examples.scandir.config.XmlConfigUtils.createNewXmlFile ( String  basename) throws IOException
static

Creates a new committed XML file for

<basename>

, containing only the

<?xml ...?>

header.

This method will rename

<basename>

to

<basename>~

, if it exists.

Returns
A newly created XML file containing the regular
<?xml ...?>
header.
Parameters
basenameThe name of the new file.
Exceptions
IOExceptionif the new XML file couldn't be created.

Definition at line 389 of file XmlConfigUtils.java.

References com.sun.jmx.examples.scandir.config.XmlConfigUtils.commit(), and com.sun.jmx.examples.scandir.config.XmlConfigUtils.newXmlTmpFile().

Referenced by com.sun.jmx.examples.scandir.ResultLogManager.createNewLogFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createUnmarshaller()

static Unmarshaller com.sun.jmx.examples.scandir.config.XmlConfigUtils.createUnmarshaller ( ) throws JAXBException
staticprivate

Definition at line 293 of file XmlConfigUtils.java.

References com.sun.jmx.examples.scandir.config.XmlConfigUtils.getContext().

Referenced by com.sun.jmx.examples.scandir.config.XmlConfigUtils.copy(), and com.sun.jmx.examples.scandir.config.XmlConfigUtils.read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getContext()

static synchronized JAXBContext com.sun.jmx.examples.scandir.config.XmlConfigUtils.getContext ( ) throws JAXBException
staticprivate

◆ newXmlTmpFile()

static File com.sun.jmx.examples.scandir.config.XmlConfigUtils.newXmlTmpFile ( String  basename) throws IOException
staticprivate

◆ read()

static ScanManagerConfig com.sun.jmx.examples.scandir.config.XmlConfigUtils.read ( File  f) throws JAXBException
static

Reads the configuration from the given XML configuration file.

Parameters
fthe file to read from.
Returns
A
ScanManagerConfig
bean read from the XML configuration file.
Exceptions
javax.xml.bind.JAXBExceptionif it fails to read the configuration.

Definition at line 240 of file XmlConfigUtils.java.

References com.sun.jmx.examples.scandir.config.XmlConfigUtils.createUnmarshaller().

Referenced by com.sun.jmx.examples.scandir.ScanDirConfig.guessConfigName(), and com.sun.jmx.examples.scandir.config.XmlConfigUtils.readFromFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readFromFile()

synchronized ScanManagerConfig com.sun.jmx.examples.scandir.config.XmlConfigUtils.readFromFile ( ) throws IOException

Reads the configuration from the XML configuration file.

Exceptions
IOExceptionif it fails to read the configuration.
Returns
A
ScanManagerConfig
bean read from the XML configuration file.

Definition at line 217 of file XmlConfigUtils.java.

References com.sun.jmx.examples.scandir.config.XmlConfigUtils.file, and com.sun.jmx.examples.scandir.config.XmlConfigUtils.read().

Referenced by com.sun.jmx.examples.scandir.ScanDirConfig.load(), com.sun.jmx.examples.scandir.ScanDirConfigTest.testAddDirectoryScanner(), com.sun.jmx.examples.scandir.ScanDirConfigTest.testAddNotificationListener(), com.sun.jmx.examples.scandir.config.XmlConfigUtilsTest.testReadFromFile(), and com.sun.jmx.examples.scandir.ScanDirConfigTest.testSave().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toString()

static String com.sun.jmx.examples.scandir.config.XmlConfigUtils.toString ( Object  bean)
static

Creates an XML string representation of the given bean.

Exceptions
IllegalArgumentExceptionif the bean class is not known by the underlying XMLbinding context.
Returns
An XML string representation of the given bean.

Definition at line 139 of file XmlConfigUtils.java.

References com.sun.jmx.examples.scandir.config.XmlConfigUtils.createMarshaller().

Referenced by com.sun.jmx.examples.scandir.ScanDirConfigTest.testGetXmlConfigString(), and com.sun.jmx.examples.scandir.config.ScanManagerConfig.toString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write() [1/2]

static void com.sun.jmx.examples.scandir.config.XmlConfigUtils.write ( ResultRecord  bean,
OutputStream  os,
boolean  fragment 
) throws JAXBException
static

Writes the given bean to the given output stream.

Parameters
beanthe bean to write.
osthe output stream to write to.
fragmentwhether the
<?xml ... ?>
header should be included. The header is not included if the bean is just an XML fragment encapsulated in a higher level XML element.
Exceptions
JAXBExceptionAn XML Binding exception occurred.

Definition at line 271 of file XmlConfigUtils.java.

References com.sun.jmx.examples.scandir.config.XmlConfigUtils.writeXml().

Here is the call graph for this function:

◆ write() [2/2]

static void com.sun.jmx.examples.scandir.config.XmlConfigUtils.write ( ScanManagerConfig  bean,
OutputStream  os,
boolean  fragment 
) throws JAXBException
static

Writes the given bean to the given output stream.

Parameters
beanthe bean to write.
osthe output stream to write to.
fragmentwhether the
<?xml ... ?>
header should be included. The header is not included if the bean is just an XML fragment encapsulated in a higher level XML element.
Exceptions
JAXBExceptionAn XML Binding exception occurred.

Definition at line 256 of file XmlConfigUtils.java.

References com.sun.jmx.examples.scandir.config.XmlConfigUtils.writeXml().

Referenced by com.sun.jmx.examples.scandir.ResultLogManager.logToFile(), com.sun.jmx.examples.scandir.ScanDirConfigTest.testLoad(), and com.sun.jmx.examples.scandir.config.XmlConfigUtils.writeToFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeToFile()

synchronized void com.sun.jmx.examples.scandir.config.XmlConfigUtils.writeToFile ( ScanManagerConfig  bean) throws IOException

Write the given bean to the XML file.

Performs an atomic write, first writing in

<file>.new

, then renaming

<file>

to

<file>~

, then renaming renaming

<file>.new

to

<file>

.

Parameters
beanThe configuration to write in the XML file.
Exceptions
IOExceptionif write to file failed.

Definition at line 103 of file XmlConfigUtils.java.

References com.sun.jmx.examples.scandir.config.XmlConfigUtils.commit(), com.sun.jmx.examples.scandir.config.XmlConfigUtils.file, com.sun.jmx.examples.scandir.config.XmlConfigUtils.newXmlTmpFile(), and com.sun.jmx.examples.scandir.config.XmlConfigUtils.write().

Referenced by com.sun.jmx.examples.scandir.ScanDirConfig.save(), com.sun.jmx.examples.scandir.config.XmlConfigUtilsTest.testReadFromFile(), and com.sun.jmx.examples.scandir.config.XmlConfigUtilsTest.testWriteToFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeXml()

static void com.sun.jmx.examples.scandir.config.XmlConfigUtils.writeXml ( Object  bean,
OutputStream  os,
boolean  fragment 
) throws JAXBException
staticprivate

Writes the given bean to the given output stream.

Parameters
beanthe bean to write.
osthe output stream to write to.
fragmentwhether the
<?xml ... ?>
header should be included. The header is not included if the bean is just an XML fragment encapsulated in a higher level XML element.
Exceptions
JAXBExceptionAn XML Binding exception occurred.

Definition at line 285 of file XmlConfigUtils.java.

References com.sun.jmx.examples.scandir.config.XmlConfigUtils.createMarshaller().

Referenced by com.sun.jmx.examples.scandir.config.XmlConfigUtils.write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xmlClone() [1/2]

static DirectoryScannerConfig com.sun.jmx.examples.scandir.config.XmlConfigUtils.xmlClone ( DirectoryScannerConfig  bean)
static

Creates an XML clone of the given bean.

In other words, this method XML-serializes the given bean, and XML-deserializes a copy of that bean.

Returns
A deep-clone of the given bean.
Exceptions
IllegalArgumentExceptionif the bean class is not known by the underlying XML binding context.
Parameters
beanThe bean to clone.

Definition at line 206 of file XmlConfigUtils.java.

References com.sun.jmx.examples.scandir.config.XmlConfigUtils.copy().

Here is the call graph for this function:

◆ xmlClone() [2/2]

static ScanManagerConfig com.sun.jmx.examples.scandir.config.XmlConfigUtils.xmlClone ( ScanManagerConfig  bean)
static

Creates an XML clone of the given bean.

In other words, this method XML-serializes the given bean, and XML-deserializes a copy of that bean.

Returns
A deep-clone of the given bean.
Exceptions
IllegalArgumentExceptionif the bean class is not known by the underlying XML binding context.
Parameters
beanThe bean to clone.

Definition at line 165 of file XmlConfigUtils.java.

References com.sun.jmx.examples.scandir.config.XmlConfigUtils.copy().

Referenced by com.sun.jmx.examples.scandir.config.ScanManagerConfig.copy(), com.sun.jmx.examples.scandir.DirectoryScanner.DirectoryScanner(), and com.sun.jmx.examples.scandir.ScanDirConfig.getConfiguration().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ context

JAXBContext com.sun.jmx.examples.scandir.config.XmlConfigUtils.context
staticprivate

◆ file

final String com.sun.jmx.examples.scandir.config.XmlConfigUtils.file
package

◆ LOG

final Logger com.sun.jmx.examples.scandir.config.XmlConfigUtils.LOG
staticprivate
Initial value:
=
Logger.getLogger(XmlConfigUtils.class.getName())

A logger for this class.

Definition at line 74 of file XmlConfigUtils.java.

◆ NAMESPACE

final String com.sun.jmx.examples.scandir.config.XmlConfigUtils.NAMESPACE
static
Initial value:
=
"jmx:com.sun.jmx.examples.scandir.config"

A URI for our XML configuration namespace. This doesn't start with http:// because we are not going to publish this private schema anywhere.

Definition at line 69 of file XmlConfigUtils.java.


The documentation for this class was generated from the following file:
com.sun.jmx.examples.scandir.config.XmlConfigUtils.file
final String file
Definition: XmlConfigUtils.java:82
com.sun.jmx.examples.scandir.config.XmlConfigUtils.XmlConfigUtils
XmlConfigUtils(String file)
Definition: XmlConfigUtils.java:89