Example usage for org.apache.commons.lang.builder ReflectionToStringBuilder toString

List of usage examples for org.apache.commons.lang.builder ReflectionToStringBuilder toString

Introduction

In this page you can find the example usage for org.apache.commons.lang.builder ReflectionToStringBuilder toString.

Prototype

public static String toString(Object object, ToStringStyle style) 

Source Link

Document

Builds a toString value through reflection.

Usage

From source file:io.reign.Reign.java

@Override
public void process(WatchedEvent event) {
    // log if TRACE
    if (logger.isTraceEnabled()) {
        logger.trace("***** Received ZooKeeper Event:  {}",
                ReflectionToStringBuilder.toString(event, ToStringStyle.DEFAULT_STYLE));

    }//w ww  . j  av  a  2  s.com

    if (shutdown) {
        logger.warn("Already shutdown:  ignoring event:  type={}; path={}", event.getType(), event.getPath());
        return;
    }

    for (Watcher watcher : watcherList) {
        watcher.process(event);
    }
}

From source file:jp.primecloud.auto.zabbix.client.ItemClientTest.java

@Test
@Ignore//  ww w .  j av  a2s .com
public void testGetFromApplication() {
    // ?
    ItemGetParam param = new ItemGetParam();

    List<String> hostids = new ArrayList<String>();
    hostids.add("10283");
    param.setHostids(hostids);
    param.setApplication("syslog-ng");
    param.setOutput("extend");
    List<Item> items = client.item().get(param);
    log.debug("item_size :" + items.size());
    for (Item item : items) {
        log.debug(ReflectionToStringBuilder.toString(item, ToStringStyle.SHORT_PREFIX_STYLE));

    }
}

From source file:bixo.examples.crawl.BaseCrawlToolOptions.java

@Override
public String toString() {
    return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
}

From source file:jp.primecloud.auto.puppet.PuppetClient.java

public void runClient(String fqdn) {
    // siteFile?touch?
    touchFile(siteFile);/*from  ww w.ja  va2 s .c  om*/

    // ??touch?
    File manifestFile = new File(manifestDir, fqdn + ".pp");
    touchFile(manifestFile.getAbsolutePath());

    // ???
    if (delayTime != null) {
        try {
            Thread.sleep(delayTime.intValue() * 1000);
        } catch (InterruptedException ignore) {
        }
    }

    // puppetrun?????
    String beforeReportFile = reportLoader.getLatestReportFile(fqdn);
    Long beforeLastModified = null;
    if (beforeReportFile != null) {
        beforeLastModified = reportLoader.getLastModified(fqdn, beforeReportFile);
    }

    List<String> commands = new ArrayList<String>();
    commands.add("/usr/bin/sudo");
    commands.add(puppetrunPath);
    commands.add("--host");
    commands.add(fqdn);
    commands.add("--foreground"); // Puppet???
    commands.add("--ping");

    // puppetrun??
    if (configTimeout != null) {
        commands.add("--configtimeout=" + configTimeout.toString());
    }

    log.debug(commands);
    CommandResult result = executeRun(commands);

    int retryCount = 0;
    while (result.getExitValue() != 0 && retryCount < 6) {
        // ???????
        boolean retry = false;
        for (String stdout : result.getStdouts()) {
            log.warn(stdout);
            if (stdout.contains("Certificates were not trusted: ")) {
                retry = true;
                break;
            } else if (stdout.contains("Connection reset by peer")) {
                retry = true;
                break;
            } else if (stdout.contains("Could not contact")) {
                retry = true;
                break;
            }
        }

        if (!retry) {
            // ????
            break;
        }

        // ???
        log.warn(ReflectionToStringBuilder.toString(result, ToStringStyle.SHORT_PREFIX_STYLE));

        // ??
        try {
            Thread.sleep(5 * 1000);
        } catch (InterruptedException ignore) {
        }
        result = executeRun(commands);

        retryCount++;
    }

    if (result.getExitValue() != 0) {
        // puppetrun??
        AutoException exception;

        if (result.getStdouts().size() > 0 && result.getStdouts().get(0).contains("Could not contact")) {
            // ??ping????????
            exception = new AutoException("EPUPPET-000002", fqdn);
        } else if (result.getStdouts().size() > 0 && result.getStdouts().get(0).contains("Could not connect")) {
            // ???????????????
            try {
                Thread.sleep(100000);
            } catch (InterruptedException ignore) {
            }
            //?
            exception = new AutoException("EPUPPET-000007", fqdn);
        } else if (result.getStdouts().size() > 0
                && result.getStdouts().get(0).contains("returned unknown answer")) {
            // ???????????????()
            try {
                Thread.sleep(100000);
            } catch (InterruptedException ignore) {
            }
            //?
            exception = new AutoException("EPUPPET-000007", fqdn);
        } else {
            exception = new AutoException("EPUPPET-000001", fqdn);
        }

        exception.addDetailInfo(
                "result=" + ReflectionToStringBuilder.toString(result, ToStringStyle.SHORT_PREFIX_STYLE));
        throw exception;
    }

    // ???
    String reportFile = null;
    for (int i = 0; i < 30; i++) {
        try {
            Thread.sleep(1 * 1000);
        } catch (InterruptedException ignore) {
        }

        String tmpReportFile = reportLoader.getLatestReportFile(fqdn);
        if (tmpReportFile != null) {
            if (beforeLastModified == null) {
                reportFile = tmpReportFile;
                break;
            } else {
                Long lastModified = reportLoader.getLastModified(fqdn, tmpReportFile);
                if (lastModified.longValue() != beforeLastModified.longValue()) {
                    reportFile = tmpReportFile;
                    break;
                }
            }
        }
    }

    if (reportFile != null) {
        // ?????
        Map<String, Object> report = reportLoader.loadReport(fqdn, reportFile);
        String status = reportAnalyzer.getStatus(report);
        if (status.equals("failed")) {
            // ????????()
            throw new AutoException("EPUPPET-000003", fqdn, reportFile);
        }
        List<MetricsResource> metricsResources = reportAnalyzer.getMetricsResources(report);
        for (MetricsResource metricsResource : metricsResources) {
            if (metricsResource.getName().startsWith("Failed") && metricsResource.getCount() > 0) {
                // ????????
                throw new AutoException("EPUPPET-000003", fqdn, reportFile);
            }
        }
    } else {
        // ????????
        throw new AutoException("EPUPPET-000007", fqdn);
    }
}

