Java Code Examples for org.jivesoftware.util.JiveGlobals#getXMLProperty()
The following examples show how to use
org.jivesoftware.util.JiveGlobals#getXMLProperty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XMPPServerInfoImpl.java From Openfire with Apache License 2.0 | 6 votes |
@Override public String getHostname() { final String fqdn = JiveGlobals.getXMLProperty( "fqdn" ); if ( fqdn != null && !fqdn.trim().isEmpty() ) { return fqdn.trim().toLowerCase(); } try { return InetAddress.getLocalHost().getCanonicalHostName().toLowerCase(); } catch (UnknownHostException ex) { Log.warn( "Unable to determine local hostname.", ex ); return "localhost"; } }
Example 2
Source File: DbConnectionManager.java From Openfire with Apache License 2.0 | 6 votes |
/** * Ensures that the connection provider exists and is set */ private static void ensureConnectionProvider() { if (connectionProvider != null) return; synchronized (providerLock) { if (connectionProvider != null) return; // Attempt to load the connection provider classname as a Jive property. String className = JiveGlobals.getXMLProperty("connectionProvider.className"); if (className != null) { // Attempt to load the class. try { Class conClass = ClassUtils.forName(className); setConnectionProvider((ConnectionProvider)conClass.newInstance()); } catch (Exception e) { Log.warn("Failed to create the " + "connection provider specified by connection" + "Provider.className. Using the default pool.", e); setConnectionProvider(new DefaultConnectionProvider()); } } else { setConnectionProvider(new DefaultConnectionProvider()); } } }
Example 3
Source File: ConnectionManagerImpl.java From Openfire with Apache License 2.0 | 5 votes |
/** * Returns the specific network interface on which Openfire is configured to listen, or null when no such preference * has been configured. * * @return A network interface or null. * @throws UnknownHostException When the configured network name cannot be resolved. */ public InetAddress getListenAddress() throws UnknownHostException { String interfaceName = JiveGlobals.getXMLProperty( "network.interface" ); InetAddress bindInterface = null; if (interfaceName != null) { if (interfaceName.trim().length() > 0) { bindInterface = InetAddress.getByName(interfaceName); } } return bindInterface; }
Example 4
Source File: ConnectionManagerImpl.java From Openfire with Apache License 2.0 | 5 votes |
/** * Returns the specific network interface on which the Openfire administration * console should be configured to listen, or null when no such preference * has been configured. * * @return A network interface or null. * @throws UnknownHostException When the configured network name cannot be resolved. */ public InetAddress getAdminConsoleListenAddress() throws UnknownHostException { String acInterfaceName = JiveGlobals.getXMLProperty( "adminConsole.interface" ); InetAddress acBindInterface = null; if (acInterfaceName != null) { if (acInterfaceName.trim().length() > 0) { acBindInterface = InetAddress.getByName(acInterfaceName); } } return acBindInterface; }
Example 5
Source File: HttpBindManager.java From Openfire with Apache License 2.0 | 5 votes |
private String getBindInterface() { String interfaceName = JiveGlobals.getXMLProperty("network.interface"); String bindInterface = null; if (interfaceName != null) { if (interfaceName.trim().length() > 0) { bindInterface = interfaceName; } } return bindInterface; }
Example 6
Source File: AuthFactory.java From Openfire with Apache License 2.0 | 5 votes |
public static AuthToken checkOneTimeAccessToken(String userToken) throws UnauthorizedException { String accessToken = JiveGlobals.getXMLProperty(ONE_TIME_PROPERTY); if (isOneTimeAccessTokenEnabled() && accessToken.equals(userToken)) { // Remove the one time token. // This invocation will overwrite the openfire.xml with removing the OneTimeAccessToken tag. JiveGlobals.deleteXMLProperty(ONE_TIME_PROPERTY); Log.info("Login with the one time access token."); return AuthToken.generateOneTimeToken(accessToken); } else { throw new UnauthorizedException(); } }
Example 7
Source File: AdminConsolePlugin.java From Openfire with Apache License 2.0 | 5 votes |
/** * Returns {@code null} if the admin console will be available in all network interfaces of this machine * or a String representing the only interface where the admin console will be available. * * @return String representing the only interface where the admin console will be available or null if it * will be available in all interfaces. */ public String getBindInterface() { String adminInterfaceName = JiveGlobals.getXMLProperty("adminConsole.interface"); String globalInterfaceName = JiveGlobals.getXMLProperty("network.interface"); String bindInterface = null; if (adminInterfaceName != null && adminInterfaceName.trim().length() > 0) { bindInterface = adminInterfaceName; } else if (globalInterfaceName != null && globalInterfaceName.trim().length() > 0) { bindInterface = globalInterfaceName; } return bindInterface; }
Example 8
Source File: DefaultConnectionProvider.java From Openfire with Apache License 2.0 | 5 votes |
/** * Load properties that already exist from Jive properties. */ private void loadProperties() { driver = JiveGlobals.getXMLProperty("database.defaultProvider.driver"); serverURL = JiveGlobals.getXMLProperty("database.defaultProvider.serverURL"); username = JiveGlobals.getXMLProperty("database.defaultProvider.username"); password = JiveGlobals.getXMLProperty("database.defaultProvider.password"); String minCons = JiveGlobals.getXMLProperty("database.defaultProvider.minConnections"); String maxCons = JiveGlobals.getXMLProperty("database.defaultProvider.maxConnections"); String conTimeout = JiveGlobals.getXMLProperty("database.defaultProvider.connectionTimeout"); testSQL = JiveGlobals.getXMLProperty("database.defaultProvider.testSQL", DbConnectionManager.getTestSQL(driver)); testBeforeUse = JiveGlobals.getXMLProperty("database.defaultProvider.testBeforeUse", false); testAfterUse = JiveGlobals.getXMLProperty("database.defaultProvider.testAfterUse", false); testTimeout = JiveGlobals.getXMLProperty("database.defaultProvider.testTimeout", (int) JiveConstants.SECOND / 2); timeBetweenEvictionRuns = JiveGlobals.getXMLProperty("database.defaultProvider.timeBetweenEvictionRuns", (int) (30 * JiveConstants.SECOND)); minIdleTime = JiveGlobals.getXMLProperty("database.defaultProvider.minIdleTime", (int) (15 * JiveConstants.MINUTE)); maxWaitTime = JiveGlobals.getXMLProperty("database.defaultProvider.maxWaitTime", (int) JiveConstants.SECOND / 2); // See if we should use Unicode under MySQL mysqlUseUnicode = Boolean.valueOf(JiveGlobals.getXMLProperty("database.mysql.useUnicode")); try { if (minCons != null) { minConnections = Integer.parseInt(minCons); } if (maxCons != null) { maxConnections = Integer.parseInt(maxCons); } if (conTimeout != null) { connectionTimeout = Double.parseDouble(conTimeout); } } catch (Exception e) { Log.error("Error: could not parse default pool properties. " + "Make sure the values exist and are correct.", e); } }
Example 9
Source File: JNDIDataSourceProvider.java From Openfire with Apache License 2.0 | 4 votes |
/** * Constructs a new JNDI pool. */ public JNDIDataSourceProvider() { dataSourceName = JiveGlobals.getXMLProperty("database.JNDIProvider.name"); }
Example 10
Source File: DbConnectionManager.java From Openfire with Apache License 2.0 | 4 votes |
/** * Returns a database connection from the currently active connection * provider. An exception will be thrown if no connection was found. * (auto commit is set to true). * * @return a connection. * @throws SQLException if a SQL exception occurs or no connection was found. */ public static Connection getConnection() throws SQLException { ensureConnectionProvider(); Integer currentRetryCount = 0; Integer maxRetries = JiveGlobals.getXMLProperty(SETTING_DATABASE_MAX_RETRIES, 10); Integer retryWait = JiveGlobals.getXMLProperty(SETTING_DATABASE_RETRY_DELAY, 250); // milliseconds SQLException lastException = null; boolean loopIfNoConnection = false; do { try { Connection con = connectionProvider.getConnection(); if (con != null) { // Got one, lets hand it off. // Usually profiling is not enabled. So we return a normal // connection unless profiling is enabled. If yes, wrap the // connection with a profiled connection. if (!profilingEnabled) { return con; } else { return new ProfiledConnection(con); } } } catch (SQLException e) { // TODO distinguish recoverable from non-recoverable exceptions. lastException = e; Log.info("Unable to get a connection from the database pool " + "(attempt " + currentRetryCount + " out of " + maxRetries + ").", e); } currentRetryCount++; loopIfNoConnection = currentRetryCount <= maxRetries; if (loopIfNoConnection) { try { Thread.sleep(retryWait); } catch (InterruptedException ex) { String msg = "Interrupted waiting for DB connection"; Log.info(msg,ex); Thread.currentThread().interrupt(); throw new SQLException(msg,ex); } } } while (loopIfNoConnection); throw new SQLException("ConnectionManager.getConnection() " + "failed to obtain a connection after " + currentRetryCount + " retries. " + "The exception from the last attempt is as follows: " + lastException); }
Example 11
Source File: ClusterManager.java From Openfire with Apache License 2.0 | 2 votes |
/** * Returns true if clustering support is enabled. This does not mean * that clustering has started or that clustering will be able to start. * * @return true if clustering support is enabled. */ public static boolean isClusteringEnabled() { return JiveGlobals.getXMLProperty(CLUSTER_PROPERTY_NAME, false); }