📄 invokeserver.java
字号:
// 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: InvokeServer.java,v 1.37 2000/10/28 16:55:16 daniela Exp $package org.ozoneDB.core;import java.io.IOException;import java.net.Socket;import org.ozoneDB.DxLib.*;import org.ozoneDB.DxLib.net.*;import org.ozoneDB.*;import org.ozoneDB.core.DbRemote.*;import org.ozoneDB.util.*;/** * @author <a href="http://www.softwarebuero.de/">SMB</a> * @version $Revision: 1.37 $Date: 2000/10/28 16:55:16 $ */public class InvokeServer extends DxMultiServer { protected transient Env env; public InvokeServer( Env _env, int port ) throws IOException{ super( port ); env = _env; } public void startup() throws Exception { env.logWriter.newEntry( this, "startup...", LogWriter.INFO ); } public void shutdown() throws Exception { env.logWriter.newEntry( this, "shutdown...", LogWriter.INFO ); close(); } public void handleClientEvent( DxMultiServerClient client, Object event ) { env.logWriter.newEntry( this, "handleClientEvent()...", LogWriter.DEBUG3 ); try { DbCommand cmd = (DbCommand)event; cmd.env = env; if (cmd instanceof DbOpen) { DbOpen command = (DbOpen)cmd; User user = env.userManager.userForName( command.userName() ); if (user == null) { client.send( new PermissionDeniedExc( "No such user: " + command.userName() + "." ) ); } else { ((DbInvokeClient)client).user = user; ((CommandThread)Thread.currentThread()).setOwner( user ); env.logWriter.newEntry( this, "user logged in: " + command.userName(), LogWriter.INFO ); client.send( null ); } } else if (cmd instanceof DbCloseConn) { removeClient( client ); } else if (cmd instanceof DbReloadClasses) { env.classManager.flushCache(); // AbstractObjectContainer.flushMethodCache(); client.send( new Integer( 0 ) ); } else { User user = ((DbInvokeClient)client).user; env.transactionManager.handleCommand( cmd, user ); client.send( cmd.result ); } } catch (Exception e) { // FIXME: should this shutdown the connection? env.logWriter.newEntry( this, "handleClientEvent(): " + e, e, LogWriter.WARN ); } } public void handleClientException( DxMultiServerClient client, Exception e ) { env.logWriter.newEntry( this, "handleClientException(): " + e, e, LogWriter.WARN ); removeClient( client ); } public synchronized DxMultiServerClient newClient( Socket sock ) { try { DbInvokeClient dc = new DbInvokeClient( sock, this ); env.logWriter.newEntry( this, "connection established...", LogWriter.INFO ); return dc; } catch (Exception e) { env.logWriter.newEntry( this, "newClient(): ", e, LogWriter.WARN ); return null; } } public void removeClient( DxMultiServerClient client ) { env.logWriter.newEntry( this, "close connection...", LogWriter.DEBUG ); env.logWriter.newEntry( this, "close pending transaction...", LogWriter.DEBUG ); env.transactionManager.handleCommand( new DbCloseConn(), null ); super.removeClient( client ); String userName = ((DbInvokeClient)client).user != null ? ((DbInvokeClient)client).user.name() : "none"; env.logWriter.newEntry( this, "connection closed (user: " + userName + ")", LogWriter.INFO ); } public Thread newThread( Runnable run ) { Thread thread; if (run == acceptor) { thread = new Thread( threadGroup(), run ); thread.setPriority( Env.ACCEPT_THREAD_PRIORITY ); thread.setDaemon( true ); } else { thread = new CommandThread( threadGroup(), run ); thread.setPriority( Env.TRANSACTION_THREAD_PRIORITY ); thread.setDaemon( true ); } return thread; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -