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

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

Introduction

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

Prototype

boolean isDebugEnabled();

Source Link

Document

Is debug logging currently enabled?

Usage

From source file:jp.terasoluna.fw.batch.util.BatchUtil.java

/**
 * ??// w w  w  .ja  v  a 2  s .c  o  m
 * @param tran PlatformTransactionManager
 * @param def TransactionDefinition
 * @param log Log
 * @return TransactionStatus
 */
public static TransactionStatus startTransaction(PlatformTransactionManager tran, TransactionDefinition def,
        Log log) {
    if (log != null && log.isDebugEnabled()) {
        logDebug(log, LogId.DAL025033, tran);
        if (def != null) {
            logDebug(log, LogId.DAL025034, def.getPropagationBehavior(), def.getIsolationLevel(),
                    def.getTimeout(), def.isReadOnly(), def.getName());
        }
    }

    TransactionStatus stat = null;
    if (tran != null) {
        stat = tran.getTransaction(def);
    }

    if (log != null && log.isDebugEnabled()) {
        logDebug(log, LogId.DAL025035, stat);
    }
    return stat;
}

From source file:edu.vt.middleware.crypt.CryptProvider.java

/**
 * <p>This creates a <code>CertificateFactory</code> using the supplied type
 * name.</p>/*from ww w. ja va2s.c om*/
 *
 * @param  type  <code>String</code>
 *
 * @return  <code>CertificateFactory</code>
 *
 * @throws  CryptException  if the type is not available from any provider or
 * the provider is not available in the environment
 */
public static CertificateFactory getCertificateFactory(final String type) throws CryptException {
    final Log logger = LogFactory.getLog(CryptProvider.class);
    CertificateFactory cf = null;
    for (int i = 0; i < providers.length; i++) {
        try {
            cf = CertificateFactory.getInstance(type, providers[i]);
        } catch (CertificateException e) {
            if (logger.isDebugEnabled()) {
                logger.debug(
                        "Could not get instance of certificate factory type " + type + " from " + providers[i]);
            }
        } catch (NoSuchProviderException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Could not find provider " + providers[i]);
            }
        } finally {
            if (cf != null) {
                break;
            }
        }
    }
    if (cf == null) {
        try {
            cf = CertificateFactory.getInstance(type);
        } catch (CertificateException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Could not get instance of certificate factory type " + type);
            }
            throw new CryptException(e.getMessage());
        }
    }
    return cf;
}

From source file:edu.vt.middleware.crypt.CryptProvider.java

/**
 * <p>This finds a <code>SecretKeyFactory</code> using the known providers and
 * the supplied algorithm parameter.</p>
 *
 * @param  algorithm  <code>String</code> name
 *
 * @return  <code>SecretKeyFactory</code>
 *
 * @throws  CryptException  if the algorithm is not available from any
 * provider or if the provider is not available in the environment
 *//*  www.jav  a2 s  .  com*/
public static SecretKeyFactory getSecretKeyFactory(final String algorithm) throws CryptException {
    final Log logger = LogFactory.getLog(CryptProvider.class);
    SecretKeyFactory kf = null;
    for (int i = 0; i < providers.length; i++) {
        try {
            kf = SecretKeyFactory.getInstance(algorithm, providers[i]);
        } catch (NoSuchAlgorithmException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Could not find algorithm " + algorithm + " in " + providers[i]);
            }
        } catch (NoSuchProviderException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Could not find provider " + providers[i]);
            }
        } finally {
            if (kf != null) {
                break;
            }
        }
    }
    if (kf == null) {
        try {
            kf = SecretKeyFactory.getInstance(algorithm);
        } catch (NoSuchAlgorithmException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Could not find algorithm " + algorithm);
            }
            throw new CryptException(e.getMessage());
        }
    }
    return kf;
}

From source file:edu.vt.middleware.crypt.CryptProvider.java

/**
 * <p>This creates a <code>MessageDigest</code> using the supplied algorithm
 * name.</p>/*from  ww  w . j a v  a  2  s .  c o m*/
 *
 * @param  algorithm  <code>String</code> name
 *
 * @return  <code>MessageDigest</code>
 *
 * @throws  CryptException  if the algorithm is not available from any
 * provider or the provider is not available in the environment
 */
