Author: gtrasuk Date: Tue Apr 17 15:17:52 2012 New Revision: 1327138 URL: http://svn.apache.org/viewvc?rev=1327138&view=rev Log: Ongoing work on starter service deployer. Changed from properties file to a custom dialect for deployer configuration. Added ApplicationEnvironment to track deployed services.
Added: river/jtsk/skunk/surrogate/src/org/apache/river/container/Optional.java - copied, changed from r1310153, river/jtsk/skunk/surrogate/src/org/apache/river/container/Injected.java river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/ river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/ASTNode.java - copied, changed from r1310153, river/jtsk/skunk/surrogate/src/org/apache/river/container/security/ASTNode.java river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/ApplicationEnvironment.java - copied, changed from r1310153, river/jtsk/skunk/surrogate/src/org/apache/river/container/ApplicationEnvironment.java river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/ClasspathFilterBuilder.java - copied, changed from r1310153, river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/ClasspathFilterBuilder.java river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/DeployerConfigParser.jjt - copied, changed from r1310153, river/jtsk/skunk/surrogate/src/org/apache/river/container/security/PermissionFileParser.jjt river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/StarterServiceDeployer.java - copied, changed from r1310153, river/jtsk/skunk/surrogate/src/org/apache/river/container/StarterServiceDeployer.java river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/Strings.java - copied, changed from r1310153, river/jtsk/skunk/surrogate/src/org/apache/river/container/security/Strings.java river/jtsk/skunk/surrogate/test/org/apache/river/container/deployer/ river/jtsk/skunk/surrogate/test/org/apache/river/container/deployer/DeployerConfigParserTest.java - copied, changed from r1310153, river/jtsk/skunk/surrogate/test/org/apache/river/container/security/PermissionFileParserTest.java river/jtsk/skunk/surrogate/test/org/apache/river/container/deployer/sample.config - copied, changed from r1310153, river/jtsk/skunk/surrogate/test/org/apache/river/container/security/sample.policy Removed: river/jtsk/skunk/surrogate/src/org/apache/river/container/ApplicationEnvironment.java river/jtsk/skunk/surrogate/src/org/apache/river/container/StarterServiceDeployer.java river/jtsk/skunk/surrogate/src/org/apache/river/container/security/ASTNode.java river/jtsk/skunk/surrogate/src/org/apache/river/container/security/PermissionFileParser.jjt river/jtsk/skunk/surrogate/src/org/apache/river/container/security/Strings.java river/jtsk/skunk/surrogate/test/org/apache/river/container/security/PermissionFileParserTest.java river/jtsk/skunk/surrogate/test/org/apache/river/container/security/sample.policy Modified: river/jtsk/skunk/surrogate/build.xml river/jtsk/skunk/surrogate/src/org/apache/river/container/Host.java river/jtsk/skunk/surrogate/src/org/apache/river/container/MessageNames.java river/jtsk/skunk/surrogate/src/org/apache/river/container/Messages.properties river/jtsk/skunk/surrogate/src/org/apache/river/container/Strings.java river/jtsk/skunk/surrogate/src/org/apache/river/container/SurrogateInstaller.java river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/ClasspathFilter.java river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/ClasspathFilterBuilder.java river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/VirtualFileSystemClassLoader.java river/jtsk/skunk/surrogate/test/org/apache/river/surrogate/SurrogateContextTest.java river/jtsk/skunk/surrogate/testfiles/testroot/profile/default/config.xml Modified: river/jtsk/skunk/surrogate/build.xml URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/build.xml?rev=1327138&r1=1327137&r2=1327138&view=diff ============================================================================== --- river/jtsk/skunk/surrogate/build.xml (original) +++ river/jtsk/skunk/surrogate/build.xml Tue Apr 17 15:17:52 2012 @@ -129,16 +129,16 @@ <!-- Pre-compiler target to run javacc against our parser sources. --> <target name="-pre-compile"> - <!-- Do parser generation for the Permissions parser --> - <mkdir dir="${build.generated.sources.dir}/org/apache/river/container/security"/> + <!-- Do parser generation for the deployer configuration parser --> + <mkdir dir="${build.generated.sources.dir}/org/apache/river/container/deployer"/> <jjtree - target="${basedir}/src/org/apache/river/container/security/PermissionFileParser.jjt" - outputdirectory="${build.generated.sources.dir}/org/apache/river/container/security" + target="${basedir}/src/org/apache/river/container/deployer/DeployerConfigParser.jjt" + outputdirectory="${build.generated.sources.dir}/org/apache/river/container/deployer" javacchome="${libs.JavaCC.src}" /> <javacc - target="${build.generated.sources.dir}/org/apache/river/container/security/PermissionFileParser.jj" - outputdirectory="${build.generated.sources.dir}/org/apache/river/container/security" + target="${build.generated.sources.dir}/org/apache/river/container/deployer/DeployerConfigParser.jj" + outputdirectory="${build.generated.sources.dir}/org/apache/river/container/deployer" javacchome="${libs.JavaCC.src}" /> Modified: river/jtsk/skunk/surrogate/src/org/apache/river/container/Host.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/Host.java?rev=1327138&r1=1327137&r2=1327138&view=diff ============================================================================== --- river/jtsk/skunk/surrogate/src/org/apache/river/container/Host.java (original) +++ river/jtsk/skunk/surrogate/src/org/apache/river/container/Host.java Tue Apr 17 15:17:52 2012 @@ -17,6 +17,7 @@ */ package org.apache.river.container; +import org.apache.river.container.deployer.ApplicationEnvironment; import java.io.File; import java.util.ArrayList; import java.util.List; Modified: river/jtsk/skunk/surrogate/src/org/apache/river/container/MessageNames.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/MessageNames.java?rev=1327138&r1=1327137&r2=1327138&view=diff ============================================================================== --- river/jtsk/skunk/surrogate/src/org/apache/river/container/MessageNames.java (original) +++ river/jtsk/skunk/surrogate/src/org/apache/river/container/MessageNames.java Tue Apr 17 15:17:52 2012 @@ -99,6 +99,7 @@ public class MessageNames { SECURITY_INIT_FAILED="securityInitializationFailed", SECURITY_INIT_SUCCEEDED="securityInitializationSucceeded", SECURITY_INIT_WRONG_POLICY="securityInitializationWrongPolicy", + SERVICE_PARENT_CLASSLOADER_IS="serviceParentClassloaderIs", SHOW_COMMAND_LINE_ARGUMENTS="showCommandLineArguments", SHUTDOWN_METHOD_HAS_PARAMETERS="shutdownMethodHasParameters", SHUTDOWN_METHOD_NOT_VOID="shutdownMethodIsntVoid", Modified: river/jtsk/skunk/surrogate/src/org/apache/river/container/Messages.properties URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/Messages.properties?rev=1327138&r1=1327137&r2=1327138&view=diff ============================================================================== --- river/jtsk/skunk/surrogate/src/org/apache/river/container/Messages.properties (original) +++ river/jtsk/skunk/surrogate/src/org/apache/river/container/Messages.properties Tue Apr 17 15:17:52 2012 @@ -81,6 +81,7 @@ readingObject.nonAnnotatedMemberFound=Me securityInitializationFailed=Failed to initialize security subsystem. securityInitializationSucceeded=Security Manager and Dynamic Policy successfully installed. securityInitializationWrongPolicy=After security manager setup, the wrong policy is installed: {0}. +serviceParentClassloaderIs=Parent of service classloader is {0}. showCommandLineArguments=Command line arguments were: {0}. shutdownMethodHasParameters=A method flagged as @Shutdown must take no parameters. \ Method ''{1}'' on class ''{0}'' has parameters. Copied: river/jtsk/skunk/surrogate/src/org/apache/river/container/Optional.java (from r1310153, river/jtsk/skunk/surrogate/src/org/apache/river/container/Injected.java) URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/Optional.java?p2=river/jtsk/skunk/surrogate/src/org/apache/river/container/Optional.java&p1=river/jtsk/skunk/surrogate/src/org/apache/river/container/Injected.java&r1=1310153&r2=1327138&rev=1327138&view=diff ============================================================================== --- river/jtsk/skunk/surrogate/src/org/apache/river/container/Injected.java (original) +++ river/jtsk/skunk/surrogate/src/org/apache/river/container/Optional.java Tue Apr 17 15:17:52 2012 @@ -56,7 +56,7 @@ import java.lang.annotation.Target; @Documented @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD, ElementType.METHOD}) -public @interface Injected { +public @interface Optional { String value() default Strings.EMPTY; InjectionStyle style() default InjectionStyle.DEFAULT; } Modified: river/jtsk/skunk/surrogate/src/org/apache/river/container/Strings.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/Strings.java?rev=1327138&r1=1327137&r2=1327138&view=diff ============================================================================== --- river/jtsk/skunk/surrogate/src/org/apache/river/container/Strings.java (original) +++ river/jtsk/skunk/surrogate/src/org/apache/river/container/Strings.java Tue Apr 17 15:17:52 2012 @@ -35,6 +35,7 @@ public class Strings { CONTEXT_CLASS = "org.apache.river.container.Context", DASH = "-", DEFAULT = "default", + DEFAULT_DEPLOY_DIRECTORY="deploy", DEFAULT_DISCOVERY_CONTEXT = "defaultDiscoveryContext", DOT=".", DOT_CLASS=".class", @@ -65,7 +66,7 @@ public class Strings { START_CLASS="startClass", START_PARAMETERS="startParameters", START_PROPERTIES="start.properties", - STARTER_SERVICE_DEPLOYER_PROPERTIES="service-starter.properties", + STARTER_SERVICE_DEPLOYER_CONFIG="service-starter.cfg", SYSTEM_CLASS_LOADER="systemClassLoader", TYPE="type", UNKNOWN="unknown", Modified: river/jtsk/skunk/surrogate/src/org/apache/river/container/SurrogateInstaller.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/SurrogateInstaller.java?rev=1327138&r1=1327137&r2=1327138&view=diff ============================================================================== --- river/jtsk/skunk/surrogate/src/org/apache/river/container/SurrogateInstaller.java (original) +++ river/jtsk/skunk/surrogate/src/org/apache/river/container/SurrogateInstaller.java Tue Apr 17 15:17:52 2012 @@ -18,6 +18,7 @@ package org.apache.river.container; +import org.apache.river.container.deployer.ApplicationEnvironment; import java.io.File; /** Modified: river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/ClasspathFilter.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/ClasspathFilter.java?rev=1327138&r1=1327137&r2=1327138&view=diff ============================================================================== --- river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/ClasspathFilter.java (original) +++ river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/ClasspathFilter.java Tue Apr 17 15:17:52 2012 @@ -28,7 +28,7 @@ public class ClasspathFilter { private String jarName = null; - void setJarName(String s) { + public void setJarName(String s) { jarName = s; } Modified: river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/ClasspathFilterBuilder.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/ClasspathFilterBuilder.java?rev=1327138&r1=1327137&r2=1327138&view=diff ============================================================================== --- river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/ClasspathFilterBuilder.java (original) +++ river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/ClasspathFilterBuilder.java Tue Apr 17 15:17:52 2012 @@ -35,16 +35,8 @@ public class ClasspathFilterBuilder { public List<ClasspathFilter> parseToFilters(String input) { try { - Reader r = new StringReader(input); - ClasspathExpressionParser parser = new ClasspathExpressionParser(r); - parser.cpExpression(); - ASTcpExpression expression = (ASTcpExpression) parser.jjtree.popNode(); - List<ClasspathFilter> filters = new ArrayList<ClasspathFilter>(); - for (int i = 0; i < expression.jjtGetNumChildren(); i++) { - ASTcpClause clause = (ASTcpClause) expression.jjtGetChild(i); - ClasspathFilter cpf = makeFilter(clause); - filters.add(cpf); - } + ASTcpExpression expression = classpathExpressionFromString(input); + List<ClasspathFilter> filters = filtersFromClasspathExpression(expression); return filters; } catch (ParseException ex) { throw new LocalizedRuntimeException(MessageNames.BUNDLE_NAME, @@ -53,6 +45,24 @@ public class ClasspathFilterBuilder { } } + private ASTcpExpression classpathExpressionFromString(String input) throws ParseException { + Reader r = new StringReader(input); + ClasspathExpressionParser parser = new ClasspathExpressionParser(r); + parser.cpExpression(); + ASTcpExpression expression = (ASTcpExpression) parser.jjtree.popNode(); + return expression; + } + + private List<ClasspathFilter> filtersFromClasspathExpression(ASTcpExpression expression) { + List<ClasspathFilter> filters = new ArrayList<ClasspathFilter>(); + for (int i = 0; i < expression.jjtGetNumChildren(); i++) { + ASTcpClause clause = (ASTcpClause) expression.jjtGetChild(i); + ClasspathFilter cpf = makeFilter(clause); + filters.add(cpf); + } + return filters; + } + public ClasspathFilter makeFilter(ASTcpClause expression) { /* First node is the jar name. Subsequent nodes are the filter conditions. Modified: river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/VirtualFileSystemClassLoader.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/VirtualFileSystemClassLoader.java?rev=1327138&r1=1327137&r2=1327138&view=diff ============================================================================== --- river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/VirtualFileSystemClassLoader.java (original) +++ river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/VirtualFileSystemClassLoader.java Tue Apr 17 15:17:52 2012 @@ -90,18 +90,22 @@ public class VirtualFileSystemClassLoade Create a nested file system from it and add it to the file objects. */ List<ClasspathFilter> filters = new ClasspathFilterBuilder().parseToFilters(classPath); - for (ClasspathFilter filter : filters) { - FileObject entryObject = fileRoot.resolveFile(filter.getJarName()); - - FileObject entryFileSystem = - fileRoot.getFileSystem().getFileSystemManager().createFileSystem(entryObject); - classpathEntries.add(new ClasspathEntry(filter, entryFileSystem)); - } + addClasspathFilters(filters, fileRoot); } catch (FileSystemException ex) { throw new LocalizedRuntimeException(ex, MessageNames.BUNDLE_NAME, MessageNames.INVALID_CLASSPATH_ENTRY, classPath); } } + public void addClasspathFilters(List<ClasspathFilter> filters, FileObject fileRoot) throws FileSystemException { + for (ClasspathFilter filter : filters) { + FileObject entryObject = fileRoot.resolveFile(filter.getJarName()); + + FileObject entryFileSystem = + fileRoot.getFileSystem().getFileSystemManager().createFileSystem(entryObject); + classpathEntries.add(new ClasspathEntry(filter, entryFileSystem)); + } + } + /** Find a resource by searching through all the classpath entries that have been set up. Copied: river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/ASTNode.java (from r1310153, river/jtsk/skunk/surrogate/src/org/apache/river/container/security/ASTNode.java) URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/ASTNode.java?p2=river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/ASTNode.java&p1=river/jtsk/skunk/surrogate/src/org/apache/river/container/security/ASTNode.java&r1=1310153&r2=1327138&rev=1327138&view=diff ============================================================================== --- river/jtsk/skunk/surrogate/src/org/apache/river/container/security/ASTNode.java (original) +++ river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/ASTNode.java Tue Apr 17 15:17:52 2012 @@ -16,12 +16,11 @@ * limitations under the License. */ -package org.apache.river.container.security; +package org.apache.river.container.deployer; -import org.apache.river.container.security.PermissionFileParser; -import org.apache.river.container.security.PermissionFileParserTreeConstants; -import org.apache.river.container.security.SimpleNode; -import org.apache.river.container.security.Strings; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; /** * @@ -44,19 +43,19 @@ public class ASTNode extends SimpleNode super(i); } - public ASTNode(PermissionFileParser p, int i) { + public ASTNode(DeployerConfigParser p, int i) { super(p, i); } public String getName() { - return PermissionFileParserTreeConstants.jjtNodeName[id]; + return DeployerConfigParserTreeConstants.jjtNodeName[id]; } public String toString() { - if (id==PermissionFileParserTreeConstants.JJTSYMBOL) { + if (id==DeployerConfigParserTreeConstants.JJTSYMBOL) { return getValue().toString(); } - if (id==PermissionFileParserTreeConstants.JJTLITERAL) { + if (id==DeployerConfigParserTreeConstants.JJTLITERAL) { Object o=getValue(); if (o instanceof String) { return "\"" + o.toString() + "\""; @@ -87,10 +86,33 @@ public class ASTNode extends SimpleNode sb.append(childStr); sb.append(Strings.RPAREN); } else { - sb.append(jjtGetChild(i).toString()); + sb.append(childStr); } } } return sb.toString(); } + + public List<ASTNode> search(Class[] path) { + List<ASTNode> matches=new ArrayList<ASTNode>(); + search(path, matches); + return matches; + } + + public void search(Class[] path, List<ASTNode> matches) { + if (path.length==0) { + return; + } + if (!this.getClass().equals(path[0])){ + return; + } + if (path.length==1) { + matches.add(this); + return; + } + path=Arrays.copyOfRange(path, 1, path.length); + for (int i=0; i < this.jjtGetNumChildren(); i++) { + ((ASTNode) jjtGetChild(i)).search(path, matches); + } + } } Copied: river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/ApplicationEnvironment.java (from r1310153, river/jtsk/skunk/surrogate/src/org/apache/river/container/ApplicationEnvironment.java) URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/ApplicationEnvironment.java?p2=river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/ApplicationEnvironment.java&p1=river/jtsk/skunk/surrogate/src/org/apache/river/container/ApplicationEnvironment.java&r1=1310153&r2=1327138&rev=1327138&view=diff ============================================================================== --- river/jtsk/skunk/surrogate/src/org/apache/river/container/ApplicationEnvironment.java (original) +++ river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/ApplicationEnvironment.java Tue Apr 17 15:17:52 2012 @@ -16,22 +16,52 @@ * limitations under the License. */ -package org.apache.river.container; +package org.apache.river.container.deployer; + +import org.apache.commons.vfs.FileObject; +import org.apache.river.container.classloading.VirtualFileSystemClassLoader; +import org.apache.river.container.codebase.CodebaseContext; /** * Everything the host needs to know about the surrogate. * @author trasukg */ public class ApplicationEnvironment { + VirtualFileSystemClassLoader classLoader=null; - SettableCodebaseClassLoader classLoader=null; + FileObject serviceArchive=null; + FileObject serviceRoot=null; + CodebaseContext codebaseContext=null; - public SettableCodebaseClassLoader getClassLoader() { + public VirtualFileSystemClassLoader getClassLoader() { return classLoader; } - public void setClassLoader(SettableCodebaseClassLoader classLoader) { + public void setClassLoader(VirtualFileSystemClassLoader classLoader) { this.classLoader = classLoader; } + public FileObject getServiceArchive() { + return serviceArchive; + } + + public void setServiceArchive(FileObject serviceArchive) { + this.serviceArchive = serviceArchive; + } + + public FileObject getServiceRoot() { + return serviceRoot; + } + + public void setServiceRoot(FileObject serviceRoot) { + this.serviceRoot = serviceRoot; + } + + public CodebaseContext getCodebaseContext() { + return codebaseContext; + } + + public void setCodebaseContext(CodebaseContext codebaseContext) { + this.codebaseContext = codebaseContext; + } } Copied: river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/ClasspathFilterBuilder.java (from r1310153, river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/ClasspathFilterBuilder.java) URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/ClasspathFilterBuilder.java?p2=river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/ClasspathFilterBuilder.java&p1=river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/ClasspathFilterBuilder.java&r1=1310153&r2=1327138&rev=1327138&view=diff ============================================================================== --- river/jtsk/skunk/surrogate/src/org/apache/river/container/classloading/ClasspathFilterBuilder.java (original) +++ river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/ClasspathFilterBuilder.java Tue Apr 17 15:17:52 2012 @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.river.container.classloading; +package org.apache.river.container.deployer; import java.io.Reader; import java.io.StringReader; @@ -24,6 +24,11 @@ import java.util.List; import java.util.logging.Logger; import org.apache.river.container.LocalizedRuntimeException; import org.apache.river.container.MessageNames; +import org.apache.river.container.classloading.Acceptor; +import org.apache.river.container.classloading.AllAcceptor; +import org.apache.river.container.classloading.ClasspathFilter; +import org.apache.river.container.classloading.ResourceAcceptor; +import org.apache.river.container.classloading.VirtualFileSystemClassLoader; /** * @@ -33,18 +38,10 @@ public class ClasspathFilterBuilder { private static final Logger log = Logger.getLogger(ClasspathFilterBuilder.class.getName()); - public List<ClasspathFilter> parseToFilters(String input) { + public static List<ClasspathFilter> parseToFilters(String input) { try { - Reader r = new StringReader(input); - ClasspathExpressionParser parser = new ClasspathExpressionParser(r); - parser.cpExpression(); - ASTcpExpression expression = (ASTcpExpression) parser.jjtree.popNode(); - List<ClasspathFilter> filters = new ArrayList<ClasspathFilter>(); - for (int i = 0; i < expression.jjtGetNumChildren(); i++) { - ASTcpClause clause = (ASTcpClause) expression.jjtGetChild(i); - ClasspathFilter cpf = makeFilter(clause); - filters.add(cpf); - } + ASTclasspath expression = classpathExpressionFromString(input); + List<ClasspathFilter> filters = filtersFromClasspathExpression(expression); return filters; } catch (ParseException ex) { throw new LocalizedRuntimeException(MessageNames.BUNDLE_NAME, @@ -53,7 +50,25 @@ public class ClasspathFilterBuilder { } } - public ClasspathFilter makeFilter(ASTcpClause expression) { + private static ASTclasspath classpathExpressionFromString(String input) throws ParseException { + Reader r = new StringReader(input); + DeployerConfigParser parser = new DeployerConfigParser(r); + parser.classpath(); + ASTclasspath expression = (ASTclasspath) parser.jjtree.popNode(); + return expression; + } + + public static List<ClasspathFilter> filtersFromClasspathExpression(ASTclasspath expression) { + List<ClasspathFilter> filters = new ArrayList<ClasspathFilter>(); + for (int i = 0; i < expression.jjtGetNumChildren(); i++) { + ASTcpEntry clause = (ASTcpEntry) expression.jjtGetChild(i); + ClasspathFilter cpf = makeFilter(clause); + filters.add(cpf); + } + return filters; + } + + public static ClasspathFilter makeFilter(ASTcpEntry expression) { /* First node is the jar name. Subsequent nodes are the filter conditions. */ @@ -67,7 +82,7 @@ public class ClasspathFilterBuilder { Acceptor acc = new ResourceAcceptor(resourceName); cpf.getAcceptors().add(acc); } - if (node instanceof ASTstringLiteral) { + if (node instanceof ASTliteral) { log.fine("Building ResourceAcceptor with string '" + node.toString() + "'"); Acceptor acc = new ResourceAcceptor(node.toString()); cpf.getAcceptors().add(acc); Copied: river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/DeployerConfigParser.jjt (from r1310153, river/jtsk/skunk/surrogate/src/org/apache/river/container/security/PermissionFileParser.jjt) URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/DeployerConfigParser.jjt?p2=river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/DeployerConfigParser.jjt&p1=river/jtsk/skunk/surrogate/src/org/apache/river/container/security/PermissionFileParser.jjt&r1=1310153&r2=1327138&rev=1327138&view=diff ============================================================================== --- river/jtsk/skunk/surrogate/src/org/apache/river/container/security/PermissionFileParser.jjt (original) +++ river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/DeployerConfigParser.jjt Tue Apr 17 15:17:52 2012 @@ -23,9 +23,9 @@ options { NODE_CLASS= "ASTNode"; } -PARSER_BEGIN(PermissionFileParser) +PARSER_BEGIN(DeployerConfigParser) -package org.apache.river.container.security; +package org.apache.river.container.deployer; import java.io.InputStream; import java.io.Reader; @@ -36,20 +36,20 @@ import java.util.List; import java.util.logging.Logger; -public class PermissionFileParser { +public class DeployerConfigParser { private static final Logger log= - Logger.getLogger(PermissionFileParser.class.getName()); + Logger.getLogger(DeployerConfigParser.class.getName()); - public static ASTgrants parseGrants(InputStream in) + public static ASTconfig parseConfig(InputStream in) throws ParseException { Reader r=new InputStreamReader(in); - PermissionFileParser parser=new PermissionFileParser(r); - parser.grants(); - return (ASTgrants) parser.jjtree.popNode(); + DeployerConfigParser parser=new DeployerConfigParser(r); + parser.config(); + return (ASTconfig) parser.jjtree.popNode(); } } -PARSER_END(PermissionFileParser) +PARSER_END(DeployerConfigParser) /* WHITE SPACE */ @@ -76,13 +76,19 @@ TOKEN : | < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ > | < LONG_LITERAL: ["0"-"9"] (["0"-"9"])* (["l", "L"]) > | < GRANT: "grant" > +| < CLASSLOADER: "classloader"> +| < CODEBASE: "codebase"> +| < CONFIGURATION: "configuration"> +| < JARS: "jars"> +| < PARENT: "parent"> | < AND: "and" > | < OR: "or" > | < NOT: "not" > | < TRUE: "true" > | < FALSE: "false" > | < SYMBOL: - ["A"-"Z", "a"-"z", "_"] (["0"-"9", "A"-"Z", "a"-"z", ".", "_"])*> + ["A"-"Z", "a"-"z", "_"] + (["0"-"9", "A"-"Z", "a"-"z", ".", "_", "-", "$"])*> | < STRING_LITERAL: ("\"" ( (~["\"","\\","\n","\r"]) @@ -123,15 +129,20 @@ TOKEN : | < GTE: ">=" > | < NEQ: "<>" > | < COMMA: "," > +| < LBRACE: "{" > +| < RBRACE: "}" > +| < LPAREN: "(" > +| < RPAREN: ")" > +| < SEMICOLON: ";"> } -void grants() #grants: +void config() #config: { - log.fine("grants()"); + log.fine("config()"); } { - (grant())* + (grant() | classloader() | configuration())* } void grant() #grant: @@ -142,12 +153,92 @@ void grant() #grant: <GRANT> "{" (permission())* "}" } -void permission() : +void permission() #permission: { log.fine("permission()"); } { - symbol() [literal()]";" + symbol() [literal() [literal()]]";" +} + +void classloader() #classloader: +{ + log.fine("classloader()"); +} +{ + <CLASSLOADER> <LBRACE> parent() [jars()] [codebase()] <RBRACE> +} + +void jars() #jars: +{ + log.fine("jars()"); +} +{ + <JARS> <LBRACE> classpath() <RBRACE> +} + +void parent() #parent: +{ + log.fine("parent()"); +} +{ + <PARENT> symbol() <SEMICOLON> +} + +void codebase() #codebase: +{ + log.fine("codebase()"); +} +{ + <CODEBASE> <LBRACE> symbol() (<COMMA> symbol())* <RBRACE> +} + +void configuration() #configuration: +{ + log.fine("configuration()"); +} +{ + <CONFIGURATION> <LBRACE> (configEntry())* <RBRACE> +} + +void classpath() #classpath: +{ + log.fine("classpath()"); +} +{ + cpEntry() (<COMMA> cpEntry() )* +} + +void cpEntry() #cpEntry: +{ + log.fine("cpEntry()"); +} +{ + symbol() [ <LPAREN> filterExpression() <RPAREN>] +} + +void filterExpression(): +{ + log.finest("filterExpression()"); +} +{ + filterClause() ( <COMMA> filterClause())* +} + +void filterClause(): +{ + log.finest("filterClause()"); +} +{ + symbol() | literal() +} + +void configEntry() #configEntry: +{ + log.fine("configEntry()"); +} +{ + symbol() <EQUALS> symbol() <SEMICOLON> } void primary() : @@ -205,7 +296,6 @@ void symbol() #symbol: } } - void expression() : { log.fine("expression()"); Copied: river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/StarterServiceDeployer.java (from r1310153, river/jtsk/skunk/surrogate/src/org/apache/river/container/StarterServiceDeployer.java) URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/StarterServiceDeployer.java?p2=river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/StarterServiceDeployer.java&p1=river/jtsk/skunk/surrogate/src/org/apache/river/container/StarterServiceDeployer.java&r1=1310153&r2=1327138&rev=1327138&view=diff ============================================================================== --- river/jtsk/skunk/surrogate/src/org/apache/river/container/StarterServiceDeployer.java (original) +++ river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/StarterServiceDeployer.java Tue Apr 17 15:17:52 2012 @@ -19,20 +19,21 @@ /* TODO: - Complete deployment of items that are in the deployment directory. */ -package org.apache.river.container; +package org.apache.river.container.deployer; import java.io.File; import java.io.FilePermission; import java.io.IOException; +import java.io.InputStream; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URL; -import java.security.AllPermission; import java.security.CodeSource; import java.security.Permission; import java.security.Principal; import java.security.cert.Certificate; +import java.util.ArrayList; import java.util.List; import java.util.Properties; import java.util.logging.Level; @@ -41,6 +42,19 @@ import net.jini.security.policy.DynamicP import org.apache.commons.vfs.FileObject; import org.apache.commons.vfs.FileSystemException; import org.apache.commons.vfs.FileType; +import org.apache.river.container.ConfigurationException; +import org.apache.river.container.Context; +import org.apache.river.container.FileUtility; +import org.apache.river.container.Init; +import org.apache.river.container.Injected; +import org.apache.river.container.InjectionStyle; +import org.apache.river.container.LocalizedRuntimeException; +import org.apache.river.container.MessageNames; +import org.apache.river.container.Name; +import org.apache.river.container.PropertiesFileReader; +import org.apache.river.container.Strings; +import org.apache.river.container.Utils; +import org.apache.river.container.classloading.ClasspathFilter; import org.apache.river.container.classloading.VirtualFileSystemClassLoader; import org.apache.river.container.codebase.CodebaseContext; import org.apache.river.container.codebase.CodebaseHandler; @@ -55,21 +69,43 @@ import org.apache.river.container.work.W */ public class StarterServiceDeployer { - private int initCount = 0; private static final Logger log = Logger.getLogger(StarterServiceDeployer.class.getName(), MessageNames.BUNDLE_NAME); @Injected(style = InjectionStyle.BY_TYPE) private FileUtility fileUtility = null; - @Injected - private ClassLoader systemClassLoader = null; + + @Injected(style=InjectionStyle.BY_TYPE) + private Context context; + @Name private String myName = null; @Injected(style = InjectionStyle.BY_TYPE) private CodebaseHandler codebaseHandler = null; - @Injected - private String deploymentDirectory = null; - @Injected(Strings.STARTER_SERVICE_DEPLOYER_PROPERTIES) - Properties configProperties = null; + + private String deployDirectory = Strings.DEFAULT_DEPLOY_DIRECTORY; + + private String config = Strings.STARTER_SERVICE_DEPLOYER_CONFIG; + private ASTconfig configNode=null; + + private List<ApplicationEnvironment> applicationEnvironments= + new ArrayList<ApplicationEnvironment>(); + + public String getDeployDirectory() { + return deployDirectory; + } + + public void setDeployDirectory(String deployDirectory) { + this.deployDirectory = deployDirectory; + } + + public String getConfig() { + return config; + } + + public void setConfig(String config) { + this.config = config; + } + private FileObject deploymentDirectoryFile = null; @Injected(style = InjectionStyle.BY_TYPE) private PropertiesFileReader propertiesFileReader = null; @@ -79,19 +115,18 @@ public class StarterServiceDeployer { private WorkManager workManager = null; @Injected(style = InjectionStyle.BY_TYPE) private DynamicPolicyProvider securityPolicy = null; - - ; public void addPlatformCodebaseJars(CodebaseContext codebaseContext) throws IOException { /* Register the platform codebase jars with the codebase service. - */ + String platformCodebaseSpec = configProperties.getProperty(Strings.PLATFORM_CODEBASE); String[] codebaseJars = Utils.splitOnWhitespace(platformCodebaseSpec); for (String codebaseJar : codebaseJars) { FileObject fo = fileUtility.getLibDirectory().resolveFile(codebaseJar); codebaseContext.addFile(fo); } + */ } public String[] constructArgs(String argLine) { @@ -106,15 +141,23 @@ public class StarterServiceDeployer { public VirtualFileSystemClassLoader createServiceClassloader(FileObject serviceRoot, CodeSource codeSource) throws IOException, FileSystemException { + String parentLoaderName=((ASTparent) configNode.search( + new Class[]{ ASTconfig.class, ASTclassloader.class, ASTparent.class})).getValue().toString(); + log.log(Level.FINE, MessageNames.SERVICE_PARENT_CLASSLOADER_IS, parentLoaderName); + ClassLoader parentLoader= (ClassLoader) context.get(parentLoaderName); VirtualFileSystemClassLoader cl = - createChildOfSystemClassloader(codeSource); + createChildOfGivenClassloader(parentLoader, codeSource); /* Include platform jars from the container's lib directory. - */ - String platformJarSpec = configProperties.getProperty(Strings.PLATFORM_JARS); + */ + ASTclasspath platformJarSpec = (ASTclasspath) + configNode.search(new Class[]{ASTconfig.class, + ASTclassloader.class, ASTjars.class, ASTclasspath.class}); addPlatformJarsToClassloader(platformJarSpec, cl); addLibDirectoryJarsToClasspath(serviceRoot, cl); + return cl; + } protected void addLibDirectoryJarsToClasspath(FileObject serviceRoot, VirtualFileSystemClassLoader cl) throws FileSystemException { @@ -129,23 +172,19 @@ public class StarterServiceDeployer { } } - protected void addPlatformJarsToClassloader(String platformJarSpec, VirtualFileSystemClassLoader cl) throws IOException, LocalizedRuntimeException { - if (platformJarSpec == null) { - throw new LocalizedRuntimeException(MessageNames.BUNDLE_NAME, - MessageNames.MISSING_PROPERTY_ENTRY, - new Object[]{Strings.STARTER_SERVICE_DEPLOYER_PROPERTIES, - Strings.PLATFORM_JARS}); - } - log.log(Level.FINE, MessageNames.ADDING_CLASSPATH_ENTRY, new Object[]{platformJarSpec}); - cl.addClassPathEntry(fileUtility.getLibDirectory(), platformJarSpec); + protected void addPlatformJarsToClassloader(ASTclasspath platformJarSpec, VirtualFileSystemClassLoader cl) throws IOException, LocalizedRuntimeException { + log.log(Level.FINE, MessageNames.ADDING_CLASSPATH_ENTRY, new Object[]{platformJarSpec.toString()}); + List<ClasspathFilter> filters=ClasspathFilterBuilder.filtersFromClasspathExpression(platformJarSpec); + + cl.addClasspathFilters(filters,fileUtility.getLibDirectory()); } - protected VirtualFileSystemClassLoader createChildOfSystemClassloader(CodeSource codeSource) { + protected VirtualFileSystemClassLoader createChildOfGivenClassloader(ClassLoader parent, CodeSource codeSource) { /* Create the service classloader. */ VirtualFileSystemClassLoader cl = - new VirtualFileSystemClassLoader(null, systemClassLoader, codeSource); + new VirtualFileSystemClassLoader(null, parent, codeSource); return cl; } @@ -164,8 +203,6 @@ public class StarterServiceDeployer { @Init public void init() { try { - initCount++; - log.info("Init count is " + initCount); tryInitialize(); } catch (Throwable ex) { log.log(Level.SEVERE, MessageNames.STARTER_SERVICE_DEPLOYER_FAILED_INIT, @@ -241,21 +278,23 @@ public class StarterServiceDeployer { } } - private void tryInitialize() throws IOException { + private void tryInitialize() throws IOException, ParseException { log.log(Level.FINE, MessageNames.STARTER_SERVICE_DEPLOYER_STARTING, myName); /* Establish the deployment directory. */ - deploymentDirectoryFile = fileUtility.getProfileDirectory().resolveFile(deploymentDirectory); + deploymentDirectoryFile = fileUtility.getProfileDirectory().resolveFile(deployDirectory); if (deploymentDirectoryFile == null || deploymentDirectoryFile.getType() != FileType.FOLDER) { log.log(Level.WARNING, MessageNames.NO_DEPLOYMENT_DIRECTORY, - new Object[]{deploymentDirectory, fileUtility.getProfileDirectory()}); + new Object[]{deployDirectory, fileUtility.getProfileDirectory()}); } - /* - Read the maximal policy file if there is one. - */ - readMaximalPolicy(); + /* Read and parse the configuration file. */ + + FileObject configFile=fileUtility.getProfileDirectory().resolveFile(config); + InputStream in=configFile.getContent().getInputStream(); + configNode=DeployerConfigParser.parseConfig(in); + /* Go through the deployment directory looking for services to deploy. */ @@ -264,11 +303,11 @@ public class StarterServiceDeployer { Strings.SSAR); if (serviceArchives != null) { log.log(Level.FINE, MessageNames.FOUND_SERVICE_ARCHIVES, - new Object[]{serviceArchives.size(), deploymentDirectory}); + new Object[]{serviceArchives.size(), deployDirectory}); deployServiceArchives(serviceArchives); } else { log.log(Level.WARNING, MessageNames.FOUND_NO_SERVICE_ARCHIVES, - new Object[]{deploymentDirectory}); + new Object[]{deployDirectory}); } @@ -292,9 +331,15 @@ public class StarterServiceDeployer { } private void deployServiceArchive(FileObject serviceArchive) throws IOException { - FileObject serviceRoot = - serviceArchive.getFileSystem().getFileSystemManager().createFileSystem(Strings.JAR, serviceArchive); - deployService(serviceArchive, serviceRoot); + // Create an application environment + ApplicationEnvironment env=new ApplicationEnvironment(); + env.setServiceArchive(serviceArchive); + env.setServiceRoot( + serviceArchive.getFileSystem().getFileSystemManager().createFileSystem(Strings.JAR, serviceArchive)); + // Store it in our list of environments. + applicationEnvironments.add(env); + // Deploy it. + deployService(env); } private String findServiceName(FileObject serviceArchive, FileObject serviceRoot) { @@ -311,21 +356,22 @@ public class StarterServiceDeployer { return serviceRoot.getURL(); } - private void deployService(FileObject serviceArchive, FileObject serviceRoot) throws IOException { - String serviceName = findServiceName(serviceArchive, serviceRoot); + private void deployService(ApplicationEnvironment env) throws IOException { + String serviceName = findServiceName(env.getServiceArchive(), env.getServiceRoot()); CodeSource serviceCodeSource = - new CodeSource(findServiceURL(serviceArchive, serviceRoot), + new CodeSource(findServiceURL(env.getServiceArchive(), env.getServiceRoot()), new Certificate[0]); log.log(Level.INFO, MessageNames.CODESOURCE_IS, new Object[]{serviceName, serviceCodeSource}); - VirtualFileSystemClassLoader cl = createServiceClassloader(serviceRoot, serviceCodeSource); + VirtualFileSystemClassLoader cl = createServiceClassloader(env.getServiceArchive(), serviceCodeSource); /* Create a codebase context. */ CodebaseContext codebaseContext = codebaseHandler.createContext(serviceName); + env.setCodebaseContext(codebaseContext); addPlatformCodebaseJars(codebaseContext); - exportServiceCodebaseJars(serviceRoot, codebaseContext); + exportServiceCodebaseJars(env.getServiceRoot(), codebaseContext); /* Setup the classloader's codebase annotation. @@ -337,8 +383,8 @@ public class StarterServiceDeployer { */ // TODO: Figure out how the protection domains, codesources, etc need to work. - setupLiaisonConfiguration(serviceArchive, serviceRoot, cl); - Properties startProps = readStartProperties(serviceRoot); + setupLiaisonConfiguration(env.getServiceArchive(), env.getServiceRoot(), cl); + Properties startProps = readStartProperties(env.getServiceRoot()); String argLine = startProps.getProperty(Strings.START_PARAMETERS); final String[] args = constructArgs(argLine); Copied: river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/Strings.java (from r1310153, river/jtsk/skunk/surrogate/src/org/apache/river/container/security/Strings.java) URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/Strings.java?p2=river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/Strings.java&p1=river/jtsk/skunk/surrogate/src/org/apache/river/container/security/Strings.java&r1=1310153&r2=1327138&rev=1327138&view=diff ============================================================================== --- river/jtsk/skunk/surrogate/src/org/apache/river/container/security/Strings.java (original) +++ river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/Strings.java Tue Apr 17 15:17:52 2012 @@ -16,7 +16,7 @@ * limitations under the License. */ -package org.apache.river.container.security; +package org.apache.river.container.deployer; /** * Copied: river/jtsk/skunk/surrogate/test/org/apache/river/container/deployer/DeployerConfigParserTest.java (from r1310153, river/jtsk/skunk/surrogate/test/org/apache/river/container/security/PermissionFileParserTest.java) URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/test/org/apache/river/container/deployer/DeployerConfigParserTest.java?p2=river/jtsk/skunk/surrogate/test/org/apache/river/container/deployer/DeployerConfigParserTest.java&p1=river/jtsk/skunk/surrogate/test/org/apache/river/container/security/PermissionFileParserTest.java&r1=1310153&r2=1327138&rev=1327138&view=diff ============================================================================== --- river/jtsk/skunk/surrogate/test/org/apache/river/container/security/PermissionFileParserTest.java (original) +++ river/jtsk/skunk/surrogate/test/org/apache/river/container/deployer/DeployerConfigParserTest.java Tue Apr 17 15:17:52 2012 @@ -15,8 +15,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.river.container.security; +package org.apache.river.container.deployer; +import java.util.List; +import java.util.logging.Logger; import java.io.InputStream; import org.junit.After; import org.junit.AfterClass; @@ -29,9 +31,9 @@ import static org.junit.Assert.*; * * @author trasukg */ -public class PermissionFileParserTest { - - public PermissionFileParserTest() { +public class DeployerConfigParserTest { + private static final Logger log=Logger.getLogger(DeployerConfigParserTest.class.getName()); + public DeployerConfigParserTest() { } @BeforeClass @@ -56,10 +58,54 @@ public class PermissionFileParserTest { run it through the parser without errors. */ public void testBasicParsing() throws ParseException { + ASTconfig config=parseTestConfig(); + log.fine("grants string is:" + config.toString()); + String expected="config (grant (permission java.io.FilePermission \"${serviceArchive}\" \"read\") " + + "(permission java.net.SocketPermission \"*\" \"connect\")) " + + "(classloader (parent systemClassLoader) " + + "(jars (classpath (cpEntry commons-vfs-1.0.jar) " + + "(cpEntry commons-logging-1.1.1.jar) (cpEntry jsk-platform.jar) " + + "(cpEntry jsk-lib.jar) (cpEntry jsk-resources.jar) " + + "(cpEntry RiverSurrogate.jar " + + "org.apache.river.container.liaison.Strings " + + "org.apache.river.container.liaison.VirtualFileSystemConfiguration " + + "org.apache.river.container.liaison.VirtualFileSystemConfiguration$MyConfigurationFile " + + "\"META-INF/services/*\"))) (codebase jsk-dl.jar)) (configuration " + + "(configEntry discoveryGroup defaultDiscoveryGroup))"; + assertEquals(expected, config.toString()); + } + + private ASTconfig parseTestConfig() throws ParseException { InputStream in= - PermissionFileParserTest.class.getResourceAsStream("sample.policy"); - assertTrue("No sample.policy file found!", in!=null); - ASTgrants grants=PermissionFileParser.parseGrants(in); - assertEquals("grants (grant java.security.AllPermission)", grants.toString()); + DeployerConfigParserTest.class.getResourceAsStream("sample.config"); + assertTrue("No sample.config file found!", in!=null); + ASTconfig config=DeployerConfigParser.parseConfig(in); + return config; + } + + /** + Matching the ASTConfig should return the root node. + @throws Exception + */ + @Test + public void testPathMatch() throws Exception { + ASTNode config=parseTestConfig(); + List<ASTNode> matches=config.search(new Class[]{ ASTconfig.class}); + assertEquals("Length of match list", 1, matches.size()); + assertEquals("matched node", config, matches.get(0)); + } + + /** + Matching the ASTConfig should return the root node. + @throws Exception + */ + @Test + public void testlongerPathMatch() throws Exception { + ASTNode config=parseTestConfig(); + List<ASTNode> matches=config.search( + new Class[]{ ASTconfig.class, ASTclassloader.class, + ASTjars.class}); + assertEquals("Length of match list", 1, matches.size()); + assertEquals("matched node class", ASTjars.class, matches.get(0).getClass()); } } \ No newline at end of file Copied: river/jtsk/skunk/surrogate/test/org/apache/river/container/deployer/sample.config (from r1310153, river/jtsk/skunk/surrogate/test/org/apache/river/container/security/sample.policy) URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/test/org/apache/river/container/deployer/sample.config?p2=river/jtsk/skunk/surrogate/test/org/apache/river/container/deployer/sample.config&p1=river/jtsk/skunk/surrogate/test/org/apache/river/container/security/sample.policy&r1=1310153&r2=1327138&rev=1327138&view=diff ============================================================================== --- river/jtsk/skunk/surrogate/test/org/apache/river/container/security/sample.policy (original) +++ river/jtsk/skunk/surrogate/test/org/apache/river/container/deployer/sample.config Tue Apr 17 15:17:52 2012 @@ -1,34 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Sample file that our policy file parser should be able to process. // Grants given to all applications. grant { - java.security.FilePermission "${serviceArchive}" "read"; -} - -// If the archive includes 'security.policy', grant the lesser of maximal -// and the requests in 'security.policy'. Decline to start the app if -// requested grants exceed the maximal grant below. -maximal grant { - java.security.AllPermission; + java.io.FilePermission "${serviceArchive}" "read"; + java.net.SocketPermission "*" "connect"; } classloader { // Variables required to set up the application classloader. //For a privileged application deployer, parent=containerClassLoader; - parent=systemClassLoader; + parent systemClassLoader; - platformJars= - commons-vfs-1.0.jar - commons-logging-1.1.1.jar - jsk-platform.jar - jsk-lib.jar - jsk-resources.jar + jars { + commons-vfs-1.0.jar, + commons-logging-1.1.1.jar, + jsk-platform.jar, + jsk-lib.jar, + jsk-resources.jar, RiverSurrogate.jar(org.apache.river.container.liaison.Strings, org.apache.river.container.liaison.VirtualFileSystemConfiguration, org.apache.river.container.liaison.VirtualFileSystemConfiguration$MyConfigurationFile, - "META-INF/services/*"); + "META-INF/services/*") + } - platformCodebase=jsk-dl.jar; + codebase {jsk-dl.jar} } configuration { Modified: river/jtsk/skunk/surrogate/test/org/apache/river/surrogate/SurrogateContextTest.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/test/org/apache/river/surrogate/SurrogateContextTest.java?rev=1327138&r1=1327137&r2=1327138&view=diff ============================================================================== --- river/jtsk/skunk/surrogate/test/org/apache/river/surrogate/SurrogateContextTest.java (original) +++ river/jtsk/skunk/surrogate/test/org/apache/river/surrogate/SurrogateContextTest.java Tue Apr 17 15:17:52 2012 @@ -19,7 +19,7 @@ package org.apache.river.surrogate; import java.io.File; -import org.apache.river.container.ApplicationEnvironment; +import org.apache.river.container.deployer.ApplicationEnvironment; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; Modified: river/jtsk/skunk/surrogate/testfiles/testroot/profile/default/config.xml URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/testfiles/testroot/profile/default/config.xml?rev=1327138&r1=1327137&r2=1327138&view=diff ============================================================================== --- river/jtsk/skunk/surrogate/testfiles/testroot/profile/default/config.xml (original) +++ river/jtsk/skunk/surrogate/testfiles/testroot/profile/default/config.xml Tue Apr 17 15:17:52 2012 @@ -39,14 +39,14 @@ <cfg:component class="org.apache.river.container.codebase.ClassServer"/> <!-- Deployer for 'service-starter'-style applications. --> - <cfg:component class="org.apache.river.container.StarterServiceDeployer"> - <property name="policy" value="service-starter.policy"/> + <cfg:component class="org.apache.river.container.deployer.StarterServiceDeployer"> + <property name="config" value="service-starter.cfg"/> <property name="deployDirectory" value="deploy"/> </cfg:component> <!-- Deployer for 'system apps' like the remote deployment service --> <cfg:component class="org.apache.river.container.StarterServiceDeployer"> - <property name="policy" value="privileged-services.policy"/> + <property name="config" value="privileged-services.config"/> <property name="deployDirectory" value="deploy-privileged"/> </cfg:component> <cfg:component class="org.apache.river.container.ShowContextToConsole"/>