001/** 002 * 003 * Copyright 2020-2021 Florian Schmaus 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.jivesoftware.smack; 018 019import java.io.InputStream; 020import java.util.logging.Logger; 021 022import org.jivesoftware.smack.util.FileUtils; 023 024public class Smack { 025 026 private static final Logger LOGGER = Logger.getLogger(Smack.class.getName()); 027 028 private static final String SMACK_ORG = "org.jivesoftware"; 029 030 public static final String SMACK_PACKAGE = SMACK_ORG + ".smack"; 031 032 /** 033 * Returns the Smack version information, eg "1.3.0". 034 * 035 * @return the Smack version information. 036 */ 037 public static String getVersion() { 038 return SmackInitialization.SMACK_VERSION; 039 } 040 041 private static final String NOTICE_RESOURCE = SMACK_PACKAGE + "/NOTICE"; 042 043 /** 044 * Get the stream of the NOTICE file of Smack. 045 * <p> 046 * This license of Smack requires that the contents of this NOTICE text file are shown "…within a display generated by 047 * the Derivative Works, if and wherever such third-party notices normally appear.". 048 * </p> 049 * 050 * @return the stream of the NOTICE file of Smack. 051 * @since 4.4.0 052 */ 053 public static InputStream getNoticeStream() { 054 InputStream res = FileUtils.getInputStreamForClasspathFile(NOTICE_RESOURCE); 055 assert res != null; 056 return res; 057 } 058 059 public static void ensureInitialized() { 060 if (SmackConfiguration.isSmackInitialized()) { 061 return; 062 } 063 064 String version = getVersion(); 065 LOGGER.finest("Smack " + version + " has been initialized"); 066 } 067}