You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hivemind.apache.org by "Kurt R. Hoehn" <kh...@etranscor.com> on 2004/07/14 18:30:50 UTC

Smart Translator - Class type

Hello,

 

    The interface that I'm implementing has 2 getter methods that return
type "Class" and it blows up every time on the getXXXX method calls.  So
I did some digging around with the Smart Translator and there is no
editor for type Class which is by design.

 

Is there a reason for the Smart Translator not supporting other java
fundamental types (i.e. Class)?  

 

I modified the  SmartTranslator.java  translate method  and it seemed to
work and it passed all Unit Tests.

 

public Object translate(Module contributingModule, Class propertyType,
String inputValue)

{

...

 

  if (e == null)

  {

    if( propertyType.getName().equals("java.lang.Class") )

    {

      ClassResolver resolver = contributingModule.getClassResolver();

      return resolver.findClass(inputValue);

    }

    else

    {

        throw new
AplicationRuntimeException(RulesMessages.noPropertyEditor(propertyType))
;

    }

  }

 

...

}

 

My hivemodule.sdl

 

      service-point ( id=LockingConfiguration 

 
interface=org.apache.ojb.odmg.locking.LockingConfiguration)

      {

            invoke-factory( service-id=hivemind.BuilderFactory )

            {

                  construct
(class=com.etranscor.hivemind.ojb.configuration.LockingConfigurationImpl
)

                  {

                      set ( property=lockManagerClass
value=${ojb.lockmanager.class} )    

                      set ( property=lockMapClass
value=${ojb.lockmap.class} )

                  }           

            }

      }

 

      contribution (configuration-id=hivemind.FactoryDefaults)

      {

            default (symbol=ojb.lockmanager.class
value=org.apache.ojb.odmg.locking.LockManagerDefaultImpl)

            default (symbol=ojb.lockmap.class
value=org.apache.ojb.odmg.locking.InMemoryLockMapImpl)

      }

 

-kurt h

 


RE: Smart Translator - Class type

Posted by "Kurt R. Hoehn" <kh...@etechstudios.com>.
Great, thanks for the info.

-kurt h

-----Original Message-----
From: Howard Lewis Ship [mailto:hlship@gmail.com] 
Sent: Wednesday, July 14, 2004 1:15 PM
To: hivemind-user@jakarta.apache.org
Subject: Re: Smart Translator - Class type

I'd rather add startup code to register a proper PropertyEditor with
the JavaBeans framework.  There's an extension point for this purpose
(hivemind.Startup).

Once the PropertyEditor is defined, it should "just work".

Better a solution for that, than to start introducing special cases
into the code.


----- Original Message -----
From: Kurt R. Hoehn <kh...@etranscor.com>
Date: Wed, 14 Jul 2004 12:30:50 -0400
Subject: Smart Translator - Class type
To: hivemind-user@jakarta.apache.org

















Hello,



 



    The interface that I'm implementing
has 2 getter methods that return type "Class" and it blows up every
time on the getXXXX method calls.  So I did some digging around with the
Smart
Translator and there is no editor for type Class which is by design.



 



Is there a reason for the Smart Translator not supporting other
java fundamental types (i.e. Class)?  



 



I modified the  SmartTranslator.java  translate
method  and it seemed to work and it passed all Unit Tests.



 



public Object translate(Module
contributingModule, Class propertyType, String inputValue)



{



.



 



  if (e == null)



  {



    if( propertyType.getName().equals("java.lang.Class")
)



    {



      ClassResolver
resolver = contributingModule.getClassResolver();



      return
resolver.findClass(inputValue);



    }



    else



    {



        throw
new
AplicationRuntimeException(RulesMessages.noPropertyEditor(propertyType));



    }



  }



 



.



}



 



My hivemodule.sdl



 



      service-point
( id=LockingConfiguration 



                     
interface=org.apache.ojb.odmg.locking.LockingConfiguration)



      {



            invoke-factory(
service-id=hivemind.BuilderFactory )



            {



                  construct
(class=com.etranscor.hivemind.ojb.configuration.LockingConfigurationImpl)



                  {



                     
set ( property=lockManagerClass value=${ojb.lockmanager.class} )    



                     
set ( property=lockMapClass     value=${ojb.lockmap.class}
)



                  }           



            }



      }



 



      contribution
(configuration-id=hivemind.FactoryDefaults)



      {



            default
(symbol=ojb.lockmanager.class 
value=org.apache.ojb.odmg.locking.LockManagerDefaultImpl)



            default
(symbol=ojb.lockmap.class     
value=org.apache.ojb.odmg.locking.InMemoryLockMapImpl)



      }



 



-kurt h



 










-- 
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind
http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org


Re: Smart Translator - Class type

Posted by Howard Lewis Ship <hl...@gmail.com>.
I'd rather add startup code to register a proper PropertyEditor with
the JavaBeans framework.  There's an extension point for this purpose
(hivemind.Startup).

Once the PropertyEditor is defined, it should "just work".

Better a solution for that, than to start introducing special cases
into the code.


----- Original Message -----
From: Kurt R. Hoehn <kh...@etranscor.com>
Date: Wed, 14 Jul 2004 12:30:50 -0400
Subject: Smart Translator - Class type
To: hivemind-user@jakarta.apache.org

















Hello,



 



    The interface that I'm implementing
has 2 getter methods that return type "Class" and it blows up every
time on the getXXXX method calls.  So I did some digging around with the Smart
Translator and there is no editor for type Class which is by design.



 



Is there a reason for the Smart Translator not supporting other
java fundamental types (i.e. Class)?  



 



I modified the  SmartTranslator.java  translate
method  and it seemed to work and it passed all Unit Tests.



 



public Object translate(Module
contributingModule, Class propertyType, String inputValue)



{



…



 



  if (e == null)



  {



    if( propertyType.getName().equals("java.lang.Class")
)



    {



      ClassResolver
resolver = contributingModule.getClassResolver();



      return
resolver.findClass(inputValue);



    }



    else



    {



        throw
new AplicationRuntimeException(RulesMessages.noPropertyEditor(propertyType));



    }



  }



 



…



}



 



My hivemodule.sdl



 



      service-point
( id=LockingConfiguration 



                     
interface=org.apache.ojb.odmg.locking.LockingConfiguration)



      {



            invoke-factory(
service-id=hivemind.BuilderFactory )



            {



                  construct
(class=com.etranscor.hivemind.ojb.configuration.LockingConfigurationImpl)



                  {



                     
set ( property=lockManagerClass value=${ojb.lockmanager.class} )    



                     
set ( property=lockMapClass     value=${ojb.lockmap.class}
)



                  }           



            }



      }



 



      contribution
(configuration-id=hivemind.FactoryDefaults)



      {



            default
(symbol=ojb.lockmanager.class 
value=org.apache.ojb.odmg.locking.LockManagerDefaultImpl)



            default
(symbol=ojb.lockmap.class     
value=org.apache.ojb.odmg.locking.InMemoryLockMapImpl)



      }



 



-kurt h



 










-- 
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind
http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org