static {
   // Ugly hack. Here lies PropertyEditors.init(). Below code is progeny. It is required to
   // properly instantiate
   // ThreadPools. The threadpools dont do that for themselves. ThreadPools are in common-core.
   try {
     PropertyEditorFinder.getInstance().register(BlockingMode.class, BlockingModeEditor.class);
   } catch (Exception ignored) {
   }
 }
 @Before
 public void init() {
   // initialize locale, this is done for date editor, it wont pass test unless its run on EN
   // system :).
   Locale testLocale = Locale.US;
   Locale.setDefault(testLocale);
   // init editors
   finder = PropertyEditorFinder.getInstance();
 }
  private static Object newValue(final Class<?> type, final String value) {
    final PropertyEditor editor = PropertyEditorFinder.getInstance().find(type);
    if (editor == null) {
      SarLogger.ROOT_LOGGER.propertyNotFound(type);
      return null;
    }
    editor.setAsText(value);

    return editor.getValue();
  }
  public Element getElementServiceBindingValue(ServiceBinding binding, Element input) {
    if (input == null) throw new IllegalArgumentException("input cannot be null");

    PropertyEditor editor = PropertyEditorFinder.getInstance().find(Element.class);
    if (editor == null)
      throw new IllegalStateException("Cannot find PropertyEditor for type Element");

    editor.setValue(input);
    Reader reader = new StringReader(editor.getAsText());
    Writer writer = new StringWriter();

    doXslTransform(binding, getConfig(binding), reader, writer);

    editor.setAsText(writer.toString());
    return (Element) editor.getValue();
  }
  public Object getValue(ServiceValueContext valueContext) throws Exception {
    MBeanAttributeInfo attributeInfo = valueContext.getAttributeInfo();
    ClassLoader cl = valueContext.getClassloader();

    String typeName = attributeInfo.getType();
    if (typeName == null)
      throw new DeploymentException(
          "AttributeInfo for " + attributeInfo.getName() + " has no type");

    // see if it is a primitive type first
    Class typeClass = Classes.getPrimitiveTypeForName(typeName);
    if (typeClass == null) {
      // nope try look up
      try {
        typeClass = cl.loadClass(typeName);
      } catch (ClassNotFoundException e) {
        throw new DeploymentException(
            "Class not found for attribute: " + attributeInfo.getName(), e);
      }
    }

    PropertyEditor editor = PropertyEditorFinder.getInstance().find(typeClass);
    if (editor == null)
      throw new DeploymentException(
          "No property editor for attribute: "
              + attributeInfo.getName()
              + "; type="
              + typeClass.getName());

    // JBAS-1709, temporarily switch the TCL so that property
    // editors have access to the actual deployment ClassLoader.
    ClassLoader tcl = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(cl);
    try {
      editor.setAsText(text);
      return editor.getValue();
    } finally {
      Thread.currentThread().setContextClassLoader(tcl);
    }
  }