I have successfully run fortress in a webstart and applet sandbox.
I'm developing an OS resource-management and scheduling application
(primary for schools and universities) and the server and also the
swing client are based on a fortress-container. The client should also
run in sandboxed environments.
To solve this I had to workaround the following problems
1. A Bug in ContextManager. I posted this issue in a Thread called
"Problem with asynchronous disposing" one month ago: The components
will not be disposed on containerManager.dispose() and this prevents
the VM from closing (if a service is using non daemon threads). I
could resolve this with the patch from Leo Sutic. Any reasons why this
patch hasn't been applied yet?
2. org.apache.excalibur.util.SystemUtil throws a SecurityException on
intitialization. Cause: The Sandbox prevents access to the
System.properties and to /proc/cpu-info (under linux). I resolved
this with to short modifications to TPCThreadManager and
ContextManager. In TPCThreadManager the m_processors variable is
initialized lazily so a call to SystemUtil is not necessary if the
processesors parameter is set. In the ContextManager the processors
value is passed to the TPCThreadManger if found on context. Patches
are appended.
3. org.apache.excalibur.source.impl.SourceResolverImpl throws
a SecurityExcetpion on contextualization. Cause:
( (File)m_context.get( "context-root" ) ).toURL()
The toURL method accesses System-variables (and the local file-system)
when trying to convert the file to an URL. The SourceResolverImpl
class is needed internally by the ContextManger to resolve the
locations of the configuration-filse. But with applets or webstart
clients these configurations are normally located on the server and
"context-root" should be something like
"http://myserver.mydomain:myport/mycontext" instead of File-Object.
I could only solve this by overriding initializeOwnComponentManager()
of ContextManager with an empty method and setting the configurations
manually with:
contextBuilder.setLoggerManagerConfiguration
contextBuilder.setContainerConfiguration
I would be pleased if you could apply the two minor patches + the one
from Leo, so that I could be in sync with the latest fortress versions.
On the other hand I could try to write a short documentation on using
fortress with clients (Issues with multithreading and swing,
sandboxing, ..) if your interested. Sandboxing should also be a
subject with restricted servlet containers.
Regards Christopher
Index: event/src/java/org/apache/excalibur/event/command/TPCThreadManager.java
===================================================================
RCS file:
/home/cvspublic/jakarta-avalon-excalibur/event/src/java/org/apache/excalibur/event/command/TPCThreadManager.java,v
retrieving revision 1.24
diff -u -r1.24 TPCThreadManager.java
--- event/src/java/org/apache/excalibur/event/command/TPCThreadManager.java 8 Aug
2002 00:36:26 -0000 1.24
+++ event/src/java/org/apache/excalibur/event/command/TPCThreadManager.java 6 Sep
+2002 14:04:06 -0000
@@ -80,7 +80,7 @@
{
private DefaultThreadPool m_tpool;
private long m_blockTimeout = 1000L;
- private int m_processors = SystemUtil.numProcessors();
+ private int m_processors = -1;
private int m_threadsPerProcessor = 1;
/**
@@ -114,9 +114,11 @@
*/
public void parameterize( Parameters parameters ) throws ParameterException
{
- this.m_processors =
- Math.max( parameters.getParameterAsInteger( "processors",
SystemUtil.numProcessors() ),
- 1 );
+ this.m_processors = parameters.getParameterAsInteger( "processors", -1);
+ if (this.m_processors < 1)
+ {
+ this.m_processors = Math.max( 1 , SystemUtil.numProcessors() );
+ }
this.m_threadsPerProcessor =
Math.max( parameters.getParameterAsInteger( "threads-per-processor", 1 ),
1 );
@@ -127,6 +129,11 @@
public void initialize() throws Exception
{
+ if (this.m_processors < 1)
+ {
+ this.m_processors = Math.max( 1 , SystemUtil.numProcessors() );
+ }
+
if( isInitialized() )
{
throw new IllegalStateException( "ThreadManager is already initailized" );
Index: fortress/src/java/org/apache/excalibur/fortress/util/ContextManager.java
===================================================================
RCS file:
/home/cvspublic/jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/util/ContextManager.java,v
retrieving revision 1.37
diff -u -r1.37 ContextManager.java
--- fortress/src/java/org/apache/excalibur/fortress/util/ContextManager.java 13 Aug
2002 07:57:27 -0000 1.37
+++ fortress/src/java/org/apache/excalibur/fortress/util/ContextManager.java 6 Sep
+2002 14:04:55 -0000
@@ -479,6 +479,15 @@
try
{
+ Integer processors = (Integer) rootContext.get( "processors" );
+ p.setParameter( "processors", processors.toString() );
+ }
+ catch( ContextException e )
+ {
+ }
+
+ try
+ {
threadsPerProcessor = (Integer) rootContext.get( THREADS_CPU );
}
catch( ContextException e )
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>