Mandy Ram wrote:So, Can any help me to understand what needs to be done if I want any method to be used in different packages of my application but not to allow the user who use my jar file to use the same.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Jeff Verdegan wrote:I thought that Java 7 introduced the notion of "modules" or something like that, which allowed more sophisticated access control. Am I imagining that?
Winston Gutkowski wrote:
Mandy Ram wrote:So, Can any help me to understand what needs to be done if I want any method to be used in different packages of my application but not to allow the user who use my jar file to use the same.
Simply put: you can't. It's a weakness of Java's recognition of packages that it treats, for example, java.util and java.util.regex as totally separate packages; otherwise you'd be able to use package-private (default) access.
However, my question would be: why do you think you need to do this?
In my experience, the need for an "internally-public" method is fairly rare, and might reflect a flaw in your design logic. If the method is that useful, chances are that it may be just as well to create a safe public version; but without a specific example, it's difficult to know exactly.
Winston
Mandy Ram wrote:2) If the answer is that I should keep all of them in a single package and there's no other way, even then I see a flaw that the users who are using my jar file can create the same package structure and even then can use my protected DAOmethods.
Winston Gutkowski wrote:However, my question would be: why do you think you need to do this? In my experience, the need for an "internally-public" method is fairly rare, and might reflect a flaw in your design logic.
Jeff Verdegan wrote:I thought that Java 7 introduced the notion of "modules" or something like that, which allowed more sophisticated access control. Am I imagining that?
Mandy Ram wrote:I want my users only to use the methods in the interface but not call the DAO methods or service methods directly.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here