Source Code Cross Referenced for StubDelegateImpl.java in  » EJB-Server-resin-3.1.5 » resin » com » caucho » iiop » orb » 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 » EJB Server resin 3.1.5 » resin » com.caucho.iiop.orb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003:         *
004:         * This file is part of Resin(R) Open Source
005:         *
006:         * Each copy or derived work must preserve the copyright notice and this
007:         * notice unmodified.
008:         *
009:         * Resin Open Source is free software; you can redistribute it and/or modify
010:         * it under the terms of the GNU General Public License as published by
011:         * the Free Software Foundation; either version 2 of the License, or
012:         * (at your option) any later version.
013:         *
014:         * Resin Open Source is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017:         * of NON-INFRINGEMENT.  See the GNU General Public License for more
018:         * details.
019:         *
020:         * You should have received a copy of the GNU General Public License
021:         * along with Resin Open Source; if not, write to the
022:         *
023:         *   Free Software Foundation, Inc.
024:         *   59 Temple Place, Suite 330
025:         *   Boston, MA 02111-1307  USA
026:         *
027:         * @author Scott Ferguson
028:         */
029:
030:        package com.caucho.iiop.orb;
031:
032:        import org.omg.CORBA.*;
033:
034:        import java.util.*;
035:        import java.util.logging.*;
036:        import java.io.*;
037:
038:        import javax.transaction.*;
039:        import javax.transaction.xa.*;
040:
041:        import com.caucho.iiop.*;
042:        import com.caucho.transaction.*;
043:        import com.caucho.vfs.*;
044:
045:        public class StubDelegateImpl extends org.omg.CORBA.portable.Delegate {
046:            public static final Logger log = Logger
047:                    .getLogger(StubDelegateImpl.class.getName());
048:
049:            private ORBImpl _orb;
050:            private byte[] _oid;
051:
052:            StubDelegateImpl(ORBImpl orb) {
053:                _orb = orb;
054:            }
055:
056:            StubDelegateImpl(ORBImpl orb, byte[] oid) {
057:                _orb = orb;
058:                _oid = oid;
059:            }
060:
061:            @Override
062:            public org.omg.CORBA.portable.OutputStream request(
063:                    org.omg.CORBA.Object self, String op,
064:                    boolean isResponseExpected) {
065:                try {
066:                    Iiop12Writer writer = new Iiop12Writer();
067:
068:                    writer.setOrb(_orb);
069:
070:                    IiopSocketPool pool = _orb.getSocketPool();
071:
072:                    ReadWritePair pair = pool.open();
073:
074:                    MessageWriter out = new StreamMessageWriter(pair
075:                            .getWriteStream());
076:
077:                    IiopReader is = new IiopReader(pool, pair);
078:
079:                    is.setOrb(_orb);
080:
081:                    writer.init(out, is);
082:
083:                    byte[] oid;
084:
085:                    if (self instanceof  StubImpl)
086:                        oid = ((StubImpl) self).getOid();
087:                    else
088:                        oid = _oid;
089:
090:                    ArrayList<ServiceContext> serviceList = null;
091:
092:                    try {
093:                        TransactionManagerImpl tm = TransactionManagerImpl
094:                                .getLocal();
095:                        TransactionImpl xa = (TransactionImpl) tm
096:                                .getTransaction();
097:
098:                        if (xa != null) {
099:                            if (serviceList == null)
100:                                serviceList = new ArrayList<ServiceContext>();
101:
102:                            serviceList.add(new TransactionServiceContext(xa));
103:                        }
104:                    } catch (Exception e) {
105:                        log.log(Level.FINER, e.toString(), e);
106:                    }
107:
108:                    writer.startRequest(oid, 0, oid.length, op, 1, serviceList);
109:
110:                    return writer;
111:                } catch (IOException e) {
112:                    throw new RuntimeException(e);
113:                }
114:            }
115:
116:            @Override
117:            public org.omg.CORBA.portable.InputStream invoke(
118:                    org.omg.CORBA.Object self,
119:                    org.omg.CORBA.portable.OutputStream os) {
120:                try {
121:                    IiopWriter writer = (IiopWriter) os;
122:
123:                    IiopReader reader = writer._call();
124:
125:                    return reader;
126:                } catch (IOException e) {
127:                    throw new RuntimeException(e);
128:                }
129:            }
130:
131:            @Override
132:            public Request create_request(org.omg.CORBA.Object obj,
133:                    Context ctx, String op, NVList argList, NamedValue result) {
134:                throw new UnsupportedOperationException();
135:            }
136:
137:            @Override
138:            public Request create_request(org.omg.CORBA.Object obj,
139:                    Context ctx, String op, NVList argList, NamedValue result,
140:                    ExceptionList excList, ContextList ctxList) {
141:                throw new UnsupportedOperationException();
142:            }
143:
144:            @Override
145:            public org.omg.CORBA.Object duplicate(org.omg.CORBA.Object obj) {
146:                return obj;
147:            }
148:
149:            @Override
150:            public org.omg.CORBA.Object get_interface_def(
151:                    org.omg.CORBA.Object self) {
152:                throw new UnsupportedOperationException();
153:            }
154:
155:            @Override
156:            public int hash(org.omg.CORBA.Object obj, int max) {
157:                throw new UnsupportedOperationException();
158:            }
159:
160:            @Override
161:            public boolean is_a(org.omg.CORBA.Object obj, String repId) {
162:                if (obj instanceof  StubImpl) {
163:                    String typeId = ((StubImpl) obj).getIOR().getTypeId();
164:
165:                    if (typeId.equals(repId))
166:                        return true;
167:                }
168:
169:                return false;
170:            }
171:
172:            @Override
173:            public boolean is_equivalent(org.omg.CORBA.Object obj,
174:                    org.omg.CORBA.Object other) {
175:                return obj == other;
176:            }
177:
178:            @Override
179:            public boolean non_existent(org.omg.CORBA.Object obj) {
180:                throw new UnsupportedOperationException();
181:            }
182:
183:            @Override
184:            public ORB orb(org.omg.CORBA.Object obj) {
185:                return _orb;
186:            }
187:
188:            @Override
189:            public void release(org.omg.CORBA.Object obj) {
190:            }
191:
192:            @Override
193:            public void releaseReply(org.omg.CORBA.Object self,
194:                    org.omg.CORBA.portable.InputStream is) {
195:            }
196:
197:            @Override
198:            public Request request(org.omg.CORBA.Object obj, String op) {
199:                throw new UnsupportedOperationException();
200:            }
201:
202:            public String toString() {
203:                return "StubDelegateImpl[]";
204:            }
205:
206:            static class TransactionServiceContext extends ServiceContext {
207:                private TransactionImpl _xa;
208:
209:                TransactionServiceContext(TransactionImpl xa) {
210:                    _xa = xa;
211:                }
212:
213:                public void write(IiopWriter out) {
214:                    try {
215:                        out.write_long(IiopReader.SERVICE_TRANSACTION);
216:
217:                        EncapsulationMessageWriter subOut = new EncapsulationMessageWriter();
218:
219:                        subOut.write(0); // endian
220:
221:                        subOut.align(4);
222:                        subOut.writeInt(_xa.getTransactionTimeout());
223:                        subOut.writeInt(0); // Coordinator
224:                        subOut.writeInt(0); // Terminator
225:
226:                        Xid xid = _xa.getXid();
227:
228:                        byte[] global = xid.getGlobalTransactionId();
229:                        byte[] local = xid.getBranchQualifier();
230:
231:                        // otid_t
232:                        subOut.writeInt(0); // format
233:                        subOut.writeInt(local.length); // bqual_length
234:                        subOut.writeInt(global.length + local.length);
235:                        subOut.write(global, 0, global.length);
236:                        subOut.write(local, 0, local.length);
237:
238:                        subOut.align(4);
239:                        subOut.writeInt(0); // parents
240:                        subOut.close();
241:
242:                        out.write_long(subOut.getOffset());
243:                        subOut.writeToWriter(out);
244:                    } catch (Exception e) {
245:                        throw new RuntimeException(e);
246:                    }
247:                }
248:            }
249:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.