Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how to restrict calling methods in different classes

Posted on 2007-04-02
7
Medium Priority
?
329 Views
Last Modified: 2010-03-31
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
Comment
Question by:chaitu chaitu
[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
7 Comments
 
LVL 92

Accepted Solution

by:
objects earned 2000 total points
ID: 18835142
u can't really.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 18835169
Install a security manager
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 18835175
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 8

Expert Comment

by:mhunts
ID: 18835183
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
 
LVL 4

Expert Comment

by:jcoombes
ID: 18835295
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
 
LVL 11

Expert Comment

by:elfe69
ID: 18835430
Is it really necessary to hide those methods to the other classes ?
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 18839212
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

636 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