⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 x3305.htm

📁 Its a xmpp protocol book
💻 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"
>&#60;jabberd:include/&#62;</TT
></I
></P
><P
>Help is at hand, in the form of the 
<TT
CLASS="LITERAL"
>&#60;jabberd:include/&#62;</TT
>
tag. </P
><P
>This tag comes from the same stable as 
<TT
CLASS="LITERAL"
>&#60;jabberd:cmdline/&#62;</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"
>&#60;jabberd:include/&#62;</TT
>
tag are imported (included) in the position that the 
<TT
CLASS="LITERAL"
>&#60;jabberd:include/&#62;</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"
>&#60;jabberd:include/&#62;</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"
>&#60;jabberd:include/&#62;</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"
>...
&#60;conference xmlns="jabber:config:conference"&#62;
  &#60;public/&#62;
  &#60;vCard&#62;
    &#60;FN&#62;yak Chatrooms&#60;/FN&#62;
    &#60;DESC&#62;This is a public chatroom service.&#60;/DESC&#62;
    &#60;URL&#62;http://yak/chat&#60;/URL&#62;
  &#60;/vCard&#62;
  ...
  &#60;jabberd:include&#62;./rooms.xml&#60;/jabberd:include&#62;
&#60;/conference&#62;
...</PRE
>
and the content of <TT
CLASS="FILENAME"
>./rooms.xml</TT
> looks like this:
<PRE
CLASS="SCREEN"
>&#60;room jid="kitchen@conference.yak"&#62;
  &#60;name&#62;The Kitchen&#60;/name&#62;
  &#60;notice&#62;
    &#60;join&#62; comes to add to the broth-spoiling&#60;/join&#62;
    &#60;leave&#62; can't stand the heat&#60;/leave&#62;
    &#60;rename&#62; is now known as &#60;/rename&#62;
  &#60;/notice&#62;
&#60;/room&#62;
&#60;room jid="cellar@conference.yak"&#62;
  &#60;name&#62;The Cellar&#60;/name&#62;
  &#60;secret&#62;cellarsecret&#60;/secret&#62;
&#60;/room&#62;</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"
>&#60;conference/&#62;</TT
> configuration
wrapper tag. </P
><P
>We can put the <TT
CLASS="LITERAL"
>&#60;jabberd:include/&#62;</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"
>&#60;jabberd:include/&#62;</TT
></B
></P
><P
><PRE
CLASS="SCREEN"
>&#60;jabber&#62;

  &#60;!-- Core components --&#62;

  &#60;jabberd:include&#62;./sessions.xml&#60;/jabberd:include&#62;
  &#60;jabberd:include&#62;./config/standard/xdb.xml&#60;/jabberd:include&#62;
  &#60;jabberd:include&#62;./config/standard/c2s.xml&#60;/jabberd:include&#62;

  &#60;!-- Testing --&#62;

  &#60;!--
  &#60;jabberd:include&#62;./config/local/conference.xml&#60;/jabberd:include&#62;
  &#60;jabberd:include&#62;./config/test/test.service.xml&#60;/jabberd:include&#62;
  --&#62;

  &#60;!-- Logging --&#62;

  &#60;jabberd:include&#62;./config/standard/elogger.xml&#60;/jabberd:include&#62;
  &#60;jabberd:include&#62;./config/standard/rlogger.xml&#60;/jabberd:include&#62;

  &#60;!--
  Internal-only server right now

  &#60;jabberd:include&#62;./config/standard/dnsrv.xml&#60;/jabberd:include&#62;
  &#60;jabberd:include&#62;./config/standard/s2s.xml&#60;/jabberd:include&#62;
  --&#62;

  &#60;!-- Misc --&#62;

  &#60;jabberd:include&#62;./config/standard/jud.xml&#60;/jabberd:include&#62;

  &#60;!-- IO (incl. karma), PIDfile --&#62;

  &#60;jabberd:include&#62;./config/standard/io.xml&#60;/jabberd:include&#62;
  &#60;jabberd:include&#62;./config/standard/pidfile.xml&#60;/jabberd:include&#62;

&#60;/jabber&#62;</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"
>&#60;jabberd:cmdline/&#62;</TT
></I
></P
><P
>The 
<TT
CLASS="LITERAL"
>&#60;jabberd:cmdline/&#62;</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"
>&#60;host&#62;&#60;jabberd:cmdline flag="h"&#62;yak&#60;/jabberd:cmdline&#62;&#60;/host&#62;</PRE
></P
><P
>and</P
><P
><PRE
CLASS="SCREEN"
>&#60;spool&#62;&#60;jabberd:cmdline flag='s'&#62;./spool&#60;/jabberd:cmdline&#62;&#60;/spool&#62;</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"
>&#60;log id='elogger'&#62;
  &#60;host/&#62;
  &#60;logtype/&#62;
  &#60;format&#62;%d: [%t] (%h): %s&#60;/format&#62;
  &#60;file&#62;<TT
CLASS="USERINPUT"
><B
>&#60;jabberd:cmdline flag="e"&#62;</B
></TT
>error.log<TT
CLASS="USERINPUT"
><B
>&#60;/jabberd:cmdline&#62;</B
></TT
>&#60;/file&#62;
  &#60;stderr/&#62;
&#60;/log&#62;</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 &#38;</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 + -