List of usage examples for org.apache.commons.lang.builder ToStringBuilder reflectionToString
public static String reflectionToString(Object object)
Forwards to ReflectionToStringBuilder
.
From source file:nl.nn.adapterframework.jms.JmsRealm.java
/** * The <code>toString()</code> method retrieves its value * by reflection.//from w w w . j av a2 s. c o m * @see org.apache.commons.lang.builder.ToStringBuilder#reflectionToString * **/ public String toString() { try { return ToStringBuilder.reflectionToString(this); } catch (Throwable t) { log.warn("exception getting string representation of jmsRealm [" + getRealmName() + "]", t); } return null; }
From source file:nl.nn.adapterframework.parameters.Parameter.java
private Object transform(Source xmlSource, ParameterResolutionContext prc) throws ParameterException, TransformerException, IOException { TransformerPool pool = getTransformerPool(); if (TYPE_NODE.equals(getType()) || TYPE_DOMDOC.equals(getType())) { DOMResult transformResult = new DOMResult(); pool.transform(xmlSource, transformResult, prc.getValueMap(paramList)); Node result = transformResult.getNode(); if (result != null && TYPE_NODE.equals(getType())) { result = result.getFirstChild(); }/*ww w.j a v a 2 s . c om*/ if (log.isDebugEnabled()) { if (result != null) log.debug("Returning Node result [" + result.getClass().getName() + "][" + result + "]: " + ToStringBuilder.reflectionToString(result)); } return result; } else { return pool.transform(xmlSource, prc.getValueMap(paramList)); } }
From source file:nl.nn.adapterframework.pipes.AbstractPipe.java
/** * The <code>toString()</code> method retrieves its value * by reflection, so overriding this method is mostly not * usefull.//from ww w .ja v a2 s .c om * @see org.apache.commons.lang.builder.ToStringBuilder#reflectionToString * **/ public String toString() { try { return ToStringBuilder.reflectionToString(this); } catch (Throwable t) { log.warn("exception getting string representation of pipe [" + getName() + "]", t); } return null; }
From source file:nl.surfnet.coin.selfservice.provisioner.SAMLProvisioner.java
private String getAuthenticatingAuthority(final Assertion assertion) { final List<AuthnStatement> authnStatements = assertion.getAuthnStatements(); for (AuthnStatement as : authnStatements) { final List<AuthenticatingAuthority> authorities = as.getAuthnContext().getAuthenticatingAuthorities(); for (AuthenticatingAuthority aa : authorities) { if (StringUtils.isNotBlank(aa.getURI())) { return aa.getURI(); }// w ww .ja v a 2 s . c om } } throw new RuntimeException("No AuthenticatingAuthority present in the Assertion:" + ToStringBuilder.reflectionToString(assertion)); }
From source file:odin.gateway.SendMail.java
public static void sendBacklogManagementMessage(String[] notificationList, String ccEmailAddress[], String subject, String content) throws Exception { LOG.info("Sending email notification to: " + ToStringBuilder.reflectionToString(notificationList)); SendGrid sendgrid = new SendGrid(Configuration.getDefaultValue("sendgrid.api_key")); SendGrid.Email email = new SendGrid.Email(); email.addTo(notificationList);/*w w w . j a va 2 s . c o m*/ if (ccEmailAddress != null) email.addCc(ccEmailAddress); email.setFrom(Configuration.getDefaultValue("odin.notify.prod.from")); email.setSubject(subject); email.setHtml(content); email.setTemplateId(Configuration.getDefaultValue("sendgrid.backlog_mgmt.template_id")); SendGrid.Response response = sendgrid.send(email); LOG.info("Email sent. Response: " + response.getMessage()); }
From source file:org.apache.cxf.jaxb.JAXBElementToStringStyleTest.java
@Test public void testToStringDefault() throws Exception { String ts = ToStringBuilder.reflectionToString(h); validateHolderString(ts);//from w w w.j a v a 2 s . c o m // JAXBElement contents not present Assert.assertTrue("has no value", ts.indexOf("value") == -1); Assert.assertTrue("has no bv", ts.indexOf("bv") == -1); }
From source file:org.apache.eagle.alert.engine.publisher.dedup.DedupCacheTest.java
@Test public void testNormal() throws Exception { Config config = ConfigFactory.load(); DedupCache dedupCache = new DedupCache(config, "testPublishment"); StreamDefinition stream = createStream(); PolicyDefinition policy = createPolicy(stream.getStreamId(), "testPolicy"); String[] states = new String[] { "OPEN", "WARN", "CLOSE" }; Random random = new Random(); for (int i = 0; i < 20; i++) { AlertStreamEvent event = createEvent(stream, policy, new Object[] { System.currentTimeMillis(), "host1", "testPolicy-host1-01", states[random.nextInt(3)], 0, 0 }); HashMap<String, String> dedupFieldValues = new HashMap<String, String>(); dedupFieldValues.put("alertKey", (String) event.getData()[event.getSchema().getColumnIndex("alertKey")]); List<AlertStreamEvent> result = dedupCache.dedup(event, new EventUniq(event.getStreamId(), event.getPolicyId(), event.getCreatedTime(), dedupFieldValues), "state", (String) event.getData()[event.getSchema().getColumnIndex("state")], "closed"); System.out.println((i + 1) + " >>>> " + ToStringBuilder.reflectionToString(result)); }/* w w w . j av a2 s.com*/ Assert.assertTrue(true); }
From source file:org.apache.eagle.alert.engine.publisher.dedup.DefaultDeduplicatorTest.java
@Test public void testNormal() throws Exception { //String intervalMin, List<String> customDedupFields, String dedupStateField, String dedupStateCloseValue // assume state: OPEN, WARN, CLOSE System.setProperty("config.resource", "/application-mongo-statestore.conf"); Config config = ConfigFactory.load(); DedupCache dedupCache = new DedupCache(config, "testPublishment"); DefaultDeduplicator deduplicator = new DefaultDeduplicator("PT1M", Arrays.asList(new String[] { "alertKey" }), "state", "close", dedupCache); StreamDefinition stream = createStream(); PolicyDefinition policy = createPolicyGroupByStreamId(stream.getStreamId(), "testPolicy"); AlertStreamEvent e1 = createEvent(stream, policy, new Object[] { System.currentTimeMillis(), "host1", "testPolicy-host1-01", "OPEN", 0, 0 }); AlertStreamEvent e2 = createEvent(stream, policy, new Object[] { System.currentTimeMillis(), "host1", "testPolicy-host1-01", "WARN", 0, 0 }); AlertStreamEvent e3 = createEvent(stream, policy, new Object[] { System.currentTimeMillis(), "host1", "testPolicy-host1-01", "OPEN", 0, 0 }); AlertStreamEvent e4 = createEvent(stream, policy, new Object[] { System.currentTimeMillis(), "host1", "testPolicy-host1-01", "WARN", 0, 0 }); AlertStreamEvent e5 = createEvent(stream, policy, new Object[] { System.currentTimeMillis(), "host1", "testPolicy-host1-01", "CLOSE", 0, 0 }); AlertStreamEvent e6 = createEvent(stream, policy, new Object[] { System.currentTimeMillis(), "host1", "testPolicy-host1-01", "OPEN", 0, 0 }); AlertStreamEvent e7 = createEvent(stream, policy, new Object[] { System.currentTimeMillis(), "host1", "testPolicy-host1-01", "OPEN", 0, 0 }); AlertStreamEvent e8 = createEvent(stream, policy, new Object[] { System.currentTimeMillis(), "host1", "testPolicy-host1-01", "OPEN", 0, 0 }); List<AlertStreamEvent> allResults = new ArrayList<AlertStreamEvent>(); new Thread(new Runnable() { @Override//from w ww.j a v a 2 s . co m public void run() { List<AlertStreamEvent> result = deduplicator.dedup(e1); if (result != null) { allResults.addAll(result); } System.out.println("1 >>>> " + ToStringBuilder.reflectionToString(result)); } }).start(); new Thread(new Runnable() { @Override public void run() { List<AlertStreamEvent> result = deduplicator.dedup(e2); if (result != null) { allResults.addAll(result); } System.out.println("2 >>>> " + ToStringBuilder.reflectionToString(result)); } }).start(); new Thread(new Runnable() { @Override public void run() { List<AlertStreamEvent> result = deduplicator.dedup(e3); if (result != null) { allResults.addAll(result); } System.out.println("3 >>>> " + ToStringBuilder.reflectionToString(result)); } }).start(); new Thread(new Runnable() { @Override public void run() { List<AlertStreamEvent> result = deduplicator.dedup(e4); if (result != null) { allResults.addAll(result); } System.out.println("4 >>>> " + ToStringBuilder.reflectionToString(result)); } }).start(); new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(500); } catch (InterruptedException e) { } List<AlertStreamEvent> result = deduplicator.dedup(e5); if (result != null) { allResults.addAll(result); } System.out.println("5 >>>> " + ToStringBuilder.reflectionToString(result)); } }).start(); new Thread(new Runnable() { @Override public void run() { List<AlertStreamEvent> result = deduplicator.dedup(e6); if (result != null) { allResults.addAll(result); } System.out.println("6 >>>> " + ToStringBuilder.reflectionToString(result)); } }).start(); new Thread(new Runnable() { @Override public void run() { List<AlertStreamEvent> result = deduplicator.dedup(e7); if (result != null) { allResults.addAll(result); } System.out.println("7 >>>> " + ToStringBuilder.reflectionToString(result)); } }).start(); new Thread(new Runnable() { @Override public void run() { List<AlertStreamEvent> result = deduplicator.dedup(e8); if (result != null) { allResults.addAll(result); } System.out.println("8 >>>> " + ToStringBuilder.reflectionToString(result)); } }).start(); Thread.sleep(2000); long maxCount = 0; for (AlertStreamEvent event : allResults) { Assert.assertNotNull(event.getData()[4]); Assert.assertNotNull(event.getData()[5]); if (((Long) event.getData()[4]) > maxCount) { maxCount = (Long) event.getData()[4]; System.out.println(String.format(">>>>>%s: %s", event, maxCount)); } } }
From source file:org.apache.storm.trident.operation.impl.ChainedResult.java
@Override public String toString() { return ToStringBuilder.reflectionToString(objs); }
From source file:org.apache.whirr.service.accumulo.AccumuloClusterTest.java
@Test @Override/* ww w.j av a 2 s . c om*/ public void testBootstrapAndConfigure() throws Exception { // override the default behaviour to create some scripts which we can // run on docker containers ClusterSpec cookbookWithDefaultRecipe = newClusterSpecForProperties(ImmutableMap.of( "whirr.instance-templates", "1 hadoop-namenode+hadoop-jobtracker+zookeeper+accumulo-master+accumulo-monitor+accumulo-gc, 1 hadoop-datanode+hadoop-tasktracker+accumulo-tserver+accumulo-tracer", "whirr.hadoop.version", "1.2.1", "whirr.zookeeper.tarball.url", "http://archive.apache.org/dist/zookeeper/zookeeper-3.4.5/zookeeper-3.4.5.tar.gz", "hadoop-hdfs.dfs.durable.sync", "true")); DryRun dryRun = launchWithClusterSpec(cookbookWithDefaultRecipe); File tgtDir = new File("target"); TreeMap<String, String> nodePropMap = new TreeMap<String, String>(); Set<String> nodes = new TreeSet<String>(); int n = -1; int i = 0; for (Entry<NodeMetadata, Statement> exe : dryRun.getExecutions().entries()) { NodeMetadata nodeMeta = exe.getKey(); System.err.println(ToStringBuilder.reflectionToString(exe.getKey())); if (!nodes.contains(nodeMeta.getName())) { i = 0; n++; nodes.add(nodeMeta.getName()); } String filename = String.format("%s-%s-%d.sh", nodeMeta.getPrivateAddresses().iterator().next(), nodeMeta.getPublicAddresses().iterator().next(), i); PrintStream ps = new PrintStream(new File(tgtDir, filename)); ps.println(exe.getValue().render(OsFamily.UNIX)); ps.close(); // System.err.println("\t" + exe.getValue().render(OsFamily.UNIX)); i++; nodePropMap.put(String.format("%d\tPUBLIC_IP", n), nodeMeta.getPublicAddresses().iterator().next()); nodePropMap.put(String.format("%d\tPRIVATE_IP", n), nodeMeta.getPrivateAddresses().iterator().next()); nodePropMap.put(String.format("%d\tHOSTNAME", n), nodeMeta.getName()); nodePropMap.put(String.format("%d\tSCRIPTS", n), String.valueOf(i)); } nodePropMap.put("NODES", String.valueOf(nodes.size())); // write jclouds assigned properties to file so we can update with the // actual ones assigned to each docker container File propFile = new File(tgtDir, "cluster.properties"); PrintStream ps = new PrintStream(propFile); for (Entry<String, String> entry : nodePropMap.entrySet()) { ps.println(entry.getKey() + "\t" + entry.getValue()); } ps.close(); }