• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 331
  • Last Modified:

how to restrict calling methods in different classes

i have a class c1 defined f1(),f2() and f3() methods;in c2 class there i have to access f1() method only and c3 class i have to access only f2 and f3 methods;how to restrcit this?
0
chaitu chaitu
Asked:
chaitu chaitu
1 Solution
 
objectsCommented:
u can't really.
0
 
CEHJCommented:
Install a security manager
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
mhuntsCommented:
Why don't you split c1 into 2 classes, one with f1, and one with f2, f3. Then c2 can access the first one, and c3 can access the second one.
0
 
jcoombesCommented:
Another approach here would be to utilise AOP techniques to inject advice and pointcuts that restrict the calling of the necessary methods, based on the type of the calling class.

There's a whole bunch of literature available out there that explains the basic concepts of AOP, here's probably a good jump off point:

http://en.wikipedia.org/wiki/Aspect-oriented_programming
0
 
elfe69Commented:
Is it really necessary to hide those methods to the other classes ?
0
 
Mayank SAssociate Director - Product EngineeringCommented:
When you define something as public, default, etc you dont do it for a specific outside class - you define it as public for all other classes to access, etc
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now