Java URL Resolve resolveXmlConfigUrl(@Nullable URL defaultXmlConfigUrl)

Here you can find the source of resolveXmlConfigUrl(@Nullable URL defaultXmlConfigUrl)

Description

resolve Xml Config Url

License

Mozilla Public License

Declaration

@Nonnull
    private static URL resolveXmlConfigUrl(@Nullable URL defaultXmlConfigUrl) 

Method Source Code

//package com.java2s;
/*****************************************************************************************
 * *** BEGIN LICENSE BLOCK *****/*from  ww  w  .j a va2  s  . co m*/
 *
 * Version: MPL 2.0
 *
 * echocat Jomon, Copyright (c) 2012-2013 echocat
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * *** END LICENSE BLOCK *****
 ****************************************************************************************/

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import java.net.MalformedURLException;
import java.net.URL;

public class Main {
    @Nonnull
    private static URL resolveXmlConfigUrl(@Nullable URL defaultXmlConfigUrl) {
        final String plainConfigUrl = System.getProperty("log4j.configuration",
                defaultXmlConfigUrl != null ? defaultXmlConfigUrl.toExternalForm() : null);
        if (plainConfigUrl == null) {
            throw new IllegalArgumentException("The system property 'log4j.configuration' is not set.");
        }
        try {
            return new URL(plainConfigUrl);
        } catch (final MalformedURLException e) {
            throw new IllegalArgumentException("The given xmlConfig '" + plainConfigUrl + "' is no valid url.", e);
        }
    }
}

Related

  1. resolveURL(String urlValue)
  2. resolveURL(URL base, String target)
  3. resolveURL(URL contextURL, String url)
  4. resolveURL(URL url)
  5. resolveWsURI(String url)
  6. reverseUrl(String urlString)