Source Code Cross Referenced for ClassLoaderInterceptor.java in  » Net » Coadunation_1.0.1 » com » rift » coad » lib » interceptor » iiop » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » Coadunation_1.0.1 » com.rift.coad.lib.interceptor.iiop 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * CoadunationLib: The coaduntion implementation library.
003:         * Copyright (C) 2006  Rift IT Contracting
004:         *
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2.1 of the License, or (at your option) any later version.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         * Lesser General Public License for more details.
014:         *
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this library; if not, write to the Free Software
017:         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
018:         *
019:         * ClassLoaderInterceptor.java
020:         */
021:
022:        // package path
023:        package com.rift.coad.lib.interceptor.iiop;
024:
025:        // java imports
026:        import java.util.Stack;
027:        import java.util.MissingResourceException;
028:        import java.lang.ThreadLocal;
029:        import org.omg.CORBA.TIMEOUT;
030:        import org.omg.IOP.ServiceContext;
031:        import org.omg.PortableInterceptor.ServerRequestInterceptor;
032:        import org.omg.PortableInterceptor.ServerRequestInfo;
033:        import org.omg.PortableInterceptor.ForwardRequest;
034:        import org.omg.PortableInterceptor.ORBInitInfo;
035:
036:        // logging import
037:        import org.apache.log4j.Logger;
038:
039:        // coadunation imports
040:        import com.rift.coad.lib.common.ObjectSerializer;
041:        import com.rift.coad.lib.naming.NamingDirector;
042:        import com.rift.coad.lib.interceptor.credentials.Credential;
043:        import com.rift.coad.lib.interceptor.InterceptorWrapper;
044:        import com.rift.coad.lib.interceptor.ServerInterceptor;
045:
046:        /**
047:         * This class is responsible for setting the class loader correctly for the in
048:         * bound thread.
049:         *
050:         * @author Brett Chaldecott
051:         */
052:        public class ClassLoaderInterceptor extends InterceptorWrapper
053:                implements  ServerRequestInterceptor {
054:
055:            // the class log variable
056:            protected static Logger log = Logger
057:                    .getLogger(ClassLoaderInterceptor.class.getName());
058:
059:            // private member variables
060:            private ThreadLocal loaderStack = new ThreadLocal();
061:
062:            /** Creates a new instance of ClassLoaderInterceptor */
063:            public ClassLoaderInterceptor(ORBInitInfo info) {
064:
065:            }
066:
067:            /**
068:             * This method returns the name of this interceptor.
069:             *
070:             * @return A string containing the name of this interceptor.
071:             */
072:            public String name() {
073:                return "ClassLoaderInterceptor";
074:            }
075:
076:            /**
077:             * This method is called to distory this object.
078:             */
079:            public void destroy() {
080:                // do nothing for time being
081:            }
082:
083:            /**
084:             * Allows the interceptor to process service context information.
085:             *
086:             * @param ri The reference to the request information
087:             */
088:            public void receive_request_service_contexts(ServerRequestInfo ri) {
089:
090:            }
091:
092:            /**
093:             * Allows an Interceptor to query request information after all the
094:             * information, including operation parameters, are available.
095:             */
096:            public void receive_request(ServerRequestInfo ri) {
097:                log.debug("receive request");
098:                ClassLoader loader = Thread.currentThread()
099:                        .getContextClassLoader();
100:                try {
101:                    loader = NamingDirector.getInstance().getPOA()
102:                            .id_to_servant(ri.object_id()).getClass()
103:                            .getClassLoader();
104:                } catch (Exception ex) {
105:                    // ignore exception
106:                }
107:                Stack stack = getLoaderStack();
108:                stack.push(Thread.currentThread().getContextClassLoader());
109:                Thread.currentThread().setContextClassLoader(loader);
110:            }
111:
112:            /**
113:             * Allows an Interceptor to query the exception information and modify the
114:             * reply service context before the exception is thrown to the client.
115:             */
116:            public void send_exception(ServerRequestInfo ri) {
117:                log.debug("send exception");
118:                Stack stack = getLoaderStack();
119:                Thread.currentThread().setContextClassLoader(
120:                        (ClassLoader) stack.pop());
121:            }
122:
123:            /**
124:             * Allows an Interceptor to query the information available when a request
125:             * results in something other than a normal reply or an exception.
126:             */
127:            public void send_other(ServerRequestInfo ri) {
128:
129:            }
130:
131:            /**
132:             * Allows an Interceptor to query reply information and modify the reply
133:             * service context after the target operation has been invoked and before
134:             * the reply is returned to the client.
135:             */
136:            public void send_reply(ServerRequestInfo ri) {
137:                log.debug("send reply");
138:                Stack stack = getLoaderStack();
139:                Thread.currentThread().setContextClassLoader(
140:                        (ClassLoader) stack.pop());
141:            }
142:
143:            /**
144:             * This method returns the stack for the given thread.
145:             */
146:            private Stack getLoaderStack() {
147:                Stack stack = (Stack) loaderStack.get();
148:                if (stack == null) {
149:                    stack = new Stack();
150:                    loaderStack.set(stack);
151:                }
152:                return stack;
153:            }
154:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.