src/share/classes/com/sun/corba/se/impl/interceptors/PIHandlerImpl.java

Print this page


   1 /*
   2  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  41 import org.omg.CORBA.UserException;
  42 import org.omg.CORBA.UNKNOWN;
  43 
  44 import org.omg.CORBA.portable.ApplicationException;
  45 import org.omg.CORBA.portable.RemarshalException;
  46 
  47 import org.omg.IOP.CodecFactory;
  48 
  49 import org.omg.PortableInterceptor.ForwardRequest;
  50 import org.omg.PortableInterceptor.Current;
  51 import org.omg.PortableInterceptor.Interceptor;
  52 import org.omg.PortableInterceptor.LOCATION_FORWARD;
  53 import org.omg.PortableInterceptor.ORBInitializer;
  54 import org.omg.PortableInterceptor.ORBInitInfo;
  55 import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName;
  56 import org.omg.PortableInterceptor.SUCCESSFUL;
  57 import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
  58 import org.omg.PortableInterceptor.TRANSPORT_RETRY;
  59 import org.omg.PortableInterceptor.USER_EXCEPTION;
  60 import org.omg.PortableInterceptor.PolicyFactory;
  61 import org.omg.PortableInterceptor.ObjectReferenceTemplate ;
  62 
  63 import com.sun.corba.se.pept.encoding.OutputObject;
  64 
  65 import com.sun.corba.se.spi.ior.IOR;
  66 import com.sun.corba.se.spi.ior.ObjectKeyTemplate;
  67 import com.sun.corba.se.spi.oa.ObjectAdapter;
  68 import com.sun.corba.se.spi.orb.ORB;
  69 import com.sun.corba.se.spi.orbutil.closure.ClosureFactory;
  70 import com.sun.corba.se.spi.protocol.CorbaMessageMediator;
  71 import com.sun.corba.se.spi.protocol.ForwardException;
  72 import com.sun.corba.se.spi.protocol.PIHandler;
  73 import com.sun.corba.se.spi.protocol.RetryType;
  74 import com.sun.corba.se.spi.logging.CORBALogDomains;
  75 
  76 import com.sun.corba.se.impl.logging.InterceptorsSystemException;
  77 import com.sun.corba.se.impl.logging.ORBUtilSystemException;
  78 import com.sun.corba.se.impl.logging.OMGSystemException;
  79 import com.sun.corba.se.impl.corba.RequestImpl;
  80 import com.sun.corba.se.impl.orbutil.ORBClassLoader;
  81 import com.sun.corba.se.impl.orbutil.ORBConstants;


  95     {
  96         if (! printPushPopEnabled) return;
  97         printSpaces(pushLevel);
  98         pushLevel++;
  99         System.out.println("PUSH");
 100     }
 101     private void printPop()
 102     {
 103         if (! printPushPopEnabled) return;
 104         pushLevel--;
 105         printSpaces(pushLevel);
 106         System.out.println("POP");
 107     }
 108     private void printSpaces(int n)
 109     {
 110         for (int i = 0; i < n; i++) {
 111             System.out.print(" ");
 112         }
 113     }
 114 
 115     private ORB orb ;
 116     InterceptorsSystemException wrapper ;
 117     ORBUtilSystemException orbutilWrapper ;
 118     OMGSystemException omgWrapper ;
 119 
 120     // A unique id used in ServerRequestInfo.
 121     // This does not correspond to the GIOP request id.
 122     private int serverRequestIdCounter = 0;
 123 
 124     // Stores the codec factory for producing codecs
 125     CodecFactory codecFactory = null;
 126 
 127     // The arguments passed to the application's main method.  May be null.
 128     // This is used for ORBInitializers and set from set_parameters.
 129     String[] arguments = null;
 130 
 131     // The list of portable interceptors, organized by type:
 132     private InterceptorList interceptorList;
 133 
 134     // Cached information for optimization - do we have any interceptors
 135     // registered of the given types?  Set during ORB initialization.
 136     private boolean hasIORInterceptors;
 137     private boolean hasClientInterceptors;  // temp always true
 138     private boolean hasServerInterceptors;


 161         TRANSPORT_RETRY.value   // = ReplyMessage.NEEDS_ADDRESSING_MODE
 162     };
 163 
 164     // ThreadLocal containing a stack to store client request info objects
 165     // and a disable count.
 166     private ThreadLocal threadLocalClientRequestInfoStack =
 167         new ThreadLocal() {
 168             protected Object initialValue() {
 169                 return new RequestInfoStack();
 170             }
 171         };
 172 
 173     // ThreadLocal containing the current server request info object.
 174     private ThreadLocal threadLocalServerRequestInfoStack =
 175         new ThreadLocal() {
 176             protected Object initialValue() {
 177                 return new RequestInfoStack();
 178             }
 179         };
 180 















 181     // Class to contain all ThreadLocal data for ClientRequestInfo
 182     // maintenance.
 183     //
 184     // We use an ArrayList instead since it is not thread-safe.
 185     // RequestInfoStack is used quite frequently.
 186     private final class RequestInfoStack extends Stack {
 187         // Number of times a request has been made to disable interceptors.
 188         // When this reaches 0, interception hooks are disabled.  Any higher
 189         // value indicates they are enabled.
 190         // NOTE: The is only currently used on the client side.
 191         public int disableCount = 0;
 192     }
 193 
 194     public PIHandlerImpl( ORB orb, String[] args ) {
 195         this.orb = orb ;
 196         wrapper = InterceptorsSystemException.get( orb,
 197             CORBALogDomains.RPC_PROTOCOL ) ;
 198         orbutilWrapper = ORBUtilSystemException.get( orb,
 199             CORBALogDomains.RPC_PROTOCOL ) ;
 200         omgWrapper = OMGSystemException.get( orb,


   1 /*
   2  * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  41 import org.omg.CORBA.UserException;
  42 import org.omg.CORBA.UNKNOWN;
  43 
  44 import org.omg.CORBA.portable.ApplicationException;
  45 import org.omg.CORBA.portable.RemarshalException;
  46 
  47 import org.omg.IOP.CodecFactory;
  48 
  49 import org.omg.PortableInterceptor.ForwardRequest;
  50 import org.omg.PortableInterceptor.Current;
  51 import org.omg.PortableInterceptor.Interceptor;
  52 import org.omg.PortableInterceptor.LOCATION_FORWARD;
  53 import org.omg.PortableInterceptor.ORBInitializer;
  54 import org.omg.PortableInterceptor.ORBInitInfo;
  55 import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName;
  56 import org.omg.PortableInterceptor.SUCCESSFUL;
  57 import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
  58 import org.omg.PortableInterceptor.TRANSPORT_RETRY;
  59 import org.omg.PortableInterceptor.USER_EXCEPTION;
  60 import org.omg.PortableInterceptor.PolicyFactory;
  61 import org.omg.PortableInterceptor.ObjectReferenceTemplate;
  62 
  63 import com.sun.corba.se.pept.encoding.OutputObject;
  64 
  65 import com.sun.corba.se.spi.ior.IOR;
  66 import com.sun.corba.se.spi.ior.ObjectKeyTemplate;
  67 import com.sun.corba.se.spi.oa.ObjectAdapter;
  68 import com.sun.corba.se.spi.orb.ORB;
  69 import com.sun.corba.se.spi.orbutil.closure.ClosureFactory;
  70 import com.sun.corba.se.spi.protocol.CorbaMessageMediator;
  71 import com.sun.corba.se.spi.protocol.ForwardException;
  72 import com.sun.corba.se.spi.protocol.PIHandler;
  73 import com.sun.corba.se.spi.protocol.RetryType;
  74 import com.sun.corba.se.spi.logging.CORBALogDomains;
  75 
  76 import com.sun.corba.se.impl.logging.InterceptorsSystemException;
  77 import com.sun.corba.se.impl.logging.ORBUtilSystemException;
  78 import com.sun.corba.se.impl.logging.OMGSystemException;
  79 import com.sun.corba.se.impl.corba.RequestImpl;
  80 import com.sun.corba.se.impl.orbutil.ORBClassLoader;
  81 import com.sun.corba.se.impl.orbutil.ORBConstants;


  95     {
  96         if (! printPushPopEnabled) return;
  97         printSpaces(pushLevel);
  98         pushLevel++;
  99         System.out.println("PUSH");
 100     }
 101     private void printPop()
 102     {
 103         if (! printPushPopEnabled) return;
 104         pushLevel--;
 105         printSpaces(pushLevel);
 106         System.out.println("POP");
 107     }
 108     private void printSpaces(int n)
 109     {
 110         for (int i = 0; i < n; i++) {
 111             System.out.print(" ");
 112         }
 113     }
 114 
 115     private ORB orb;
 116     InterceptorsSystemException wrapper;
 117     ORBUtilSystemException orbutilWrapper;
 118     OMGSystemException omgWrapper;
 119 
 120     // A unique id used in ServerRequestInfo.
 121     // This does not correspond to the GIOP request id.
 122     private int serverRequestIdCounter = 0;
 123 
 124     // Stores the codec factory for producing codecs
 125     CodecFactory codecFactory = null;
 126 
 127     // The arguments passed to the application's main method.  May be null.
 128     // This is used for ORBInitializers and set from set_parameters.
 129     String[] arguments = null;
 130 
 131     // The list of portable interceptors, organized by type:
 132     private InterceptorList interceptorList;
 133 
 134     // Cached information for optimization - do we have any interceptors
 135     // registered of the given types?  Set during ORB initialization.
 136     private boolean hasIORInterceptors;
 137     private boolean hasClientInterceptors;  // temp always true
 138     private boolean hasServerInterceptors;


 161         TRANSPORT_RETRY.value   // = ReplyMessage.NEEDS_ADDRESSING_MODE
 162     };
 163 
 164     // ThreadLocal containing a stack to store client request info objects
 165     // and a disable count.
 166     private ThreadLocal threadLocalClientRequestInfoStack =
 167         new ThreadLocal() {
 168             protected Object initialValue() {
 169                 return new RequestInfoStack();
 170             }
 171         };
 172 
 173     // ThreadLocal containing the current server request info object.
 174     private ThreadLocal threadLocalServerRequestInfoStack =
 175         new ThreadLocal() {
 176             protected Object initialValue() {
 177                 return new RequestInfoStack();
 178             }
 179         };
 180 
 181     public void close() {
 182         orb = null;
 183         wrapper = null;
 184         orbutilWrapper = null;
 185         omgWrapper = null;
 186         codecFactory = null;
 187         arguments = null;
 188         interceptorList = null;
 189         interceptorInvoker = null;
 190         current = null;
 191         policyFactoryTable = null;
 192         threadLocalClientRequestInfoStack = null;
 193         threadLocalServerRequestInfoStack = null;
 194     }
 195 
 196     // Class to contain all ThreadLocal data for ClientRequestInfo
 197     // maintenance.
 198     //
 199     // We use an ArrayList instead since it is not thread-safe.
 200     // RequestInfoStack is used quite frequently.
 201     private final class RequestInfoStack extends Stack {
 202         // Number of times a request has been made to disable interceptors.
 203         // When this reaches 0, interception hooks are disabled.  Any higher
 204         // value indicates they are enabled.
 205         // NOTE: The is only currently used on the client side.
 206         public int disableCount = 0;
 207     }
 208 
 209     public PIHandlerImpl( ORB orb, String[] args ) {
 210         this.orb = orb ;
 211         wrapper = InterceptorsSystemException.get( orb,
 212             CORBALogDomains.RPC_PROTOCOL ) ;
 213         orbutilWrapper = ORBUtilSystemException.get( orb,
 214             CORBALogDomains.RPC_PROTOCOL ) ;
 215         omgWrapper = OMGSystemException.get( orb,