• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Trouble with Proxies. Invocation Handler not called - what am I doing wrong?

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All

I'm having a few issues trying to get a simple proxy to work.

The problem is that the invocation handler doesn't seem to be called.

The basic concept seems pretty simple so I must be doing something fundamentally wrong in the code. Can anyone help please?

Code is below:

main thread


Interface for Proxy


Class for Proxy


Invocation Handler
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

java myproxytest.ProxyTestClass
divide() : 10 / 1 = 10.00
divide(args) : 25 / 6 = 4.17
divide() : 11 / 2 = 5.50
divide(args) : 26 / 7 = 3.71
divide() : 12 / 3 = 4.00
divide(args) : 27 / 8 = 3.38
divide() : 13 / 4 = 3.25
divide(args) : 28 / 9 = 3.11
divide() : 14 / 5 = 2.80
divide(args) : 29 / 10 = 2.90
divide() : 15 / 6 = 2.50
divide(args) : 30 / 11 = 2.73
divide() : 16 / 7 = 2.29
divide(args) : 31 / 12 = 2.58
divide() : 17 / 8 = 2.13
divide(args) : 32 / 13 = 2.46
divide() : 18 / 9 = 2.00
divide(args) : 33 / 14 = 2.36
divide() : 19 / 10 = 1.90
divide(args) : 34 / 15 = 2.27
divide() : 20 / 11 = 1.82
divide(args) : 35 / 16 = 2.19
divide() : 21 / 12 = 1.75
divide(args) : 36 / 17 = 2.12
divide() : 22 / 13 = 1.69
divide(args) : 37 / 18 = 2.06
divide() : 23 / 14 = 1.64
divide(args) : 38 / 19 = 2.00
divide() : 24 / 15 = 1.60
divide(args) : 39 / 20 = 1.95
divide() : 25 / 16 = 1.56
divide(args) : 40 / 21 = 1.90
divide() : 26 / 17 = 1.53
divide(args) : 41 / 22 = 1.86
divide() : 27 / 18 = 1.50
divide(args) : 42 / 23 = 1.83
divide() : 28 / 19 = 1.47
divide(args) : 43 / 24 = 1.79
divide() : 29 / 20 = 1.45
divide(args) : 44 / 25 = 1.76

Please explain how that differs from what you wanted.
 
Gary Fletcher
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Campbel.

The Invocation Handler should be called so that when calling the devide() method the extra messages, from the handler object, should also be displayed.
 
Gary Fletcher
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rightio..have got a little further. My InvocationHandler is now being called, but the field extraction is not doing as I expected.

On invocation I want the arguments for the MyClass.public float divide(float a, float b) method to be extracted, added togther with the result displayed, and the the divide to be proessed as normal. Currently the InvocationHandler is being called, the MyClass.GetA(), MyClass.Get() and MyClass.divide() methods are processing as required.

The MyClass.public float divide(float a, float b), looks to be poplated with POSITIVE_INFINITY values. I am guessing that the argument extraction process in the Invocation Handler is not quite up to scratch.

Where am I going wrong?

The new Class details are provided below.

Main Thread


Interface to proxy




Invocation Handler
 
Gary Fletcher
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Think I've got it.

Please take a look and make any suggestions as to things that could/should be done better.

Many thanks

Invocation Handler
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No idea. I am not sure what you are trying to do anyway.

It is too difficult for “beginning”, so I shall move the deiscussion.
reply
    Bookmark Topic Watch Topic
  • New Topic