server.java

来自「主要考察的是资源池的设计和实现」· Java 代码 · 共 38 行

JAVA
38
字号
import ServerImpl.ServerConfigure;
import ServerImpl.*;

import org.omg.CORBA.ORB;
import org.omg.CORBA.Policy;
import org.omg.PortableServer.*;
public class Server {
    public static void main(String[] args) {
        // java Server RoundRobin 1000
        if(args.length!=0){
           if(args.length==2)
           {
               ServerConfigure.pooling=true;
               ServerConfigure.SetPooling(args[0],Integer.parseInt(args[1]));
               System.out.println(ServerConfigure.GetStrategyType()+"  "+ServerConfigure.GetPoolSize());
           }
           else{
               System.out.println("args error\n");
           }
        }
        try{  
            ORB orb=ORB.init(args,null) ;
            POA rootPOA=POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
            Policy[] policies={
                    rootPOA.create_lifespan_policy(LifespanPolicyValue.PERSISTENT)
            };
            POA myPOA=rootPOA.create_POA("BankPOA",rootPOA.the_POAManager(),policies);
            AccountManagerImpl servant =new AccountManagerImpl();
            myPOA.activate_object_with_id("BankManager".getBytes(),servant);
            rootPOA.the_POAManager().activate();
            System.out.println("Server launch\n");
            orb.run();
        }catch(Exception e){
            e.printStackTrace();         
        }
    }
}

⌨️ 快捷键说明

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