public static MessageDigest getMessageDigest(final String algorithm) throws CryptException {
    final Log logger = LogFactory.getLog(CryptProvider.class);
    MessageDigest digest = null;
    for (int i = 0; i < providers.length; i++) {
        try {
            digest = MessageDigest.getInstance(algorithm, providers[i]);
        } catch (NoSuchAlgorithmException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Could not find algorithm " + algorithm + " in " + providers[i]);
            }
        } catch (NoSuchProviderException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Could not find provider " + providers[i]);
            }
        } finally {
            if (digest != null) {
                break;
            }
        }
    }
    if (digest == null) {
        try {
            digest = MessageDigest.getInstance(algorithm);
        } catch (NoSuchAlgorithmException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Could not find algorithm " + algorithm);
            }
            throw new CryptException(e.getMessage());
        }
    }
    return digest;
}

From source file:com.healthmarketscience.rmiio.RemoteRetry.java

/**
 * Implementation of a simple backoff strategy:
 * <ol>/* ww w  .j  av  a 2 s  .  c o  m*/
 * <li>First retry returns immediately
 * <li>Retries 1 - 30 wait that many seconds each time before returning (after 1st retry wait 1 second, after 2nd retry wait 2 seconds...)
 * <li>Retries > 30 wait 30 seconds each time before returning
 * </ol>
 * 
 * @param numRetries
 *           number of retries which have happended thus far
 * @param log
 *           debug log
 */
protected static void simpleBackOff(int numRetries, Log log) {
    if (numRetries == 0) {
        // immediate retry first time
        return;
    }
    long sleepTime = numRetries;
    if (sleepTime > 30) {
        sleepTime = 30;
    }
    try {
        Thread.sleep(sleepTime * 1000);
    } catch (InterruptedException ignored) {
        // pass interrupt along
        Thread.currentThread().interrupt();
        if (log.isDebugEnabled()) {
            log.debug("Caught exception while sleeping", ignored);
        }
    }
}

From source file:edu.vt.middleware.crypt.CryptProvider.java

/**
 * <p>This finds a <code>KeyGenerator</code> using the known providers and the
 * supplied algorithm parameter.</p>
 *
 * @param  algorithm  <code>String</code> name
 *
 * @return  <code>KeyGenerator</code>
 *
 * @throws  CryptException  if the algorithm is not available from any
 * provider or if the provider is not available in the environment
 */// w w w .  jav a2s.  c om
public static KeyGenerator getKeyGenerator(final String algorithm) throws CryptException {
    final Log logger = LogFactory.getLog(CryptProvider.class);
    KeyGenerator generator = null;
    for (int i = 0; i < providers.length; i++) {
        try {
            generator = KeyGenerator.getInstance(algorithm, providers[i]);
        } catch (NoSuchAlgorithmException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Could not find algorithm " + algorithm + " in " + providers[i]);
            }
        } catch (NoSuchProviderException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Could not find provider " + providers[i]);
            }
        } finally {
            if (generator != null) {
                break;
            }
        }
    }
    if (generator == null) {
        try {
            generator = KeyGenerator.getInstance(algorithm);
        } catch (NoSuchAlgorithmException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Could not find algorithm " + algorithm);
            }
            throw new CryptException(e.getMessage());
        }
    }
    return generator;
}

From source file:edu.vt.middleware.crypt.CryptProvider.java

/**
 * <p>This finds a <code>KeyPairGenerator</code> using the known providers and
 * the supplied algorithm parameter.</p>
 *
 * @param  algorithm  <code>String</code> name
 *
 * @return  <code>KeyPairGenerator</code>
 *
 * @throws  CryptException  if the algorithm is not available from any
 * provider or if the provider is not available in the environment
 *//*from   w w  w .  j av  a2 s.  c  o m*/
public static KeyPairGenerator getKeyPairGenerator(final String algorithm) throws CryptException {
    final Log logger = LogFactory.getLog(CryptProvider.class);
    KeyPairGenerator generator = null;
    for (int i = 0; i < providers.length; i++) {
        try {
            generator = KeyPairGenerator.getInstance(algorithm, providers[i]);
        } catch (NoSuchAlgorithmException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Could not find algorithm " + algorithm + " in " + providers[i]);
            }
        } catch (NoSuchProviderException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Could not find provider " + providers[i]);
            }
        } finally {
            if (generator != null) {
                break;
            }
        }
    }
    if (generator == null) {
        try {
            generator = KeyPairGenerator.getInstance(algorithm);
        } catch (NoSuchAlgorithmException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Could not find algorithm " + algorithm);
            }
            throw new CryptException(e.getMessage());
        }
    }
    return generator;
}

