Results 1 to 2 of 2
- 03-01-2011, 03:23 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 1
- Rep Power
- 0
sdk development: restricting access from outside
Hi,
I need to develop an SDK which will be consumed by the third party writers. I've the following issue:
I have factory methods which can be called to get an instance (say for example a database Connection). These instances are very critical and hence third party code should not be able to get these instances. At the same time my code which is in multiple packages should be able to access.
My packages will be something like:
src.sdk.pack1
src.sdk.pack2.innerPack1
src.sdk.pack2.innerPack2
src.sdk.pack3
etc.
I mean all these packages start with 'src.sdk' while the thirdparty code will not be in src.sdk.*
I was hoping that package private access would help me. I thought that if a class is in src.sdk and had package private access, then all the packages which start with 'src.sdk' can access the class. But it is not the case. I mean a class say src.sdk.MyClass with package private access is not accessible to another class say src.sdk.pack1.MyAnotherClass.
Is there anyway to control the access to those factory methods to only my code? Controlling access does not necessarily mean compile time restriction. Even if the method can intelligently know that it is being called from a third party code, it can throw an exception.
- 03-01-2011, 04:20 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Stick the stuff they aren't supposed to use under an obvious package structure.
Write documentation that explains the bits they are supposed to work with, and points out the stuff under (say) "internal" is not for external use.
Then if the twits insist on using those classes then it's their own fault.
Oh and mark them as @Deprecated if you feel really particular about it, but that might confuse your own development.
Similar Threads
-
Difference Between Access Specifiers & Access Modifiers
By ujjwal in forum New To JavaReplies: 0Last Post: 01-10-2011, 06:26 AM -
Significanlty lower development costs in high quality development
By espeo in forum Reviews / AdvertisingReplies: 5Last Post: 04-23-2010, 06:08 PM -
Default Access (package access) confusion
By gauravrajbehl in forum New To JavaReplies: 1Last Post: 11-18-2009, 10:48 AM -
Method access or field access
By carderne in forum New To JavaReplies: 2Last Post: 12-06-2008, 06:20 PM -
Help with access a database using Microsoft Access
By cachi in forum JDBCReplies: 1Last Post: 08-07-2007, 07:51 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks