Source Code Cross Referenced for AdminObjectWrapper.java in  » EJB-Server-geronimo » plugins » org » apache » geronimo » connector » 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.connector 
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.connector;
017:
018:        import java.lang.reflect.Constructor;
019:        import java.util.HashMap;
020:        import java.util.Map;
021:
022:        import org.apache.geronimo.gbean.AbstractName;
023:        import org.apache.geronimo.gbean.DynamicGBean;
024:        import org.apache.geronimo.gbean.DynamicGBeanDelegate;
025:        import org.apache.geronimo.naming.ResourceSource;
026:        import org.apache.geronimo.kernel.Kernel;
027:        import org.apache.geronimo.management.geronimo.JCAAdminObject;
028:
029:        /**
030:         * Wrapper around AdminObject that exposes its config-properties as GBeanAttributes and
031:         * supplies a disconnectable proxy to bind in jndi.
032:         *
033:         * @version $Rev: 607943 $ $Date: 2008-01-01 15:07:17 -0800 (Tue, 01 Jan 2008) $
034:         */
035:        public class AdminObjectWrapper implements  DynamicGBean,
036:                JCAAdminObject, ResourceSource<RuntimeException> {
037:
038:            private final String adminObjectInterface;
039:            private final String adminObjectClass;
040:
041:            private final DynamicGBeanDelegate delegate;
042:            private final Object adminObject;
043:
044:            private final Kernel kernel;
045:            private final AbstractName abstractName;
046:            private final String objectName;
047:
048:            /**
049:             * Default constructor required when a class is used as a GBean Endpoint.
050:             */
051:            public AdminObjectWrapper() {
052:                adminObjectInterface = null;
053:                adminObjectClass = null;
054:                adminObject = null;
055:                delegate = null;
056:                kernel = null;
057:                abstractName = null;
058:                objectName = null;
059:            }
060:
061:            /**
062:             * Normal managed constructor.
063:             *
064:             * @param adminObjectInterface Interface the proxy will implement.
065:             * @param adminObjectClass Class of admin object to be wrapped.
066:             * @throws IllegalAccessException
067:             * @throws InstantiationException
068:             */
069:            public AdminObjectWrapper(final String adminObjectInterface,
070:                    final String adminObjectClass, final Kernel kernel,
071:                    final AbstractName abstractName, final String objectName,
072:                    final ClassLoader cl) throws IllegalAccessException,
073:                    InstantiationException, ClassNotFoundException {
074:                this .adminObjectInterface = adminObjectInterface;
075:                this .adminObjectClass = adminObjectClass;
076:                this .kernel = kernel;
077:                this .abstractName = abstractName;
078:                this .objectName = objectName;
079:                Class clazz = cl.loadClass(adminObjectClass);
080:                adminObject = clazz.newInstance();
081:                delegate = new DynamicGBeanDelegate();
082:                delegate.addAll(adminObject);
083:            }
084:
085:            public String getAdminObjectInterface() {
086:                return adminObjectInterface;
087:            }
088:
089:            /**
090:             * Returns class of wrapped AdminObject.
091:             * @return class of wrapped AdminObject
092:             */
093:            public String getAdminObjectClass() {
094:                return adminObjectClass;
095:            }
096:
097:            /**
098:             * Returns disconnectable proxy for binding in jndi.
099:             * @return proxy implementing adminObjectInterface.
100:             */
101:            public Object $getResource() {
102:                return adminObject;
103:            }
104:
105:            //DynamicGBean implementation
106:
107:            /**
108:             * Delegating DynamicGBean getAttribute method.
109:             * @param name of attribute.
110:             * @return attribute value.
111:             * @throws Exception
112:             */
113:            public Object getAttribute(final String name) throws Exception {
114:                return delegate.getAttribute(name);
115:            }
116:
117:            /**
118:             * Delegating DynamicGBean setAttribute method.
119:             * @param name of attribute.
120:             * @param value of attribute to be set.
121:             * @throws Exception
122:             */
123:            public void setAttribute(final String name, final Object value)
124:                    throws Exception {
125:                delegate.setAttribute(name, value);
126:            }
127:
128:            /**
129:             * no-op DynamicGBean method
130:             * @param name
131:             * @param arguments
132:             * @param types
133:             * @return nothing, there are no operations.
134:             * @throws Exception
135:             */
136:            public Object invoke(final String name, final Object[] arguments,
137:                    final String[] types) throws Exception {
138:                //we have no dynamic operations.
139:                return null;
140:            }
141:
142:            /**
143:             * Gets the config properties in the form of a map where the key is the
144:             * property name and the value is property type (as a String not a Class).
145:             */
146:            public Map getConfigProperties() {
147:                String[] props = delegate.getProperties();
148:                Map map = new HashMap();
149:                for (int i = 0; i < props.length; i++) {
150:                    String prop = props[i];
151:                    if (prop.equals("logWriter")) {
152:                        continue;
153:                    }
154:                    map.put(prop, delegate.getPropertyType(prop));
155:                }
156:                return map;
157:            }
158:
159:            public void setConfigProperty(String property, Object value)
160:                    throws Exception {
161:                Class cls = delegate.getPropertyType(property);
162:                if (value != null && value instanceof  String
163:                        && !cls.getName().equals("java.lang.String")) {
164:                    if (cls.isPrimitive()) {
165:                        if (cls.equals(int.class)) {
166:                            cls = Integer.class;
167:                        } else if (cls.equals(boolean.class)) {
168:                            cls = Boolean.class;
169:                        } else if (cls.equals(float.class)) {
170:                            cls = Float.class;
171:                        } else if (cls.equals(double.class)) {
172:                            cls = Double.class;
173:                        } else if (cls.equals(long.class)) {
174:                            cls = Long.class;
175:                        } else if (cls.equals(short.class)) {
176:                            cls = Short.class;
177:                        } else if (cls.equals(byte.class)) {
178:                            cls = Byte.class;
179:                        } else if (cls.equals(char.class)) {
180:                            cls = Character.class;
181:                        }
182:                    }
183:                    Constructor con = cls
184:                            .getConstructor(new Class[] { String.class });
185:                    value = con.newInstance(new Object[] { value });
186:                }
187:                kernel.setAttribute(abstractName, property, value);
188:            }
189:
190:            public Object getConfigProperty(String property) throws Exception {
191:                return delegate.getAttribute(property);
192:            }
193:
194:            public String getObjectName() {
195:                return objectName;
196:            }
197:
198:            public boolean isStateManageable() {
199:                return false;
200:            }
201:
202:            public boolean isStatisticsProvider() {
203:                return false;
204:            }
205:
206:            public boolean isEventProvider() {
207:                return false;
208:            }
209:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.