We help IT Professionals succeed at work.

How to restrict method access outside of jar or set of packages

sharon669
sharon669 asked
on
Medium Priority
504 Views
Last Modified: 2013-11-23
Hi all
I have a base class – WebContainer from which I derive two classes, Request class and Response class.
WebContainer is a like aMap and donate both get() and set() methods for both derived classes .
The entire project is packaged into a jar and distributed to other development teams.
The team's has no need of calling request.set(objId) or response.get(objId), they only use request.get(objId) and
All set() method usages are restricted to classes in the jar file (sevarel of packages) .
What I can do is declare the request.set , and response.get methods as deprecated, so the teams will no not to use them ,
Is there any other way I can prevent them from accessing these methods?
Thank you
Sharon
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2016

Commented:
Try installing a SecurityManager
Java Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
best would be to declare them package protected, and put any of your classes that need them in the same package

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
if you just want to mark them then use deplecated

http://java.sun.com/j2se/1.4.2/docs/guide/misc/deprecation/deprecated.html

Author

Commented:
objects  >>>  and put any of your classes that need them in the same package
The project is large scale entrprise application ,and  we commonly use the Request/Reponse objects in all packages ,

objects  >>>  if you just want to mark them then use deplecated
quote from the question :
>What I can do is declare the request.set , and response.get methods as deprecated, so ....
this way the programmers who develop the Jar will be bothered from the warning generated by the compiler .
isn't there any elegant solution ?

thank you for your time !
Sharon
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
> and  we commonly use the Request/Reponse objects in all packages

you can still use the objects, you just want to limit the visibility of those methods

Author

Commented:
will SecurityManager cause significant overhead  to a large scale j2ee app ?
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
how would you use a security manager?
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.