List of usage examples for org.apache.commons.lang.builder ReflectionToStringBuilder toString
public static String toString(Object object)
Builds a toString
value using the default ToStringStyle
through reflection.
From source file:jp.primecloud.auto.nifty.process.NiftyProcessClient.java
public VolumeDto waitAttachVolume(String volumeId, String instanceId) { // TODO: API?????????????? VolumeDto volume = null;//from w ww . ja v a 2 s . c o m long timeout = 600 * 1000L; long startTime = System.currentTimeMillis(); while (true) { volume = waitVolume(volumeId); if ("in-use".equals(volume.getStatus())) { break; } if (System.currentTimeMillis() - startTime > timeout) { // ????????? throw new AutoException("EPROCESS-000623", instanceId, volumeId, volume.getStatus()); } } if (!"in-use".equals(volume.getStatus())) { // ? AutoException exception = new AutoException("EPROCESS-000623", instanceId, volumeId, volume.getStatus()); exception.addDetailInfo("result=" + ReflectionToStringBuilder.toString(volume)); throw exception; } // if (log.isInfoEnabled()) { log.info(MessageUtils.getMessage("IPROCESS-100524", volumeId, instanceId)); } return volume; }
From source file:jp.primecloud.auto.nifty.process.NiftyProcessClient.java
public VolumeDto waitDetachVolume(String volumeId, String instanceId) { // TODO: API?????????????? VolumeDto volume = null;/*from w ww . j a va 2 s .c o m*/ long timeout = 600 * 1000L; long startTime = System.currentTimeMillis(); while (true) { volume = waitVolume(volumeId); if ("available".equals(volume.getStatus())) { break; } if (System.currentTimeMillis() - startTime > timeout) { // ????????? throw new AutoException("EPROCESS-000625", instanceId, volumeId, volume.getStatus()); } } if (!"available".equals(volume.getStatus())) { // ? AutoException exception = new AutoException("EPROCESS-000625", instanceId, volumeId, volume.getStatus()); exception.addDetailInfo("result=" + ReflectionToStringBuilder.toString(volume)); throw exception; } // if (log.isInfoEnabled()) { log.info(MessageUtils.getMessage("IPROCESS-100526", volumeId, instanceId)); } return volume; }
From source file:jp.primecloud.auto.process.vmware.VmwareProcessClient.java
public VirtualDisk attachDisk(String machineName, Integer scsiId, Integer size, String fileName) { // VirtualMachine VirtualMachine machine = getVirtualMachine(machineName); // ???????/* w w w .j a va2 s . c o m*/ boolean existDisk = StringUtils.isEmpty(fileName) ? false : true; // ?? VirtualDisk disk; if (!existDisk) { // ????? disk = newDisk(machine, scsiId, size); } else { // ??? disk = reuseDisk(machine, scsiId, fileName); } // ?? VirtualDeviceConfigSpec diskSpec = new VirtualDeviceConfigSpec(); diskSpec.setOperation(VirtualDeviceConfigSpecOperation.add); if (!existDisk) { diskSpec.setFileOperation(VirtualDeviceConfigSpecFileOperation.create); } diskSpec.setDevice(disk); VirtualMachineConfigSpec configSpec = new VirtualMachineConfigSpec(); configSpec.setDeviceChange(new VirtualDeviceConfigSpec[] { diskSpec }); // ?? Task task; try { task = machine.reconfigVM_Task(configSpec); } catch (RemoteException e) { throw new AutoException("EPROCESS-000515", e, machineName); } if (log.isInfoEnabled()) { log.info(MessageUtils.getMessage("IPROCESS-100451", machineName)); } // ????? try { task.waitForTask(); } catch (RemoteException e) { throw new AutoException("EPROCESS-000515", e, machineName); } catch (InterruptedException ignore) { } // ?? TaskInfo taskInfo; try { taskInfo = task.getTaskInfo(); } catch (RemoteException e) { throw new AutoException("EPROCESS-000515", e, machineName); } if (taskInfo.getState() != TaskInfoState.success) { // ?????? AutoException exception = new AutoException("EPROCESS-000515", machineName); if (taskInfo.getError() != null) { exception.addDetailInfo(ReflectionToStringBuilder.toString(taskInfo.getError().getFault())); exception.addDetailInfo(taskInfo.getError().getLocalizedMessage()); } throw exception; } if (log.isInfoEnabled()) { log.info(MessageUtils.getMessage("IPROCESS-100452", machineName)); } return getVirtualDisk(machine, scsiId); }
From source file:jp.primecloud.auto.process.vmware.VmwareProcessClient.java
public void detachDisk(String machineName, Integer scsiId) { // VirtualMachine VirtualMachine machine = getVirtualMachine(machineName); // ???//from w w w .j a va 2 s. c o m VirtualDisk disk = getVirtualDisk(machine, scsiId); // ?? VirtualDeviceConfigSpec diskSpec = new VirtualDeviceConfigSpec(); diskSpec.setOperation(VirtualDeviceConfigSpecOperation.remove); //diskSpec.setFileOperation(VirtualDeviceConfigSpecFileOperation.destroy); diskSpec.setDevice(disk); VirtualMachineConfigSpec configSpec = new VirtualMachineConfigSpec(); configSpec.setDeviceChange(new VirtualDeviceConfigSpec[] { diskSpec }); // ?? Task task; try { task = machine.reconfigVM_Task(configSpec); } catch (RemoteException e) { throw new AutoException("EPROCESS-000516", e, machineName); } if (log.isInfoEnabled()) { log.info(MessageUtils.getMessage("IPROCESS-100453", machineName)); } // ????? try { task.waitForTask(); } catch (RemoteException e) { throw new AutoException("EPROCESS-000516", e, machineName); } catch (InterruptedException ignore) { } // ?? TaskInfo taskInfo; try { taskInfo = task.getTaskInfo(); } catch (RemoteException e) { throw new AutoException("EPROCESS-000516", e, machineName); } if (taskInfo.getState() != TaskInfoState.success) { // ?????? AutoException exception = new AutoException("EPROCESS-000516", machineName); if (taskInfo.getError() != null) { exception.addDetailInfo(ReflectionToStringBuilder.toString(taskInfo.getError().getFault())); exception.addDetailInfo(taskInfo.getError().getLocalizedMessage()); } throw exception; } if (log.isInfoEnabled()) { log.info(MessageUtils.getMessage("IPROCESS-100454", machineName)); } }
From source file:jp.primecloud.auto.process.vmware.VmwareProcessClient.java
public void customize(String machineName, CustomizationSpec customSpec) { // VirtualMachine VirtualMachine machine = getVirtualMachine(machineName); // ?/*from www . ja v a 2 s. c o m*/ Task task; try { task = machine.customizeVM_Task(customSpec); } catch (RemoteException e) { throw new AutoException("EPROCESS-000529", e, machineName); } // ????? try { task.waitForTask(); } catch (RemoteException e) { throw new AutoException("EPROCESS-000529", e, machineName); } catch (InterruptedException ignore) { } // ?? TaskInfo taskInfo; try { taskInfo = task.getTaskInfo(); } catch (RemoteException e) { throw new RuntimeException(e); } if (taskInfo.getState() != TaskInfoState.success) { // ????? AutoException exception = new AutoException("EPROCESS-000529", machineName); if (taskInfo.getError() != null) { exception.addDetailInfo(ReflectionToStringBuilder.toString(taskInfo.getError().getFault())); exception.addDetailInfo(taskInfo.getError().getLocalizedMessage()); } throw exception; } }
From source file:org.apache.hadoop.hdfs.protocol.RandomObjectsGenerators.java
/** Compares writable objects and outputs them verbosely in case of mismatch */ static void assertEqualsVerbose(Writable object, Writable objectCopy) { assertArrayEquals(//from www . ja v a2s. c om "\nwritten : " + ReflectionToStringBuilder.toString(object) + "\nread : " + ReflectionToStringBuilder.toString(objectCopy), WritableUtils.toByteArray(object), WritableUtils.toByteArray(objectCopy)); }
From source file:org.diffkit.common.DKElementComparator.java
public String getDescription() { return ReflectionToStringBuilder.toString(this); }
From source file:org.jboss.windup.decorator.java.JavaASTAnnotationVisitor.java
protected String extract(org.eclipse.jdt.core.dom.Expression value) { if (value instanceof Name) { return extract((Name) value); } else if (value instanceof ArrayInitializer) { return extract((ArrayInitializer) value); } else if (value instanceof NullLiteral) { return extract((NullLiteral) value); } else if (value instanceof NumberLiteral) { return extract((NumberLiteral) value); } else if (value instanceof StringLiteral) { return extract((StringLiteral) value); } else if (value instanceof BooleanLiteral) { return extract((BooleanLiteral) value); } else if (value instanceof TypeLiteral) { return extract((TypeLiteral) value); }/*from w ww .j av a 2 s. c om*/ return "Unknown: " + ReflectionToStringBuilder.toString(value); }
From source file:org.jboss.windup.decorator.java.JavaASTAnnotationVisitor.java
@Override public boolean visit(NormalAnnotation node) { List objects = node.values(); String name = qualify(node.getTypeName()); LOG.info("Node Type: " + name); if (objects != null) { for (Object object : objects) { if (object instanceof MemberValuePair) { MemberValuePair pair = (MemberValuePair) object; String val = extract(pair.getValue()); LOG.info("Name: " + pair.getName().toString() + ", Value: " + val); } else { LOG.info("Unknown: Value: " + ReflectionToStringBuilder.toString(object)); }/*w ww .j a va2s . c o m*/ } } return super.visit(node); }
From source file:org.jboss.windup.decorator.java.JavaASTDecorator.java
@Override public void processMeta(final JavaMetadata meta) { ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setBindingsRecovery(true);/*from w ww .jav a2 s.co m*/ parser.setResolveBindings(true); try { parser.setSource(FileUtils.readFileToString(meta.getFilePointer()).toCharArray()); } catch (IOException e) { LOG.error("Exception setting source for parser.", e); return; } parser.setKind(ASTParser.K_COMPILATION_UNIT); Set<String> allDependencies = new HashSet<String>(meta.getClassDependencies().size()); allDependencies.addAll(javaLangDependencies); final CompilationUnit cu = (CompilationUnit) parser.createAST(null); cu.accept(new JavaASTVariableResolvingVisitor(cu, meta.getDecorations(), meta.getQualifiedClassName(), allDependencies, meta.getBlackListedDependencies())); //TODO: finish. cu.accept(new JavaASTAnnotationVisitor(cu, meta.getDecorations(), allDependencies)); for (Object o : cu.types()) { TypeDeclaration td = (TypeDeclaration) o; String qualifiedTemp = cu.getPackage().getName() + "." + td.getName().toString(); if (StringUtils.equals(qualifiedTemp, meta.getQualifiedClassName())) { LOG.debug("Matched: " + qualifiedTemp); } else { LOG.warn(qualifiedTemp + " did not match " + meta.getQualifiedClassName()); continue; } meta.setInterfaceClz(td.isInterface()); for (Object m : td.modifiers()) { if (!(m instanceof Modifier)) { // skip if it isn't a modifier type. LOG.debug("Instance: " + ReflectionToStringBuilder.toString(m)); continue; } Modifier mod = (Modifier) m; if (StringUtils.equals("public", mod.getKeyword().toString())) { if (LOG.isDebugEnabled()) { LOG.debug("Setting class: " + qualifiedTemp + " as public."); } meta.setPublicClz(true); } if (StringUtils.equals("abstract", mod.getKeyword().toString())) { if (LOG.isDebugEnabled()) { LOG.debug("Setting class: " + qualifiedTemp + " as abstract."); } meta.setAbstractClz(true); } } } // at this point, we should have all of the interested parties. super.chainDecorators(meta); }