Source Code Cross Referenced for StatelessInterceptedBean.java in  » J2EE » openejb3 » org » apache » openejb » test » stateless » 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 » openejb3 » org.apache.openejb.test.stateless 
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.openejb.test.stateless;
017:
018:        import java.util.Map;
019:        import java.util.LinkedHashMap;
020:
021:        import javax.annotation.PostConstruct;
022:        import javax.annotation.PreDestroy;
023:        import javax.ejb.Stateless;
024:        import javax.interceptor.AroundInvoke;
025:        import javax.interceptor.ExcludeClassInterceptors;
026:        import javax.interceptor.ExcludeDefaultInterceptors;
027:        import javax.interceptor.Interceptors;
028:        import javax.interceptor.InvocationContext;
029:
030:        import org.apache.openejb.test.SuperInterceptedBean;
031:        import org.apache.openejb.test.interceptor.ClassInterceptor;
032:        import org.apache.openejb.test.interceptor.Interceptor;
033:        import org.apache.openejb.test.interceptor.MethodInterceptor;
034:
035:        /**
036:         * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 $
037:         */
038:        @Stateless(name="StatelessIntercepted")
039:        @Interceptors({ClassInterceptor.class})
040:        public class StatelessInterceptedBean extends SuperInterceptedBean
041:                implements  BasicStatelessInterceptedLocal,
042:                BasicStatelessInterceptedRemote {
043:
044:            private static Map<String, Object> contextData = new LinkedHashMap<String, Object>();
045:
046:            /**
047:             * A simple dummy business method to concat 2 strings
048:             * @see org.apache.openejb.test.stateless.BasicStatelessInterceptedLocal#concat(java.lang.String, java.lang.String)
049:             */
050:            public String concat(String str1, String str2) {
051:                return str1.concat(str2);
052:            }
053:
054:            /**
055:             * A simple dummy busines method to reverse a string
056:             * @see org.apache.openejb.test.stateless.BasicStatelessInterceptedLocal#reverse(java.lang.String)
057:             */
058:            @Interceptors({MethodInterceptor.class})
059:            public String reverse(String str) {
060:                if (str.length() > 0) {
061:                    throw new NullPointerException();
062:                }
063:                StringBuffer b = new StringBuffer(str);
064:                return b.reverse().toString();
065:            }
066:
067:            /**
068:             * @param ctxData the contextData to set
069:             */
070:            private void setContextData(Map<String, Object> ctxData) {
071:                StatelessInterceptedBean.contextData.putAll(ctxData);
072:            }
073:
074:            /**
075:             * <code>ClassInterceptor</code> should not intercept this.
076:             * 
077:             * @return the contextData
078:             */
079:            @ExcludeDefaultInterceptors
080:            @ExcludeClassInterceptors
081:            public Map<String, Object> getContextData() {
082:                return contextData;
083:            }
084:
085:            /**
086:             * The interceptor method. 
087:             * This should intercept all business methods in this bean class.
088:             * It cannot exclude even those annotated with <code>@ExcludeClassInterceptors</code>
089:             * 
090:             * @param ctx - InvocationContext
091:             * 
092:             * @return - the result of the next method invoked. If a method returns void, proceed returns null. 
093:             * For lifecycle callback interceptor methods, if there is no callback method defined on the bean class, 
094:             * the invocation of proceed in the last interceptor method in the chain is a no-op, and null is returned. 
095:             * If there is more than one such interceptor method, the invocation of proceed causes the container to execute those methods in order.
096:             * 
097:             * @throws Exception runtime exceptions or application exceptions that are allowed in the throws clause of the business method.
098:             */
099:            @AroundInvoke
100:            public Object inBeanInterceptor(InvocationContext ctx)
101:                    throws Exception {
102:                Map<String, Object> ctxData = Interceptor.profile(ctx,
103:                        "inBeanInterceptor");
104:                setContextData(ctxData);
105:
106:                return ctx.proceed();
107:            }
108:
109:            /**
110:             * The interceptor method. 
111:             * This should intercept postConstruct of the bean
112:             * 
113:             * @throws Exception runtime exceptions.
114:             */
115:            @PostConstruct
116:            public void inBeanInterceptorPostConstruct() throws Exception {
117:                Map<String, Object> ctxData = Interceptor.profile(this ,
118:                        "inBeanInterceptorPostConstruct");
119:                setContextData(ctxData);
120:            }
121:
122:            /**
123:             * The interceptor method. 
124:             * This should intercept preDestroy of the bean.
125:             * 
126:             * @throws Exception runtime exceptions.
127:             */
128:            @PreDestroy
129:            public void inBeanInterceptorPreDestroy() throws Exception {
130:                Map<String, Object> ctxData = Interceptor.profile(this ,
131:                        "inBeanInterceptorPreDestroy");
132:                setContextData(ctxData);
133:            }
134:
135:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.