网络会议openmeetings下的openmeetings-util文件分析6

2021SC@SDUSC

上篇文章对main下的类进行了分析,对ws下的IClusterWsMessage接口,main下的CalendarHelper类、CalendarPatterns类、ImportHelper类进行了分析。本篇将继续分析main下的类。

目录

ConnectionProperties类

NullStringer类

OMContextListener类

OmException类

Version类

总结


ConnectionProperties

public class ConnectionProperties implements Serializable {
   private static final long serialVersionUID = 1L;

   public enum DbType {
      db2
      , derby
      , mssql
      , mysql
      , oracle
      , postgresql
   }

   private String driver = "org.apache.derby.jdbc.EmbeddedDriver";
   private String url = "jdbc:derby:openmeetings";
   private String login = "user";
   private String password = "secret";
   private DbType dbType = DbType.derby;

   public String getDriver() {
      return driver;
   }

   public void setDriver(String driverName) {
      this.driver = driverName;
   }

   public String getURL() {
      return url;
   }

   public void setURL(String connectionURL) {
      this.url = connectionURL;
   }

   public String getLogin() {
      return login;
   }

   public void setLogin(String connectionLogin) {
      this.login = connectionLogin;
   }

   public String getPassword() {
      return password;
   }

   public void setPassword(String connectionPass) {
      this.password = connectionPass;
   }

   public DbType getDbType() {
      return dbType;
   }

   public void setDbType(DbType dbType) {
      this.dbType = dbType;
   }

   @Override
   public String toString() {
      return "ConnectionProperties [type=" + dbType + ", driver=" + driver + ", url=" + url + ", login=" + login + "]";
   }
}

ConnectionProperties类主要是用来配置数据库文件,实现了Serializable接口用来实现序列化,序列化是将对象状态转换为可保持或传输的格式的过程。与序列化相对的是反序列化,它将流转换为对象。这两个过程结合起来,可以轻松地存储和传输数据。首先定义了一个枚举变量DbType用来表示所连接的数据库类型,入db2、mysql、oracle等,定义了连接数据库的属性driver、url、login、password以及DbType。然后通过get和set方法来获取和设置属性值。以及重写了toString方法返回字符串"ConnectionProperties [type=" + dbType + ", driver=" + driver + ", url=" + url + ", login=" + login + "]"以便调用。

NullStringer类

public class NullStringer extends JSONStringer {
   public NullStringer() {
      super();
   }

   public NullStringer(int indent) {
      super(indent);
   }

   @Override
   public JSONStringer entry(Entry<String, Object> entry) {
      return this.key(entry.getKey()).value(entry.getValue());
   }
}

该NullStringer类继承了JSONStringer类,JSONStringer是工具包org.json.jar下的类,该工具包是一个轻量级的java下的json构造和解析工具包,JSONStringer是JSONWriter的子类,用法跟JSONWtriter几乎一样,可以用来构建一个JSON格式的文本,便于传输和存储,可以直接new JSONStringer()创建对象,不用传入构造参数。

其中NullStringer()构造方法继承父类构造方法。

public JSONStringer entry(Entry<String, Object> entry) {
   return this.key(entry.getKey()).value(entry.getValue());
}

entry方法将输入的键值对作为JSONStringer对象返回。

OMContextListener类

public class OMContextListener extends ContextLoggingListener {

   @Override
   public void contextInitialized(ServletContextEvent event) {
      setWebAppRootKey(pathToName(event));
      System.setProperty("current_openmeetings_context_name", getWebAppRootKey());
      System.setProperty("webapp.contextPath", String.format("/%s", getWebAppRootKey()));
      System.setProperty("logback.configurationFile", "logback-config.xml");
      super.contextInitialized(event);
   }

   private static String pathToName(ServletContextEvent event) {
      String contextName = event.getServletContext().getContextPath().replaceAll("/", "");
      if ("".equals(contextName)) {
         contextName = "root";
      }
      return contextName;
   }
}

OMContextListener类继承了ContextLoggingListener类,即日志内容监听。

其中pathToName(ServletContextEvent event)来获取该web项目的绝对路径。

web.xml文件中webAppRootKey属性是web项目的绝对路径,默认值是webApp.root,可以通过System.getProperty(“webApp.root”)来获取属性值或者在配置文件中通过${webApp.root}获得。

contextInitialized(ServletContextEvent event)方法中第一行是设置web项目的绝对路径,然后利用System.setProperty()方法当该openmeetings项目初始化时设置属性。设置current_openmeetings_context_name为当前绝对路径,设置webapp.contextPath同样为当前绝对路径的字符串格式,设置logback的配置文件为logback-config.xml。

OmException类

public class OmException extends Exception {
   private static final long serialVersionUID = 1L;
   public static final OmException UNKNOWN = new OmException("error.unknown");
   public static final OmException BAD_CREDENTIALS = new OmException("error.bad.credentials");
   private final String key;

   public OmException(String key) {
      super();
      this.key = key;
   }

   public OmException(Throwable cause) {
      super(cause);
      this.key = null;
   }

   public String getKey() {
      return key;
   }
}

Version类

public class Version {
   private static final Logger log = Red5LoggerFactory.getLogger(Version.class, OpenmeetingsVariables.getWebAppRootKey());
   private static final int TOTAL_LENGTH = 78;
   private static String version = null;
   private static String revision = null;
   private static String buildDate = null;
   static {
      try {
         Properties props = new Properties();
         try (InputStream is = Version.class.getResourceAsStream("version.properties")) {
            props.load(is);
         }
         version = props.getProperty("version");
         revision = props.getProperty("revision");
         buildDate = props.getProperty("date");
      } catch (Exception e) {
         log.error("Error", e);
      }
   }

   private Version() {}

   public static String getVersion() {
      return version;
   }

   public static String getRevision() {
      return revision;
   }

   public static String getBuildDate() {
      return buildDate;
   }

   private static void getLine(StringBuilder sb, String text, char fill) {
      sb.append("\t#");
      int l = text.length();
      int headLength = (TOTAL_LENGTH - l) / 2;
      for (int i = 0; i < headLength; ++i) {
         sb.append(fill);
      }
      sb.append(text);
      for (int i = 0; i < (TOTAL_LENGTH - l - headLength); ++i) {
         sb.append(fill);
      }
      sb.append("#\n");
   }

   public static void logOMStarted() {
      StringBuilder sb = new StringBuilder("\n");
      getLine(sb, "", '#');
      getLine(sb, "Openmeetings is up", ' ');
      getLine(sb, getVersion() + " " + getRevision() + " " + getBuildDate(), ' ');
      getLine(sb, "and ready to use", ' ');
      getLine(sb, "", '#');
      log.debug(sb.toString());
   }
}

Version类定义了Logger日志对象log,定义了一个常量TOTAL_LENGTH为78,version、revision、buildDate分别表示版本、修订版本和日期。其中三个get方法来获取这三个属性。然后getLine(StringBuilder sb,String text,char fill):获取传入的参数text的长度,然后添加一定长度的fill字符(一般是空格  符合)至缓冲区,然后在缓冲区加入text内容,再添加一定长度的fill字符加入至缓冲区。

logOMStarted()方法,即是当openmeetings启动时,将会打印如下内容:# Openmeetings is up 版本号+修改版本+日期 and ready to use #。

总结

本篇文章分析了main下的:ConnectionProperties类、NullStringer类、OMContextListener类、OmException类、Version类。后面将继续分析main下的类,还剩下OmFileHelper类、OpenmeetingsVariables类、StoredFile类、XmlExport类,则openmeetings-util包分析完毕。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Openmeetings提供视频会议,即时消息,白板,协作文档编辑和其他组件软件工具。它使用Media Server的API函数进行远程和流媒体Kurento。 OpenMeetings是一个多语言可定制的视频会议和协作系统。它支持音频、视频,能让你查看每个与会者的桌面。OpenMeetings还包含一个白板,通过白板可以导入各种格式的图片和涂鸦。 功能细节: 音频和视频会议 有四个使用OpenMeetings音频/视频功能的选项,您可以在会议期间选择它们。 音频+视频 仅音频 仅视频 仅图片 另外,您可以更改视频/音频质量,选择多个摄像机分辨率(4:3、16:9或3:2),然后选择输入设备。 会议录制和屏幕共享 录制的会议包含一切内容,包括从所有音频流中录制的声音,完全按照您在会议中看到的方式进行。 录制的会话可以下载为AVI / FLV文件。 可以选择共享的屏幕区域。 屏幕共享的不同质量步骤。 在集成的拖放文件资源管理器中观看和整理录音 文件管理器 每个会议室都有高级File-Explorer,拖放界面用于管理上载的文件,包括使用文件夹创建文档树的可能性。 File-Explorer中的私有和公共驱动器。File-Explorer有两个不同的视图,一个是Private Drive,另一个是Public Drive。专用驱动器始终包含相同的文件。这些文件仅对当前登录的用户可见。公共驱动器不与用户绑定,而是与会议室绑定。会议室中的所有用户都可以访问公共驱动器。 审核系统 在会议期间,主持人可以针对每个用户分别调整用户权限。  允许/拒绝审核  允许/拒绝权利在白板上绘画  添加/删除演示者角色  允许/拒绝屏幕共享/记录屏幕  允许/拒绝远程控制屏幕  允许/拒绝“静音其他人”权限  让其他用户静音时让一个用户讲话  允许/拒绝视频  允许/拒绝音频 Multi白板和聊天 在Multi白板中,您可以添加新的白板实例,每个白板中都可以包含所有工具和文档。 保存白板。您可以将每个白板实例另存为一个文件。该文件位于File-Explorer中,可以再次拖放到白板上,并且可以像其他任何文档,图像或文件夹一样组织。 带有绘图,书写,拖放,调整大小,图像(来自File-Explorer的拖放),Symbol / sCliparts的白板。 Full-fit确实会重新缩放屏幕上的文档,使其在所有屏幕上均100%可见,无论不同用户使用哪种屏幕分辨率。 您可以导入各种文档格式(PDF,DOC,ODT,PPT等) 用户和房间管理 您可以在单个OpenMeetings实例中管理用户和多个组织。您还可以创建只能通过SOAP-API进行访问的用户。 MyRooms部分。默认情况下,每个用户都有2个私人房间,该房间始终仅供该用户访问。有一些按钮可从仪表板进入这些房间。 您可以将会议室分配给所有用户,也可以仅将它们分配给特定的用户组。 私人留言中心 向用户发送消息并将其组织在文件夹中。您可以通过发送私人消息预订会议室。预订的活动将自动出现在您和参与者的日历中,对该活动的更改将填充到预订该活动的所有用户中。 用户联系人,您可以搜索用户并将其添加到您的联系人中。您甚至可以授予他们查看日历的权利。 使用集成的日历计划会议 计划您的会议并邀请OpenMeetings或External的与会者。 被邀请的与会者将收到一封包含会议详细信息的电子邮件,以及带有安全哈希表的会议室链接。 与您的联系人共享您的日历。 投票和投票 您可以使用是/否或1-10个问题创建民意调查,让用户投票并查看投票结果。 可以存储民意测验并将结果显示为饼图 后备 您可以将所有用户生成的数据(包括用户上传的文件)备份到一个ZIP文件中,然后将该ZIP导入到新安装的OpenMeetings中。 使用者介面: 翻译得到改善 邀请表显示客户所在时区的时间 使用JS Notification API显示通知 视频窗格的大小可以是固定的,并且可以按用户配置

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值