Reputation: 1482
I have a java class containing my Database settings (username, password). I want to use this class in all the packages of my plugin but I don't want it to be available to other plugins.
How can I do that? Removing the public attribute of the class hides it from all other packages and leaving it public exposes it to all other plugins wich is bad in my case.
Isn't there some kind of keyword like protected for functions and variables?
Upvotes: 0
Views: 152
Reputation: 20442
If your database information is stored as plain text variables, it doesn't matter what visibility you set. Anyone interested will easily find those strings.
I'm not sure what you are plugging into, but most platforms that I have used have a way of stating which packages should be shared/hidden. This would be specific to the platform (Netbeans, Eclipse, etc...)
Aside from that, if you make your class/variables protected
then only classes in the same package
or which extend
it would be able to use them. If no visibility modifier is set, then it defaults to package and use is restricted to classes in the same package.
Upvotes: 0
Reputation: 13872
How can I do that?
Instead of having credentials in class, create a configuration file and use it in classes where required.
Upvotes: 1