Return-Path: X-Original-To: apmail-clerezza-commits-archive@www.apache.org Delivered-To: apmail-clerezza-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 64915100E7 for ; Wed, 6 Nov 2013 18:03:31 +0000 (UTC) Received: (qmail 23301 invoked by uid 500); 6 Nov 2013 18:03:31 -0000 Delivered-To: apmail-clerezza-commits-archive@clerezza.apache.org Received: (qmail 23275 invoked by uid 500); 6 Nov 2013 18:03:31 -0000 Mailing-List: contact commits-help@clerezza.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@clerezza.apache.org Delivered-To: mailing list commits@clerezza.apache.org Received: (qmail 23268 invoked by uid 99); 6 Nov 2013 18:03:30 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Nov 2013 18:03:30 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Nov 2013 18:03:24 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id E627C23889FA; Wed, 6 Nov 2013 18:03:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1539411 - in /clerezza/trunk: scala-scripting/script-engine/ scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/ shell/ shell/src/main/scala/org/apache/clerezza/shell/ Date: Wed, 06 Nov 2013 18:03:01 -0000 To: commits@clerezza.apache.org From: reto@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131106180301.E627C23889FA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: reto Date: Wed Nov 6 18:03:01 2013 New Revision: 1539411 URL: http://svn.apache.org/r1539411 Log: CLEREZZA-842: using the orginal bundle-classloader rather than the scalate one. Modified: clerezza/trunk/scala-scripting/script-engine/pom.xml clerezza/trunk/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/BundleContextScalaCompiler.scala clerezza/trunk/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/CompilerService.scala clerezza/trunk/shell/pom.xml clerezza/trunk/shell/src/main/scala/org/apache/clerezza/shell/Shell.scala clerezza/trunk/shell/src/main/scala/org/apache/clerezza/shell/ShellFactory.scala Modified: clerezza/trunk/scala-scripting/script-engine/pom.xml URL: http://svn.apache.org/viewvc/clerezza/trunk/scala-scripting/script-engine/pom.xml?rev=1539411&r1=1539410&r2=1539411&view=diff ============================================================================== --- clerezza/trunk/scala-scripting/script-engine/pom.xml (original) +++ clerezza/trunk/scala-scripting/script-engine/pom.xml Wed Nov 6 18:03:01 2013 @@ -40,11 +40,11 @@ org.scala-lang scala-actors - + org.apache.felix org.apache.felix.scr.annotations @@ -72,13 +72,13 @@ OSGI-INF/serviceComponents.xml org.apache.clerezza.scala.scripting,org.apache.clerezza.scala.scripting.util - !com.sun.*,!javax.servlet,!javax.servlet.*, + + * org.apache.clerezza.scala.scripting - scalate-core_2.10 + Modified: clerezza/trunk/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/BundleContextScalaCompiler.scala URL: http://svn.apache.org/viewvc/clerezza/trunk/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/BundleContextScalaCompiler.scala?rev=1539411&r1=1539410&r2=1539411&view=diff ============================================================================== --- clerezza/trunk/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/BundleContextScalaCompiler.scala (original) +++ clerezza/trunk/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/BundleContextScalaCompiler.scala Wed Nov 6 18:03:01 2013 @@ -19,6 +19,7 @@ package org.apache.clerezza.scala.scripting import org.osgi.framework.BundleContext +//import org.fusesource.scalate.util.Strings import org.osgi.framework.Bundle /*import java.io.File import scala.tools.nsc._; @@ -29,8 +30,8 @@ import java.net._ import scala.tools.nsc.io.AbstractFile import scala.tools.nsc.reporters.Reporter import scala.tools.util.PathResolver*/ -import org.fusesource.scalate._ -import osgi.{BundleHeaders, BundleClassPathBuilder, BundleClassLoader} +import java.net.URL +//import org.fusesource.scalate.osgi.BundleClassPathBuilder import scala.tools.nsc.Global import scala.tools.nsc.Settings import scala.tools.nsc.interpreter.ReplGlobal @@ -43,8 +44,9 @@ import scala.runtime.ByteRef import scala.util.parsing.input.OffsetPosition import collection.mutable.ListBuffer import org.osgi.framework.Bundle -import java.io.{PrintWriter, StringWriter, File} +import java.io.{PrintWriter, StringWriter, File, IOException, InputStream} import org.slf4j.scala._ +import scala.collection.mutable.ListBuffer /* * unfortunately there seems to be no way to change the classpath, so this doesn't @@ -69,11 +71,11 @@ class BundleContextScalaCompiler(bundleC def createClassPath[T](original: ClassPath[T]) = { var result = ListBuffer(original) - for (bundle <- bundleContext.getBundles; if bundle.getResource("/") != null) { + for (bundle <- bundleContext.getBundles/*; if bundle.getResource("/") != null*/) { try { - val files = BundleClassPathBuilder.fromBundle(bundle) + val files = ListBuffer(BundleFS.create(bundle)); //BundleClassPathBuilder.fromBundle(bundle) files.foreach(file => { - //debug("Adding bundle " + file + " to the Scala compiler classpath") + //println("Adding bundle " + file + " to the Scala compiler classpath for "+bundle) result += original.context.newClassPath(file) }) } catch { @@ -110,6 +112,6 @@ class BundleContextScalaCompiler(bundleC /*override def rootLoader: LazyType = { new loaders.JavaPackageLoader(classPath) }*/ -} + } Modified: clerezza/trunk/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/CompilerService.scala URL: http://svn.apache.org/viewvc/clerezza/trunk/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/CompilerService.scala?rev=1539411&r1=1539410&r2=1539411&view=diff ============================================================================== --- clerezza/trunk/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/CompilerService.scala (original) +++ clerezza/trunk/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/CompilerService.scala Wed Nov 6 18:03:01 2013 @@ -46,143 +46,143 @@ import java.io.Reader import java.net._ class CompileErrorsException(message: String, cause: Exception) extends Exception(message, cause) { - def this(cause: Exception) = this(null, cause) - def this() = this(null) + def this(cause: Exception) = this(null, cause) + def this() = this(null) } class CompilePermission extends Permission("Compile Permssion") { - def getActions() = "" - def implies(p: Permission) = p.isInstanceOf[CompilePermission] - override def equals(o: Any): Boolean = o.isInstanceOf[CompilePermission] - override def hashCode = classOf[CompilePermission].hashCode + def getActions() = "" + def implies(p: Permission) = p.isInstanceOf[CompilePermission] + override def equals(o: Any): Boolean = o.isInstanceOf[CompilePermission] + override def hashCode = classOf[CompilePermission].hashCode } class CompilerService() extends BundleListener { - protected var bundleContext : BundleContext = null; - //protected val sharedVirtualDirectory = new VirtualDirectory("(memory)", None) - protected var currentSharedCompilerOutputStream: OutputStream = null - protected val splipptingOutputStream = new OutputStream() { - def write(b: Int) { - if (currentSharedCompilerOutputStream == null) { - throw new IOException("no currentSharedCompilerOutputStream set") - } - currentSharedCompilerOutputStream.write(b) - } - } - protected val splittingPrintWriter = new PrintWriter(splipptingOutputStream, true) - - protected var currentSharedCompiler: TrackingCompiler = null; - protected def sharedCompiler = { - if (currentSharedCompiler == null) { - synchronized { - if (currentSharedCompiler == null) { - currentSharedCompiler = TrackingCompiler(bundleContext, splittingPrintWriter, None) - //createCompiler(splittingPrintWriter, sharedVirtualDirectory) - } - } - } - currentSharedCompiler - } - - def activate(componentContext: ComponentContext)= { - bundleContext = componentContext.getBundleContext - bundleContext.addBundleListener(this) - } - - def deactivate(componentContext: ComponentContext) = { - currentSharedCompiler = null - bundleContext.removeBundleListener(this) - } - - def bundleChanged(event: BundleEvent) = { - currentSharedCompiler = null - } - - def createCompiler(out: PrintWriter, outputSirectory: AbstractFile) : TrackingCompiler = { - TrackingCompiler(bundleContext, out, Some(outputSirectory)) - } - - def compile(sources: Array[Array[Char]]): Array[Class[_]] = { - compile(sources.toList).toArray - } - - def compile(sources: List[Array[Char]]): List[Class[_]] = { - AccessController.checkPermission(new CompilePermission) - sharedCompiler.synchronized { - try { - AccessController.doPrivileged[List[Class[_]]]( - new PrivilegedExceptionAction[List[Class[_]]] { - def run(): List[Class[_]] = { - val baos = new ByteArrayOutputStream - currentSharedCompilerOutputStream = baos - try { - sharedCompiler.compile(sources) - } catch { - case c: CompileErrorsException => { - throw new CompileErrorsException( - new String(baos.toByteArray, "utf-8"), c) - } - case e: Exception => throw e - } finally { - currentSharedCompilerOutputStream = null - } - } - }) - } catch { - case e: PrivilegedActionException => throw e.getCause - case e: Exception => throw e - } - } - } - - /** - * compiles a set of sources with a dedicated compiler - */ - def compileIsolated(sources: List[Array[Char]]): List[Class[_]] = { - val virtualDirectory = new VirtualDirectory("(memory)", None) - compileIsolated(sources, virtualDirectory) - } - - def compileIsolated(sources: List[Array[Char]], outputDirectory: AbstractFile): List[Class[_]] = { - AccessController.checkPermission(new CompilePermission) - sharedCompiler.synchronized { - AccessController.doPrivileged[List[Class[_]]]( - new PrivilegedExceptionAction[List[Class[_]]] { - def run() = { - val out = new ByteArrayOutputStream - val printWriter = new PrintWriter(out) - val compiler = createCompiler(printWriter, outputDirectory) - try { - compiler.compile(sources) - } catch { - case c: CompileErrorsException => throw new CompileErrorsException(new String(out.toByteArray, "utf-8"), c) - case e: Exception => throw e - } - } - }) - } - } - - def compileToDir(sources: List[Array[Char]], outputDirectory: AbstractFile): List[AbstractFile] = { - AccessController.checkPermission(new CompilePermission) - sharedCompiler.synchronized { - AccessController.doPrivileged[List[AbstractFile]]( - new PrivilegedExceptionAction[List[AbstractFile]] { - def run() = { - val out = new ByteArrayOutputStream - val printWriter = new PrintWriter(out) - val compiler = createCompiler(printWriter, outputDirectory) - try { - compiler.compileToDir(sources) - } catch { - case c: CompileErrorsException => throw new CompileErrorsException(new String(out.toByteArray, "utf-8"), c) - case e: Exception => throw e - } - } - }) - } - } + protected var bundleContext : BundleContext = null; + //protected val sharedVirtualDirectory = new VirtualDirectory("(memory)", None) + protected var currentSharedCompilerOutputStream: OutputStream = null + protected val splipptingOutputStream = new OutputStream() { + def write(b: Int) { + if (currentSharedCompilerOutputStream == null) { + throw new IOException("no currentSharedCompilerOutputStream set") + } + currentSharedCompilerOutputStream.write(b) + } + } + protected val splittingPrintWriter = new PrintWriter(splipptingOutputStream, true) + + protected var currentSharedCompiler: TrackingCompiler = null; + protected def sharedCompiler = { + if (currentSharedCompiler == null) { + synchronized { + if (currentSharedCompiler == null) { + currentSharedCompiler = TrackingCompiler(bundleContext, splittingPrintWriter, None) + //createCompiler(splittingPrintWriter, sharedVirtualDirectory) + } + } + } + currentSharedCompiler + } + + def activate(componentContext: ComponentContext)= { + bundleContext = componentContext.getBundleContext + bundleContext.addBundleListener(this) + } + + def deactivate(componentContext: ComponentContext) = { + currentSharedCompiler = null + bundleContext.removeBundleListener(this) + } + + def bundleChanged(event: BundleEvent) = { + currentSharedCompiler = null + } + + def createCompiler(out: PrintWriter, outputSirectory: AbstractFile) : TrackingCompiler = { + TrackingCompiler(bundleContext, out, Some(outputSirectory)) + } + + def compile(sources: Array[Array[Char]]): Array[Class[_]] = { + compile(sources.toList).toArray + } + + def compile(sources: List[Array[Char]]): List[Class[_]] = { + AccessController.checkPermission(new CompilePermission) + sharedCompiler.synchronized { + try { + AccessController.doPrivileged[List[Class[_]]]( + new PrivilegedExceptionAction[List[Class[_]]] { + def run(): List[Class[_]] = { + val baos = new ByteArrayOutputStream + currentSharedCompilerOutputStream = baos + try { + sharedCompiler.compile(sources) + } catch { + case c: CompileErrorsException => { + throw new CompileErrorsException( + new String(baos.toByteArray, "utf-8"), c) + } + case e: Exception => throw e + } finally { + currentSharedCompilerOutputStream = null + } + } + }) + } catch { + case e: PrivilegedActionException => throw e.getCause + case e: Exception => throw e + } + } + } + + /** + * compiles a set of sources with a dedicated compiler + */ + def compileIsolated(sources: List[Array[Char]]): List[Class[_]] = { + val virtualDirectory = new VirtualDirectory("(memory)", None) + compileIsolated(sources, virtualDirectory) + } + + def compileIsolated(sources: List[Array[Char]], outputDirectory: AbstractFile): List[Class[_]] = { + AccessController.checkPermission(new CompilePermission) + sharedCompiler.synchronized { + AccessController.doPrivileged[List[Class[_]]]( + new PrivilegedExceptionAction[List[Class[_]]] { + def run() = { + val out = new ByteArrayOutputStream + val printWriter = new PrintWriter(out) + val compiler = createCompiler(printWriter, outputDirectory) + try { + compiler.compile(sources) + } catch { + case c: CompileErrorsException => throw new CompileErrorsException(new String(out.toByteArray, "utf-8"), c) + case e: Exception => throw e + } + } + }) + } + } + + def compileToDir(sources: List[Array[Char]], outputDirectory: AbstractFile): List[AbstractFile] = { + AccessController.checkPermission(new CompilePermission) + sharedCompiler.synchronized { + AccessController.doPrivileged[List[AbstractFile]]( + new PrivilegedExceptionAction[List[AbstractFile]] { + def run() = { + val out = new ByteArrayOutputStream + val printWriter = new PrintWriter(out) + val compiler = createCompiler(printWriter, outputDirectory) + try { + compiler.compileToDir(sources) + } catch { + case c: CompileErrorsException => throw new CompileErrorsException(new String(out.toByteArray, "utf-8"), c) + case e: Exception => throw e + } + } + }) + } + } } Modified: clerezza/trunk/shell/pom.xml URL: http://svn.apache.org/viewvc/clerezza/trunk/shell/pom.xml?rev=1539411&r1=1539410&r2=1539411&view=diff ============================================================================== --- clerezza/trunk/shell/pom.xml (original) +++ clerezza/trunk/shell/pom.xml Wed Nov 6 18:03:01 2013 @@ -94,7 +94,8 @@ scala.tools.jline.console.history, scala.tools.jline.console.completer org.apache.clerezza.shell - org.apache.clerezza.platform.security;resolution:=optional, * + org.apache.clerezza.platform.security;resolution:=optional, + org.osgi.*; version="[1,2)", * jline, scala-actors Modified: clerezza/trunk/shell/src/main/scala/org/apache/clerezza/shell/Shell.scala URL: http://svn.apache.org/viewvc/clerezza/trunk/shell/src/main/scala/org/apache/clerezza/shell/Shell.scala?rev=1539411&r1=1539410&r2=1539411&view=diff ============================================================================== --- clerezza/trunk/shell/src/main/scala/org/apache/clerezza/shell/Shell.scala (original) +++ clerezza/trunk/shell/src/main/scala/org/apache/clerezza/shell/Shell.scala Wed Nov 6 18:03:01 2013 @@ -69,7 +69,7 @@ import scala.tools.jline.UnixTerminal import scala.tools.jline.console.history.History class Shell(factory: InterpreterFactory, val inStream: InputStream, - outStream: OutputStream, shellCommands: immutable.Set[ShellCommand], terminalOption: Option[Terminal] = None) extends Logging { + outStream: OutputStream, shellCommands: immutable.Set[ShellCommand], terminalOption: Option[Terminal] = None) extends Logging { private var bundleContext: BundleContext = null @@ -101,11 +101,11 @@ class Shell(factory: InterpreterFactory, override lazy val standardCommands: List[LoopCommand] = { import LoopCommand._ (for (shellCommand <- shellCommands) yield { - new LineCmd(shellCommand.command, "", shellCommand.description, (line: String) => { - val (continue, linesToRecord) = shellCommand.execute(line, Shell.this.outStream) - Result(continue, linesToRecord) - }) - }).toList ::: List( + new LineCmd(shellCommand.command, "", shellCommand.description, (line: String) => { + val (continue, linesToRecord) = shellCommand.execute(line, Shell.this.outStream) + Result(continue, linesToRecord) + }) + }).toList ::: List( cmd("help", "[command]", "print this summary or command-specific help", helpCommand), historyCommand, cmd("h?", "", "search the history", searchHistory), @@ -119,65 +119,65 @@ class Shell(factory: InterpreterFactory, } /** print a friendly help message */ - override def helpCommand(line: String): Result = { - if (line == "") printAdditinalHelp(); + override def helpCommand(line: String): Result = { + if (line == "") printAdditinalHelp(); - super.helpCommand(line); - } + super.helpCommand(line); + } def printAdditinalHelp() = { - out println "This is a scala based console, it supports any Scala expression, as well as the command described below." - out println "To access an OSGi service use $[interface]." - out println "" - out println "Initially the following variables are bound:" - for ((name, boundType, value) <- bindings) { - out println (name+": "+boundType+" = "+value) - } - out println "" - out println "This are the initial imports: " - for (v <- imports) { - out println ("import "+v) - } - out println "" - } + out println "This is a scala based console, it supports any Scala expression, as well as the command described below." + out println "To access an OSGi service use $[interface]." + out println "" + out println "Initially the following variables are bound:" + for ((name, boundType, value) <- bindings) { + out println (name+": "+boundType+" = "+value) + } + out println "" + out println "This are the initial imports: " + for (v <- imports) { + out println ("import "+v) + } + out println "" + } override def process(settings: Settings): Boolean = { this.settings = settings createInterpreter() // sets in to some kind of reader depending on environmental cues - //ignore settings.noCompletion.value) + //ignore settings.noCompletion.value) { - val myIn = new StreamJLineReader(new JLineCompletion(intp), inStream, outStream, terminal) - in = myIn - //are we postinit already? - addThunk(myIn.consoleReader.postInit) + val myIn = new StreamJLineReader(new JLineCompletion(intp), inStream, outStream, terminal) + in = myIn + //are we postinit already? + addThunk(myIn.consoleReader.postInit) } loadFiles(settings) - // it is broken on startup; go ahead and exit - if (intp.reporter.hasErrors) - return false - - // This is about the illusion of snappiness. We call initialize() - // which spins off a separate thread, then print the prompt and try - // our best to look ready. The interlocking lazy vals tend to - // inter-deadlock, so we break the cycle with a single asynchronous - // message to an actor. - if (isAsync) { - intp initialize initializedCallback() - createAsyncListener() // listens for signal to run postInitialization - } - else { - intp.initializeSynchronous() - postInitialization() - } - printWelcome() - - try loop() - catch AbstractOrMissingHandler() - finally closeInterpreter() + // it is broken on startup; go ahead and exit + if (intp.reporter.hasErrors) + return false + + // This is about the illusion of snappiness. We call initialize() + // which spins off a separate thread, then print the prompt and try + // our best to look ready. The interlocking lazy vals tend to + // inter-deadlock, so we break the cycle with a single asynchronous + // message to an actor. + if (isAsync) { + intp initialize initializedCallback() + createAsyncListener() // listens for signal to run postInitialization + } + else { + intp.initializeSynchronous() + postInitialization() + } + printWelcome() + + try loop() + catch AbstractOrMissingHandler() + finally closeInterpreter() - true + true } override def printWelcome() { @@ -187,7 +187,7 @@ class Shell(factory: InterpreterFactory, |Console is based on Scala %s (%s, Java %s). |Type in expressions to have them evaluated. |Type :help for more information.""". - stripMargin.format(versionString, javaVmName, javaVersion) + stripMargin.format(versionString, javaVmName, javaVersion) echo(welcomeMsg) } Modified: clerezza/trunk/shell/src/main/scala/org/apache/clerezza/shell/ShellFactory.scala URL: http://svn.apache.org/viewvc/clerezza/trunk/shell/src/main/scala/org/apache/clerezza/shell/ShellFactory.scala?rev=1539411&r1=1539410&r2=1539411&view=diff ============================================================================== --- clerezza/trunk/shell/src/main/scala/org/apache/clerezza/shell/ShellFactory.scala (original) +++ clerezza/trunk/shell/src/main/scala/org/apache/clerezza/shell/ShellFactory.scala Wed Nov 6 18:03:01 2013 @@ -25,7 +25,7 @@ import org.osgi.service.component.Compon import java.io.InputStream import java.io.OutputStream import java.security.AccessController -import java.security.PrivilegedAction +import java.security.PrivilegedExceptionAction import org.apache.clerezza.scala.scripting.InterpreterFactory import scala.tools.jline.Terminal @@ -34,77 +34,78 @@ class ShellFactory() { - private var interpreterFactory: InterpreterFactory = null - private var componentContext: ComponentContext = null - private var commands = Set[ShellCommand]() - private var customizers = Set[ShellCustomizer]() - - def activate(componentContext: ComponentContext)= { - this.componentContext = componentContext - } - - def deactivate(componentContext: ComponentContext) = { - this.componentContext = componentContext - } - - /* - * Using overloading instead of default, as default is not supported when calling from java - */ - def createShell(pIn: InputStream, pOut: OutputStream): Shell = { - createShell(pIn, pOut, None) - } - def createShell(pIn: InputStream, pOut: OutputStream, terminalOption: Option[Terminal]): Shell = { + private var interpreterFactory: InterpreterFactory = null + private var componentContext: ComponentContext = null + private var commands = Set[ShellCommand]() + private var customizers = Set[ShellCustomizer]() + + def activate(componentContext: ComponentContext)= { + this.componentContext = componentContext + } + + def deactivate(componentContext: ComponentContext) = { + this.componentContext = componentContext + } + + /* + * Using overloading instead of default, as default is not supported when calling from java + */ + def createShell(pIn: InputStream, pOut: OutputStream): Shell = { + createShell(pIn, pOut, None) + } + def createShell(pIn: InputStream, pOut: OutputStream, terminalOption: Option[Terminal]): Shell = { var security: SecurityManager = System.getSecurityManager if (security != null) { AccessController.checkPermission(new ShellPermission()) } - AccessController.doPrivileged(new PrivilegedAction[Shell] { - override def run() = { - val shell = new Shell(interpreterFactory, pIn, pOut, commands, terminalOption) - //shell.bind("bundleContext", classOf[BundleContext].getName, componentContext.getBundleContext) - //shell.bind("componentContext", classOf[ComponentContext].getName, componentContext) - shell.bind("osgiDsl", classOf[OsgiDsl].getName, new OsgiDsl(componentContext, pOut)) - shell.addImport("org.apache.clerezza.{scala => zzscala, _ }") - shell.addImport("osgiDsl._") - val environment = new Shell.Environment { - val componentContext: ComponentContext = ShellFactory.this.componentContext - val in: InputStream = pIn; - val out: OutputStream = pOut; - } - for (c <- customizers) { - for(b <- c.bindings(environment)) { - shell.bind(b._1, b._2, b._3) - } - for(i <- c.imports) { - shell.addImport(i) - } - } - shell - } - }) - } - - def bindInterpreterFactory(f: InterpreterFactory) = { - interpreterFactory = f - } - - def unbindInterpreterFactory(f: InterpreterFactory) = { - interpreterFactory = null - } - - def bindCommand(c: ShellCommand) = { - commands += c - } - - def unbindCommand(c: ShellCommand) = { - commands -= c - } - - def bindCustomizer(c: ShellCustomizer) = { - customizers += c - } - - def unbindCustomizer(c: ShellCustomizer) = { - customizers -= c - } + AccessController.doPrivileged(new PrivilegedExceptionAction[Shell] { + override def run() = { + val shell = new Shell(interpreterFactory, pIn, pOut, commands, terminalOption) + //shell.bind("bundleContext", classOf[BundleContext].getName, componentContext.getBundleContext) + //shell.bind("componentContext", classOf[ComponentContext].getName, componentContext) + shell.bind("osgiDsl", classOf[OsgiDsl].getName, new OsgiDsl(componentContext, pOut)) + shell.addImport("org.apache.clerezza.{scala => zzscala, _ }") + shell.addImport("osgiDsl._") + val environment = new Shell.Environment { + val componentContext: ComponentContext = ShellFactory.this.componentContext + val in: InputStream = pIn; + val out: OutputStream = pOut; + } + for (c <- customizers) { + for(b <- c.bindings(environment)) { + shell.bind(b._1, b._2, b._3) + } + for(i <- c.imports) { + shell.addImport(i) + } + } + shell + } + }) + + } + + def bindInterpreterFactory(f: InterpreterFactory) = { + interpreterFactory = f + } + + def unbindInterpreterFactory(f: InterpreterFactory) = { + interpreterFactory = null + } + + def bindCommand(c: ShellCommand) = { + commands += c + } + + def unbindCommand(c: ShellCommand) = { + commands -= c + } + + def bindCustomizer(c: ShellCustomizer) = { + customizers += c + } + + def unbindCustomizer(c: ShellCustomizer) = { + customizers -= c + } } \ No newline at end of file