public synchronized MBeanServerConnection getMBeanServerConnection(Subject delegationSubject) throws IOException { if (terminated) { if (logger.traceOn()) logger.trace("getMBeanServerConnection","[" + this.toString() + "] already closed."); throw new IOException("Connection closed"); } else if (!connected) { if (logger.traceOn()) logger.trace("getMBeanServerConnection","[" + this.toString() + "] is not connected."); throw new IOException("Not connected"); } return getConnectionWithSubject(delegationSubject); }
@Test public void testSingleWriter() throws IOException { final JMXConnector connection = getConnection(); final MBeanServerConnection mbs = getMbeanServer(connection); final ObjectName writerObject = getWriterObjectName(mbs); final String fileName = StringGenerator.nextRandomString(5); final File file = new File(testSpaceDirectory, fileName); //set parameter to service JmxClientDiscHelper.setByteTarget(mbs,writerObject, (long) (10* TransformValues.MEGABYTE)); JmxClientDiscHelper.setChunkSize(mbs,writerObject,64000); JmxClientDiscHelper.setFileName(mbs,writerObject, fileName); JmxClientDiscHelper.setOutputPath(mbs,writerObject,testSpaceDirectory); JmxClientDiscHelper.setWriterBufferSize(mbs,writerObject,64000); JmxClientDiscHelper.setWriterImplementation(mbs,writerObject, WriterType.BufferedWriter.getKey()); //set run parameter //start a single writer JmxClientDiscHelper.startWriter(mbs,writerObject); }
/** * Execute the specified command. This logic only performs the common * attribute validation required by all subclasses; it does not perform any * functional logic directly. * * @exception BuildException * if a validation error occurs */ @Override public void execute() throws BuildException { if (testIfCondition() && testUnlessCondition()) { try { String error = null; MBeanServerConnection jmxServerConnection = getJMXConnection(); error = jmxExecute(jmxServerConnection); if (error != null && isFailOnError()) { // exception should be thrown only if failOnError == true // or error line will be logged twice throw new BuildException(error); } } catch (Exception e) { if (isFailOnError()) { throw new BuildException(e); } else { handleErrorOutput(e.getMessage()); } } finally { closeRedirector(); } } }
/** * Obtain the default JBoss JCA WorkManager through a JMX lookup * for the JBossWorkManagerMBean. * @param mbeanName the JMX object name to use * @see org.jboss.resource.work.JBossWorkManagerMBean */ public static WorkManager getWorkManager(String mbeanName) { Assert.hasLength(mbeanName, "JBossWorkManagerMBean name must not be empty"); try { Class<?> mbeanClass = JBossWorkManagerUtils.class.getClassLoader().loadClass(JBOSS_WORK_MANAGER_MBEAN_CLASS_NAME); InitialContext jndiContext = new InitialContext(); MBeanServerConnection mconn = (MBeanServerConnection) jndiContext.lookup(MBEAN_SERVER_CONNECTION_JNDI_NAME); ObjectName objectName = ObjectName.getInstance(mbeanName); Object workManagerMBean = MBeanServerInvocationHandler.newProxyInstance(mconn, objectName, mbeanClass, false); Method getInstanceMethod = workManagerMBean.getClass().getMethod("getInstance"); return (WorkManager) getInstanceMethod.invoke(workManagerMBean); } catch (Exception ex) { throw new IllegalStateException( "Could not initialize JBossWorkManagerTaskExecutor because JBoss API is not available", ex); } }
/** * @param jmxServerConnection * @param name * @return The value of the given named attribute * @throws Exception */ protected String jmxGet(MBeanServerConnection jmxServerConnection,String name) throws Exception { String error = null; if(isEcho()) { handleOutput("MBean " + name + " get attribute " + attribute ); } Object result = jmxServerConnection.getAttribute( new ObjectName(name), attribute); if (result != null) { echoResult(attribute,result); createProperty(result); } else error = "Attribute " + attribute + " is empty"; return error; }
/** * Test all base variables of the reader jmx interface */ @Test public void t1testStandardVariableOverJMX() throws IOException { final JMXConnector connection = getConnection(); final MBeanServerConnection mbs = getMbeanServer(connection); final ObjectName readerObject = getReaderObjectName(mbs); //assert path final String path = JmxClientReaderHelper.getFilePath(mbs,readerObject); Assert.assertEquals(System.getProperty("user.dir"), path); //assert filename final String filename = JmxClientReaderHelper.getFileName(mbs,readerObject); Assert.assertEquals("none", filename); //assert chunksize final int chunkSize = JmxClientReaderHelper.getChunkSize(mbs,readerObject); Assert.assertEquals(8192, chunkSize); //assert takeMeasurements final String takeMeasurements = JmxClientReaderHelper.getTakeMeasurements(mbs,readerObject); final boolean takeMeasurementsAsBoolean = JmxClientReaderHelper.getTakeMeasurementsAsBoolean(mbs,readerObject); Assert.assertEquals(true, takeMeasurementsAsBoolean); Assert.assertEquals("true", takeMeasurements); //assert measurementvolume final int measurementVolume = JmxClientReaderHelper.getMeasurementVolume(mbs,readerObject); Assert.assertEquals(-1,measurementVolume); //assert readertype final String readerType = JmxClientReaderHelper.getReaderType(mbs,readerObject); final ReaderType readerTypeAsEnum = JmxClientReaderHelper.getReaderTypeAsType(mbs,readerObject); Assert.assertEquals(ReaderType.none, readerTypeAsEnum); Assert.assertEquals("none", readerType); }
/** * get the current state of the TakeMeasurements flag as boolean. * @param mbs mbean server * @param on client reader object name * @return boolean | false is the default value or error value */ public static boolean getTakeMeasurementsAsBoolean(final MBeanServerConnection mbs, final ObjectName on){ String param = getTakeMeasurements(mbs,on); if("true".equals(param)) return true; else if("false".equals(param)) return false; else log.log(Level.INFO,"JmxClientReaderHelper getTakeMeasurement - JMX returned some weird value for TakeMeasurements: " + param); return false; }
protected int doSetRequest(MBeanServerConnection mbsc, ObjectName on, boolean expectedException) { int errorCount = 0; try { Utils.debug(Utils.DEBUG_STANDARD, "ClientSide::doSetRequest: Set attributes of the MBean") ; Attribute attribute = new Attribute("Attribute", "My value") ; mbsc.setAttribute(on, attribute) ; if (expectedException) { System.out.println("ClientSide::doSetRequest: " + "(ERROR) Set did not fail with expected SecurityException"); errorCount++; } else { System.out.println("ClientSide::doSetRequest: (OK) Set succeed") ; } } catch(Exception e) { Utils.printThrowable(e, true) ; if (expectedException) { if (e instanceof java.lang.SecurityException) { System.out.println("ClientSide::doSetRequest: " + "(OK) Set failed with expected SecurityException") ; } else { System.out.println("ClientSide::doSetRequest: " + "(ERROR) Set failed with " + e.getClass() + " instead of expected SecurityException"); errorCount++; } } else { System.out.println("ClientSide::doSetRequest: (ERROR) Set failed"); errorCount++; } } return errorCount; }
public AgentLoggerJMXProxy(IAgentId agentName, MBeanServerConnection mbsc, ObjectName parentName) { super(agentName); this.mbsc = mbsc; this.parentName = parentName; ObjectName objectName = AgentLogger.getJMXAgentLoggerName(parentName); this.agentLoggerProxy = new DynamicProxy(objectName, mbsc); }
public MBeanServerConnection call() { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); try { JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://"); JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer( url, null, mbs); cs.start(); JMXServiceURL addr = cs.getAddress(); connector = JMXConnectorFactory.connect(addr); return connector.getMBeanServerConnection(); } catch (IOException e) { throw new RuntimeException(e); } }
protected int doCreateRequest(MBeanServerConnection mbsc, ObjectName on, boolean expectedException) { int errorCount = 0; try { Utils.debug(Utils.DEBUG_STANDARD, "ClientSide::doCreateRequest: Create and register the MBean") ; mbsc.createMBean("Simple", on) ; if (expectedException) { System.out.println("ClientSide::doCreateRequest: " + "(ERROR) Create did not fail with expected SecurityException"); errorCount++; } else { System.out.println("ClientSide::doCreateRequest: (OK) Create succeed") ; } } catch(Exception e) { Utils.printThrowable(e, true) ; if (expectedException) { if (e instanceof java.lang.SecurityException) { System.out.println("ClientSide::doCreateRequest: " + "(OK) Create failed with expected SecurityException") ; } else { System.out.println("ClientSide::doCreateRequest: " + "(ERROR) Create failed with " + e.getClass() + " instead of expected SecurityException"); errorCount++; } } else { System.out.println("ClientSide::doCreateRequest: " + "(ERROR) Create failed"); errorCount++; } } return errorCount; }
/** * Dumps a local or remote MBeanServer's entire object tree for support purposes. Nested arrays and CompositeData * objects in MBean attribute values are handled. * * @param connection * the server connection (or server itself) * @param out * PrintWriter to write the output to * @throws IOException * Signals that an I/O exception has occurred. */ public static void dumpConnection(MBeanServerConnection connection, PrintWriter out) throws IOException { JmxDumpUtil.showStartBanner(out); // Get all the object names Set<ObjectName> objectNames = connection.queryNames(null, null); // Sort the names (don't assume ObjectName implements Comparable in JDK 1.5) Set<ObjectName> newObjectNames = new TreeSet<ObjectName>(new Comparator<ObjectName>() { public int compare(ObjectName o1, ObjectName o2) { return o1.toString().compareTo(o2.toString()); } }); newObjectNames.addAll(objectNames); objectNames = newObjectNames; // Dump each MBean for (ObjectName objectName : objectNames) { try { printMBeanInfo(connection, objectName, out); } catch (JMException e) { // Sometimes beans can disappear while we are examining them } } }
/** * Dumps the details of a single MBean. * * @param connection * the server connection (or server itself) * @param objectName * the object name * @param out * PrintWriter to write the output to * @throws IOException * Signals that an I/O exception has occurred. * @throws JMException * Signals a JMX error */ private static void printMBeanInfo(MBeanServerConnection connection, ObjectName objectName, PrintWriter out) throws IOException, JMException { Map<String, Object> attributes = new TreeMap<String, Object>(); MBeanInfo info = connection.getMBeanInfo(objectName); attributes.put("** Object Name", objectName.toString()); attributes.put("** Object Type", info.getClassName()); for (MBeanAttributeInfo element : info.getAttributes()) { Object value; if (element.isReadable()) { try { value = connection.getAttribute(objectName, element.getName()); } catch (Exception e) { value = JmxDumpUtil.PROTECTED_VALUE; } } else { value = JmxDumpUtil.PROTECTED_VALUE; } attributes.put(element.getName(), value); } if (objectName.getCanonicalName().equals("Alfresco:Name=SystemProperties")) { String osName = (String) attributes.get(OS_NAME); if (osName != null && osName.toLowerCase().startsWith("linux")) { attributes.put(OS_NAME, updateOSNameAttributeForLinux(osName)); } } tabulate(JmxDumpUtil.NAME_HEADER, JmxDumpUtil.VALUE_HEADER, attributes, out, 0); }
private static void doExploit ( final Object payloadObject, MBeanServerConnection mbc ) throws IOException, InstanceNotFoundException, IntrospectionException, ReflectionException { Object[] params = new Object[1]; params[ 0 ] = payloadObject; System.err.println("Querying MBeans"); Set<ObjectInstance> testMBeans = mbc.queryMBeans(null, null); System.err.println("Found " + testMBeans.size() + " MBeans"); for ( ObjectInstance oi : testMBeans ) { MBeanInfo mBeanInfo = mbc.getMBeanInfo(oi.getObjectName()); for ( MBeanOperationInfo opInfo : mBeanInfo.getOperations() ) { try { mbc.invoke(oi.getObjectName(), opInfo.getName(), params, new String[] {}); System.err.println(oi.getObjectName() + ":" + opInfo.getName() + " -> SUCCESS"); return; } catch ( Throwable e ) { String msg = e.getMessage(); if ( msg.startsWith("java.lang.ClassNotFoundException:") ) { int start = msg.indexOf('"'); int stop = msg.indexOf('"', start + 1); String module = ( start >= 0 && stop > 0 ) ? msg.substring(start + 1, stop) : "<unknown>"; if ( !"<unknown>".equals(module) && !"org.jboss.as.jmx:main".equals(module) ) { int cstart = msg.indexOf(':'); int cend = msg.indexOf(' ', cstart + 2); String cls = msg.substring(cstart + 2, cend); System.err.println(oi.getObjectName() + ":" + opInfo.getName() + " -> FAIL CNFE " + cls + " (" + module + ")"); } } else { System.err.println(oi.getObjectName() + ":" + opInfo.getName() + " -> SUCCESS|ERROR " + msg); return; } } } } }
/** * @param jmxServerConnection * @param name * @return The value of the given named attribute * @throws Exception */ protected String jmxGet(MBeanServerConnection jmxServerConnection, String name) throws Exception { String error = null; if (isEcho()) { handleOutput("MBean " + name + " get attribute " + attribute); } Object result = jmxServerConnection.getAttribute(new ObjectName(name), attribute); if (result != null) { echoResult(attribute, result); createProperty(result); } else error = "Attribute " + attribute + " is empty"; return error; }
/** * Execute the specified command, based on the configured properties. The * input stream will be closed upon completion of this task, whether it was * executed successfully or not. * * @exception Exception * if an error occurs */ @Override public String jmxExecute(MBeanServerConnection jmxServerConnection) throws Exception { if (getName() == null) { throw new BuildException("Must specify a 'name'"); } return jmxUuregister(jmxServerConnection, getName()); }
/** * Unregister Mbean * @param jmxServerConnection * @param name * @return The value of the given named attribute * @throws Exception */ protected String jmxUuregister(MBeanServerConnection jmxServerConnection,String name) throws Exception { String error = null; if(isEcho()) { handleOutput("Unregister MBean " + name ); } jmxServerConnection.unregisterMBean( new ObjectName(name)); return error; }
/** * Execute the specified command, based on the configured properties. The * input stream will be closed upon completion of this task, whether it was * executed successfully or not. * * @exception Exception * if an error occurs */ @Override public String jmxExecute(MBeanServerConnection jmxServerConnection) throws Exception { if (getName() == null) { throw new BuildException("Must specify a 'name'"); } if ((className == null)) { throw new BuildException( "Must specify a 'className' for get"); } return jmxCreate(jmxServerConnection, getName()); }
private Map<String, MeterMetric> getMetricsFromMBean(MBeanServerConnection mBeanServerConnection, Optional<String> topic) { Map<String, MeterMetric> result = new HashMap<String, MeterMetric>(); KafkaMetrics metrics = new KafkaMetrics(); for (String metric : metricName) { if (result.containsKey(metric)) { result.put(metric, merge(result.get(metric), metrics.getItem(mBeanServerConnection, topic, metric))); } else { result.put(metric, metrics.getItem(mBeanServerConnection, topic, metric)); } } return result; }
/** * Execute the specified command, based on the configured properties. The * input stream will be closed upon completion of this task, whether it was * executed successfully or not. * * @exception BuildException * if an error occurs */ @Override public String jmxExecute(MBeanServerConnection jmxServerConnection) throws Exception { if (getName() == null) { throw new BuildException("Must specify a 'name'"); } if ((operation == null)) { throw new BuildException("Must specify a 'operation' for call"); } return jmxInvoke(jmxServerConnection, getName()); }
/** Wait until AMX has loaded and is ready for use. <p> This will <em>not</em> cause AMX to load; it will block forever until AMX is ready. In other words, don't call this method unless it's a convenient thread that can wait forever. */ public ObjectName waitAMXReady( final MBeanServerConnection server) { final WaitForDomainRootListenerCallback callback = new WaitForDomainRootListenerCallback(server); listenForDomainRoot( server, callback ); callback.await(); return callback.getRegistered(); }
protected MBeanServerConnection getJMXConnection() throws MalformedURLException, IOException { return JMXAccessorTask.accessJMXConnection( getProject(), getUrl(), getHost(), getPort(), getUsername(), getPassword(), ref); }
static MXBeanLookup lookupFor(MBeanServerConnection mbsc) { synchronized (mbscToLookup) { WeakReference<MXBeanLookup> weakLookup = mbscToLookup.get(mbsc); MXBeanLookup lookup = (weakLookup == null) ? null : weakLookup.get(); if (lookup == null) { lookup = new MXBeanLookup(mbsc); mbscToLookup.put(mbsc, new WeakReference<MXBeanLookup>(lookup)); } return lookup; } }
private JvmReadingInstance getHeapSurvivor( MBeanServerConnection connection, ReadingBean reading ) { String jvmPort = reading.getParameter("JMX_PORT"); final MBeanWrapper mbeanWrapper = mbeanWrappers.get(jvmPort); return new JvmReadingInstance(connection, String.valueOf(reading.getDbId()), reading.getMonitorName(), getName(reading, jvmPort), reading.getUnit(), 0) { private static final long serialVersionUID = 1L; @Override public void init() { applyMemoryNormalizationFactor(); mBeanName = mbeanWrapper.getObjectName("java.lang:type=MemoryPool,name=Survivor Space"); } @Override public float poll() { CompositeData attribute = (CompositeData) mbeanWrapper.getMBeanAttribute(mBeanName, "Usage"); return fixLongValue(Long.valueOf( (attribute).get("used").toString())) * normalizationFactor; } }; }
private JvmReadingInstance getClassesCount( MBeanServerConnection connection, ReadingBean reading ) { String jvmPort = reading.getParameter("JMX_PORT"); final MBeanWrapper mbeanWrapper = mbeanWrappers.get(jvmPort); return new JvmReadingInstance(connection, String.valueOf(reading.getDbId()), reading.getMonitorName(), getName(reading, jvmPort), reading.getUnit(), 1) { private static final long serialVersionUID = 1L; @Override public void init() { mBeanName = mbeanWrapper.getObjectName("java.lang:type=ClassLoading"); } @Override public float poll() { return fixLongValue(Long.valueOf(mbeanWrapper.getMBeanAttribute(mBeanName, "LoadedClassCount") .toString())) * normalizationFactor; } }; }
private JvmReadingInstance getThreadsCount( MBeanServerConnection connection, ReadingBean reading ) { String jvmPort = reading.getParameter("JMX_PORT"); final MBeanWrapper mbeanWrapper = mbeanWrappers.get(jvmPort); return new JvmReadingInstance(connection, String.valueOf(reading.getDbId()), reading.getMonitorName(), getName(reading, jvmPort), reading.getUnit(), 1) { private static final long serialVersionUID = 1L; @Override public void init() { mBeanName = mbeanWrapper.getObjectName("java.lang:type=Threading"); } @Override public float poll() { return fixLongValue(Long.valueOf(mbeanWrapper.getMBeanAttribute(mBeanName, "ThreadCount") .toString())) * normalizationFactor; } }; }
/** * Prints all MBeans whatever the domain is. */ private static void printMBeans(MBeanServerConnection mbsc) throws Exception { Set<ObjectName> set = mbsc.queryNames(null, null); System.out.println("---- MBeans found :"); for (Iterator<ObjectName> iter = set.iterator(); iter.hasNext(); ) { System.out.println(iter.next().toString()); } System.out.println("\n") ; }
/** * Call Mbean server for some mbeans with same domain, attributes. * with <em>attributebinding=true</em> you can save all attributes from all found objects * as your ant properties * @param jmxServerConnection * @param qry * @return The query result */ protected String jmxQuery(MBeanServerConnection jmxServerConnection, String qry) { String isError = null; Set<ObjectName> names = null; String resultproperty = getResultproperty(); try { names = jmxServerConnection.queryNames(new ObjectName(qry), null); if (resultproperty != null) { setProperty(resultproperty + ".Length",Integer.toString(names.size())); } } catch (Exception e) { if (isEcho()) handleErrorOutput(e.getMessage()); return "Can't query mbeans " + qry; } if (resultproperty != null) { Iterator<ObjectName> it = names.iterator(); int oindex = 0; String pname = null; while (it.hasNext()) { ObjectName oname = it.next(); pname = resultproperty + "." + Integer.toString(oindex) + "."; oindex++; setProperty(pname + "Name", oname.toString()); if (isAttributebinding()) { bindAttributes(jmxServerConnection, resultproperty, pname, oname); } } } return isError; }
/** * Test if there are Controller and NetworkManager registered to MBeanServer */ @Test public void testRegisteredObjects() throws IOException { //connect to server final JMXConnector connection = JmxConnectionHelper.buildJmxMPConnector(JMXSERVERIP,serverObj.getConnectorSystemPort()); //get MBeanServerConnection MBeanServerConnection mbsConnection = JmxServerHelper.getMBeanServer(connection); //do test Assert.assertNotSame(0,mbsConnection.getMBeanCount()); //check if there are beans registered //look for all standard mbeans List<ObjectName> standardMbeans = JmxServerHelper.findObjectNames(mbsConnection,"de.b4sh.byter"); Assert.assertNotEquals(0,standardMbeans.size()); //see if there is a network manager registered to ObjectName networkManager = null; for(ObjectName on: standardMbeans){ if(on.getCanonicalName().contains("NetworkManager")){ networkManager = on; } } Assert.assertNotNull(networkManager); }
private void initTransients() { rmbscMap = new WeakHashMap<Subject, WeakReference<MBeanServerConnection>>(); connected = false; terminated = false; connectionBroadcaster = new NotificationBroadcasterSupport(); }
/** Listen for the registration of the {@link BootAMXMBean}. Listening starts automatically. See {@link AMXBooter#BootAMXCallback}. */ public <T extends MBeanListener.Callback> MBeanListener<T> listenForBootAMX( final MBeanServerConnection server, final T callback) { final MBeanListener<T> listener = new MBeanListener<T>( server, getBootAMXMBeanObjectName(), callback); listener.startListening(); return listener; }
@Test public void t4testStartMultipleReader() throws IOException { //create a test case file TestCaseHelper.createTestCaseFile(testSpaceDir,"test-multi-file.test",10000,100); //connect to client final JMXConnector connection = getConnection(); final MBeanServerConnection mbs = getMbeanServer(connection); final ObjectName readerObject = getReaderObjectName(mbs); //set params JmxClientReaderHelper.setFilePath(mbs,readerObject,testSpaceDir); JmxClientReaderHelper.setFileName(mbs,readerObject,"test-multi-file.test"); JmxClientReaderHelper.setChunkSize(mbs,readerObject,16000); JmxClientReaderHelper.setTakeMeasurements(mbs,readerObject,false); JmxClientReaderHelper.setMeasurementVolume(mbs,readerObject,-1); JmxClientReaderHelper.setReaderType(mbs,readerObject,ReaderType.rafr.getType()); JmxClientReaderHelper.startMultipleReader(mbs,readerObject,5); ThreadManager.nap(2500);//let the reader read a bit :) Assert.assertEquals(5,JmxClientReaderHelper.getReaderPoolSize(mbs,readerObject)); final String response = JmxClientReaderHelper.stopServicePool(mbs,readerObject); log.log(Level.INFO, response); }
private static void printAttrs( MBeanServerConnection mbsc1, Class<? extends Exception> expectX) throws Exception { Set<ObjectName> names = mbsc1.queryNames(null, null); for (ObjectName name : names) { System.out.println(name + ":"); MBeanInfo mbi = mbsc1.getMBeanInfo(name); MBeanAttributeInfo[] mbais = mbi.getAttributes(); for (MBeanAttributeInfo mbai : mbais) { String attr = mbai.getName(); Object value; try { value = mbsc1.getAttribute(name, attr); } catch (Exception e) { if (expectX != null && expectX.isInstance(e)) value = "<" + e + ">"; else throw e; } String s = " " + attr + " = " + value; if (s.length() > 80) s = s.substring(0, 77) + "..."; System.out.println(s); } } }
private final int doCompilationMXBeanTest(MBeanServerConnection mbsc) { int errorCount = 0 ; System.out.println("---- CompilationMXBean") ; try { ObjectName compilationName = new ObjectName(ManagementFactory.COMPILATION_MXBEAN_NAME); if ( mbsc.isRegistered(compilationName) ) { MBeanInfo mbInfo = mbsc.getMBeanInfo(compilationName); errorCount += checkNonEmpty(mbInfo); System.out.println("getMBeanInfo\t\t" + mbInfo); CompilationMXBean compilation = null ; compilation = JMX.newMXBeanProxy(mbsc, compilationName, CompilationMXBean.class) ; System.out.println("getName\t\t" + compilation.getName()); boolean supported = compilation.isCompilationTimeMonitoringSupported() ; System.out.println("isCompilationTimeMonitoringSupported\t\t" + supported); if ( supported ) { System.out.println("getTotalCompilationTime\t\t" + compilation.getTotalCompilationTime()); } } System.out.println("---- OK\n") ; } catch (Exception e) { Utils.printThrowable(e, true) ; errorCount++ ; System.out.println("---- ERROR\n") ; } return errorCount ; }
/** * Execute the specified command. This logic only performs the common * attribute validation required by all subclasses; it does not perform any * functional logic directly. * * @exception BuildException * if a validation error occurs */ public void execute() throws BuildException { if (testIfCondition() && testUnlessCondition()) { try { String error = null; MBeanServerConnection jmxServerConnection = getJMXConnection(); error = jmxExecute(jmxServerConnection); if (error != null && isFailOnError()) { // exception should be thrown only if failOnError == true // or error line will be logged twice throw new BuildException(error); } } catch (Throwable t) { if (isFailOnError()) { throw new BuildException(t); } else { handleErrorOutput(t.getMessage()); } } finally { closeRedirector(); } } }