Smack.java

  1. /**
  2.  *
  3.  * Copyright 2020-2021 Florian Schmaus
  4.  *
  5.  * Licensed under the Apache License, Version 2.0 (the "License");
  6.  * you may not use this file except in compliance with the License.
  7.  * You may obtain a copy of the License at
  8.  *
  9.  *     http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.jivesoftware.smack;

  18. import java.io.InputStream;
  19. import java.util.logging.Logger;

  20. import org.jivesoftware.smack.util.FileUtils;

  21. public class Smack {

  22.     private static final Logger LOGGER = Logger.getLogger(Smack.class.getName());

  23.     private static final String SMACK_ORG = "org.jivesoftware";

  24.     public static final String SMACK_PACKAGE = SMACK_ORG + ".smack";

  25.     /**
  26.      * Returns the Smack version information, e.g."1.3.0".
  27.      *
  28.      * @return the Smack version information.
  29.      */
  30.     public static String getVersion() {
  31.         return SmackInitialization.SMACK_VERSION;
  32.     }

  33.     private static final String NOTICE_RESOURCE = SMACK_PACKAGE + "/NOTICE";

  34.     /**
  35.      * Get the stream of the NOTICE file of Smack.
  36.      * <p>
  37.      * This license of Smack requires that the contents of this NOTICE text file are shown "…within a display generated by
  38.      * the Derivative Works, if and wherever such third-party notices normally appear.".
  39.      * </p>
  40.      *
  41.      * @return the stream of the NOTICE file of Smack.
  42.      * @since 4.4.0
  43.      */
  44.     public static InputStream getNoticeStream() {
  45.         InputStream res = FileUtils.getInputStreamForClasspathFile(NOTICE_RESOURCE);
  46.         assert res != null;
  47.         return res;
  48.     }

  49.     public static void ensureInitialized() {
  50.         if (SmackConfiguration.isSmackInitialized()) {
  51.             return;
  52.         }

  53.         String version = getVersion();
  54.         LOGGER.finest("Smack " + version + " has been initialized");
  55.     }
  56. }