/** * convienence method: * * @return shortName(obj.getClass()); */ public String shortName(Object obj) { return shortName(obj.getClass()); }
String versionAttributeName() { return "version_of_" + classUtil.shortName(getClass()); }
synchronized private File pidFile() { if (pidFile == null) { String className = classUtil.shortName(getClass()); pidFile = new File(this.baseDir, className + ".pid"); } return pidFile; }
String trimToOptions(String help) { boolean success = false; try { int dividerPos = help.indexOf(DIVIDER); int start = dividerPos + DIVIDER.length(); int stop = help.indexOf(END_TEXT); if (dividerPos == -1) { throw new RuntimeException("Can not parse: <" + help + ">"); } help = help.substring(start, stop); help = help + System.getProperty("line.separator"); success = true; return help; } finally { if (!success) { StringBuffer msg = new StringBuffer(); msg.append("["); msg.append(classUtil.shortName(this)); msg.append("] parsing unseccessful:"); msg.append(str.newLine()); msg.append(help); err.println(msg); } } }
public void testShortName() { assertEquals("String", new ClassUtil().shortName(String.class)); } }
MysqldResource(File baseDir, PrintStream out, PrintStream err, FileUtil fileUtil, Shell.Factory shellFactory, Streams streams, Threads threads, Str str, ClassUtil classUtil) { this.out = out; this.err = err; this.fileUtil = fileUtil; this.shellFactory = shellFactory; this.streams = streams; this.threads = threads; this.str = str; this.classUtil = classUtil; this.optionParser = new HelpOptionsParser(err, threads, classUtil, str); this.versionString = MysqldResourceI.DEFAULT_VERSION; this.killDelay = 30000; if (baseDir.equals(fileUtil.nullFile())) { this.baseDir = new File(fileUtil.tmp(), "mysql-c.mxj"); } else { this.baseDir = baseDir; } this.pidFile = null; this.msgPrefix = "[" + classUtil.shortName(getClass()) + "] "; this.options = new HashMap(); this.setShell(null); setOsAndArch(System.getProperty(Platform.OS_NAME), System .getProperty(Platform.OS_ARCH)); this.trace = new Exception(); this.completionListensers = new ArrayList(); }
public void testGetAgentVersion() throws Exception { Map options = new HashMap(); options.put("foo", "bar"); MysqldResourceI mysqld = new MysqldResourceTestImpl(options); SimpleMysqldDynamicMBean myBean = new SimpleMysqldDynamicMBean(mysqld); String verAttName = myBean.versionAttributeName(); String expected = "$Id: " + new ClassUtil().shortName(myBean); String beanVersion = (String) myBean.getAttribute(verAttName); new TestUtil().assertContainsIgnoreCase(beanVersion, expected); MBeanInfo info = myBean.getMBeanInfo(); MBeanAttributeInfo[] atts = info.getAttributes(); assertTrue(atts[0].isReadable()); assertTrue(atts[0].isWritable()); assertFalse(atts[0].isIs()); assertTrue(atts[1].isReadable()); assertTrue(atts[1].isWritable()); assertFalse(atts[1].isIs()); assertTrue(atts[2].isReadable()); assertFalse(atts[2].isWritable()); assertFalse(atts[2].isIs()); }