I also posted this in the other forum, but probably makes sense to put here as well:
I found that I needed to comment out line 71 of org.knopflerfish.framework.FrameworkPolicy to avoid a security exception on startup if any security manager is installed:
java.lang.SecurityException: attempt to add a Permission to a readonly Permissions object
at java.security.Permissions.add(Unknown Source)
at java.security.Policy.addStaticPerms(Unknown Source)
at java.security.Policy.getPermissions(Unknown Source)
at java.security.Policy.implies(Unknown Source)
at java.security.ProtectionDomain.implies(Unknown Source)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at org.knopflerfish.framework.Services.register(Services.java:106)
at org.knopflerfish.framework.Framework.<init>(Framework.java:260)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I basically took the path of least resistence to embedding, so what I did was to pull a bunch of code in from the Main class into my own launcher class. It got me to where I wanted to be the quickest, and I was able to get the framework running in my app, but it does seem to me that the Main class could be refactored into the following:
1) A utility class for parsing xargs files.
2) Some sort of startup service bundle that uses the xargs files to install and start bundles just the same way the Main class currently does, except using the SystemBundleContext rather than calling methods in the Framework object, etc.
3) A hopefully very thin Main class that really doesn't do more that set a couple of system properties, specify the startup service, and instantiate the framework.
I'm happy to help, although I'm still learning the standard.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I needed to add the following methods to make embedding easier:
In Framework:
public StartLevel getStartLevel() {
return startLevelService;
}
In StartLevelImpl:
public void setCompatibilityMode(boolean compat) {
bCompat = compat;
}
I needed to add these in order to be able to reuse the xargs code from Main to launch the framework from my app.
Also, because callbacks to Main.shutdown and Main.restart are hardcoded elsewhere in the system, I've added the following to Main:
public static void setBootMgr(long bootMgr) {
Main.bootMgr = bootMgr;
}
public static void setFramework(Framework framework) {
Main.framework = framework;
}
I also posted this in the other forum, but probably makes sense to put here as well:
I found that I needed to comment out line 71 of org.knopflerfish.framework.FrameworkPolicy to avoid a security exception on startup if any security manager is installed:
FrameworkPolicy(PermissionAdminImpl pa) {
all.add(new AllPermission());
//all.setReadOnly();
permissionAdmin = pa;
}
otherwise, the following exception is thrown:
java.lang.SecurityException: attempt to add a Permission to a readonly Permissions object
at java.security.Permissions.add(Unknown Source)
at java.security.Policy.addStaticPerms(Unknown Source)
at java.security.Policy.getPermissions(Unknown Source)
at java.security.Policy.implies(Unknown Source)
at java.security.ProtectionDomain.implies(Unknown Source)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at org.knopflerfish.framework.Services.register(Services.java:106)
at org.knopflerfish.framework.Framework.<init>(Framework.java:260)
We should definetely work on making it easier to embed the KF framework. I consider this related to tidying up the startup config format.
thanks for your comments!
/E
I basically took the path of least resistence to embedding, so what I did was to pull a bunch of code in from the Main class into my own launcher class. It got me to where I wanted to be the quickest, and I was able to get the framework running in my app, but it does seem to me that the Main class could be refactored into the following:
1) A utility class for parsing xargs files.
2) Some sort of startup service bundle that uses the xargs files to install and start bundles just the same way the Main class currently does, except using the SystemBundleContext rather than calling methods in the Framework object, etc.
3) A hopefully very thin Main class that really doesn't do more that set a couple of system properties, specify the startup service, and instantiate the framework.
I'm happy to help, although I'm still learning the standard.