Source Code Cross Referenced for AdapterStateful.java in  » EJB-Server-geronimo » plugins » org » apache » geronimo » corba » 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 geronimo » plugins » org.apache.geronimo.corba 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */package org.apache.geronimo.corba;
017:
018:        import java.io.ByteArrayInputStream;
019:        import java.io.ByteArrayOutputStream;
020:        import java.io.IOException;
021:        import java.io.ObjectInputStream;
022:        import java.io.ObjectOutputStream;
023:
024:        import org.apache.commons.logging.Log;
025:        import org.apache.commons.logging.LogFactory;
026:        import org.omg.CORBA.Any;
027:        import org.omg.CORBA.LocalObject;
028:        import org.omg.CORBA.OBJECT_NOT_EXIST;
029:        import org.omg.CORBA.ORB;
030:        import org.omg.CORBA.Policy;
031:        import org.omg.PortableServer.IdAssignmentPolicyValue;
032:        import org.omg.PortableServer.ImplicitActivationPolicyValue;
033:        import org.omg.PortableServer.LifespanPolicyValue;
034:        import org.omg.PortableServer.POA;
035:        import org.omg.PortableServer.RequestProcessingPolicyValue;
036:        import org.omg.PortableServer.Servant;
037:        import org.omg.PortableServer.ServantLocator;
038:        import org.omg.PortableServer.ServantLocatorPackage.CookieHolder;
039:        import org.omg.PortableServer.ServantRetentionPolicyValue;
040:        import org.apache.openejb.InterfaceType;
041:        import org.apache.geronimo.corba.transaction.ServerTransactionPolicyFactory;
042:        import org.apache.geronimo.openejb.EjbDeployment;
043:
044:        /**
045:         * @version $Revision: 497125 $ $Date: 2007-01-17 10:51:30 -0800 (Wed, 17 Jan 2007) $
046:         */
047:        public class AdapterStateful extends Adapter {
048:            private final Log log = LogFactory.getLog(AdapterStateful.class);
049:
050:            private final POA poa;
051:            private final String referenceInterface;
052:            private String deploymentId;
053:
054:            public AdapterStateful(TSSLink tssLink, ORB orb, POA parentPOA,
055:                    Policy securityPolicy) throws CORBAException {
056:                super (tssLink, orb, parentPOA, securityPolicy);
057:
058:                deploymentId = tssLink.getContainerId();
059:
060:                Any any = orb.create_any();
061:                any.insert_Value(tssLink.getRemoteTxPolicyConfig());
062:
063:                try {
064:                    Policy[] policies = new Policy[] {
065:                            securityPolicy,
066:                            orb.create_policy(
067:                                    ServerTransactionPolicyFactory.POLICY_TYPE,
068:                                    any),
069:                            homePOA
070:                                    .create_lifespan_policy(LifespanPolicyValue.TRANSIENT),
071:                            homePOA
072:                                    .create_request_processing_policy(RequestProcessingPolicyValue.USE_SERVANT_MANAGER),
073:                            homePOA
074:                                    .create_servant_retention_policy(ServantRetentionPolicyValue.NON_RETAIN),
075:                            homePOA
076:                                    .create_id_assignment_policy(IdAssignmentPolicyValue.USER_ID),
077:                            homePOA
078:                                    .create_implicit_activation_policy(ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION), };
079:                    // make sure we create this with the appropriate ORB-specific policies. 
080:                    policies = tssLink.addPolicyOverrides(policies);
081:                    poa = homePOA.create_POA(tssLink.getContainerId(), homePOA
082:                            .the_POAManager(), policies);
083:                    poa.set_servant_manager(new ObjectActivator());
084:
085:                    poa.the_POAManager().activate();
086:
087:                    StandardServant servant = new StandardServant(orb,
088:                            InterfaceType.EJB_OBJECT, tssLink.getDeployment());
089:                    referenceInterface = servant._all_interfaces(null, null)[0];
090:                } catch (Exception e) {
091:                    throw new CORBAException("Unable to activate EJB "
092:                            + deploymentId + " as CORBA object", e);
093:                }
094:            }
095:
096:            public POA getPOA() {
097:                return poa;
098:            }
099:
100:            public void stop() throws CORBAException {
101:                poa.destroy(true, true);
102:                super .stop();
103:            }
104:
105:            public org.omg.CORBA.Object genObjectReference(Object primaryKey)
106:                    throws CORBAException {
107:
108:                byte[] bytes;
109:                try {
110:                    ByteArrayOutputStream b = new ByteArrayOutputStream();
111:                    ObjectOutputStream os = new ObjectOutputStream(b);
112:
113:                    os.writeObject(primaryKey);
114:                    bytes = b.toByteArray();
115:
116:                    os.close();
117:                } catch (IOException e) {
118:                    log.error("Could not serialize deployment info for "
119:                            + deploymentId, e);
120:                    throw new CORBAException(
121:                            "Could not serialize deployment info for "
122:                                    + deploymentId, e);
123:                }
124:                return poa.create_reference_with_id(bytes, referenceInterface);
125:            }
126:
127:            protected class ObjectActivator extends LocalObject implements 
128:                    ServantLocator {
129:
130:                public Servant preinvoke(byte[] oid, POA poa, String operation,
131:                        CookieHolder cookie) {
132:                    // the byte array can be cached in a weak hash map for performance
133:                    Object pk = null;
134:
135:                    try {
136:                        ObjectInputStream is = new ObjectInputStream(
137:                                new ByteArrayInputStream(oid));
138:                        pk = is.readObject();
139:                        is.close();
140:
141:                        EjbDeployment deployment = getDeployment();
142:                        return new StandardServant(getOrb(),
143:                                InterfaceType.EJB_OBJECT, deployment, pk);
144:                    } catch (IOException e) {
145:                        // if we can't deserialize, then this object can't exist in this process
146:                        throw (OBJECT_NOT_EXIST) new OBJECT_NOT_EXIST(0,
147:                                org.omg.CORBA.CompletionStatus.COMPLETED_NO)
148:                                .initCause(e);
149:                    } catch (Exception e) {
150:                        log.error("Exception during dispatch to method "
151:                                + operation + " in bean " + pk, e);
152:                        return null;
153:                    }
154:                }
155:
156:                public void postinvoke(byte[] oid, POA poa, String operation,
157:                        Object cookie, Servant servant) {
158:                }
159:            }
160:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.