poaorb.java
来自「java jdk 1.4的源码」· Java 代码 · 共 988 行 · 第 1/3 页
JAVA
988 行
if (port == -1) { throw new Exception("ORBD must support IIOP_CLEAR_TEXT"); } } ep.setLocatorPort(port); } orbdPortInitialized = true; } catch (Exception ex) { throw new INITIALIZE(MinorCodes.ORBD_ERROR, CompletionStatus.COMPLETED_MAYBE); } } initServices(); // Register back with the Activator (ORBD). // This is done at the end so that ORBD will not reply to the // client until this server has finished all initialization. if (serverIsORBActivated) { try { Activator activator = ActivatorHelper.narrow( resolve_initial_references( ORBConstants.SERVER_ACTIVATOR_NAME )) ; Collection serverEndpoints = getServerGIOP().getServerEndpoints(); EndPointInfo[] endpointList = new EndPointInfo[serverEndpoints.size()]; Iterator iterator = serverEndpoints.iterator(); int i = 0; while (iterator.hasNext()) { EndPoint ep = (EndPoint) iterator.next(); endpointList[i] = new EndPointInfo(ep.getType(), ep.getPort()); i++; } activator.registerEndpoints( getPersistentServerId(), orbId, endpointList); } catch (Exception ex) { throw new INITIALIZE(MinorCodes.ORBD_ERROR, CompletionStatus.COMPLETED_MAYBE); } } } // Convenience package method for getting poaCurrent public POACurrent getCurrent() { return (POACurrent)poaCurrent; }/****************************************************************************** * The following internal methods are accessors/modifiers for ORB internal * variables. ******************************************************************************/ /** Return the persistent-server-id of this server. This id is the same * across multiple activations of this server. This is in contrast to * com.sun.corba.se.internal.iiop.ORB.getTransientServerId() which returns a transient * id that is guaranteed to be different across multiple activations of * this server. The user/environment is required to supply the * persistent-server-id every time this server is started, in * the ORBServerId parameter, System properties, or other means. * The user is also required to ensure that no two persistent servers * on the same host have the same server-id. */ public int getPersistentServerId() { if ( persistentServerIdInitialized ) return persistentServerId; else throw new INITIALIZE( "Persistent Server Id not initialized", MinorCodes.PERSISTENT_SERVERID_NOT_SET, CompletionStatus.COMPLETED_MAYBE); } /** Set the persistent-server-id of this server. This id is the same * across multiple activations of this server. The id can be set to any * integer value other than 0. This id must be set before any persistent * objects can be created. */ public void setPersistentServerId(int id) { persistentServerId = id; persistentServerIdInitialized = true; } public boolean getPersistentServerIdInitialized() { return persistentServerIdInitialized; } public void setPersistentServerPort(int sp) { if ( persistentPortInitialized ) throw new INTERNAL(MinorCodes.PERSISTENT_SERVERPORT_ERROR, CompletionStatus.COMPLETED_MAYBE); // Create an endpoint for the port. // Note: for transient servers, a ServerSocket is created lazily, // only when an objref is created, which allows the ORB to work in // applets which do not allow ServerSockets to be created. // But for persistent servers, it is possible that the server is // servicing a persistent objref which was created on a previous // incarnation. Hence we have to create the ServerSocket now. // getEndpoint is defined in com.sun.corba.se.internal.iiop.GIOPImpl; // it creates the ServerSocket, listenerThread and sets listenerPort. // Changed on 11/24 to unify the port for Alliance delivery // With this change the POAORB can work without ORBD and it // will listen all the requests on one port if ORBInitialPort = ORBServerPort. // Start the Listener thread only of the ports are different, otherwise // it will be started from the BootStrapServer. if( sp != ORBInitialPort ) { ServerGIOP sgiop = getServerGIOP(); serverEndPoint = sgiop.getEndpoint(EndPoint.IIOP_CLEAR_TEXT, sp, null); } persistentServerPort = sp; persistentPortInitialized = true; } public org.omg.CORBA.Object getInitialService( String theKey ) { // Simply return Null, If the end user wants to replace // any of the initial Service then this method has to be // overridden and a particular service handle shold be // returned based upon the Key. // This method is useful for replacing Sun's NameService // with Vendor's NameService return null; } public int getPersistentServerPort(String socketType) { if ( orbdPortInitialized ) // this server is activated by orbd return getServerGIOP().getPersistentServerPort(socketType); else if ( persistentPortInitialized ) // this is a user-activated server return persistentServerPort; else throw new INITIALIZE("Persistent Server Port not initialized", MinorCodes.PERSISTENT_SERVERPORT_NOT_SET, CompletionStatus.COMPLETED_MAYBE); } // This overrides iiop.ORB.getServerPort. public int getServerPort(String socketType) { if ( serverIsORBActivated ) { return getPersistentServerPort(socketType); } else { return super.getServerPort(socketType); } } public EndPoint getServerEndpoint() { if ( serverEndPoint == null ) { // create one ServerGIOP sgiop = getServerGIOP(); sgiop.initEndpoints(); serverEndPoint = sgiop.getDefaultEndpoint(); } return serverEndPoint; } public Collection getServerEndpoints() { getServerGIOP().initEndpoints(); return getServerGIOP().getServerEndpoints(); } /** * The bad server id handler is used by the Locator to * send back the location of a persistant server to the client. */ public BadServerIdHandler getBadServerIdHandler() { return badServerIdHandler; } public void setBadServerIdHandler(BadServerIdHandler handler) { badServerIdHandler = handler; } public String getBadServerIdHandlerClass() { return badServerIdHandlerClass; } protected void removePoaManager(POAManager manager) { poaManagers.remove(manager); } protected void addPoaManager(POAManager manager) { poaManagers.add(manager); } public synchronized POA getRootPOA() { if (rootPOA == null) { try { Object obj = resolve_initial_references( ORBConstants.ROOT_POA_NAME ) ; rootPOA = (POAImpl)obj ; } catch (InvalidName inv) { throw new INTERNAL() ; } } return rootPOA; } public String getORBId() { return orbId; }/****************************************************************************** * The following public methods are for ORB shutdown. * ******************************************************************************/ /** This method shuts down the ORB and causes orb.run() to return. * It will cause all POAManagers to be deactivated, which in turn * will cause all POAs to be deactivated. */ protected void shutdownServants(boolean wait_for_completion) { // It is important to copy the list of POAManagers first because // pm.deactivate removes itself from poaManagers! Iterator managers = (new HashSet(poaManagers)).iterator(); while ( managers.hasNext() ) { try { ((POAManager)managers.next()).deactivate(true, wait_for_completion); } catch ( org.omg.PortableServer.POAManagerPackage.AdapterInactive e ) {} } super.shutdownServants(wait_for_completion); } /** This method always returns false because the ORB never needs the * main thread to do work. */ public boolean work_pending() { checkShutdownState(); return false; } /** This method does nothing. It is not required by the spec to do anything! */ public void perform_work() { checkShutdownState(); } synchronized boolean isProcessingInvocation() { return isProcessingInvocation.get() == Boolean.TRUE; } // // Client side service context interceptors // /** * Called before the arguments are marshalled and before the * request is sent. A derived class may override this hook to view the * service contexts that the ORB has prepared for this request. The * overriding method may also add new service contexts. * Note: this hook may be invoked concurrently by multiple threads. * However, ServiceContexts objects are not shared between threads. */ protected void sendingRequestServiceContexts( ServiceContexts scs ) { } /** * Called after the ORB receives a reply, before result is * unmarshalled. A derived class may override this hook to view the * service contexts that the ORB has received in this reply. The * overriding method should only view the received service contexts. * The contents of scs will be further processed by the ORB after * receivedServiceContexts returns. * Note: this hook may be invoked concurrently by multiple threads. * However, ServiceContexts objects are not shared between threads. */ protected void receivedReplyServiceContexts(ServiceContexts scs) { } // // Server side service context interceptors // /** * Called after the ORB receives a request, before arguments are * unmarshalled. A derived class may override this hook to view the * service contexts that the ORB has received in this request. The * overriding method should only view the received service contexts. * The contents of scs will be further processed by the ORB after * receivedServiceContexts returns. * Note: this hook may be invoked concurrently by multiple threads. * However, ServiceContexts objects are not shared between threads. */ protected void receivedRequestServiceContexts(ServiceContexts scs) { } /** * Called before the arguments are marshalled and before the * reply is sent. A derived class may override this hook to view the * service contexts that the ORB has prepared for this reply. The * overriding method may also add new service contexts. * Note: this hook may be invoked concurrently by multiple threads. * However, ServiceContexts objects are not shared between threads. */ protected void sendingReplyServiceContexts(ServiceContexts scs) { } // Hook that can be overridden in a derived class to add more specific // subcontracts to the SubContractRegistry protected void initSubcontractRegistry() { for (int i =0; i<scTable.length;i++) { try { int scid = Integer.parseInt(scTable[i][2]); Class clientSCclass = ORBClassLoader.loadClass(scTable[i][0]); subcontractRegistry.registerClient(clientSCclass, scid); String serverSCclass = scTable[i][1]; ServerSubcontract sc = (ServerSubcontract) ORBClassLoader.loadClass(serverSCclass).newInstance();
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?