Solved

how to restrict calling methods in different classes

Posted on 2007-04-02
7
291 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
7 Comments
 
LVL 92

Accepted Solution

by:
objects earned 500 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
topping1 challenge 7 73
Unexpected HttpURLConnection connection behavior 2 86
ForLoop Example 3 40
Way to decrease size of apk file 9 46
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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 will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

867 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now