Source Code Cross Referenced for CmiLifeCycleCallback.java in  » J2EE » ow2-easybeans » org » ow2 » easybeans » component » cmi » 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 » J2EE » ow2 easybeans » org.ow2.easybeans.component.cmi 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 2007 Bull S.A.S.
004:         * Contact: jonas-team@ow2.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or (at your option) any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
019:         *
020:         * --------------------------------------------------------------------------
021:         * $Id: CmiLifeCycleCallback.java 2163 2007-12-11 18:19:23Z loris $
022:         * --------------------------------------------------------------------------
023:         */package org.ow2.easybeans.component.cmi;
024:
025:        import org.ow2.carol.cmi.annotation.Cluster;
026:        import org.ow2.carol.cmi.info.CMIInfoExtractor;
027:        import org.ow2.carol.cmi.info.CMIInfoExtractorException;
028:        import org.ow2.carol.cmi.info.CMIInfoRepository;
029:        import org.ow2.carol.cmi.info.ClusteredObjectInfo;
030:        import org.ow2.easybeans.api.EZBContainerCallbackInfo;
031:        import org.ow2.easybeans.api.Factory;
032:        import org.ow2.easybeans.api.LifeCycleCallbackException;
033:        import org.ow2.easybeans.api.binding.EZBRef;
034:        import org.ow2.easybeans.container.EmptyLifeCycleCallBack;
035:        import org.ow2.easybeans.container.session.stateless.StatelessSessionFactory;
036:        import org.ow2.easybeans.proxy.reference.RemoteCallRef;
037:        import org.ow2.util.log.Log;
038:        import org.ow2.util.log.LogFactory;
039:
040:        /**
041:         * Provide a callback for CMI.
042:         * @author WEI Zhouyue & ZHU Ning
043:         */
044:        public class CmiLifeCycleCallback extends EmptyLifeCycleCallBack {
045:
046:            /**
047:             * Logger.
048:             */
049:            private static Log logger = LogFactory
050:                    .getLog(CmiLifeCycleCallback.class);
051:
052:            /**
053:             * Called before binding a reference into the registry.
054:             * Extract the informations on clustering and register it in the repository of CMI.
055:             * @param info some information on the container which is running.
056:             * @param reference a reference on the bean that will be bound
057:             * @throws LifeCycleCallbackException if the invocation of the callback failed
058:             */
059:            @Override
060:            public void beforeBind(final EZBContainerCallbackInfo info,
061:                    final EZBRef reference) throws LifeCycleCallbackException {
062:                // CMI only works on remote interfaces
063:                if (reference instanceof  RemoteCallRef) {
064:                    Factory<?, ?> factory = reference.getFactory();
065:                    // Only for stateless beans
066:                    // TODO Support of stateful beans
067:                    if (factory instanceof  StatelessSessionFactory) {
068:                        Class<?> beanClass = ((StatelessSessionFactory) factory)
069:                                .getBeanClass();
070:                        if (beanClass.isAnnotationPresent(Cluster.class)) {
071:                            Class<?> itfClass = null;
072:                            String jndiName = reference.getJNDIName();
073:                            String itfClassname = reference.getItfClassName();
074:                            logger
075:                                    .info(
076:                                            "The bean with the jndi name {0} and the interface name {1} is clustered.",
077:                                            jndiName, itfClassname);
078:                            for (Class<?> klass : beanClass.getInterfaces()) {
079:                                if (klass.getName().equals(itfClassname)) {
080:                                    itfClass = klass;
081:                                }
082:                            }
083:                            if (itfClass == null) {
084:                                logger
085:                                        .error(
086:                                                "Cannot find the interface for name {0}",
087:                                                itfClassname);
088:                                throw new LifeCycleCallbackException(
089:                                        "Cannot find the interface for name "
090:                                                + itfClassname);
091:                            }
092:                            // Extract the informations on clustering
093:                            ClusteredObjectInfo infos;
094:                            try {
095:                                infos = CMIInfoExtractor
096:                                        .extractClusteringInfoFromAnnotatedPOJO(
097:                                                itfClass, beanClass, false);
098:                            } catch (CMIInfoExtractorException e) {
099:                                logger
100:                                        .error(
101:                                                "Cannot extract infos for the class with name {0}",
102:                                                beanClass.getName(), e);
103:                                throw new LifeCycleCallbackException(
104:                                        "Cannot extract infos for the class with name "
105:                                                + beanClass.getName(), e);
106:                            }
107:                            // Register the informations in the repository of CMI
108:                            CMIInfoRepository.addClusteredObjectInfo(jndiName,
109:                                    infos);
110:                        }
111:                    }
112:                }
113:            }
114:
115:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.