avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-phoenix/src/script run.bat run.sh
Date Sat, 24 Feb 2001 04:59:35 GMT
donaldp     01/02/23 20:59:35

  Modified:    src/java/org/apache/phoenix/engine Main.java
               src/manifest loader-Manifest.mf
               src/script run.bat run.sh
  Added:       src/java/org/apache/phoenix/engine/loader PhoenixLoader.java
  Removed:     src/java/org/apache/phoenix/engine/loader AvalonLoader.java
  Log:
  Changed remaining avalon named things to phoenix named things
  
  Revision  Changes    Path
  1.3       +5 -5      jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine/Main.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Main.java	2001/02/24 04:41:32	1.2
  +++ Main.java	2001/02/24 04:59:35	1.3
  @@ -44,11 +44,11 @@
   public class Main
       extends AbstractMain
   {
  -    private static final String    AVALON_HOME          = 
  -        System.getProperty( "avalon.home", ".." );
  +    private static final String    PHOENIX_HOME         = 
  +        System.getProperty( "phoenix.home", ".." );
   
  -    private static final String    DEFAULT_LOG_FILE     = AVALON_HOME + "/logs/avalon.log";
  -    private static final String    DEFAULT_APPS_PATH    = AVALON_HOME + "/apps";
  +    private static final String    DEFAULT_LOG_FILE     = PHOENIX_HOME + "/logs/phoenix.log";
  +    private static final String    DEFAULT_APPS_PATH    = PHOENIX_HOME + "/apps";
   
       private static final String    DEFAULT_KERNEL_CLASS =
           "org.apache.phoenix.engine.DefaultServerKernel";
  @@ -210,7 +210,7 @@
           logTarget.setFormatter( formatter );
           
           LogKit.addLogTarget( m_logFile, logTarget );
  -        m_logger = LogKit.createLogger( LogKit.createCategory( "Avalon", Priority.DEBUG
), 
  +        m_logger = LogKit.createLogger( LogKit.createCategory( "Phoenix", Priority.DEBUG
), 
                                           new LogTarget[] { logTarget } );
           m_logger.info( "Loader started" );
           
  
  
  
  1.1                  jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine/loader/PhoenixLoader.java
  
  Index: PhoenixLoader.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  package org.apache.phoenix.engine.loader;
  
  import java.io.File;
  import java.lang.reflect.Method;
  import java.net.URL;
  import java.net.URLClassLoader;
  import java.security.AccessControlContext;
  import java.security.AccessController;
  import java.security.CodeSource;
  import java.security.PermissionCollection;
  import java.security.Permissions;
  import java.security.Policy;
  import java.security.PrivilegedActionException;
  import java.security.PrivilegedExceptionAction;
  import java.security.ProtectionDomain;
  import java.security.Security;
  import java.util.ArrayList;
  import java.util.Enumeration;
  import java.util.StringTokenizer;
  
  /**
   * PhoenixLoader is the class that bootstraps and installs the security manager.
   * It also a default policy that gives all code all permssions.
   *
   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
   */
  public final class PhoenixLoader
  {
      protected final static boolean         ENABLE_SECURITY_MANAGER =
          !Boolean.getBoolean("phoenix.insecure");
  
      protected final static String          RESTRICTED_PACKAGES = 
          System.getProperty( "phoenix.restricted.packages", 
                              Security.getProperty("package.access") );
  
      protected final static String          MAIN_JAR =
          System.getProperty( "phoenix.mainJar", "phoenix-engine.jar" );
  
      protected final static String          MAIN_CLASS =
          System.getProperty( "phoenix.mainClass", "org.apache.phoenix.engine.Main" );
  
      public final static void main( final String args[] )
          throws Exception
      {
          //setup restricted packages
          Security.setProperty( "phoenix.access", RESTRICTED_PACKAGES );
  
          //setup new Policy manager
          Policy.setPolicy( new FreeNEasyPolicy() );
  
          final File loaderDir = findLoaderDir();
          final String avalonHome = 
              loaderDir.getAbsoluteFile().getParentFile() + File.separator;
          System.setProperty( "phoenix.home", avalonHome );
  
          final File mainJar = new File( loaderDir, MAIN_JAR );
  
          //load main jar
          final URL archive = mainJar.toURL();
          final URLClassLoader classLoader = new URLClassLoader( new URL[] { archive } );
  
          runSystem( classLoader, args );
      }
  
      /**
       * load class and retrieve appropriate main method.
       */
      protected static void runSystem( final ClassLoader classLoader, final String[] args
)
      {
          try
          {
              final Class clazz = classLoader.loadClass( MAIN_CLASS );
              final Method method = clazz.getMethod( "main", new Class[] { args.getClass()
} );
  
              final Object instance = clazz.newInstance();
  
              // Set security manager unless it has been disabled by system property
              if( ENABLE_SECURITY_MANAGER )
              {
                  System.setSecurityManager( new SecurityManager() );
              }
  
              //kick the tires and light the fires....
              try
              {
                  final PrivilegedExceptionAction action = new PrivilegedExceptionAction()

                  {
                      public Object run() throws Exception
                      {        
                          method.invoke( instance, new Object[] { args } );
                          return null;
                      }
                  };
                  
                  AccessController.doPrivileged( action );
              } 
              catch( final PrivilegedActionException pae )
              {
                  // only "checked" exceptions will be "wrapped" in a PrivilegedActionException.
                  throw pae.getException();
              }
          }
          catch( final Exception throwable ) 
          {
              throwable.printStackTrace( System.err );
          }
      }
  
      /**
       *  Finds the avalon-loader.jar file in the classpath.
       */
      protected final static File findLoaderDir() 
          throws Exception
      {
          final String classpath = System.getProperty( "java.class.path" );
          final String pathSeparator = System.getProperty( "path.separator" );
          final StringTokenizer tokenizer = new StringTokenizer( classpath, pathSeparator
);
          
          while( tokenizer.hasMoreTokens() )
          {
              final String element = tokenizer.nextToken();
              
              if( element.endsWith( "phoenix-loader.jar" ) )
              {
                  File file = (new File( element )).getCanonicalFile();
                  file = file.getParentFile();
                  return file;                
              }
          }
          
          throw new Exception( "Unable to locate avalon-loader.jar in classpath" );
      }
  
      /**
       * Default polic class to give every code base all permssions. 
       * Will be replaced once the kernel loads.
       */
      private static class FreeNEasyPolicy
          extends Policy
      {
          public PermissionCollection getPermissions( final CodeSource codeSource )
          {
              final Permissions permissions = new Permissions();
              permissions.add( new java.security.AllPermission() );
              return permissions;
          }
  
          public void refresh() {}
      }
  }
  
  
  
  1.2       +1 -1      jakarta-avalon-phoenix/src/manifest/loader-Manifest.mf
  
  Index: loader-Manifest.mf
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/manifest/loader-Manifest.mf,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- loader-Manifest.mf	2001/02/24 04:32:36	1.1
  +++ loader-Manifest.mf	2001/02/24 04:59:35	1.2
  @@ -1,4 +1,4 @@
   Manifest-Version: 1.0
  -Main-Class: org.apache.phoenix.engine.loader.AvalonLoader
  +Main-Class: org.apache.phoenix.engine.loader.PhoenixLoader
   Created-By: Apache Avalon Project
   
  
  
  
  1.2       +1 -1      jakarta-avalon-phoenix/src/script/run.bat
  
  Index: run.bat
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/script/run.bat,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- run.bat	2001/02/24 04:20:41	1.1
  +++ run.bat	2001/02/24 04:59:35	1.2
  @@ -1,3 +1,3 @@
   @echo off
   
  -java %PHOENIX_JVM_OPTS% -jar avalon-loader.jar %1 %2 %3 %4 %5 %6 %7 %8 %9
  \ No newline at end of file
  +java %PHOENIX_JVM_OPTS% -jar phoenix-loader.jar %1 %2 %3 %4 %5 %6 %7 %8 %9
  \ No newline at end of file
  
  
  
  1.2       +1 -1      jakarta-avalon-phoenix/src/script/run.sh
  
  Index: run.sh
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/script/run.sh,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- run.sh	2001/02/24 04:20:41	1.1
  +++ run.sh	2001/02/24 04:59:35	1.2
  @@ -8,4 +8,4 @@
     exit 1
   fi
   
  -$JAVA_HOME/bin/java $PHOENIX_JVM_OPTS -jar avalon-loader.jar $*
  +$JAVA_HOME/bin/java $PHOENIX_JVM_OPTS -jar phoenix-loader.jar $*
  
  
  

Mime
View raw message