colus       2003/03/01 02:41:38

  Modified:    src/java/org/apache/avalon/phoenix/components/manager
                        MBeanScripter.java
               .        build.xml
  Log:
  remove dependency to converter.
  
  Revision  Changes    Path
  1.6       +55 -12    
avalon-phoenix/src/java/org/apache/avalon/phoenix/components/manager/MBeanScripter.java
  
  Index: MBeanScripter.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-phoenix/src/java/org/apache/avalon/phoenix/components/manager/MBeanScripter.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- MBeanScripter.java        1 Mar 2003 02:56:54 -0000       1.5
  +++ MBeanScripter.java        1 Mar 2003 10:41:38 -0000       1.6
  @@ -13,8 +13,6 @@
   import javax.management.ObjectName;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.realityforge.converter.Converter;
  -import org.realityforge.converter.lib.SimpleMasterConverter;
   
   /**
    * Support JMX MBean lifecycle.
  @@ -23,9 +21,6 @@
    */
   public class MBeanScripter
   {
  -    private final static Converter c_valueConverter =
  -        new SimpleMasterConverter();
  -
       private final MBeanServer m_mBeanServer;
       private final Configuration m_configuration;
       private final ObjectName m_objectName;
  @@ -88,16 +83,17 @@
       {
           final String name = attribute.getAttribute( "name" );
           final String type = attribute.getAttribute( "type" );
  -        Object value = attribute.getValue( null );
  -        if( null != value )
  +        final String rawValue = attribute.getValue( null );
  +        Object value = null;
  +        if( null != rawValue )
           {
               final Class valueClass = Class.forName( type );
  -            value = c_valueConverter.convert( valueClass, value, null );
  +            value = convertToObject( valueClass, rawValue );
           }
           m_mBeanServer.setAttribute( getObjectName(),
                                       new Attribute( name, value ) );
       }
  -
  +    
       private void setUses()
           throws Exception
       {
  @@ -153,15 +149,62 @@
           for( int i = 0; i < paramConfs.length; i++ )
           {
               final String type = paramConfs[ i ].getAttribute( "type" );
  -            Object value = paramConfs[ i ].getValue( null );
  -            if( null != value )
  +            final String rawValue = paramConfs[ i ].getValue( null );
  +            Object value = null;
  +            if( null != rawValue )
               {
                   final Class valueClass = Class.forName( type );
  -                value = c_valueConverter.convert( valueClass, value, null );
  +                value = convertToObject( valueClass, rawValue );
               }
               types[ i ] = type;
               values[ i ] = value;
           }
           m_mBeanServer.invoke( getObjectName(), operationName, values, types );
  +    }
  +    
  +    private Object convertToObject( final Class valueClass, final String s )
  +    {
  +        Object value = null;
  +        if ( valueClass.equals( String.class ) )
  +        {
  +            value = s;
  +        }
  +        else if ( valueClass.equals( Byte.class ) )
  +        {
  +            value = new Byte( Byte.parseByte( s ) );
  +        }
  +        else if ( valueClass.equals( Short.class ) )
  +        {
  +            value = new Short( Short.parseShort( s ) );
  +        }
  +        else if ( valueClass.equals( Integer.class ) )
  +        {
  +            value = new Integer( Integer.parseInt( s ) );
  +        }
  +        else if ( valueClass.equals( Long.class ) )
  +        {
  +            value = new Long( Long.parseLong( s ) );
  +        }
  +        else if ( valueClass.equals( Float.class ) )
  +        {
  +            value = new Float( Float.parseFloat( s ) );
  +        }
  +        else if ( valueClass.equals( Double.class ) )
  +        {
  +            value = new Double( Double.parseDouble( s ) );
  +        }
  +        else if ( valueClass.equals( Character.class ) )
  +        {
  +            value = new Character( s.charAt( 0 ) );
  +        }
  +        else if ( valueClass.equals( Boolean.class ) )
  +        {
  +            value = new Boolean( s );
  +        }
  +        else
  +        {
  +            throw new UnsupportedOperationException ( "can't yet convert " + 
valueClass );
  +        }
  +        return value;
       }
   }
  
  
  
  1.214     +1 -31     avalon-phoenix/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/avalon-phoenix/build.xml,v
  retrieving revision 1.213
  retrieving revision 1.214
  diff -u -r1.213 -r1.214
  --- build.xml 1 Mar 2003 08:48:30 -0000       1.213
  +++ build.xml 1 Mar 2003 10:41:38 -0000       1.214
  @@ -88,7 +88,6 @@
       <!-- Invoke 'ant get-mx4j' to get these -->
       <property name="mx4j.jar" value="${repo.dir}/mx4j-1.1.1/lib/mx4j-jmx.jar"/>
       <property name="mx4j-tools.jar" 
