Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-11-07
10
Medium Priority
?
485 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
0
Comment
Question by:sharon669
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
10 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 17893273
Try installing a SecurityManager
0
 
LVL 92

Accepted Solution

by:
objects earned 750 total points
ID: 17893281
best would be to declare them package protected, and put any of your classes that need them in the same package
0
 
LVL 92

Expert Comment

by:objects
ID: 17893286
if you just want to mark them then use deplecated

http://java.sun.com/j2se/1.4.2/docs/guide/misc/deprecation/deprecated.html
0
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 
LVL 1

Author Comment

by:sharon669
ID: 17893543
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
0
 
LVL 92

Expert Comment

by:objects
ID: 17894828
> 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
0
 
LVL 1

Author Comment

by:sharon669
ID: 17917453
will SecurityManager cause significant overhead  to a large scale j2ee app ?
0
 
LVL 92

Expert Comment

by:objects
ID: 17918031
how would you use a security manager?
0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question