/** * attaches aspectj without arguments * @param args */ public static final void main(String[] args) { System.setProperty("LogMeAs.system.out", "true"); if (args == null) args = new String[0]; if (args.length <= 1 && (args[0].contains("?") || args[0].toLowerCase().contains("help"))) { System.out.println(AttachAgent.class.getName() + "{VM-PID or 0} [agent-lib-jar [agent-class [argent-method]]]"); return; } int i = 0; String pid = args.length > i ? args[i++] : null; String jar = args.length > i ? args[i++] : AGENT_JAR_ASPECTJ; String cls = args.length > i ? args[i++] : AGENT_CLS_ASPECTJ; String mtd = args.length > i ? args[i++] : AGENT_MTD_ASPECTJ; if (NumberUtil.toNumber(pid) <= 0) pid = null; if (!attachGivenAgentToThisVM(jar, cls, mtd, pid)) throw new IllegalStateException("agent couldn't be loaded!"); } }
/** * creates new objects, cloned from defaultClone and with increasing attribute value - evaluated by first+count+step. * @param defaultClone * @param attributeName * @param first first attribute value - defaultClone can contain the value or this must not be null * @param count number of objects to create * @param step step of increase * @return list of new created objects */ public static <S> List<S> create(S defaultClone, String attributeName, Object first, int count, double step) { Object clone, value; ArrayList result = new ArrayList(); if (first == null) { first = Bean.getBean(defaultClone).getAttribute(attributeName).getValue(); } long start = NumberUtil.toNumber(first); long end = (long) (start + count * step); for (long i = start; i < end; i+=step) { clone = clone(defaultClone); value = NumberUtil.fromNumber(i, first.getClass()); Bean.getBean(clone).getAttribute(attributeName).setValue(value); result.add(clone); } return result; }