---
title: "openfire(1)配置属性"
author: "buerkai"
date: "2013-03-17T17:51:13Z"
tags: []
categories: ["企业架构"]
slug: "openfire-1"
draft: false
lastmod: "2013-03-17T20:14:43Z"
id: 1830809
url: "https://buerkai.iteye.com/blog/1830809"
---

在openfire中有3中配置属性

1\.

 

在openfire\_src\\src\\conf\\openfire.xml：

&lt;jive&gt;  
    &lt;adminConsole&gt;  
               &lt;port&gt;9090&lt;/port&gt;此处为openfire访问端口  
               &lt;securePort&gt;9091&lt;/securePort&gt;此处为openfire加密访问端口  
    &lt;/adminConsole&gt;

    &lt;locale&gt;en&lt;/locale&gt;

&lt;/jive&gt;

此文件为openfire的原始文件。

当运行openfire后，会增加下面的属性：

   &lt;connectionProvider&gt;  
    &lt;className&gt;org.jivesoftware.database.DefaultConnectionProvider&lt;/className&gt;  
  &lt;/connectionProvider&gt;

  &lt;!--connectionProvider为数据库的连接属性，所有的ConnectionProvider都必须实现此接口，DefaultConnectionProvider使用的org.logicalcobwebs.proxool.ProxoolDriver代理连接池,此类主要实现了数据连接词，及其相关配置参数  --&gt;

 

&lt;!--- 下面为连接池的参数 ---&gt;  
  &lt;database&gt;  
    &lt;defaultProvider&gt;  
      &lt;driver&gt;com.mysql.jdbc.Driver&lt;/driver&gt;  
      &lt;serverURL&gt;jdbc:mysql://localhost:3306/openfire?useUnicode=true&amp;amp;characterEncoding=UTF-8&amp;amp;zeroDateTimeBehavior=convertToNull&lt;/serverURL&gt;  
      &lt;username&gt;root&lt;/username&gt;  
      &lt;password&gt;admin&lt;/password&gt;  
      &lt;testSQL&gt;select 1&lt;/testSQL&gt;  
      &lt;testBeforeUse&gt;false&lt;/testBeforeUse&gt;  
      &lt;testAfterUse&gt;false&lt;/testAfterUse&gt;  
      &lt;minConnections&gt;5&lt;/minConnections&gt;  
      &lt;maxConnections&gt;25&lt;/maxConnections&gt;  
      &lt;connectionTimeout&gt;1.0&lt;/connectionTimeout&gt;  
    &lt;/defaultProvider&gt;  
  &lt;/database&gt;

 

&lt;!--- 次参数标识系统是否初始化，如果已经初始化，openfire.xml文件中会有此参数 ---&gt;  
  &lt;setup&gt;true&lt;/setup&gt;

 

2.在数据库中的配置参数：

数据库中的表：ofproperty，记录一些属性，可以是系统属性，也可以是插件属性。

 

3.在插件开发中会有plugin.xml这个文件，主要记录插件信息

&lt;plugin&gt;

    &lt;!-- 插件类 --&gt;  
    &lt;class&gt;org.jivesoftware.openfire.plugin.ClientControlPlugin&lt;/class&gt;  
     
    &lt;!-- 插件信息--&gt;  
    &lt;name&gt;Client Control&lt;/name&gt; --插件名字  
    &lt;description&gt;Controls clients allowed to connect and available features&lt;/description&gt; --插件描述  
    &lt;author&gt;Jive Software&lt;/author&gt; --插件开发的作者  
    &lt;version&gt;1.1.0&lt;/version&gt;--插件版本  
    &lt;date&gt;12/1/2009&lt;/date&gt;--开发日期  
    &lt;minServerVersion&gt;3.7.0&lt;/minServerVersion&gt;

    &lt;databaseKey&gt;clientcontrol&lt;/databaseKey&gt;-- 插件自动生成数据的版本标识  
    &lt;databaseVersion&gt;0&lt;/databaseVersion&gt;--版本号  
   
    &lt;!-- 在控制台的页面展示，暂时不做过多介绍--&gt;  
    &lt;adminconsole&gt;    
         &lt;/adminconsole&gt;  
     
&lt;/plugin&gt;

 

下面主要介绍openfire中配置属性的读取和写入以及删除。

在openfire中 JiveGlobals类提供读取xml和数据配置的方法：

 

 private static XMLProperties xmlProperties = null;  
 private static JiveProperties properties = null;

XMLProperties ，主要获取本地的xml配置文件属性

对于 JiveProperties有如下sql,

private static final String LOAD\_PROPERTIES = "SELECT name, propValue FROM ofProperty";  
private static final String INSERT\_PROPERTY = "INSERT INTO ofProperty(name, propValue) VALUES(?,?)";private static final String UPDATE\_PROPERTY = "UPDATE ofProperty SET propValue=? WHERE name=?";  
private static final String DELETE\_PROPERTY = "DELETE FROM ofProperty WHERE name LIKE ?";

 

JiveProperties中提供了相关的删除属性，修改属性，创建属性，查询全部属性的方法，其中很多方法都涉及数据库的操作，数据库链接很费时，这样可能会影响系统性能。要是这个地方能够优化一下，系统就更好了。

 

而对于JiveGlobals，只是对2中属性处理的一种封装，以及一些通用格式日期和字符串的方法。

![](http://dl.iteye.com/upload/attachment/0081/7929/d2a8cf2c-5382-345b-b37e-c5bfdfc77db9.jpg)  
 

此篇文章就到此，稍后会有更多关于openfire的个人解读。

联系方式（qq）:851392159

出处：[http://buerkai.iteye.com](/)