Example usage for org.apache.commons.logging Log warn

List of usage examples for org.apache.commons.logging Log warn

Introduction

In this page you can find the example usage for org.apache.commons.logging Log warn.

Prototype

void warn(Object message, Throwable t);

Source Link

Document

Logs an error with warn log level.

Usage

From source file:net.sf.nmedit.nomad.core.NomadLoader.java

private void initLookAndFeel(String lafClassName, String themeClassName, String defaultLafOnPlatform) {
    EnumSet<Platform.OS> defaultLafPlatforms = EnumSet.noneOf(Platform.OS.class);
    {/*  www .  ja v a2 s .  co m*/
        // remove whitespace + lowercase
        defaultLafOnPlatform = defaultLafOnPlatform.replaceAll("\\s", "").toLowerCase();
        // split comma separated list
        String[] dlop = defaultLafOnPlatform.split(",");
        // check items
        for (String s : dlop) {
            if (s.equals("all")) {
                // on all platforms
                defaultLafPlatforms.addAll(EnumSet.allOf(Platform.OS.class));
                break;
            } else if (s.equals("mac")) {
                defaultLafPlatforms.add(Platform.OS.MacOSFlavor);
            } else if (s.equals("unix")) {
                defaultLafPlatforms.add(Platform.OS.UnixFlavor);
            } else if (s.equals("windows")) {
                defaultLafPlatforms.add(Platform.OS.WindowsFlavor);
            }
        }
    }

    // jgoodies specific properties

    PlasticLookAndFeel.setTabStyle(PlasticLookAndFeel.TAB_STYLE_METAL_VALUE);
    //UIManager.put(Options.POPUP_DROP_SHADOW_ENABLED_KEY, Boolean.FALSE);
    Options.setPopupDropShadowEnabled(false);
    Options.setUseNarrowButtons(true);

    //UIManager.put(Options.PLASTIC_MENU_FONT_KEY, new FontUIResource("Verdana", Font.PLAIN, 9));
    //PlasticLookAndFeel.setFontPolicy(FontPolicies.getDefaultWindowsPolicy());
    /*
            UIManager.put("MenuItem.margin", new InsetsUIResource(2,2,1,2));
            UIManager.put("Menu.margin", new InsetsUIResource(1,2,1,2));
            */
    // set the metal theme

    if (defaultLafPlatforms.contains(Platform.flavor())) {
        // use default LAF on current platform

        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Throwable e) {
            Log log = LogFactory.getLog(getClass());
            log.warn("could not set look and feel theme", e);

        }

        if (Platform.isFlavor(Platform.OS.MacOSFlavor)) {
            System.setProperty("apple.laf.useScreenMenuBar", "true");
        }

    } else {
        // use LAF setting

        MetalTheme theme = null;
        if (themeClassName != null) {
            try {
                theme = (MetalTheme) Class.forName(themeClassName).newInstance();
                UIManager.put("Plastic.theme", themeClassName);

                if (theme instanceof PlasticTheme) {
                    PlasticLookAndFeel.setPlasticTheme((PlasticTheme) theme);
                    // PlasticLookAndFeel.setTabStyle(settings.getPlasticTabStyle());
                } else if (theme instanceof MetalTheme) {
                    MetalLookAndFeel.setCurrentTheme(theme);
                }

            } catch (Throwable e) {
                Log log = LogFactory.getLog(getClass());
                log.warn("could not set look and feel theme", e);
            }
        }
        // set the look and feel
        if (lafClassName != null) {
            try {
                LookAndFeel LAF = (LookAndFeel) Class.forName(lafClassName).newInstance();
                // it is very important to set the classloader  
                UIManager.getDefaults().put("ClassLoader", getClass().getClassLoader());
                UIManager.setLookAndFeel(LAF);
            } catch (Throwable e) {
                Log log = LogFactory.getLog(getClass());
                log.warn("could not set custom look and feel", e);
            }
        }
    }

}

From source file:net.sf.nmedit.jtheme.store.DefaultStorageContext.java

private ComponentElement tryBuildComponentStore(Element moduleElement, Element element) {
    try {/*from  ww w.j ava2s .  c  o m*/
        return buildComponentStore(element);
    } catch (JTException e) {
        Log log = getLogger();
        if (log.isWarnEnabled()) {
            log.warn("could not create component store for element " + element.getName() + " (parent "
                    + moduleElement.getAttributeValue("component-id") + ")", e);
        }
        return null;
    }
}

From source file:net.sf.nmedit.jtheme.store.DefaultStorageContext.java

