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

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

Introduction

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

Prototype

public static Log getLog(String name) 

Source Link

Document

Convenience method to return a named logger.

Usage

From source file:com.robonobo.common.media.PlaylistItem.java

public static List getPlaylist(String uri) throws IOException, PlaylistFormatException {
    Log log = LogFactory.getLog(PlaylistItem.class);
    Vector list = new Vector();
    HttpClient client = new HttpClient();
    GetMethod get = new GetMethod(uri);
    int status = client.executeMethod(get);
    switch (status) {
    case 200:/*from w ww.  j  ava  2 s.  co  m*/
        BufferedReader reader = new BufferedReader(new InputStreamReader(get.getResponseBodyAsStream()));
        String line = reader.readLine();
        if (!line.equals("[playlist]"))
            throw new PlaylistFormatException("The provided URL does not describe a playlist");
        String[] kvp;
        int currentEntryNumber = 1;
        int version = 2;
        int supposedNumberOfEntries = 1;
        PlaylistItem currentEntry = new PlaylistItem();
        while ((line = reader.readLine()) != null) {
            kvp = line.split("=");
            if (kvp[0].equals("NumberOfEntries")) {
                supposedNumberOfEntries = Integer.parseInt(kvp[1]);
            } else if (kvp[0].equals("Version")) {
                version = Integer.parseInt(kvp[1]);
                if (version != 2)
                    throw new PlaylistFormatException(
                            "This parser currently only supports version 2 .pls files");
            } else {
                if (!kvp[0].endsWith(String.valueOf(currentEntryNumber))) {
                    list.add(currentEntry);
                    currentEntryNumber++;
                    currentEntry = new PlaylistItem();
                }
                if (kvp[0].startsWith("File")) {
                    currentEntry.setFile(kvp[1]);
                } else if (kvp[0].startsWith("Title")) {
                    currentEntry.setTitle(kvp[1]);
                } else if (kvp[0].startsWith("Length")) {
                    currentEntry.setLength(Integer.parseInt(kvp[1]));
                }
            }
        }
        if (currentEntry != null)
            list.add(currentEntry);
        if (supposedNumberOfEntries != list.size())
            throw new PlaylistFormatException("The server said there were " + supposedNumberOfEntries
                    + " but we actually got " + list.size());
        return list;
    default:
        throw new IOException(
                "The remote server responded with a status " + status + " and not 200 as expected");
    }
}

From source file:com.curl.orb.security.RemoteServiceAnnotationChecker.java

/**
 * Check the PublicService annotation. Throw AccessException if false.
 * //from w ww  . ja va2s.c  o  m
 * @param cls the class
 * @throws AccessException
 */
public static void check(Class<?> cls, Environment environment) throws AccessException {
    // ignore security
    if (environment == null)
        return;

    RemoteService remoteServiceAnnotation = (RemoteService) cls.getAnnotation(RemoteService.class);
    if (!Modifier.isPublic(cls.getModifiers()) || remoteServiceAnnotation == null
            || !environment.contain(remoteServiceAnnotation.value())) {
        Log log = LogFactory.getLog(RemoteServiceAnnotationChecker.class);
        log.debug("Cannot allow to access the class [" + cls.getName() + "]");
        throw new AccessException("Cannot allow to access the class [" + cls.getName() + "]");
    }
    // TODO: Cache the class(cls). Which is faster, cache or annotation?
}

From source file:com.curl.orb.generator.ClassPropertyLoader.java

/**
 * Get one class property./*  ww  w .jav a 2  s  .c o m*/
 * 
 * @param name the component name
 * @return the class property
 * @throws GeneratorException
 */
public static ClassProperty getClassPropertyFromClassName(String name) throws GeneratorException {
    // debug
    (LogFactory.getLog(ClassPropertyLoader.class)).info("Generate Curl code [" + name + "]");
    ClassProperty classProperty = new ClassProperty(name);
    if (!classProperty.isPublic())
        throw new GeneratorException("Cannot access to this class:" + name);
    return classProperty;
}

From source file:de.xwic.sandbox.base.model.util.StreamUtil.java

/**
 * @param closable/* w  w w .  ja  v  a2 s  .  c o  m*/
 * @param log
 */
public static void close(Closeable... closables) {
    close(LogFactory.getLog(StreamUtil.class), closables);
}

From source file:com.amazonaws.services.s3.internal.crypto.CryptoRuntime.java

public static void enableBouncyCastle() {
    try {// w w w . j a  va2 s . c  o m
        @SuppressWarnings("unchecked")
        Class<Provider> c = (Class<Provider>) Class.forName(BC_PROVIDER_FQCN);
        Provider provider = c.newInstance();
        Security.addProvider(provider);
    } catch (Exception e) {
        LogFactory.getLog(CryptoRuntime.class).debug("Bouncy Castle not available", e);
    }
}

From source file:com.alibaba.dragoon.common.daemon.filter.CommonsLogFilter.java

public CommonsLogFilter() {
    log = LogFactory.getLog(CommonsLogFilter.class);
}

From source file:net.sf.nmedit.nomad.core.jpf.JPFServiceInstallerTool.java

private static Log getLogger() {
    if (_logger == null)
        _logger = LogFactory.getLog(JPFServiceInstallerTool.class);

    return _logger;
}

From source file:arena.mail.MailAddressUtils.java

/**
 * Builds a list of internet address objects by parsing the
 * address list of the form "name <email>, name <email>"
 *//*  w ww  .  j a  v  a2  s  .co  m*/
public static InternetAddress[] parseAddressList(String addressList, String delim, String encoding) {
    if ((addressList == null) || (addressList.trim().length() == 0)) {
        return new InternetAddress[0];
    }
    Log log = LogFactory.getLog(MailAddressUtils.class);
    log.debug("Address list for parsing: " + addressList);
    StringTokenizer st = new StringTokenizer(addressList.trim(), delim);
    List<InternetAddress> addresses = new ArrayList<InternetAddress>();

    for (int n = 0; st.hasMoreTokens(); n++) {
        String fullAddress = st.nextToken().trim();
        if (fullAddress.equals("")) {
            continue;
        }

        try {
            int openPos = fullAddress.indexOf('<');
            int closePos = fullAddress.indexOf('>');

            if (openPos == -1) {
                addresses.add(new InternetAddress(
                        (closePos == -1) ? fullAddress.trim() : fullAddress.substring(0, closePos).trim()));
            } else if (closePos == -1) {
                addresses.add(new InternetAddress(fullAddress.substring(openPos + 1).trim(),
                        fullAddress.substring(0, openPos).trim(), encoding));
            } else {
                addresses.add(new InternetAddress(fullAddress.substring(openPos + 1, closePos).trim(),
                        fullAddress.substring(0, openPos).trim(), encoding));
            }
        } catch (Throwable err) {
            throw new RuntimeException("Error parsing address: " + fullAddress, err);
        }
    }

    log.debug("Found mail addresses: " + addresses);

    return (InternetAddress[]) addresses.toArray(new InternetAddress[addresses.size()]);
}

From source file:br.com.sicoob.cro.cop.batch.core.TaskletListenerImpl.java

public void afterStep(BatchStepContribution stepExecution) {
    LogFactory.getLog(TaskletListenerImpl.class).info("AFTER - STEP - TASKLET");
}

From source file:documents.DocumentProvider.java

public DocumentProvider() {
    this.listeners = new ArrayList<>();
    docsAvailable = new HashMap<>();
    log = LogFactory.getLog(getClass());
}