Source Code Cross Referenced for ENCHelper.java in  » EJB-Server-geronimo » plugins » org » apache » geronimo » naming » deployment » 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.naming.deployment 
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.naming.deployment;
017:
018:        import java.util.HashMap;
019:        import java.util.Map;
020:        import javax.enterprise.deploy.model.DDBean;
021:        import javax.enterprise.deploy.spi.DConfigBean;
022:        import javax.enterprise.deploy.spi.exceptions.BeanNotFoundException;
023:        import javax.enterprise.deploy.spi.exceptions.ConfigurationException;
024:
025:        import org.apache.geronimo.xbeans.geronimo.naming.GerEjbLocalRefType;
026:        import org.apache.geronimo.xbeans.geronimo.naming.GerEjbRefType;
027:        import org.apache.geronimo.xbeans.geronimo.naming.GerResourceEnvRefType;
028:        import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType;
029:        import org.apache.xmlbeans.SchemaTypeLoader;
030:        import org.apache.xmlbeans.XmlBeans;
031:
032:        /**
033:         * @version $Rev: 495635 $ $Date: 2007-01-12 08:46:40 -0800 (Fri, 12 Jan 2007) $
034:         */
035:        public class ENCHelper {
036:            static final SchemaTypeLoader SCHEMA_TYPE_LOADER = XmlBeans
037:                    .typeLoaderUnion(new SchemaTypeLoader[] { XmlBeans
038:                            .typeLoaderForClassLoader(org.apache.geronimo.xbeans.javaee.String.class
039:                                    .getClassLoader()), });
040:
041:            public static final String[][] ENC_XPATHS = { { "ejb-ref" },
042:                    { "ejb-local-ref" }, { "resource-env-ref" },
043:                    { "resource-ref" }, };
044:
045:            public static final String[][] NAME_XPATHS = { { "ejb-ref-name" },
046:                    { "ejb-ref-name" }, { "resource-env-ref-name" },
047:                    { "res-ref-name" } };
048:
049:            private final String[] xpaths;
050:            private final String[] namePaths;
051:
052:            private RemoteRefDConfigBean[] ejbRefs;
053:
054:            private LocalRefDConfigBean[] ejbLocalRefs;
055:            private LocalRefDConfigBean[] resourceEnvRefs;
056:            private LocalRefDConfigBean[] resourceRefs;
057:
058:            public ENCHelper(DDBean ddBean, XmlEnvRefs envRefs,
059:                    String[] xpaths, String[] namePaths) {
060:                this .xpaths = xpaths;
061:                this .namePaths = namePaths;
062:                DDBean[] ddEjbRefs = ddBean.getChildBean(xpaths[0]);
063:                if (ddEjbRefs == null) {
064:                    ddEjbRefs = new DDBean[0];
065:                }
066:                ejbRefs = new RemoteRefDConfigBean[ddEjbRefs.length];
067:                GerEjbRefType[] xmlEjbRefs = envRefs.getEjbRefs();
068:                Map ejbRefMap = new HashMap();
069:                for (int i = 0; i < xmlEjbRefs.length; i++) {
070:                    GerEjbRefType refAdapter = xmlEjbRefs[i];
071:                    ejbRefMap.put(refAdapter.getRefName(), refAdapter);
072:                    //            envRefs.removeEjbRef(0);
073:                }
074:                //        for (int i = 0; i < ddEjbRefs.length; i++) {
075:                //            DDBean ddRef = ddEjbRefs[i];
076:                //            String name = ddRef.getText(namePaths[0])[0];
077:                //            GerRemoteRefType refAdapter;
078:                //            if (ejbRefMap.get(name) == null) {
079:                //                refAdapter = envRefs.addNewEjbRef();
080:                //                refAdapter.setRefName(name);
081:                //            } else {
082:                //                refAdapter = (GerRemoteRefType) ejbRefMap.get(name);
083:                //                envRefs.setEjbRef(i, refAdapter);
084:                //            }
085:                //            ejbRefs[i] = new RemoteRefDConfigBean(ddRef, refAdapter, namePaths[0]);
086:                //        }
087:                //
088:                //        DDBean[] ddEjbLocalRefs = ddBean.getChildBean(xpaths[1]);
089:                //        if (ddEjbLocalRefs == null) {
090:                //            ddEjbLocalRefs = new DDBean[0];
091:                //        }
092:                //        ejbLocalRefs = new LocalRefDConfigBean[ddEjbLocalRefs.length];
093:                //        GerLocalRefType[] xmlEjbLocalRefs = envRefs.getEjbLocalRefs();
094:                //        Map ejbLocalRefMap = new HashMap();
095:                //        for (int i = 0; i < xmlEjbLocalRefs.length; i++) {
096:                //            GerLocalRefType refAdapter = xmlEjbLocalRefs[i];
097:                //            ejbLocalRefMap.put(refAdapter.getRefName(), refAdapter);
098:                //            envRefs.removeEjbLocalRef(0);
099:                //        }
100:                //        for (int i = 0; i < ddEjbLocalRefs.length; i++) {
101:                //            DDBean ddRef = ddEjbLocalRefs[i];
102:                //            String name = ddRef.getText(namePaths[1])[0];
103:                //            GerLocalRefType refAdapter;
104:                //            if (ejbLocalRefMap.get(name) == null) {
105:                //                refAdapter = envRefs.addNewEjbLocalRef();
106:                //                refAdapter.setRefName(name);
107:                //            } else {
108:                //                refAdapter = (GerLocalRefType) ejbLocalRefMap.get(name);
109:                //                envRefs.setEjbLocalRef(i, refAdapter);
110:                //            }
111:                //            ejbLocalRefs[i] = new LocalRefDConfigBean(ddRef, refAdapter, namePaths[1]);
112:                //        }
113:                //
114:                //
115:                //        DDBean[] ddResourceEnvRefs = ddBean.getChildBean(xpaths[2]);
116:                //        if (ddResourceEnvRefs == null) {
117:                //            ddResourceEnvRefs = new DDBean[0];
118:                //        }
119:                //        resourceEnvRefs = new LocalRefDConfigBean[ddResourceEnvRefs.length];
120:                //        GerLocalRefType[] xmlResourceEnvRefs = envRefs.getResourceEnvRefs();
121:                //        Map resourceEnvRefMap = new HashMap();
122:                //        for (int i = 0; i < xmlResourceEnvRefs.length; i++) {
123:                //            GerLocalRefType refAdapter = xmlResourceEnvRefs[i];
124:                //            resourceEnvRefMap.put(refAdapter.getRefName(), refAdapter);
125:                //            envRefs.removeResourceEnvRef(0);
126:                //        }
127:                //        for (int i = 0; i < ddResourceEnvRefs.length; i++) {
128:                //            DDBean ddRef = ddResourceEnvRefs[i];
129:                //            String name = ddRef.getText(namePaths[2])[0];
130:                //            GerLocalRefType refAdapter;
131:                //            if (resourceEnvRefMap.get(name) == null) {
132:                //                refAdapter = envRefs.addNewResourceEnvRef();
133:                //                refAdapter.setRefName(name);
134:                //            } else {
135:                //                refAdapter = (GerLocalRefType) resourceEnvRefMap.get(name);
136:                //                envRefs.setResourceEnvRef(i, refAdapter);
137:                //            }
138:                //            resourceEnvRefs[i] = new LocalRefDConfigBean(ddRef, refAdapter, namePaths[2]);
139:                //        }
140:                //
141:                //        DDBean[] ddResourceRefs = ddBean.getChildBean(xpaths[3]);
142:                //        if (ddResourceRefs == null) {
143:                //            ddResourceRefs = new DDBean[0];
144:                //        }
145:                //        resourceRefs = new LocalRefDConfigBean[ddResourceRefs.length];
146:                //        GerLocalRefType[] xmlResourceRefs = envRefs.getResourceRefs();
147:                //        Map resourceRefMap = new HashMap();
148:                //        for (int i = 0; i < xmlResourceRefs.length; i++) {
149:                //            GerLocalRefType refAdapter = xmlResourceRefs[i];
150:                //            resourceRefMap.put(refAdapter.getRefName(), refAdapter);
151:                //            envRefs.removeResourceRef(0);
152:                //        }
153:                //        for (int i = 0; i < ddResourceRefs.length; i++) {
154:                //            DDBean ddRef = ddResourceRefs[i];
155:                //            String name = ddRef.getText(namePaths[3])[0];
156:                //            GerLocalRefType refAdapter;
157:                //            if (resourceRefMap.get(name) == null) {
158:                //                refAdapter = envRefs.addNewResourceRef();
159:                //                refAdapter.setRefName(name);
160:                //            } else {
161:                //                refAdapter = (GerLocalRefType) resourceRefMap.get(name);
162:                //                envRefs.setResourceRef(i, refAdapter);
163:                //            }
164:                //            resourceRefs[i] = new LocalRefDConfigBean(ddRef, refAdapter, namePaths[3]);
165:                //        }
166:
167:            }
168:
169:            public DConfigBean getDConfigBean(DDBean ddBean)
170:                    throws ConfigurationException {
171:                String xpath = ddBean.getXpath();
172:                if (xpath.equals(xpaths[0])) {
173:                    String name = ddBean.getText(namePaths[0])[0];
174:                    for (int i = 0; i < ejbRefs.length; i++) {
175:                        RemoteRefDConfigBean ejbRef = ejbRefs[i];
176:                        if (ejbRef.getRefName().equals(name)) {
177:                            return ejbRef;
178:                        }
179:                    }
180:                    throw new ConfigurationException("no such ejb-ref-name"
181:                            + name);
182:                } else if (xpath.equals(xpaths[1])) {
183:                    String name = ddBean.getText(namePaths[1])[0];
184:                    for (int i = 0; i < ejbLocalRefs.length; i++) {
185:                        LocalRefDConfigBean ejbLocalRef = ejbLocalRefs[i];
186:                        if (ejbLocalRef.getRefName().equals(name)) {
187:                            return ejbLocalRef;
188:                        }
189:                    }
190:                    throw new ConfigurationException("no such ejb-ref-name"
191:                            + name);
192:                } else if (xpath.equals(xpaths[2])) {
193:                    String name = ddBean.getText(namePaths[2])[0];
194:                    for (int i = 0; i < resourceEnvRefs.length; i++) {
195:                        LocalRefDConfigBean resourceEnvRef = resourceEnvRefs[i];
196:                        if (resourceEnvRef.getRefName().equals(name)) {
197:                            return resourceEnvRef;
198:                        }
199:                    }
200:                    throw new ConfigurationException("no such ejb-ref-name"
201:                            + name);
202:                } else if (xpath.equals(xpaths[3])) {
203:                    String name = ddBean.getText(namePaths[3])[0];
204:                    for (int i = 0; i < resourceRefs.length; i++) {
205:                        LocalRefDConfigBean resourceRef = resourceRefs[i];
206:                        if (resourceRef.getRefName().equals(name)) {
207:                            return resourceRef;
208:                        }
209:                    }
210:                    throw new ConfigurationException("no such res-ref-name"
211:                            + name);
212:                } else {
213:                    throw new ConfigurationException("Unrecognized XPath: "
214:                            + ddBean.getXpath());
215:                }
216:            }
217:
218:            public void removeDConfigBean(DConfigBean dcBean)
219:                    throws BeanNotFoundException {
220:                //          DDBean ddBean = dcBean.getDDBean();
221:                //          String xpath = ddBean.getXpath();
222:                //          String name = ddBean.getText();
223:                /*
224:                      if (xpath.endsWith("ejb-ref/ejb-ref-name")) {
225:                          if (ejbRefs.remove(name) == null) {
226:                              throw new BeanNotFoundException("No DConfigBean found with name: " + name);
227:                          }
228:                      } else if (xpath.endsWith("ejb-local-ref/ejb-ref-name")) {
229:                          if (ejbLocalRefs.remove(name) == null) {
230:                              throw new BeanNotFoundException("No DConfigBean found with name: " + name);
231:                          }
232:                      } else if (xpath.endsWith("service-ref/service-ref-name")) {
233:                          if (serviceRefs.remove(name) == null) {
234:                              throw new BeanNotFoundException("No DConfigBean found with name: " + name);
235:                          }
236:                      } else if (xpath.endsWith("resource-ref/res-ref-name")) {
237:                          if (resourceRefs.remove(name) == null) {
238:                              throw new BeanNotFoundException("No DConfigBean found with name: " + name);
239:                          }
240:                      } else {
241:                          throw new BeanNotFoundException("Unrecognized XPath: " + xpath);
242:                      }
243:                 */
244:            }
245:
246:            public static class XmlEnvRefs {
247:                private final GerEjbRefType[] ejbRefs;
248:                private final GerEjbLocalRefType[] ejbLocalRefs;
249:                private final GerResourceRefType[] resourceRefs;
250:                private final GerResourceEnvRefType[] resourceEnvRefs;
251:
252:                public XmlEnvRefs(GerEjbRefType[] ejbRefs,
253:                        GerEjbLocalRefType[] ejbLocalRefs,
254:                        GerResourceRefType[] resourceRefs,
255:                        GerResourceEnvRefType[] resourceEnvRefs) {
256:                    this .ejbRefs = ejbRefs;
257:                    this .ejbLocalRefs = ejbLocalRefs;
258:                    this .resourceRefs = resourceRefs;
259:                    this .resourceEnvRefs = resourceEnvRefs;
260:                }
261:
262:                public GerEjbRefType[] getEjbRefs() {
263:                    return ejbRefs;
264:                }
265:
266:                public GerEjbLocalRefType[] getEjbLocalRefs() {
267:                    return ejbLocalRefs;
268:                }
269:
270:                public GerResourceRefType[] getResourceRefs() {
271:                    return resourceRefs;
272:                }
273:
274:                public GerResourceEnvRefType[] getResourceEnvRefs() {
275:                    return resourceEnvRefs;
276:                }
277:
278:            }
279:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.