Solved

how to restrict calling methods in different classes

Posted on 2007-04-02
7
279 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
Comment Utility
u can't really.
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
Install a security manager
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 8

Expert Comment

by:mhunts
Comment Utility
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
Comment Utility
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
Comment Utility
Is it really necessary to hide those methods to the other classes ?
0
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

744 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

17 Experts available now in Live!

Get 1:1 Help Now