Examples of PropertyEditor


Examples of java.beans.PropertyEditor

                     log.warn("Unable to find class '" + type + "' for " + "property '" + name
                           + "' - skipping property.");
                     continue;
                  }
               }
               PropertyEditor pe = PropertyEditorManager.findEditor(clazz);
               if (pe == null)
               {
                  log.warn("Unable to find a PropertyEditor for class '" + clazz + "' of property '" + name + "' - "
                        + "skipping property");
                  continue;
               }
               log.debug("setting property: " + name + " to value " + value);
               try
               {
                  pe.setAsText(value);
               }
               catch (IllegalArgumentException iae)
               {
                  log.warn("Value '" + value + "' is not valid for property '" + name + "' of class '" + clazz
                        + "' - skipping " + "property");
                  continue;
               }
               Object v = pe.getValue();
               setManagedConnectionFactoryAttribute(name, clazz, v);
            }
         }
      }
   }
View Full Code Here

Examples of java.beans.PropertyEditor

                     type = String.class;
                  }
               }

               Method setter = clazz.getMethod("set" + name, new Class[] { type });
               PropertyEditor editor = PropertyEditorManager.findEditor(type);
               if (editor == null)
                  throw new JBossResourceException("No property editor found for type: " + type);
               editor.setAsText(value);
               setter.invoke(xads, new Object[] { editor.getValue() });
            }
         }
         catch (ClassNotFoundException cnfe)
         {
            throw new JBossResourceException("Class not found for XADataSource " + xaDataSourceClass, cnfe);
View Full Code Here

Examples of java.beans.PropertyEditor

    * @param mustExist
    * @return
    */
   private Object getValue(String propertyName, Class actualType, String value, boolean mustExist)
   {
      PropertyEditor editor = PropertyEditorManager.findEditor(actualType);
      if (editor == null)
      {
         String error = "No property editor found for property " + propertyName;
         if (mustExist)
         {
            throw new IllegalArgumentException(error);
         }
         else
         {
            log.warn(error);
            return null;
         }
      }
      try
      {
         editor.setAsText(value);
      }
      catch (IllegalArgumentException iae)
      {
         if (mustExist)
         {
            throw iae;
         }
         log.warn("Value '" + value + "' is not valid for property '" + propertyName + "' of class '" + actualType
               + "' - skipping " + "property");
         return null;
      }

      return editor.getValue();
   }
View Full Code Here

Examples of java.beans.PropertyEditor

                      continue;
                    }
                 }

                 Method setter = clazz.getMethod("set" + name, new Class[] { type });
                 PropertyEditor editor = PropertyEditorManager.findEditor(type);
                 if (editor == null)
                    throw new JBossResourceException("No property editor found for type: " + type);
                 editor.setAsText(value);
                 setter.invoke(dataSource, new Object[] { editor.getValue() });
              }
           }
           catch (ClassNotFoundException cnfe)
           {
              throw new JBossResourceException("Class not found for DataSource " + getDriverClass(), cnfe);
View Full Code Here

Examples of java.beans.PropertyEditor

       * @return an <code>Object</code> value
       * @exception Exception if an error occurs
       */
      public Object getValue() throws Exception
      {
         PropertyEditor editor = PropertyEditors.getEditor(type);
         editor.setAsText(arg);
         return editor.getValue();
      }
View Full Code Here

Examples of java.beans.PropertyEditor

            }
            catch (ClassNotFoundException e) {
               throw new RuntimeException("Class not found for property '" + pi.getName() +
                                    "' of type '" + pi.getType() + "'");
            }
            PropertyEditor peditor = PropertyEditorManager.findEditor(clazz);

            if (peditor != null) {
               peditor.setAsText(value);
               pi.setDefaultValue(peditor.getValue());
            }
            else
               throw new RuntimeException("Property editor not found for property '" + pi.getName() +
                                    "' of type '" + pi.getType() + "'");
         }
View Full Code Here

Examples of java.beans.PropertyEditor

            typeClass = loader.loadClass(attrType);
      }
      catch(ClassNotFoundException ignore)
      {
      }
      PropertyEditor editor = null;
      if( typeClass != null )
         editor = PropertyEditorManager.findEditor(typeClass);

      return new AttrResultInfo(attrName, editor, value, throwable);
   }
View Full Code Here

Examples of java.beans.PropertyEditor

                           ("Class not found for type: " + signature, e);
                     }
                  }

                  // Convert the string to the real value
                  PropertyEditor editor = PropertyEditorManager.findEditor(typeClass);
                  if (editor == null)
                  {
                     try
                     {
                        // See if there is a ctor(String) for the type
                        Class[] sig = {String.class};
                        Constructor ctor = typeClass.getConstructor(sig);
                        Object[] args = {value};
                        realValue = ctor.newInstance(args);
                     }
                     catch (Exception e)
                     {
                        throw new ConfigurationException("No property editor for type: " + typeClass);
                     }
                  }
                  else
                  {
                     editor.setAsText(value);
                     realValue = editor.getValue();
                  }
               }
               info.signature[j] = signature;
               info.params[j] = realValue;
            }
View Full Code Here

Examples of java.beans.PropertyEditor

            }
         }
         // Replace any ${x} references in the element text
         if (replace)
         {
            PropertyEditor editor = PropertyEditorManager.findEditor(typeClass);
            if (editor == null)
            {
               log.warn("Cannot perform property replace on Element");
            }
            else
            {
               editor.setValue(value);
               String text = editor.getAsText();
               text = StringPropertyReplacer.replaceProperties(text);
               editor.setAsText(text);
               value = editor.getValue();
            }
         }
      }

      if (value == null)
      {
         PropertyEditor editor = PropertyEditorManager.findEditor(typeClass);
         if (editor == null)
         {
            throw new DeploymentException
               ("No property editor for attribute: " + attributeName +
               "; type=" + typeClass);
         }

         // 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(attributeText);
            value = editor.getValue();
         }
         finally
         {
            Thread.currentThread().setContextClassLoader(tcl);
         }
View Full Code Here

Examples of java.beans.PropertyEditor

            root.appendChild(element);
         }
         else {
            Class clazz = value.getClass();
            String type = clazz.getName();
          PropertyEditor peditor = PropertyEditorManager.findEditor(clazz);

          if (peditor != null) {
           // (c) use a PropertyEditor - mark the type and append the value as string              
             peditor.setValue(value);
            
             element.setAttribute(AL_TYPE_ATTRIBUTE, type);
             element.appendChild(doc.createTextNode(peditor.getAsText()));
            
             // append the attribute to the attribute-list
             root.appendChild(element);
          }
          else if (value instanceof Serializable) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.