The Artima Developer Community
Sponsored Link

Java Answers Forum
Dynamic proxy

4 replies on 1 page. Most recent reply: Aug 30, 2005 3:34 AM by fancy

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 4 replies on 1 page
fancy

Posts: 3
Nickname: davidfan
Registered: Aug, 2005

Dynamic proxy Posted: Aug 29, 2005 3:45 AM
Reply to this message Reply
Advertisement
Use the Java dynamic proxy to create an object that acts as a front end for a simple configuration file. For example, in good_stuff.txt you can have entries like this:

a=1
b=2
c="Hello World"

A client programmer of this NeatPropertyBundle could then write:

NeatPropertyBundle p =

new NeatPropertyBundle("good_stuff");

System.out.println(p.a);

System.out.println (p.b);

System.out.println(p.c);



The contents of the configuration file can contain anything, with any variable names. The dynamic proxy will either map to the name or tell you it doesn’t exist somehow (probably by returning null). If you set a property and it doesn’t already exist, the dynamic proxy will create the new entry. The toString( ) method should display all the current entries.


Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: Dynamic proxy Posted: Aug 29, 2005 5:46 AM
Reply to this message Reply
So what'S the question?

Note that you should do your homework yourself.

fancy

Posts: 3
Nickname: davidfan
Registered: Aug, 2005

Re: Dynamic proxy Posted: Aug 29, 2005 11:31 PM
Reply to this message Reply
It isn't my homework
The question is how to implement the class NeatPropertyBundle.

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: Dynamic proxy Posted: Aug 29, 2005 11:47 PM
Reply to this message Reply
Even though it was kind of harsh, I kind of agree that
the Q, is a little bit too unclear.

>
> NeatPropertyBundle p =
>
> new NeatPropertyBundle("good_stuff");
>
> System.out.println(p.a);
>
> System.out.println(p.b);
>
> System.out.println(p.c);
>

> The contents of the configuration file can contain
> anything, with any variable names. The dynamic proxy will
> either map to the name or tell you it doesn’t exist

The dynamic proxy I assume acts as your server,
what type of Client/Server interaction (regulations
or protocol) is the requirement. You want to know
how to implement the Client, you tell us how the
Server works (which is all good), yet you tell
us nothing of how NeatPropertyBundle sends its
requests.

fancy

Posts: 3
Nickname: davidfan
Registered: Aug, 2005

Re: Dynamic proxy Posted: Aug 30, 2005 3:34 AM
Reply to this message Reply
This exercise is from book Thinking in patterns by Bruce Eckel

Flat View: This topic has 4 replies on 1 page
Topic: why is double data type giving an garbage value Previous Topic   Next Topic Topic: null in java

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use