⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 env.java

📁 用Java写的面相对象的数据库管理系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// You can redistribute this software and/or modify it under the terms of// the Ozone Core License version 1 published by ozone-db.org.//// The original code and portions created by SMB are// Copyright (C) 1997-2000 by SMB GmbH. All rights reserved.//// $Id: Env.java,v 1.70 2000/11/03 13:57:18 daniela Exp $package org.ozoneDB.core;import java.io.*;import java.util.*;import org.ozoneDB.DxLib.*;import org.ozoneDB.*;import org.ozoneDB.core.DbRemote.*;import org.ozoneDB.core.dr.*;import org.ozoneDB.util.*;/** * Env is the environment of a ozone database server. Currently there * is only one environment allowed per JVM. A server environment can be * initialized by the a Server or by a LocalDatabase. *  *  * @author <a href="http://www.softwarebuero.de/">SMB</a> * @version $Revision: 1.70 $Date: 2000/11/03 13:57:18 $ */public final class Env implements Observer {        // constant members ***********************************    public final static String VERSION = "0.6";    public final static String OS_DIR = "ostab";    public final static String STATE_FILE = "state.properties";    public final static String CONFIG_FILE = "config.properties";    public final static String LOG_FILE = "log";    public final static String DATA_DIR = "data" + File.separator;    public final static String STATS_DIR = "stats";        /**     * AdminPort and InvokeServer accepts and admin requests     */    public final static int ACCEPT_THREAD_PRIORITY = Thread.NORM_PRIORITY + 2;        /**     * Thread priority of normal transaction.     */    public final static int TRANSACTION_THREAD_PRIORITY = Thread.NORM_PRIORITY;        public final static int TRANSACTION_MUTEX_PRIORITY = TRANSACTION_THREAD_PRIORITY + 1;        /**     * Thread priority deadlock recognition.     */    public final static int DEADLOCK_THREAD_PRIORITY = Thread.NORM_PRIORITY;        /**     * Priority of the server thread (Server.main())     */    public final static int SERVER_THREAD_PRIORITY = Thread.NORM_PRIORITY + 2;            // class members **************************************        /**     * The one and only ozone environment of this VM.     */    public static Env theEnv;        protected static OzoneSecurityManager securityManager;            // instance members ***********************************        public String dir;        /**     * Holds the content of the 'state.properties' file. After     * changing the content the state must be written to disk to make     * changes persistent.     */    public Setup state;        /**     * Holds the content of the 'config.properties' config file.     */    public Setup config;        public LogWriter logWriter = new LogWriter();        /**     * This indicates that we are about to shutdown.     */    public boolean shuttingdown = false;        protected long idCount = 0;    protected long idBorder = 0;    protected long idRange = 1000;        protected long totalMemory;        /**     * Interface for the database objects inside the server.     */    public Database database;        public ClassManager classManager;        public TransactionManager transactionManager;        public Store store;        public UserManager userManager;        protected InvokeServer invokeServer;        protected AdminPort adminPort;        protected DeadlockThread deadlockThread;        protected DeadlockRecognition dr;            // class methods **************************************        /**     * Returns the environment of the current thread. Useful for objects that     * do not store the enviroment itself like ObjectContainer.     *      *      * @return The environment of the current thread or null if called outside     * the server.     */    public static Env currentEnv() {        return theEnv;    }             // instance methods ***********************************        /**     * Construct a new ozone server environment.     *      *      * @param _dirName Directory of the database.     * @param _local     */    public Env( String _dirName, int _debugLevel, boolean _verbose, boolean _local ) throws Exception{                if (theEnv != null) {            throw new Exception( "ozone environment (Env) already initialized for this VM" );        }                 try {            // give the engine its environment first but don't forget to            // reset it if we catch an exception            theEnv = this;                        dir = new String( _dirName ) + File.separator;            if (!new File( dir ).isDirectory()) {                throw new Exception( "No database found at '" + dir + "'." );            }                         initSetup();            initLogs( _local, _debugLevel );                        logWriter.newEntry( this, "Copyright (C) 1997-2000 The Ozone Database Project", LogWriter.INFO );            logWriter.newEntry( this, "contains libraries from the Apache Software Foundation", LogWriter.INFO );            logWriter.newEntry( this, "contains libraries from SUN microsystems", LogWriter.INFO );            logWriter.newEntry( this, "contains libraries from the W3C", LogWriter.INFO );            logWriter.newEntry( this, "contains libraries from Exoffice, Inc.", LogWriter.INFO );            logWriter.newEntry( this, "contains libraries (JavaClass) from Markus Dahm ", LogWriter.INFO );            logWriter.newEntry( this, "Copyright (C) under owner's respective terms.", LogWriter.INFO );                        if (System.getSecurityManager() == null) {                securityManager = new OzoneSecurityManager();                System.setSecurityManager( securityManager );            }                         calcMemory();                        database = new Database( this );                        classManager = new ClassManager( this );            classManager.startup();                        // UserManager has to be initialized before the recovery            userManager = new UserManager( this );            userManager.startup();                        transactionManager = new TransactionManager( this );            transactionManager.startup();                        // initialize the store            String storeClassName = config.stringProperty( Setup.STORE, "org.ozoneDB.core.wizardStore.WizardStore" );            Class storeClass = Class.forName( storeClassName );            if (storeClass == null) {                logWriter.newEntry( this, "Store not found: " + storeClassName, LogWriter.ERROR );                System.exit( 1 );            }             store = (Store)storeClass.newInstance();            store.init( this );            store.startup();        } catch (Exception e) {            theEnv = null;            if (logWriter != null) {                logWriter.newEntry( this, "Unable to initialize server.", e, LogWriter.ERROR );            } else {                System.out.println( "Unable to initialize server." );                e.printStackTrace();            }             throw e;        }     }            public void startExternalEventProcessing() throws Exception {        try {            invokeServer = new InvokeServer( this, portNum() );            invokeServer.startup();            invokeServer.accept();                        adminPort = new AdminPort( this, adminPortNum() );            adminPort.startup();                        logWriter.newEntry( this, "external event processing started", LogWriter.INFO );        } catch (Exception e) {            logWriter.newEntry( this,                    "Client port (" + portNum() + ") or admin port (" + adminPortNum() + ") are already in use.", e,                    LogWriter.ERROR );            throw e;        }     }             public void startDeadlockRecognition() {        logWriter.newEntry( this, "deadlock recognition started", LogWriter.INFO );        deadlockThread = new DeadlockThread( 3000, transactionManager );        deadlockThread.setPriority( DEADLOCK_THREAD_PRIORITY );        deadlockThread.setDaemon( true );        deadlockThread.start();    }             /**     * Initialize the setup (state and config) of this server environment. When     * searching specific property look in setup file first, then in the     * properties file, then use defaults, then use System properties.     */    protected void initSetup() throws Exception {        Setup defaults = new Setup( this );        defaults.fillWithOzoneDefaults();                FileInputStream configIn = new FileInputStream( new File( dir, CONFIG_FILE ) );        FileInputStream stateIn = new FileInputStream( new File( dir, STATE_FILE ) );        try {            config = new Setup( this, defaults );            config.load( configIn );            config.addProperties( System.getProperties(), "ozoneDB." );            config.print( System.out, "ozoneDB.", "    " );                        state = new Setup( this );            state.load( stateIn );        } finally {            configIn.close();            stateIn.close();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -