📄 orbimpl.java
字号:
*/ public synchronized TypeCode create_interface_tc(String id, String name) { checkShutdownState(); return new TypeCodeImpl(this, TCKind._tk_objref, id, name); } /** * Create a TypeCode for a string. * * @param bound the bound for the string. * @return the requested TypeCode. */ public synchronized TypeCode create_string_tc(int bound) { checkShutdownState(); return new TypeCodeImpl(this, TCKind._tk_string, bound); } /** * Create a TypeCode for a wide string. * * @param bound the bound for the string. * @return the requested TypeCode. */ public synchronized TypeCode create_wstring_tc(int bound) { checkShutdownState(); return new TypeCodeImpl(this, TCKind._tk_wstring, bound); } /** * Create a TypeCode for a sequence. * * @param bound the bound for the sequence. * @param element_type * the type of elements of the sequence. * @return the requested TypeCode. */ public synchronized TypeCode create_sequence_tc(int bound, TypeCode element_type) { checkShutdownState(); return new TypeCodeImpl(this, TCKind._tk_sequence, bound, element_type); } /** * Create a recursive TypeCode in a sequence. * * @param bound the bound for the sequence. * @param offset the index to the enclosing TypeCode that is * being referenced. * @return the requested TypeCode. */ public synchronized TypeCode create_recursive_sequence_tc(int bound, int offset) { checkShutdownState(); return new TypeCodeImpl(this, TCKind._tk_sequence, bound, offset); } /** * Create a TypeCode for an array. * * @param length the length of the array. * @param element_type * the type of elements of the array. * @return the requested TypeCode. */ public synchronized TypeCode create_array_tc(int length, TypeCode element_type) { checkShutdownState(); return new TypeCodeImpl(this, TCKind._tk_array, length, element_type); } public synchronized org.omg.CORBA.TypeCode create_native_tc(String id, String name) { checkShutdownState(); return new TypeCodeImpl(this, TCKind._tk_native, id, name); } public synchronized org.omg.CORBA.TypeCode create_abstract_interface_tc( String id, String name) { checkShutdownState(); return new TypeCodeImpl(this, TCKind._tk_abstract_interface, id, name); } public synchronized org.omg.CORBA.TypeCode create_fixed_tc(short digits, short scale) { checkShutdownState(); return new TypeCodeImpl(this, TCKind._tk_fixed, digits, scale); } public synchronized org.omg.CORBA.TypeCode create_value_tc(String id, String name, short type_modifier, TypeCode concrete_base, ValueMember[] members) { checkShutdownState(); return new TypeCodeImpl(this, TCKind._tk_value, id, name, type_modifier, concrete_base, members); } public synchronized org.omg.CORBA.TypeCode create_recursive_tc(String id) { checkShutdownState(); return new TypeCodeImpl(this, id); } public synchronized org.omg.CORBA.TypeCode create_value_box_tc(String id, String name, TypeCode boxed_type) { checkShutdownState(); return new TypeCodeImpl(this, TCKind._tk_value_box, id, name, boxed_type); } /** * Create a new Any * * @return the new Any created. */ public synchronized Any create_any() { checkShutdownState(); return new AnyImpl(this); } // TypeCodeFactory interface methods. // Keeping track of type codes by repository id. // Keeping a cache of TypeCodes associated with the class // they got created from in Util.writeAny(). public synchronized void setTypeCodeForClass(Class c, TypeCodeImpl tci) { if (typeCodeForClassMap == null) typeCodeForClassMap = Collections.synchronizedMap( new WeakHashMap(64)); // Store only one TypeCode per class. if ( ! typeCodeForClassMap.containsKey(c)) typeCodeForClassMap.put(c, tci); } public synchronized TypeCodeImpl getTypeCodeForClass(Class c) { if (typeCodeForClassMap == null) return null; return (TypeCodeImpl)typeCodeForClassMap.get(c); }/**************************************************************************** * The following methods deal with listing and resolving the initial * (bootstrap) object references such as "NameService". ****************************************************************************/ /** * Get a list of the initially available CORBA services. * This does not work unless an ORBInitialHost is specified during * initialization (or unless there is an ORB running on the AppletHost) * since the localhostname * is inaccessible to applets. If a service properties URL was specified, * then it is used, otherwise the bootstrapping protocol is used. * @return A list of the initial services available. */ public String[] list_initial_services() { Resolver res ; synchronized( this ) { checkShutdownState(); res = resolver ; } synchronized (resolverLock) { java.util.Set keys = res.list() ; return (String[])keys.toArray( new String[keys.size()] ) ; } } /** * Resolve the stringified reference of one of the initially * available CORBA services. * @param identifier The stringified object reference of the * desired service. * @return An object reference for the desired service. * @exception InvalidName The supplied identifier is not associated * with a known service. * @exception SystemException One of a fixed set of Corba system exceptions. */ public org.omg.CORBA.Object resolve_initial_references( String identifier) throws InvalidName { Resolver res ; synchronized( this ) { checkShutdownState(); res = resolver ; } synchronized (resolverLock) { org.omg.CORBA.Object result = res.resolve( identifier ) ; if (result == null) throw new InvalidName() ; else return result ; } } /** * If this operation is called with an id, <code>"Y"</code>, and an * object, <code>YY</code>, then a subsequent call to * <code>ORB.resolve_initial_references( "Y" )</code> will * return object <code>YY</code>. * * @param id The ID by which the initial reference will be known. * @param obj The initial reference itself. * @throws InvalidName if this operation is called with an empty string id * or this operation is called with an id that is already registered, * including the default names defined by OMG. * @throws BAD_PARAM if the obj parameter is null. */ public void register_initial_reference( String id, org.omg.CORBA.Object obj ) throws InvalidName { CorbaServerRequestDispatcher insnd ; if ((id == null) || (id.length() == 0)) throw new InvalidName() ; synchronized (this) { checkShutdownState(); } synchronized (resolverLock) { insnd = insNamingDelegate ; java.lang.Object obj2 = localResolver.resolve( id ) ; if (obj2 != null) throw new InvalidName(id + " already registered") ; localResolver.register( id, ClosureFactory.makeConstant( obj )) ; } synchronized (this) { if (StubAdapter.isStub(obj)) // Make all remote object references available for INS. requestDispatcherRegistry.registerServerRequestDispatcher( insnd, id ) ; } }/**************************************************************************** * The following methods (introduced in POA / CORBA2.1) deal with * shutdown / single threading. ****************************************************************************/ public void run() { synchronized (this) { checkShutdownState(); } synchronized (runObj) { try { runObj.wait(); } catch ( InterruptedException ex ) {} } } public void shutdown(boolean wait_for_completion) { synchronized (this) { checkShutdownState(); } // Avoid more than one thread performing shutdown at a time. synchronized (shutdownObj) { checkShutdownState(); // This is to avoid deadlock if (wait_for_completion && isProcessingInvocation.get() == Boolean.TRUE) { throw omgWrapper.shutdownWaitForCompletionDeadlock() ; } status = STATUS_SHUTTING_DOWN; // XXX access to requestDispatcherRegistry should be protected // by the ORBImpl instance monitor, but is not here in the // shutdownServants call. shutdownServants(wait_for_completion); if (wait_for_completion) { synchronized ( waitForCompletionObj ) { while (numInvocations > 0) { try { waitForCompletionObj.wait(); } catch (InterruptedException ex) {} } } } synchronized ( runObj ) { runObj.notifyAll(); } status = STATUS_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) { Iterator iter = requestDispatcherRegistry.getObjectAdapterFactories().iterator() ; while (iter.hasNext()) { ObjectAdapterFactory oaf = (ObjectAdapterFactory)iter.next() ; oaf.shutdown( wait_for_completion ) ; } } // REVISIT: was protected - made public for framework // Note that the caller must hold the ORBImpl lock. public void checkShutdownState() { if (status == STATUS_DESTROYED) { throw wrapper.orbDestroyed() ; } if (status == STATUS_SHUTDOWN) { throw omgWrapper.badOperationAfterShutdown() ; } } public boolean isDuringDispatch() { Boolean value = (Boolean)(isProcessingInvocation.get()) ; return value.booleanValue() ; } public void startingDispatch() { synchronized (invocationObj) { isProcessingInvocation.set(Boolean.TRUE); numInvocations++; } } public void finishedDispatch() { synchronized (invocationObj) { numInvocations--; isProcessingInvocation.set(Boolean.FALSE); if (numInvocations == 0) { synchronized (waitForCompletionObj) { waitForCompletionObj.notifyAll(); } } else if (numInvocations < 0) { throw wrapper.numInvocationsAlreadyZero( CompletionStatus.COMPLETED_YES ) ; } } } /** * formal/99-10-07 p 159: "If destroy is called on an ORB that has * not been shut down, it will start the shutdown process and block until * the ORB has shut down before it destroys the ORB." */ public synchronized void destroy() { if (status == STATUS_OPERATING) { shutdown(true); } getCorbaTransportManager().close(); getPIHandler().destroyInterceptors() ; status = STATUS_DESTROYED; } /** * Registers a value factory for a particular repository ID. * * @param repositoryID the repository ID. * @param factory the factory. * @return the previously registered factory for the given repository ID, * or null if no such factory was previously registered. * @exception org.omg.CORBA.BAD_PARAM if the registration fails. **/ public synchronized ValueFactory register_value_factory(String repositoryID, ValueFactory factory) { checkShutdownState(); if ((repositoryID == null) || (factory == null)) throw omgWrapper.unableRegisterValueFactory() ; return (ValueFactory)valueFactoryCache.put(repositoryID, factory); } /** * Unregisters a value factory for a particular repository ID. * * @param repositoryID the repository ID. **/ public synchronized void unregister_value_factory(String repositoryID) { checkShutdownState(); if (valueFactoryCache.remove(repositoryID) == null) throw wrapper.nullParam() ; } /** * Finds and returns a value factory for the given repository ID. * The value factory returned was previously registered by a call to * {@link #register_value_factory} or is the default factory. * * @param repositoryID the repository ID. * @return the value factory. * @exception org.omg.CORBA.BAD_PARAM if unable to locate a factory. **/ public synchronized ValueFactory lookup_value_factory(String repositoryID) { checkShutdownState(); ValueFactory factory = (ValueFactory)valueFactoryCache.get(repositoryID); if (factory == null) { try { factory = Utility.getFactory(null, null, null, repositoryID); } catch(org.omg.CORBA.MARSHAL ex) { throw wrapper.unableFindValueFactory( ex ) ; } } return factory ; } public OAInvocationInfo peekInvocationInfo() { StackImpl stack = (StackImpl)(OAInvocationInfoStack.get()) ; return (OAInvocationInfo)(stack.peek()) ; } public void pushInvocationInfo( OAInvocationInfo info ) { StackImpl stack = (StackImpl)(OAInvocationInfoStack.get()) ; stack.push( info ) ; } public OAInvocationInfo popInvocationInfo() { StackImpl stack = (StackImpl)(OAInvocationInfoStack.get()) ; return (OAInvocationInfo)(stack.pop()) ; } /** * The bad server id handler is used by the Locator to * send back the location of a persistant server to the client. */ private Object badServerIdHandlerAccessLock = new Object(); public void initBadServerIdHandler() {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -