?? x3305.htm
字號:
<HTML
><HEAD
><TITLE
>Managing the Configuration</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.64
"><LINK
REL="HOME"
TITLE="Programming Jabber"
HREF="book1.htm"><LINK
REL="UP"
TITLE="Server Architecture and Configuration"
HREF="c1223.htm"><LINK
REL="PREVIOUS"
TITLE="A Tour of jabber.xml"
HREF="x1740.htm"><LINK
REL="NEXT"
TITLE="Server Constellations"
HREF="x3381.htm"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Programming Jabber</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="x1740.htm"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 4. Server Architecture and Configuration</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x3381.htm"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="JABTDG-CH-4-SECT-4.4"
>Managing the Configuration</A
></H1
><P
>Now that we've had a tour of the components, and have an idea of what
sorts of configurations are possible, you may be wondering whether there's
a way to retain some sort of overview of the actual XML. Dropping
component instance definitions in and out of the configuration file is
somewhat tedious, and certainly when editing such a large file, it's not
difficult to lose sense of direction and comment out or edit the wrong section.</P
><P
><I
CLASS="EMPHASIS"
><TT
CLASS="LITERAL"
><jabberd:include/></TT
></I
></P
><P
>Help is at hand, in the form of the
<TT
CLASS="LITERAL"
><jabberd:include/></TT
>
tag. </P
><P
>This tag comes from the same stable as
<TT
CLASS="LITERAL"
><jabberd:cmdline/></TT
>
and provides the Jabber server administrator with ways to better manage
the XML configuration.</P
><P
>The contents of a file specified with the
<TT
CLASS="LITERAL"
><jabberd:include/></TT
>
tag are imported (included) in the position that the
<TT
CLASS="LITERAL"
><jabberd:include/></TT
>
tag occupies. Depending on what the root tag in the file to be included
is, the import is done in one of two ways:</P
><P
></P
><UL
><LI
><P
><I
CLASS="EMPHASIS"
>root tag matches the parent tag of
<TT
CLASS="LITERAL"
><jabberd:include/></TT
></I
></P
><P
>The contents of the file <I
CLASS="EMPHASIS"
>minus the root tag</I
>
are included</P
></LI
><LI
><P
><I
CLASS="EMPHASIS"
>root tag does not match the parent tag of
<TT
CLASS="LITERAL"
><jabberd:include/></TT
></I
></P
><P
>The entire contents of the file are included</P
></LI
></UL
><P
>For example, if we have a section like this in the
<TT
CLASS="FILENAME"
>jabber.xml</TT
> file:</P
><P
><PRE
CLASS="SCREEN"
>...
<conference xmlns="jabber:config:conference">
<public/>
<vCard>
<FN>yak Chatrooms</FN>
<DESC>This is a public chatroom service.</DESC>
<URL>http://yak/chat</URL>
</vCard>
...
<jabberd:include>./rooms.xml</jabberd:include>
</conference>
...</PRE
>
and the content of <TT
CLASS="FILENAME"
>./rooms.xml</TT
> looks like this:
<PRE
CLASS="SCREEN"
><room jid="kitchen@conference.yak">
<name>The Kitchen</name>
<notice>
<join> comes to add to the broth-spoiling</join>
<leave> can't stand the heat</leave>
<rename> is now known as </rename>
</notice>
</room>
<room jid="cellar@conference.yak">
<name>The Cellar</name>
<secret>cellarsecret</secret>
</room></PRE
></P
><P
>then these rooms will be defined to the <I
CLASS="EMPHASIS"
>Conferencing</I
>
component as if the
configuration XML had appeared directly inside of the
<TT
CLASS="LITERAL"
><conference/></TT
> configuration
wrapper tag. </P
><P
>We can put the <TT
CLASS="LITERAL"
><jabberd:include/></TT
>
tag to good use and organise our configuration component instances as shown
in <A
HREF="x3305.htm#JABTDG-CH-4-EX-19"
>Example 4-23</A
>.</P
><DIV
CLASS="EXAMPLE"
><A
NAME="JABTDG-CH-4-EX-19"
></A
><P
><B
>Example 4-23. Configuration XML organised with
<TT
CLASS="LITERAL"
><jabberd:include/></TT
></B
></P
><P
><PRE
CLASS="SCREEN"
><jabber>
<!-- Core components -->
<jabberd:include>./sessions.xml</jabberd:include>
<jabberd:include>./config/standard/xdb.xml</jabberd:include>
<jabberd:include>./config/standard/c2s.xml</jabberd:include>
<!-- Testing -->
<!--
<jabberd:include>./config/local/conference.xml</jabberd:include>
<jabberd:include>./config/test/test.service.xml</jabberd:include>
-->
<!-- Logging -->
<jabberd:include>./config/standard/elogger.xml</jabberd:include>
<jabberd:include>./config/standard/rlogger.xml</jabberd:include>
<!--
Internal-only server right now
<jabberd:include>./config/standard/dnsrv.xml</jabberd:include>
<jabberd:include>./config/standard/s2s.xml</jabberd:include>
-->
<!-- Misc -->
<jabberd:include>./config/standard/jud.xml</jabberd:include>
<!-- IO (incl. karma), PIDfile -->
<jabberd:include>./config/standard/io.xml</jabberd:include>
<jabberd:include>./config/standard/pidfile.xml</jabberd:include>
</jabber></PRE
></P
></DIV
><P
>The XML in <A
HREF="x3305.htm#JABTDG-CH-4-EX-19"
>Example 4-23</A
>
gives us a great overview of which components are included in
our Jabber server; we have the core components providing the
<I
CLASS="EMPHASIS"
>Session Management</I
>,
<I
CLASS="EMPHASIS"
>Client (to Server) Connections</I
> and
<I
CLASS="EMPHASIS"
>Data Storage</I
>
services; a couple of components under test (<I
CLASS="EMPHASIS"
>Conferencing</I
>
and a custom component we're calling 'test.service') that are currently
deactivated; the <I
CLASS="EMPHASIS"
>Logging</I
> services in their standard
configuration; the components providing facilities for connecting to other
Jabber servers - <I
CLASS="EMPHASIS"
>Server (to Server) Connections</I
>
and <I
CLASS="EMPHASIS"
>Hostname Resolution</I
> - are currently inactive,
meaning that as configured, the Jabber server will be purely internal;
there's also a local JUD defined too, and finally we have the IO and
PIDfile specifications - also abstracted out into separate XML chunks.</P
><P
>This works well especially if there are certain parts of the configuration -
for example certain component instance definitions - that don't normally
change; you can see that many of the component configuration files are in
a 'standard' directory, which by convention could signify that they're
the same as the XML configuration as-delivered and are not likely to change.</P
><P
><I
CLASS="EMPHASIS"
><TT
CLASS="LITERAL"
><jabberd:cmdline/></TT
></I
></P
><P
>The
<TT
CLASS="LITERAL"
><jabberd:cmdline/></TT
>
tag was mentioned in Chapter 3 as a way of providing a command line
hook into the configuration - values stored in the XML could be overridden
by command line switches used when invoking <B
CLASS="COMMAND"
>jabberd</B
>.</P
><P
>The tag is used in the standard XML configuration
(see <A
HREF="x1581.htm#JABTDG-CH-4-FIG-4.2"
>Figure 4-3</A
>)
to allow replacement of the hostname and spool directory:</P
><P
><PRE
CLASS="SCREEN"
><host><jabberd:cmdline flag="h">yak</jabberd:cmdline></host></PRE
></P
><P
>and</P
><P
><PRE
CLASS="SCREEN"
><spool><jabberd:cmdline flag='s'>./spool</jabberd:cmdline></spool></PRE
></P
><P
>In fact, this tag can be used in most places in the XML - so if for example
you have a requirement to modify (re-specify) the error and record log
files for each <B
CLASS="COMMAND"
>jabberd</B
> invocation, you can do something
like this:</P
><P
><PRE
CLASS="SCREEN"
><log id='elogger'>
<host/>
<logtype/>
<format>%d: [%t] (%h): %s</format>
<file><TT
CLASS="USERINPUT"
><B
><jabberd:cmdline flag="e"></B
></TT
>error.log<TT
CLASS="USERINPUT"
><B
></jabberd:cmdline></B
></TT
></file>
<stderr/>
</log></PRE
></P
><P
>and then override the value <TT
CLASS="FILENAME"
>error.log</TT
> with something else
at invocation time:</P
><P
><PRE
CLASS="SCREEN"
>yak:~/jabber-1.4.1$ <TT
CLASS="USERINPUT"
><B
>./jabberd/jabberd -e error_log.txt &</B
></TT
></PRE
></P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="x1740.htm"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="book1.htm"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="x3381.htm"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>A Tour of <TT
CLASS="FILENAME"
>jabber.xml</TT
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="c1223.htm"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Server Constellations</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -