Re: how to limit access to source code...
From: Sebastian Scheid (mynewsgroup_at_web.de)
Date: 02/11/05
- Next message: Andrew Thompson: "Re: getByName() and getAllByName(0"
- Previous message: patrick: "Re: ImageIcons"
- In reply to: Sue: "how to limit access to source code..."
- Next in thread: Tom Dyess: "Re: how to limit access to source code..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 11 Feb 2005 10:05:19 +0100
"Sue" <sea_099@hotmail.com> schrieb im Newsbeitrag
news:1108100716.857254.213480@f14g2000cwb.googlegroups.com...
>I have a java application which has source code for the graphical user
> interface and also additional code for some calculations. I have to
> give access to a few users so they can edit the calculations but I have
> to limit access to the source code for the gui itself. What is the best
> way to do this? I was thinking of splitting the source code into two
> classes, one with the code for the graphical interface alone and the
> other for the calculations part. If I do this will it be possible to
You are on the right way.
> give the users the .java file for the calculations part alone with the
> .class files for the gui? Should the gui class extend the calculations
> class or vice versa? Also if the gui class is the one for which the
> source code is not available, which class should contain the main
> method? As always thank you very much for any help!
>
Reflection helps you here.
Make an interface for calculations like
-----
public interface Calc {
public void compute(someParams);
}
-----
Your application incl. gui code and main-method has to use only this
interface. Do not hardcode the classes implementing this interface (except
for a default implementation). That is the user's task. He writes a class
implementing Calc, compiles it, puts the class file to the classpath. And
now he has to provide your app with the name of the class. Perhaps via
command line, a config file or a gui dialog. Your app uses reflection to
instantiate the given class (implementing Calc) and can now use it:
-----
Class calcImpl = Class.forName(classNameGivenByUser);
Calc calc = (Calc) calcImpl.newInstance();
-----
Regards
Sebastian
- Next message: Andrew Thompson: "Re: getByName() and getAllByName(0"
- Previous message: patrick: "Re: ImageIcons"
- In reply to: Sue: "how to limit access to source code..."
- Next in thread: Tom Dyess: "Re: how to limit access to source code..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|