private ComponentElement buildComponentStore(Element element) throws JTException {
    // TODO not all elements can be handled ????
    try {//w  w w.  j a  v  a 2  s .com
        return createStore(element);
    } catch (JTException e) {
        // TODO find a better solution for unsupported elements
        if (e.getMessage().startsWith("No store for element")) {
            Log log = getLogger();
            if (log.isWarnEnabled()) {
                log.warn(this, e);
            }
            return null;
        }
        throw e;
    }
}

From source file:net.sf.nmedit.jtheme.store.DefaultStorageContext.java

private void buildCssFromString(String cssText) throws JTException {
    CSSOMParser cssParser = CSSUtils.getCSSOMParser();
    try {//from ww  w  .  j  a  v a 2 s  .com
        // TODO set uri ???
        //source.setURI(arg0)
        if (cssText == null)
            return;

        org.w3c.css.sac.InputSource source = new org.w3c.css.sac.InputSource(new StringReader(cssText));

        styleSheet = cssParser.parseStyleSheet(source, null, null);
    } catch (NullPointerException e) {
        Log log = getLogger();
        if (log.isWarnEnabled()) {
            log.warn("buildCssFromString", e);
        }
    } catch (IOException e) {
        Log log = getLogger();
        if (log.isWarnEnabled()) {
            log.warn("buildCssFromString", e);
        }
        return;
        // throw new JTException(e);
    }
}

From source file:com.amazon.carbonado.repo.replicated.ReplicationTrigger.java

/**
 * Runs a repair in a background thread. This is done for two reasons: It
 * allows repair to not be hindered by locks acquired by transactions and
 * repairs don't get rolled back when culprit exception is thrown. Culprit
 * may be UniqueConstraintException or OptimisticLockException.
 *///from ww w.j  a  v  a 2  s  . c om
private void repair(S replica) throws PersistException {
    replica = (S) replica.copy();
    S master = mMasterStorage.prepare();
    // Must copy more than just primary key properties to master since
    // replica object might only have alternate keys.
    replica.copyAllProperties(master);

    try {
        if (replica.tryLoad()) {
            if (master.tryLoad()) {
                if (replica.equalProperties(master)) {
                    // Both are equal -- no repair needed.
                    return;
                }
            }
        } else {
            if (!master.tryLoad()) {
                // Both are missing -- no repair needed.
                return;
            }
        }
    } catch (IllegalStateException e) {
        // Can be caused by not fully defining the primary key on the
        // replica, but an alternate key is. The insert will fail anyhow,
        // so don't try to repair.
        return;
    } catch (FetchException e) {
        throw e.toPersistException();
    }

    final S finalReplica = replica;
    final S finalMaster = master;

    RepairExecutor.execute(new Runnable() {
        public void run() {
            try {
                Transaction txn = mRepository.enterTransaction();
                try {
                    txn.setForUpdate(true);
                    if (finalReplica.tryLoad()) {
                        if (finalMaster.tryLoad()) {
                            resyncEntries(null, finalReplica, finalMaster, false);
                        } else {
                            resyncEntries(null, finalReplica, null, false);
                        }
                    } else if (finalMaster.tryLoad()) {
                        resyncEntries(null, null, finalMaster, false);
                    }
                    txn.commit();
                } finally {
                    txn.exit();
                }
            } catch (FetchException fe) {
                Log log = LogFactory.getLog(ReplicatedRepository.class);
                log.warn("Unable to check if repair is required for " + finalReplica.toStringKeyOnly(), fe);
            } catch (PersistException pe) {
                Log log = LogFactory.getLog(ReplicatedRepository.class);
                log.error("Unable to repair entry " + finalReplica.toStringKeyOnly(), pe);
            }
        }
    });
}

From source file:com.moss.error_reporting.client.ErrorReportProxyFactory.java

