Mar 3rd, 2009, 03:28 AM
Avoiding java.net.* in bootdelegation path
I have a use case where in i want to avoid the bundles using java.net packages in the bundles unedr spring dm.
Since these java.* are implicitly imported and i can not control this throught manifest file.
How can i avoid direct access of this java.net package ?
Mar 3rd, 2009, 06:53 AM
Well, at this stage of the game you canít. It is not as much about bootdelegation, as it is abut the fact that java.net is required by the dmServer kernel itself. Removing the java.net entry from the *profile will result in the server not being able to start.
But even if you could, how would you stop developers from using it (writing code) anyway. Java.net is part of JDK which means the developers would still see it during the development. So until there is an IDE that recognizes OSGi partitioning of JVM you have to rely on your local conventions and coding guidelines.
What is your use case for this anyway?
Mar 3rd, 2009, 09:36 PM
My use case is that we have a third party vendor who will deploy his jar in our OSGi environment , and we want to impose restriction on using java.net packages in his bundles.
Having import in the manifest file helps us a easy way for us to identify if the third party is using any of the unwanted java packages .
One more thought is that in java* profile file, i did not see a listing for java.net package.i just saw i sun.com.* Then how did it get imported ?
I am using Dm version 1.0.1.
Mar 4th, 2009, 12:32 AM
As an FYI, java.net is listed under org.osgi.framework.system.packages, but in any event. . .
Section 3.8.5 of OSGi R4 spec states:
"The set of implicitly imported packages are all java.* packages, since these
packages are required by the Java runtime, . . . A bundle must not declare imports or exports for java.* packages; doing so
is an error and any such bundle must fail to install. . .", which means there is not much you can do as far as java.net. . . especially java.net which is not only about accessing network, but also about URLs, URIs etc. . which are widely used.
You can probably play with java policy files. . .
Mar 4th, 2009, 07:23 AM
java.net is not present in the system packages only javax.net is present in that.
Mar 4th, 2009, 08:00 AM
Nice catch :-). . .My bad, for whatever reason I assumed javax.net. But as I said all java.* are implicitly imported so there is no way to manage them via OSGi semantics