Example usage for org.apache.commons.logging LogFactory getFactory

List of usage examples for org.apache.commons.logging LogFactory getFactory

Introduction

In this page you can find the example usage for org.apache.commons.logging LogFactory getFactory.

Prototype

@Deprecated
public static LogFactory getFactory() 

Source Link

Document

This method only exists for compatibility with unusual Commons Logging API usage like e.g.

Usage

From source file:uk.ac.ed.epcc.webapp.logging.commons.CommonsLoggerService.java

public CommonsLoggerService(AppContext c) {
    fac = LogFactory.getFactory();
    this.c = c;
}

From source file:webreader.WebReader.java

private HtmlPage getPage() throws IOException {
    //---Suppresses unneeded warnings for CSS and other things
    LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log",
            "org.apache.commons.logging.impl.NoOpLog");

    //---Creating webClient and allowing access to website
    //---Also supresses some unneeded script warnings
    final WebClient webClient = new WebClient(BrowserVersion.getDefault());
    webClient.getOptions().setUseInsecureSSL(true);
    webClient.getOptions().setThrowExceptionOnScriptError(false);
    //---Get the first page
    final HtmlPage page1 = webClient.getPage("https://moodle.umn.edu");

    //---Gets the login form, username, and password fields in html
    final HtmlForm form = page1.getElementByName("lform");

    final HtmlSubmitInput button = form.getInputByValue("Sign In");
    final HtmlTextInput userField = form.getInputByName("j_username");
    final HtmlPasswordInput passwordField = form.getInputByName("j_password");

    userField.setValueAttribute(username);//---Insert username here
    passwordField.setValueAttribute(password);//---Insert password here
    button.click();//from  w  w w  .  j a v a 2s  . co  m
    //---New page after clicking the button
    final HtmlPage page2 = webClient.getPage("https://ay14.moodle.umn.edu/my/");

    webClient.closeAllWindows();
    return page2;
}

From source file:yt_server_side.YT_Server_Side.java

public ArrayList<Tile> getRecommendedPlaylistTiles(String url) {
    System.out.println("Attempting to generate recomended tiles...");
    ArrayList<Tile> tiles = new ArrayList();

    try {/*  ww  w . j  a va2 s .c  o m*/
        WebClient wc = new WebClient();

        //<editor-fold defaultstate="collapsed" desc="Turn off HtmlUnit logging">
        LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log",
                "org.apache.commons.logging.impl.NoOpLog");

        java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(Level.OFF);
        java.util.logging.Logger.getLogger("org.apache.commons.httpclient").setLevel(Level.OFF);

        wc.getOptions().setCssEnabled(false);

        wc.setIncorrectnessListener(new IncorrectnessListener() {
            @Override
            public void notify(String string, Object o) {
            }
        });
        wc.setCssErrorHandler(new ErrorHandler() {
            @Override
            public void warning(CSSParseException csspe) throws CSSException {
            }

            @Override
            public void error(CSSParseException csspe) throws CSSException {
            }

            @Override
            public void fatalError(CSSParseException csspe) throws CSSException {
            }
        });
        wc.setJavaScriptErrorListener(new JavaScriptErrorListener() {

            @Override
            public void scriptException(InteractivePage ip, ScriptException se) {
            }

            @Override
            public void timeoutError(InteractivePage ip, long l, long l1) {
            }

            @Override
            public void malformedScriptURL(InteractivePage ip, String string, MalformedURLException murle) {
            }

            @Override
            public void loadScriptError(InteractivePage ip, URL url, Exception excptn) {
            }
        });
        wc.setHTMLParserListener(new HTMLParserListener() {
            @Override
            public void error(String string, URL url, String string1, int i, int i1, String string2) {
            }

            @Override
            public void warning(String string, URL url, String string1, int i, int i1, String string2) {
            }
        });

        wc.getOptions().setThrowExceptionOnFailingStatusCode(false);
        wc.getOptions().setThrowExceptionOnScriptError(false);
        //</editor-fold>

        HtmlPage yt = wc.getPage(url);

        //span[@class='yt-thumb-clip']//img
        yt.getByXPath("//tr[@class='pl-video yt-uix-tile ']").forEach(tr -> {

            System.out.println("TR");

            String songName = ((HtmlElement) tr).getAttribute("data-title");
            String songUrl = "https://www.youtube.com/watch?v="
                    + ((HtmlElement) tr).getAttribute("data-video-id");
            HtmlImage hi = ((HtmlElement) tr).getFirstByXPath(".//td[3]//img");
            String imgUrl = hi.getAttribute("data-thumb");

            tiles.add(new Tile(urlToJpg(imgUrl), songName, songUrl));

        });

    } catch (IOException io) {
        io.printStackTrace(System.out);
    }

    System.out.println("Finished getting recomeded playlists.");
    return tiles;
}