From source file:com.moss.posixfifosockets.PosixFifoSocket.java

public static PosixFifoSocket newClientConnection(PosixFifoSocketAddress address, int timeoutMillis)
        throws IOException {
    final Log log = LogFactory.getLog(PosixFifoSocket.class);

    if (!address.controlPipe().exists()) {
        throw new IOException("There is no server at " + address);
    }/*from ww w  . java 2  s.  com*/

    File in;
    File out;
    File control;
    long id;
    do {
        id = r.nextLong();
        in = new File(address.socketsDir(), id + ".fifo.out");
        out = new File(address.socketsDir(), id + ".fifo.in");
        control = new File(address.socketsDir(), id + ".fifo.control");
    } while (out.exists() || in.exists());

    createFifo(in);
    createFifo(control);

    final String registrationString = "{" + id + "}";
    if (log.isDebugEnabled())
        log.debug("Sending registration " + registrationString);
    Writer w = new FileWriter(address.controlPipe());
    w.write(registrationString);
    w.flush();

    if (log.isDebugEnabled())
        log.debug("Sent Registration " + registrationString);

    PosixFifoSocket socket = new PosixFifoSocket(id, in, out);
    Reader r = new FileReader(control);

    StringBuilder text = new StringBuilder();
    for (int c = r.read(); c != -1 && c != '\n'; c = r.read()) {
        // READ UNTIL THE FIRST LINE BREAK
        text.append((char) c);
    }
    r.close();
    if (!control.delete()) {
        throw new RuntimeException("Could not delete file:" + control.getAbsolutePath());
    }
    if (!text.toString().equals("OK")) {
        throw new RuntimeException("Connection error: received \"" + text + "\"");
    }
    return socket;
}

From source file:edu.vt.middleware.crypt.CryptProvider.java

/**
 * <p>This creates a <code>KeyStore</code> using the supplied type name.</p>
 *
 * @param  type  <code>String</code>
 *
 * @return  <code>KeyStore</code>
 *
 * @throws  CryptException  if the type is not available from any provider or
 * the provider is not available in the environment
 *///from w w  w  .ja v  a 2s . co  m
public static KeyStore getKeyStore(final String type) throws CryptException {
    final Log logger = LogFactory.getLog(CryptProvider.class);
    KeyStore store = null;
    String keyStoreType = type;
    if (keyStoreType == null) {
        keyStoreType = KeyStore.getDefaultType();
    }
    for (int i = 0; i < providers.length; i++) {
        try {
            store = KeyStore.getInstance(keyStoreType, providers[i]);
        } catch (KeyStoreException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Could not get instance of keystore type " + type + " from " + providers[i]);
            }
        } catch (NoSuchProviderException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Could not find provider " + providers[i]);
            }
        } finally {
            if (store != null) {
                break;
            }
        }
    }
    if (store == null) {
        try {
            store = KeyStore.getInstance(keyStoreType);
        } catch (KeyStoreException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Could not get instance of keystore type " + type);
            }
            throw new CryptException(e.getMessage());
        }
    }
    return store;
}

From source file:com.wavemaker.runtime.data.util.DataServiceUtils.java

public static Object loadById(Object originalInstance, Session session, DataServiceMetaData metaData,
        Log logger) {

    if (originalInstance == null) {
        throw new IllegalArgumentException("instance to reload cannot be null");
    }//from   w ww .  j  av  a 2s  .c o m

    Class<?> clazz = getEntityClass(originalInstance.getClass());

    String s = metaData.getIdPropertyName(clazz);

    Serializable id = (Serializable) objectAccess.getProperty(originalInstance, s);

    Object rtn = session.get(clazz, id);

    if (logger != null && logger.isDebugEnabled()) {
        logger.debug("reloadById: " + ObjectUtils.getId(originalInstance) + " " + s + ":" + id);
    }

    return rtn;
}