Init
method, each with a different number of parameters.
cpldeploy.xml
by looking in the following places in this order:
user.home
system property
classpath
if (isApplet()) IltSystem.Init(this, "deploy.xml"); else IltSystem.Init("deploy.xml");
IltSystem.Init
has not been called before
IltSystem.GetDefaultContext
is called, the latter will implicitly call
IltSystem.Init()
(the version with no parameter) to initialize the default
context. This has the following two effects, one a drawback and
one a feature:
IltSystem.Init
method with parameters, you must make sure that instances of
classes using the default context are not created before
IltSystem.Init
is invoked. For example these instances should not be created
during static initialization.
<?xml version="1.0"?> <deployment xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation = "ilog/cpl/schema/deploy.xsd"> <urlAccess verbose="true"> <relativePath>data/images</relativePath> </urlAccess> <classManager> <file>model.xml</file> </classManager> </deployment>
<deployment>
. This element can contain a number of subelements each
corresponding to the contextual information and services as
described in The concepts.
<urlAccess>
element will be systematically read before the
<classManager>
element even if it is placed after it in the deployment
descriptor file. Therefore, you can arrange these subelements in
any order.
<urlAccess>
element is read before the elements that potentially use it,
that is, elements that require files to be loaded (the
<classManager>
, for example).
<classManager>
element includes a list of file elements that contain
filenames. These files are read in the order in which they
appear in the file.
parse
method of IlpDeploymentParser.
IlpDefaultURLAccessService urlBootService = new IlpDefaultURLAccessService(); URL url = urlBootService.getFileLocation("deploy.xml"); IlpDeploymentParser parser = new IlpDeploymentParser(url); IltDefaultContext context = new IltDefaultContext(); try { parser.parse(null, context); } catch (Exception e) { e.printStackTrace(); }
deploy.xml
file, then a new context is created and passed to the
parse
method. Note that the first parameter of the
parse
method is not used here.
<?xml version="1.0"?> <deployment xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation = "ilog/cpl/schema/deploy.xsd"> <custom handlerClass="UserHandler"/>Joe Williams</custom> </deployment>
public class UserHandler implements IlpDeploymentParser.IlpCustomHandler { public UserHandler() {} public void handleCustomElement(Element customElement, IlpDefaultContext context) { String name = customElement.getTextTrim(); context.setProperty("userName",name); } }
<custom>
elements in the order in which they appear, after dealing with
standard elements. It tries to load the Java™ class specified in
the
handlerClass
attribute and instantiate it using the default constructor. Then
it calls the method handleCustomElement.