Extension.xml

Top  Previous  Next

This file defines the contents of the extension and how it should be loaded by the server.  The file is broken down into a series of sections that define each component of the extension. The layout looks like this:

 

<Extension>
     <ManagedObjects>
           <ManagedObject>…</ManagedObject>
     </ManagedObjects>
     <EventHandlers>
           <LoginHandlers>
                 <LoginHandler>…</LoginHandler>
           </LoginHandlers>
           <LogoutHandlers>
                 <LogoutHandler>…</LogoutHandler>
           </LogoutHandlers>
     </EventHandlers>
     <Plugins>
           <Plugin>…</Plugin>
     </Plugins>
</Extension>

 

Each section supports multiple entries.  For example, many plug-ins could exist inside the Plugins node as long as each is enclosed in its own Plugin node.  The actual data definition of the extension component is the same for all components and would look like this for a Java plug-in (if it had all options enabled):

 

<Plugin>
     <Handle>ExampleJavaPlugin</Handle>
     <Type>Java</Type>
     <Path>com.electrotank.electroserver4.testextension.SpringTest</Path>
     <Synchronized>true</Synchronized>
     <Variables>
           <Variable name="Variable1Name" type="string">variable 1 value</Variable>
           <Variable name="Variable2Name" type="string">variable 2 value</Variable>
      </Variables>
</Plugin>

Each node breaks down as indicated below.

Handle:  This is the “handle” of the component and is used as a name for the component's definition.  When creating a new instance of a component, the handle is needed for the server to identify which component is being referenced.
Type:  The type node defines what language was used to create the component.  It currently must be either Java or ActionScript (with other languages soon to follow in future versions).
Path:  This is the path to the location of the component’s code.  In the case of a scripting-language component, this is a relative path from the scripts directory of the extension.  In the case of a Java component, this will be the fully-qualified path.
Synchronized (optional): This node is used to determine if the server should automatically synchronize all access to the component.  In the case of Java components, this is often a poor approach because the server must synchronize aggressively due to the fact that it doesn’t know the details of the component, only the entry points. Generally a developer can synchronize the component more efficiently on their own.  In the case of an ActionScript component, this flag is crucial because ActionScript doesn’t directly support the ability to synchronize threads.
Variables (optional):  All components in ElectroServer 4 support a series of life cycle methods that include being initialized and destroyed.  The variables node allows configuration information to be passed into the component’s initialize method directly as an EsObject.  Each variable entry will become a single variable in the EsObject.  The name attribute will be the name of the variable and the type will be the data type used.  All data types are supported with the exception of arrays.

 

As noted before, every component uses the same structure in the Extension.xml file.  Here is an example ActionScript login event handler without variables:

 

<LoginHandler>
     <Handle>ExampleActionScriptEventHandler</Handle>
     <Type>ActionScript</Type>
     <Path>login/AsLoginHandler.as</Path>
     <Synchronized>true</Synchronized>
</LoginHandler>