How to hide the internal structure of a Java API to the rest of the world

前端 未结 4 1334
不思量自难忘°
不思量自难忘° 2020-12-03 11:16

i am developing a Java Api to do things (secret, uhhhh ;).

Is there a way to hide classes, and the internal structure of my API?

What i found until now:

4条回答
  •  情书的邮戳
    2020-12-03 11:56

    • You can try and make only your interfaces public. Have a look at the Factory Pattern.
    • Alternatively, you can implement you're application in OSGI.

    Neither of these methods would allow you to hide the implementation completely to someone who really wanted to see it. Someone could still use a decompiler to examine you .class files, or even examine the code in memory.

    If you really need to protect your implementation in this way, then a good approach would be to only allow access to your application as a remote service and host it on a secure machine.

提交回复
热议问题