From source file:jp.primecloud.auto.zabbix.client.ItemClientTest.java

@Test
@Ignore/*from  w  w w.  ja v a2 s .c  o m*/
public void testUpdate() {
    ItemUpdateParam param = new ItemUpdateParam();
    param.setItemid("22285");
    //:0 ??1
    param.setStatus(ItemUpdateParam.ENABLE);

    List<String> items = client.item().update(param);
    for (String item : items) {
        log.debug(ReflectionToStringBuilder.toString(item, ToStringStyle.SHORT_PREFIX_STYLE));

    }
}

From source file:jp.primecloud.auto.common.component.DnsStrategy.java

/**
 * TODO: //  ww w. ja v a 2 s  .co  m
 *
 * @param fqdn
 * @param canonicalName
 */
public void addCanonicalName(String fqdn, String canonicalName) {
    List<String> commands = createCommands();

    List<String> stdins = createStdinsCommon();
    stdins.addAll(createAddCanonicalName(fqdn, canonicalName));
    stdins.add("quit");

    CommandResult result = execute(commands, stdins);

    if (result.getExitValue() != 0) {
        // CNAME??
        AutoException exception = new AutoException("ECOMMON-000205", fqdn, canonicalName);
        exception.addDetailInfo(
                "result=" + ReflectionToStringBuilder.toString(result, ToStringStyle.SHORT_PREFIX_STYLE));
        throw exception;
    }

    // CNAME??????????????????
}

From source file:com.kbotpro.ui.FieldWatcher.java

public void run() {
    while (active) {
        String html = "<html><body>"
                + EscapeChars/*w w w . ja  v a  2  s  . c o  m*/
                        .forHTML(ReflectionToStringBuilder.toString(watchedObj, ToStringStyle.MULTI_LINE_STYLE))
                + "</body></html>";
        infoLabel.setText(html);
        try {
            Thread.sleep((int) (1000D / ((Double) updateRateSpinner.getValue())));
        } catch (InterruptedException e) {
            Logger.getRootLogger().error("Exception: ", e); //To change body of catch statement use File | Settings | File Templates.
        }
    }
}

From source file:com.restqueue.framework.SerializerUnitTest.java

@Test
public void toStringOfEntryWrapperShouldMatchAfterSerializingAndDeSerializing() {
    final EntryWrapper entryWrapperBefore = new EntryWrapper();
    entryWrapperBefore.setCreator("Testing");
    entryWrapperBefore.setContent("Hello - Testing");
    entryWrapperBefore.addReturnAddress(new ReturnAddress(ReturnAddressType.EMAIL, "me@there.com"));
    entryWrapperBefore.addReturnAddress(new ReturnAddress(ReturnAddressType.URL,
            "http://localhost:9998/channels/1.0/stockQueryResultsQueue"));
    entryWrapperBefore.setDelay("60");
    entryWrapperBefore.setPriority(11);/*from  w  w  w  . j av  a 2s .  com*/
    entryWrapperBefore.setSequence(8);

    final String beforeString = ReflectionToStringBuilder.toString(entryWrapperBefore,
            ToStringStyle.SHORT_PREFIX_STYLE);

    final EntryWrapper entryWrapperAfter = (EntryWrapper) new Serializer().fromType(
            new Serializer().toType(entryWrapperBefore, MediaType.APPLICATION_XML), MediaType.APPLICATION_XML);

    final String afterString = ReflectionToStringBuilder.toString(entryWrapperAfter,
            ToStringStyle.SHORT_PREFIX_STYLE);

    assertEquals(beforeString, afterString);
}

From source file:jp.primecloud.auto.common.component.DnsStrategy.java

/**
 * TODO: //from   w w  w.  j a v a 2s .  co  m
 *
 * @param fqdn
 */
public void deleteForward(String fqdn) {
    List<String> commands = createCommands();

    List<String> stdins = createStdinsCommon();
    stdins.addAll(createDeleteForward(fqdn));
    stdins.add("quit");

    CommandResult result = execute(commands, stdins);

    if (result.getExitValue() != 0) {
        // ????
        AutoException exception = new AutoException("ECOMMON-000207", fqdn);
        exception.addDetailInfo(
                "result=" + ReflectionToStringBuilder.toString(result, ToStringStyle.SHORT_PREFIX_STYLE));
        throw exception;
    }

    // ????
    long timeout = 10000L;
    long startTime = System.currentTimeMillis();
    while (true) {
        String hostAddress = getHostAddress(fqdn);
        if (hostAddress == null) {
            break;
        }
        if (System.currentTimeMillis() - startTime > timeout) {
            // 
            throw new AutoException("ECOMMON-000208", fqdn, hostAddress);
        }
        try {
            Thread.sleep(1000);
        } catch (InterruptedException ignore) {
        }
    }
}

From source file:com.shishu.utility.string.StringUtil.java

public static String javabeanToString(Object javabean) {
    return ReflectionToStringBuilder.toString(javabean, ToStringStyle.MULTI_LINE_STYLE);
}