You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hivemind.apache.org by "Brian K. Wallace" <br...@transmorphix.com> on 2005/02/04 00:15:49 UTC

Question about ClassFabUtils / adding methods

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Continuing on through understanding what happens when...

Looking at TestEJBProxyFactory, one portion of the code that was never
tested was an implementation that already had a toString() method. I
added one. This covered that case - verified with an assertEquals() on
the object.toString() - that if a class already had a toString() method,
it wouldn't try to add another one.

What I found, however, was in going back to verify the original
toString() returned what I thought it should. Since the
'addToStringMethod' was being called (3 times), I looked at the code for
that which does the following:
~  ClassFabUtils.addToStringMethod(classFab,
ImplMessages.ejbProxyDescription(serviceId, serviceInterface, jndiName));

Since ImplMessages isn't visible, I created a
MessagesUtil.getEjbProxyDescription(...) method taking the same
parameters and returning what should be passed to addToStringMethod(...).

To the testEJBProxy() method, I then added:

assertEquals(MessagesUtil.getEjbProxyDescription("hivemind.test.lib.SimpleRemote",
SimpleRemote.class, "hivemind.test.lib.Simple"), object.toString());

This assertion fails.

I added a debug to the addToStringMethod(...) to verify I was using the
right values, then printed out the object's toString() and what's
returned from my MessagesUtil method. What I got was the following:

Service Id: hivemind.test.lib.SimpleRemote, ServiceInterface: interface
hivemind.test.lib.SimpleRemote, JNDI: hivemind.test.lib.Simple
SimpleRemote toString: <SingletonProxy for
hivemind.test.lib.SimpleRemote(hivemind.test.lib.SimpleRemote)>
MessageUtil  toString: <EJBProxy for
SimpleRemote(hivemind.test.lib.SimpleRemote) at hivemind.test.lib.Simple>

The toString() actually added to the class is from SingletonProxy, not
EJBProxy. I'm willing to bet I'm missing something, but I'm at a loss as
to what. Am I missing it? Or is this a bug somewhere?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)

iD8DBQFCArClaCoPKRow/gARAoFCAKDFN9ugluoWe3WHSwL51oNDreje/ACghmOB
EadZI1Xw2PzjxnDixuh0YD8=
=JugS
-----END PGP SIGNATURE-----

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


Re: Question about ClassFabUtils / adding methods

Posted by "Brian K. Wallace" <br...@transmorphix.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thanks Howard. Makes a lot more sense now knowing the reasoning behind it.

Brian

Howard Lewis Ship wrote:
| I like each proxy, interceptor, etc. to provide its own toString().
| When I'm debugging, I can find out what each oddly named object on the
| stack is easily.  As is, the class names are unitellgable on their
| own, i.e., $SingletonProxy_17234ac... to having a real toString() for
| each level of  proxy is important.
|
|
| On Fri, 04 Feb 2005 00:14:53 -0600, Brian K. Wallace
| <br...@transmorphix.com> wrote:
|
| First off, let me apologize for dwelling on a non-issue. I've been very
| impressed with what I can do with HiveMind and decided to take a closer
| look at 'how' - and instead of complaining, try to learn it and help
| improve it. Just a bit stuck in the 'learn it' stage.
|
| I found out what is happening, but I'm not sure if it's a bug in
| EJBProxyFactory, ProxyBuilder or a non-issue (non-issue being a relative
| term). EJBProxyFactory adds a toString method if there isn't one. The
| problem is that it isn't the toString() that is used when getting the
| service from the registry. The proxy's toString() is used (hence the
| "<SingletonProxy...." output). Modifying ProxyBuilder's toString to use
| the inner class' toString() results in Java Object toString() until the
| class is actually used - then it returns the output defined. Removing
| the toString building entirely from EJBProxyFactory isn't noticable as
| the proxy's toString is used anyway. The difference being:
| <SingletonProxy for
| hivemind.test.lib.SimpleRemote(hivemind.test.lib.SimpleRemote)>
| vs.
| <EJBProxy for SimpleRemote(hivemind.test.lib.SimpleRemote) at
| hivemind.test.lib.Simple>
|
| My question is: while removal of the 'addToString' from EJBProxyFactory
| clears this up, is it actually a bug in ProxyBuilder? Where a
| subordinate factory doesn't attempt to add a toString method, or the
| implementation actually has a toString, it's a non-issue entirely. But
| if a factory tries to add a toString method (as EJBProxyFactory does -
| and I'd assume someone could come up with other factories to plug in),
| that method will not be the method used.
|
| Again, my apologies for harping on a fringe example.
|
| Howard Lewis Ship wrote:
| | You'll have to dig through the SingletonProxy to get to the EJBProxy.
| |
| | Most of the code that generates classes is careful to work around
| | toString().  The  logic for this is part of the MethodIterator.  This
| | may be a minor bug in EJBProxyFactory, but toString() is generally not
| | a valid EJB method (it certainly doesn't throw RemoteException).
| |
| |
| | On Thu, 03 Feb 2005 17:15:49 -0600, Brian K. Wallace
| | <br...@transmorphix.com> wrote:
| |
| | Continuing on through understanding what happens when...
| |
| | Looking at TestEJBProxyFactory, one portion of the code that was never
| | tested was an implementation that already had a toString() method. I
| | added one. This covered that case - verified with an assertEquals() on
| | the object.toString() - that if a class already had a toString() method,
| | it wouldn't try to add another one.
| |
| | What I found, however, was in going back to verify the original
| | toString() returned what I thought it should. Since the
| | 'addToStringMethod' was being called (3 times), I looked at the code for
| | that which does the following:
| | ~  ClassFabUtils.addToStringMethod(classFab,
| | ImplMessages.ejbProxyDescription(serviceId, serviceInterface,
jndiName));
| |
| | Since ImplMessages isn't visible, I created a
| | MessagesUtil.getEjbProxyDescription(...) method taking the same
| | parameters and returning what should be passed to
addToStringMethod(...).
| |
| | To the testEJBProxy() method, I then added:
| |
| |
|
assertEquals(MessagesUtil.getEjbProxyDescription("hivemind.test.lib.SimpleRemote",
| | SimpleRemote.class, "hivemind.test.lib.Simple"), object.toString());
| |
| | This assertion fails.
| |
| | I added a debug to the addToStringMethod(...) to verify I was using the
| | right values, then printed out the object's toString() and what's
| | returned from my MessagesUtil method. What I got was the following:
| |
| | Service Id: hivemind.test.lib.SimpleRemote, ServiceInterface: interface
| | hivemind.test.lib.SimpleRemote, JNDI: hivemind.test.lib.Simple
| | SimpleRemote toString: <SingletonProxy for
| | hivemind.test.lib.SimpleRemote(hivemind.test.lib.SimpleRemote)>
| | MessageUtil  toString: <EJBProxy for
| | SimpleRemote(hivemind.test.lib.SimpleRemote) at
hivemind.test.lib.Simple>
| |
| | The toString() actually added to the class is from SingletonProxy, not
| | EJBProxy. I'm willing to bet I'm missing something, but I'm at a loss as
| | to what. Am I missing it? Or is this a bug somewhere?
|
| ---------------------------------------------------------------------
| To unsubscribe, e-mail: hivemind-dev-unsubscribe@jakarta.apache.org
| For additional commands, e-mail: hivemind-dev-help@jakarta.apache.org
|

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





-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)

iD8DBQFCA+2maCoPKRow/gARAqjBAJ0ZklymuyimzIxpzuOfKMdwgDFZbACbBmEV
mZkl2sVvrLYyc7Hya8Tqg3A=
=lHvX
-----END PGP SIGNATURE-----

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


Re: Question about ClassFabUtils / adding methods

Posted by Howard Lewis Ship <hl...@gmail.com>.
I like each proxy, interceptor, etc. to provide its own toString(). 
When I'm debugging, I can find out what each oddly named object on the
stack is easily.  As is, the class names are unitellgable on their
own, i.e., $SingletonProxy_17234ac... to having a real toString() for
each level of  proxy is important.


On Fri, 04 Feb 2005 00:14:53 -0600, Brian K. Wallace
<br...@transmorphix.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> First off, let me apologize for dwelling on a non-issue. I've been very
> impressed with what I can do with HiveMind and decided to take a closer
> look at 'how' - and instead of complaining, try to learn it and help
> improve it. Just a bit stuck in the 'learn it' stage.
> 
> I found out what is happening, but I'm not sure if it's a bug in
> EJBProxyFactory, ProxyBuilder or a non-issue (non-issue being a relative
> term). EJBProxyFactory adds a toString method if there isn't one. The
> problem is that it isn't the toString() that is used when getting the
> service from the registry. The proxy's toString() is used (hence the
> "<SingletonProxy...." output). Modifying ProxyBuilder's toString to use
> the inner class' toString() results in Java Object toString() until the
> class is actually used - then it returns the output defined. Removing
> the toString building entirely from EJBProxyFactory isn't noticable as
> the proxy's toString is used anyway. The difference being:
> <SingletonProxy for
> hivemind.test.lib.SimpleRemote(hivemind.test.lib.SimpleRemote)>
> vs.
> <EJBProxy for SimpleRemote(hivemind.test.lib.SimpleRemote) at
> hivemind.test.lib.Simple>
> 
> My question is: while removal of the 'addToString' from EJBProxyFactory
> clears this up, is it actually a bug in ProxyBuilder? Where a
> subordinate factory doesn't attempt to add a toString method, or the
> implementation actually has a toString, it's a non-issue entirely. But
> if a factory tries to add a toString method (as EJBProxyFactory does -
> and I'd assume someone could come up with other factories to plug in),
> that method will not be the method used.
> 
> Again, my apologies for harping on a fringe example.
> 
> Howard Lewis Ship wrote:
> | You'll have to dig through the SingletonProxy to get to the EJBProxy.
> |
> | Most of the code that generates classes is careful to work around
> | toString().  The  logic for this is part of the MethodIterator.  This
> | may be a minor bug in EJBProxyFactory, but toString() is generally not
> | a valid EJB method (it certainly doesn't throw RemoteException).
> |
> |
> | On Thu, 03 Feb 2005 17:15:49 -0600, Brian K. Wallace
> | <br...@transmorphix.com> wrote:
> |
> | Continuing on through understanding what happens when...
> |
> | Looking at TestEJBProxyFactory, one portion of the code that was never
> | tested was an implementation that already had a toString() method. I
> | added one. This covered that case - verified with an assertEquals() on
> | the object.toString() - that if a class already had a toString() method,
> | it wouldn't try to add another one.
> |
> | What I found, however, was in going back to verify the original
> | toString() returned what I thought it should. Since the
> | 'addToStringMethod' was being called (3 times), I looked at the code for
> | that which does the following:
> | ~  ClassFabUtils.addToStringMethod(classFab,
> | ImplMessages.ejbProxyDescription(serviceId, serviceInterface, jndiName));
> |
> | Since ImplMessages isn't visible, I created a
> | MessagesUtil.getEjbProxyDescription(...) method taking the same
> | parameters and returning what should be passed to addToStringMethod(...).
> |
> | To the testEJBProxy() method, I then added:
> |
> |
> assertEquals(MessagesUtil.getEjbProxyDescription("hivemind.test.lib.SimpleRemote",
> | SimpleRemote.class, "hivemind.test.lib.Simple"), object.toString());
> |
> | This assertion fails.
> |
> | I added a debug to the addToStringMethod(...) to verify I was using the
> | right values, then printed out the object's toString() and what's
> | returned from my MessagesUtil method. What I got was the following:
> |
> | Service Id: hivemind.test.lib.SimpleRemote, ServiceInterface: interface
> | hivemind.test.lib.SimpleRemote, JNDI: hivemind.test.lib.Simple
> | SimpleRemote toString: <SingletonProxy for
> | hivemind.test.lib.SimpleRemote(hivemind.test.lib.SimpleRemote)>
> | MessageUtil  toString: <EJBProxy for
> | SimpleRemote(hivemind.test.lib.SimpleRemote) at hivemind.test.lib.Simple>
> |
> | The toString() actually added to the class is from SingletonProxy, not
> | EJBProxy. I'm willing to bet I'm missing something, but I'm at a loss as
> | to what. Am I missing it? Or is this a bug somewhere?
> 
> - ---------------------------------------------------------------------
> To unsubscribe, e-mail: hivemind-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: hivemind-dev-help@jakarta.apache.org
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.5 (MingW32)
> 
> iD8DBQFCAxLdaCoPKRow/gARAuKLAJ9cig6MxIUdqp/vQGvylRpypsQ+lgCgt0IQ
> wP8/r9uM3unKngA5DcmtD7c=
> =+6Lg
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: hivemind-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: hivemind-dev-help@jakarta.apache.org
> 
> 


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

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

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


Re: Question about ClassFabUtils / adding methods

Posted by "Brian K. Wallace" <br...@transmorphix.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

First off, let me apologize for dwelling on a non-issue. I've been very
impressed with what I can do with HiveMind and decided to take a closer
look at 'how' - and instead of complaining, try to learn it and help
improve it. Just a bit stuck in the 'learn it' stage.

I found out what is happening, but I'm not sure if it's a bug in
EJBProxyFactory, ProxyBuilder or a non-issue (non-issue being a relative
term). EJBProxyFactory adds a toString method if there isn't one. The
problem is that it isn't the toString() that is used when getting the
service from the registry. The proxy's toString() is used (hence the
"<SingletonProxy...." output). Modifying ProxyBuilder's toString to use
the inner class' toString() results in Java Object toString() until the
class is actually used - then it returns the output defined. Removing
the toString building entirely from EJBProxyFactory isn't noticable as
the proxy's toString is used anyway. The difference being:
<SingletonProxy for
hivemind.test.lib.SimpleRemote(hivemind.test.lib.SimpleRemote)>
vs.
<EJBProxy for SimpleRemote(hivemind.test.lib.SimpleRemote) at
hivemind.test.lib.Simple>

My question is: while removal of the 'addToString' from EJBProxyFactory
clears this up, is it actually a bug in ProxyBuilder? Where a
subordinate factory doesn't attempt to add a toString method, or the
implementation actually has a toString, it's a non-issue entirely. But
if a factory tries to add a toString method (as EJBProxyFactory does -
and I'd assume someone could come up with other factories to plug in),
that method will not be the method used.

Again, my apologies for harping on a fringe example.


Howard Lewis Ship wrote:
| You'll have to dig through the SingletonProxy to get to the EJBProxy.
|
| Most of the code that generates classes is careful to work around
| toString().  The  logic for this is part of the MethodIterator.  This
| may be a minor bug in EJBProxyFactory, but toString() is generally not
| a valid EJB method (it certainly doesn't throw RemoteException).
|
|
| On Thu, 03 Feb 2005 17:15:49 -0600, Brian K. Wallace
| <br...@transmorphix.com> wrote:
|
| Continuing on through understanding what happens when...
|
| Looking at TestEJBProxyFactory, one portion of the code that was never
| tested was an implementation that already had a toString() method. I
| added one. This covered that case - verified with an assertEquals() on
| the object.toString() - that if a class already had a toString() method,
| it wouldn't try to add another one.
|
| What I found, however, was in going back to verify the original
| toString() returned what I thought it should. Since the
| 'addToStringMethod' was being called (3 times), I looked at the code for
| that which does the following:
| ~  ClassFabUtils.addToStringMethod(classFab,
| ImplMessages.ejbProxyDescription(serviceId, serviceInterface, jndiName));
|
| Since ImplMessages isn't visible, I created a
| MessagesUtil.getEjbProxyDescription(...) method taking the same
| parameters and returning what should be passed to addToStringMethod(...).
|
| To the testEJBProxy() method, I then added:
|
|
assertEquals(MessagesUtil.getEjbProxyDescription("hivemind.test.lib.SimpleRemote",
| SimpleRemote.class, "hivemind.test.lib.Simple"), object.toString());
|
| This assertion fails.
|
| I added a debug to the addToStringMethod(...) to verify I was using the
| right values, then printed out the object's toString() and what's
| returned from my MessagesUtil method. What I got was the following:
|
| Service Id: hivemind.test.lib.SimpleRemote, ServiceInterface: interface
| hivemind.test.lib.SimpleRemote, JNDI: hivemind.test.lib.Simple
| SimpleRemote toString: <SingletonProxy for
| hivemind.test.lib.SimpleRemote(hivemind.test.lib.SimpleRemote)>
| MessageUtil  toString: <EJBProxy for
| SimpleRemote(hivemind.test.lib.SimpleRemote) at hivemind.test.lib.Simple>
|
| The toString() actually added to the class is from SingletonProxy, not
| EJBProxy. I'm willing to bet I'm missing something, but I'm at a loss as
| to what. Am I missing it? Or is this a bug somewhere?

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





-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)

iD8DBQFCAxLdaCoPKRow/gARAuKLAJ9cig6MxIUdqp/vQGvylRpypsQ+lgCgt0IQ
wP8/r9uM3unKngA5DcmtD7c=
=+6Lg
-----END PGP SIGNATURE-----

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


Re: Question about ClassFabUtils / adding methods

Posted by Howard Lewis Ship <hl...@gmail.com>.
You'll have to dig through the SingletonProxy to get to the EJBProxy.

Most of the code that generates classes is careful to work around
toString().  The  logic for this is part of the MethodIterator.  This
may be a minor bug in EJBProxyFactory, but toString() is generally not
a valid EJB method (it certainly doesn't throw RemoteException).


On Thu, 03 Feb 2005 17:15:49 -0600, Brian K. Wallace
<br...@transmorphix.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Continuing on through understanding what happens when...
> 
> Looking at TestEJBProxyFactory, one portion of the code that was never
> tested was an implementation that already had a toString() method. I
> added one. This covered that case - verified with an assertEquals() on
> the object.toString() - that if a class already had a toString() method,
> it wouldn't try to add another one.
> 
> What I found, however, was in going back to verify the original
> toString() returned what I thought it should. Since the
> 'addToStringMethod' was being called (3 times), I looked at the code for
> that which does the following:
> ~  ClassFabUtils.addToStringMethod(classFab,
> ImplMessages.ejbProxyDescription(serviceId, serviceInterface, jndiName));
> 
> Since ImplMessages isn't visible, I created a
> MessagesUtil.getEjbProxyDescription(...) method taking the same
> parameters and returning what should be passed to addToStringMethod(...).
> 
> To the testEJBProxy() method, I then added:
> 
> assertEquals(MessagesUtil.getEjbProxyDescription("hivemind.test.lib.SimpleRemote",
> SimpleRemote.class, "hivemind.test.lib.Simple"), object.toString());
> 
> This assertion fails.
> 
> I added a debug to the addToStringMethod(...) to verify I was using the
> right values, then printed out the object's toString() and what's
> returned from my MessagesUtil method. What I got was the following:
> 
> Service Id: hivemind.test.lib.SimpleRemote, ServiceInterface: interface
> hivemind.test.lib.SimpleRemote, JNDI: hivemind.test.lib.Simple
> SimpleRemote toString: <SingletonProxy for
> hivemind.test.lib.SimpleRemote(hivemind.test.lib.SimpleRemote)>
> MessageUtil  toString: <EJBProxy for
> SimpleRemote(hivemind.test.lib.SimpleRemote) at hivemind.test.lib.Simple>
> 
> The toString() actually added to the class is from SingletonProxy, not
> EJBProxy. I'm willing to bet I'm missing something, but I'm at a loss as
> to what. Am I missing it? Or is this a bug somewhere?
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.5 (MingW32)
> 
> iD8DBQFCArClaCoPKRow/gARAoFCAKDFN9ugluoWe3WHSwL51oNDreje/ACghmOB
> EadZI1Xw2PzjxnDixuh0YD8=
> =JugS
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: hivemind-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: hivemind-dev-help@jakarta.apache.org
> 
> 


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

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

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