private static ProxyFactory create(ProxyProviderOption option, ProxyProviderOption defaultOption) {

    Log log = LogFactory.getLog(ErrorReportProxyFactory.class);

    if (option == null) {

        if (log.isDebugEnabled()) {
            log.debug(//from w  w  w  . j  a va 2 s .co m
                    "No option was provided as an argument, attempting to determine option from system property '"
                            + PROXY_PROVIDER_PROPERTY + "'");
        }

        try {
            String prop = System.getProperty(PROXY_PROVIDER_PROPERTY);
            if (prop != null) {
                option = ProxyProviderOption.valueOf(prop.toUpperCase());

                if (option == null) {
                    if (log.isDebugEnabled()) {
                        log.debug("Could not determine option from system property '" + PROXY_PROVIDER_PROPERTY
                                + "': " + prop);
                    }
                } else {
                    if (log.isDebugEnabled()) {
                        log.debug("Determined option from system property '" + PROXY_PROVIDER_PROPERTY + "': "
                                + option);
                    }
                }
            } else {
                if (log.isDebugEnabled()) {
                    log.debug("The system property '" + PROXY_PROVIDER_PROPERTY
                            + "' was not set, cannot use it to determine which option to use.");
                }
            }
        } catch (Exception ex) {
            log.warn(
                    "Encountered unexpected failure while attempting to determine which option to use from system property '"
                            + PROXY_PROVIDER_PROPERTY + "'",
                    ex);
        }

        if (option == null) {
            if (defaultOption == null) {
                throw new RuntimeException(
                        "No default option was provided, cannot determine which option to use for supplying the proxy provider.");
            } else {
                if (log.isDebugEnabled()) {
                    log.debug("No specific option was chosen, using default option: " + defaultOption);
                }
                option = defaultOption;
            }
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Option " + option + " was provided as an argument, using it directly.");
        }
    }

    ProxyProvider prov = option.makeProvider();
    ProxyFactory factory = new ProxyFactory(prov);

    return factory;
}

From source file:com.moss.identity.veracity.VeracityProxyFactory.java

private static ProxyFactory create(ProxyProviderOption option, ProxyProviderOption defaultOption) {

    Log log = LogFactory.getLog(VeracityProxyFactory.class);

    if (option == null) {

        if (log.isDebugEnabled()) {
            log.debug(/*from ww w .  j av a 2  s .co m*/
                    "No option was provided as an argument, attempting to determine option from system property '"
                            + PROXY_PROVIDER_PROPERTY + "'");
        }

        try {
            String prop = System.getProperty(PROXY_PROVIDER_PROPERTY);
            if (prop != null) {
                option = ProxyProviderOption.valueOf(prop.toUpperCase());

                if (option == null) {
                    if (log.isDebugEnabled()) {
                        log.debug("Could not determine option from system property '" + PROXY_PROVIDER_PROPERTY
                                + "': " + prop);
                    }
                } else {
                    if (log.isDebugEnabled()) {
                        log.debug("Determined option from system property '" + PROXY_PROVIDER_PROPERTY + "': "
                                + option);
                    }
                }
            } else {
                if (log.isDebugEnabled()) {
                    log.debug("The system property '" + PROXY_PROVIDER_PROPERTY
                            + "' was not set, cannot use it to determine which option to use.");
                }
            }
        } catch (Exception ex) {
            log.warn(
                    "Encountered unexpected failure while attempting to determine which option to use from system property '"
                            + PROXY_PROVIDER_PROPERTY + "'",
                    ex);
        }

        if (option == null) {
            if (defaultOption == null) {
                throw new RuntimeException(
                        "No default option was provided, cannot determine which option to use for supplying the proxy provider.");
            } else {
                if (log.isDebugEnabled()) {
                    log.debug("No specific option was chosen, using default option: " + defaultOption);
                }
                option = defaultOption;
            }
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Option " + option + " was provided as an argument, using it directly.");
        }
    }

    ProxyProvider prov = option.makeProvider();
    ProxyFactory factory = new ProxyFactory(prov);

    return factory;
}

From source file:com.moss.error_reporting.server.TestErrorReportProxyFactory.java

private static ProxyFactory create(ProxyProviderOption option, ProxyProviderOption defaultOption) {

    Log log = LogFactory.getLog(TestErrorReportProxyFactory.class);

    if (option == null) {

        if (log.isDebugEnabled()) {
            log.debug(/*from  w  ww.j av  a  2  s. c om*/
                    "No option was provided as an argument, attempting to determine option from system property '"
                            + PROXY_PROVIDER_PROPERTY + "'");
        }

        try {
            String prop = System.getProperty(PROXY_PROVIDER_PROPERTY);
            if (prop != null) {
                option = ProxyProviderOption.valueOf(prop.toUpperCase());

                if (option == null) {
                    if (log.isDebugEnabled()) {
                        log.debug("Could not determine option from system property '" + PROXY_PROVIDER_PROPERTY
                                + "': " + prop);
                    }
                } else {
                    if (log.isDebugEnabled()) {
                        log.debug("Determined option from system property '" + PROXY_PROVIDER_PROPERTY + "': "
                                + option);
                    }
                }
            } else {
                if (log.isDebugEnabled()) {
                    log.debug("The system property '" + PROXY_PROVIDER_PROPERTY
                            + "' was not set, cannot use it to determine which option to use.");
                }
            }
        } catch (Exception ex) {
            log.warn(
                    "Encountered unexpected failure while attempting to determine which option to use from system property '"
                            + PROXY_PROVIDER_PROPERTY + "'",
                    ex);
        }

        if (option == null) {
            if (defaultOption == null) {
                throw new RuntimeException(
                        "No default option was provided, cannot determine which option to use for supplying the proxy provider.");
            } else {
                if (log.isDebugEnabled()) {
                    log.debug("No specific option was chosen, using default option: " + defaultOption);
                }
                option = defaultOption;
            }
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Option " + option + " was provided as an argument, using it directly.");
        }
    }

    ProxyProvider prov = option.makeProvider();
    ProxyFactory factory = new ProxyFactory(prov);

    return factory;
}

From source file:net.sf.jabb.util.ex.LoggedException.java

/**
 * Create a new instance, and at the same time, ensure the original exception is logged.
 * //from w w w  .  j a  v a  2 s  . c o  m
 * @param log      the log utility
 * @param level      level of the log
 * @param message   description
 * @param cause      the original exception. If it is of type LoggedException, 
 *                then the newly created instance is a clone of itself.
 */
public LoggedException(Log log, int level, String message, Throwable cause) {
    super(cause instanceof LoggedException ? cause.getMessage() : message,
            cause instanceof LoggedException ? cause.getCause() : cause);
    if (!(cause instanceof LoggedException)) {
        switch (level) {
        case TRACE:
            if (log.isTraceEnabled()) {
                log.trace(message, cause);
            }
            break;
        case DEBUG:
            if (log.isDebugEnabled()) {
                log.debug(message, cause);
            }
            break;
        case WARN:
            if (log.isWarnEnabled()) {
                log.warn(message, cause);
            }
            break;
        case FATAL:
            log.fatal(message, cause);
            break;
        case INFO:
            log.info(message, cause);
            break;
        default:
            log.error(message, cause);
        }
    }
}

From source file:net.sf.nmedit.nomad.core.NomadLoader.java

public Nomad createNomad(final NomadPlugin plugin) {
    NomadLoader.plugin = plugin;//from   w ww. j  a v  a  2s  .c o m

    // first get the boot progress callbeck
    final SplashHandler progress = Boot.getSplashHandler();
    // initializing ...
    progress.setText("Initializing Nomad...");
    progress.setProgress(0.1f);
    // now we read all property files
    // 1. nomad.properties
    final Properties nProperties = new Properties();
    getProperties(nProperties, Nomad.getCorePropertiesFile());

    RootSystemProperties sproperties = new RootSystemProperties(nProperties);
    SystemPropertyFactory.sharedInstance().setFactory(new NomadPropertyFactory(sproperties));

    // 1.2 init locale
    initLocale();
    // 1.4 menu layout configuration
    InputStream mlIn = null;
    try {
        ClassLoader loader = getClass().getClassLoader();
        mlIn = loader.getResourceAsStream("./MenuLayout.xml");

        menuLayout = MenuLayout.getLayout(new BufferedInputStream(mlIn));
    } catch (Exception e) {
        Log log = LogFactory.getLog(getClass());
        if (log.isFatalEnabled()) {
            log.fatal("could not read MenuLayout", e);
        }
        throw new RuntimeException(e);
    } finally {
        try {
            if (mlIn != null)
                mlIn.close();
        } catch (IOException e) {
            Log log = LogFactory.getLog(NomadLoader.class);
            if (log.isWarnEnabled()) {
                log.warn("closing menu layout", e);
            }
        }
    }
    // increase progress
    progress.setProgress(0.2f);
    // 1.5 initialize look and feel (important: before creating any swing components)

    String lafClassName = plugin.getDescriptor().getAttribute("javax.swing.LookAndFeel").getValue();
    String themeClassName = plugin.getDescriptor().getAttribute("javax.swing.plaf.metal.MetalTheme").getValue();
    String defaultLafOnPlatform = plugin.getDescriptor().getAttribute("nomad.plaf.usePlatformDefault")
            .getValue();

    initLookAndFeel(lafClassName, themeClassName, defaultLafOnPlatform);
    // 1.6 initialize main window's menu
    progress.setProgress(0.3f);

    /*     NomadActionControl nomadActions = new NomadActionControl( Nomad.sharedInstance() );
          nomadActions.installActions(menuBuilder);
      */
    progress.setProgress(0.5f);
    progress.setText("Initializing main window...");

    activatePlugins();

    progress.setText("Initializing services...");

    JPFServiceInstallerTool.activateAllServices(plugin);
    progress.setText("Starting Nomad...");

    // SwingUtilities.invokeLater(run);

    Nomad nomad = new Nomad(plugin, menuLayout);
    return nomad;
}