value="${repo.dir}/mx4j-1.1.1/lib/mx4j-tools.jar"/>
  -    <property name="converter.jar" 
value="${repo.dir}/converter-0.9.1/converter-0.9.1.jar"/>
   
       <path id="project.class.path">
           <pathelement location="${xerces.jar}"/>
  @@ -96,7 +95,6 @@
           <pathelement location="${logkit.jar}"/>
           <pathelement location="${sandbox-info.jar}"/>
           <pathelement location="${wrapper.jar}"/>
  -        <pathelement path="${converter.jar}"/>
           <pathelement path="${mx4j.jar}"/>
           <pathelement path="${mx4j-tools.jar}"/>
           <pathelement path="${java.class.path}"/>
  @@ -149,26 +147,8 @@
           <fail message="MX4J needed. See above."/>
       </target>
   
  -    <target name="check-converter">
  -        <available property="converter.present" 
classname="org.realityforge.converter.Converter">
  -            <classpath refid="project.class.path"/>
  -        </available>
  -        <antcall target="check-converter2"/>
  -    </target>
  -    <target name="check-converter2" unless="converter.present">
  -        <echo>**************************</echo>
  -        <echo>* Please execute target  *</echo>
  -        <echo>* 'get-converter' in the *</echo>
  -        <echo>* main target.xml build  *</echo>
  -        <echo>* file to download one   *</echo>
  -        <echo>* and a half Mb of       *</echo>
  -        <echo>* converter              *</echo>
  -        <echo>**************************</echo>
  -        <fail message="Converter needed. See above."/>
  -    </target>
  -
       <!-- Check requirements of environment -->
  -    <target name="check-environment" depends="check-mx4j, check-converter">
  +    <target name="check-environment" depends="check-mx4j">
           <available property="xerces.present" type="file" file="${xerces.jar}"/>
           <available property="servlet.present" classname="javax.servlet.Servlet">
               <classpath refid="project.class.path"/>
  @@ -193,15 +173,6 @@
           <untar src="${repo.dir}/mx4j.tar" dest="${repo.dir}"/>
       </target>
   
  -    <target name="get-converter">
  -        <mkdir dir="${repo.dir}"/>
  -        <get 
src="http://unc.dl.sourceforge.net/sourceforge/spice/converter-0.9.1.zip";
  -            dest="${repo.dir}/converter.zip"
  -            verbose="true"
  -            usetimestamp="true"/>
  -        <unzip src="${repo.dir}/converter.zip" dest="${repo.dir}"/>
  -    </target>
  -
       <!-- Prepares the build directory -->
       <target name="prepare" depends="check-environment">
   
  @@ -485,7 +456,6 @@
           <copy file="${target.lib}/phoenix-tools.jar" todir="${bin.dist.lib}/"/>
           <copy file="${target.lib}/phoenix-loader.jar" todir="${bin.dist.bin}/"/>
           <copy file="${target.lib}/phoenix-engine.jar" 
todir="${bin.dist.container.lib}"/>
  -        <copy file="${converter.jar}" todir="${bin.dist.container.lib}"/>
   
           <copy file="${logkit.jar}" todir="${bin.dist.lib}"/>
           <copy file="${framework.jar}" todir="${bin.dist.lib}"/>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to