Source Code Cross Referenced for EjbRefTracker.java in  » IDE-Netbeans » visualweb.api.designer » org » netbeans » modules » visualweb » ejb » 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 » IDE Netbeans » visualweb.api.designer » org.netbeans.modules.visualweb.ejb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:        /*
042:         * EjbRefTracker.java
043:         *
044:         * Created on March 23, 2005, 11:24 PM
045:         */
046:
047:        package org.netbeans.modules.visualweb.ejb;
048:
049:        import org.netbeans.modules.visualweb.ejb.datamodel.EjbContainerVendor;
050:        import org.netbeans.modules.visualweb.ejb.datamodel.EjbGroup;
051:        import org.netbeans.modules.visualweb.ejb.datamodel.EjbInfo;
052:        import java.util.ArrayList;
053:        import java.util.Iterator;
054:        import javax.xml.parsers.DocumentBuilder;
055:        import javax.xml.parsers.DocumentBuilderFactory;
056:        import org.netbeans.api.project.Project; //This was a hacker. Can not use it anymore
057:        //import org.netbeans.modules.j2ee.deployment.devmodules.spi.RequestedEjbResource;
058:        import org.netbeans.spi.project.AuxiliaryConfiguration;
059:        import org.openide.ErrorManager;
060:        import org.w3c.dom.Document;
061:        import org.w3c.dom.Element;
062:        import org.w3c.dom.NodeList;
063:
064:        /**
065:         *
066:         * @author  cao
067:         */
068:        public class EjbRefTracker {
069:            private static final String EJB_DATASOURCE_ELEMENT_NAME = "ejb-data-sources"; // NOI18N
070:            private static final String EJB_DATASOURCE_ELEMENT_NAMESPACE = "http://creator.sun.com/project/ejb-datasfdsources"; // NOI18N
071:
072:            /*public static RequestedEjbResource[] getRequestedEjbResources( Project project ) 
073:            {
074:                AuxiliaryConfiguration projectAux = (AuxiliaryConfiguration)project.getLookup().lookup(AuxiliaryConfiguration.class) ;
075:                if ( projectAux == null ) {
076:                    ErrorManager.getDefault().getInstance( "org.netbeans.modules.visualweb.ejb.nodes.SessionBeanNode" ).log( ErrorManager.ERROR, "no AuxiliaryConfiguration.class implementation for Project "+ project ) ; // NOI18N
077:                } else {
078:                    ErrorManager.getDefault().getInstance( "org.netbeans.modules.visualweb.ejb.nodes.SessionBeanNode" ).log( ErrorManager.INFORMATIONAL, "we have an AuxiliaryConfiguration") ; // NOI18N
079:                }
080:                Element ejbdatasourceElement = projectAux.getConfigurationFragment(EJB_DATASOURCE_ELEMENT_NAME, EJB_DATASOURCE_ELEMENT_NAMESPACE, false) ;
081:                
082:                if ( ejbdatasourceElement != null ) {
083:                    ErrorManager.getDefault().getInstance( "org.netbeans.modules.visualweb.ejb.nodes.SessionBeanNode" ).log( ErrorManager.INFORMATIONAL, "Restoring ejb datasoruce for " + project ) ;
084:                    
085:                    String tagName = ejbdatasourceElement.getTagName();
086:                    
087:                    ArrayList ejbResources = new ArrayList();
088:                    NodeList groupNodeList = ejbdatasourceElement.getElementsByTagName( "ejb-group"); 
089:                    for( int i = 0; i < groupNodeList.getLength(); i ++ )
090:                    {
091:                        Element grpElement = (Element)groupNodeList.item( i );
092:                        
093:                        Element groupNameElement = (Element)grpElement.getElementsByTagName( "group-name" ).item( 0 );
094:                        
095:                        Element containerElement = (Element)grpElement.getElementsByTagName( "container" ).item( 0 );
096:                        String appServer = containerElement.getFirstChild().getNodeValue();
097:                        
098:                        Element serverHostElement = (Element)grpElement.getElementsByTagName( "server-host" ).item( 0 );
099:                        String hostName = serverHostElement.getFirstChild().getNodeValue();
100:                        
101:                        Element iiopElement = (Element)grpElement.getElementsByTagName( "iiop-port" ).item( 0 );
102:                        String iiop = iiopElement.getFirstChild().getNodeValue();
103:                        
104:                        Element ejbsElement = (Element)grpElement.getElementsByTagName( "enterprise-beans" ).item( 0 );
105:                        // TODO stateful-session too
106:                        NodeList ejbNodeList = ejbsElement.getElementsByTagName( "stateless-session" ); 
107:                        for( int ei = 0; ei < ejbNodeList.getLength(); ei ++ ) 
108:                        {
109:                            Element ejbElement = (Element)ejbNodeList.item( ei );
110:                            
111:                            Element homeElement = (Element)ejbElement.getElementsByTagName( "home").item( 0 );
112:                            String home = homeElement.getFirstChild().getNodeValue();
113:                            
114:                            Element remoteElement = (Element)ejbElement.getElementsByTagName( "remote").item( 0 );
115:                            String remote = remoteElement.getFirstChild().getNodeValue();
116:                            
117:                            Element ejbRefElement = (Element)ejbElement.getElementsByTagName( "web-ejb-ref").item( 0 ); 
118:                            String refName = ejbRefElement.getFirstChild().getNodeValue();
119:                            
120:                            // The global JNDI name for this EJB
121:                            //  - corbaname:iiop:<hostname>:<port>#<jndiname> for Sun Application server, weblogic
122:                            //  - corbaname:iiop:<hostname>:<port>/NameServiceServerRoot#<jndiname> for websphere 5.1
123:                            Element jndiNameElement = (Element)ejbElement.getElementsByTagName( "jndi-name" ).item( 0 );
124:                            String jndiName = jndiNameElement.getFirstChild().getNodeValue();
125:                            
126:                            String globalJndiName = "corbaname:iiop:" + hostName + ":" + iiop + "#" + jndiName;
127:                            if( appServer.equals( EjbContainerVendor.WEBSPHERE_5_1 ) )
128:                                globalJndiName = "corbaname:iiop:" + hostName + ":" + iiop + "/NameServiceServerRoot#" + jndiName;
129:                            
130:                            // TODO should use global JDNI name 
131:                            ejbResources.add(  new RequestedEjbResource( refName, jndiName, "Session", home, remote ) );
132:                        } 
133:                    }
134:                    
135:                    return (RequestedEjbResource[])ejbResources.toArray( new RequestedEjbResource[0] );
136:                }
137:                else
138:                    return new RequestedEjbResource[0];
139:            }*/
140:
141:            public static void AddEjbDataSourcesToProject(Project project,
142:                    EjbGroup ejbGroup) {
143:                // Get the AuxiliaryConfiguration
144:                AuxiliaryConfiguration projectAux = (AuxiliaryConfiguration) project
145:                        .getLookup().lookup(AuxiliaryConfiguration.class);
146:                if (projectAux == null) {
147:                    ErrorManager
148:                            .getDefault()
149:                            .getInstance(
150:                                    "org.netbeans.modules.visualweb.ejb.nodes.SessionBeanNode")
151:                            .log(
152:                                    ErrorManager.ERROR,
153:                                    "no AuxiliaryConfiguration.class implementation for Project "
154:                                            + project); // NOI18N
155:                } else {
156:                    ErrorManager
157:                            .getDefault()
158:                            .getInstance(
159:                                    "org.netbeans.modules.visualweb.ejb.nodes.SessionBeanNode")
160:                            .log(ErrorManager.INFORMATIONAL,
161:                                    "we have an AuxiliaryConfiguration"); // NOI18N
162:                }
163:
164:                try {
165:                    Element ejbdatasourceElement = projectAux
166:                            .getConfigurationFragment(
167:                                    EJB_DATASOURCE_ELEMENT_NAME,
168:                                    EJB_DATASOURCE_ELEMENT_NAMESPACE, false);
169:
170:                    Document doc = null;
171:                    // No such thing yet, create one now
172:                    if (ejbdatasourceElement == null) {
173:                        DocumentBuilderFactory docFactory = DocumentBuilderFactory
174:                                .newInstance();
175:                        DocumentBuilder db = docFactory.newDocumentBuilder();
176:                        doc = db.newDocument();
177:                        ejbdatasourceElement = doc.createElementNS(
178:                                EJB_DATASOURCE_ELEMENT_NAMESPACE,
179:                                EJB_DATASOURCE_ELEMENT_NAME);
180:                        doc.appendChild(ejbdatasourceElement);
181:                    } else {
182:                        doc = ejbdatasourceElement.getOwnerDocument();
183:
184:                        NodeList groupNodeList = ejbdatasourceElement
185:                                .getElementsByTagName("ejb-group");
186:                        for (int i = 0; i < groupNodeList.getLength(); i++) {
187:                            Element grpElement = (Element) groupNodeList
188:                                    .item(i);
189:
190:                            Element groupName = (Element) grpElement
191:                                    .getElementsByTagName("group-name").item(0);
192:                            if (groupName.getFirstChild().getNodeValue()
193:                                    .equals(ejbGroup.getName()))
194:                                ejbdatasourceElement.removeChild(grpElement);
195:                        }
196:                    }
197:
198:                    Element group = doc.createElement("ejb-group");
199:                    ejbdatasourceElement.appendChild(group);
200:
201:                    // Child node of ejb-group: group-name
202:                    Element groupName = doc.createElement("group-name");
203:                    groupName.appendChild(doc
204:                            .createTextNode(ejbGroup.getName()));
205:                    group.appendChild(groupName);
206:
207:                    // Child node of ejb-group: container
208:                    Element container = doc.createElement("container");
209:                    container.appendChild(doc.createTextNode(ejbGroup
210:                            .getAppServerVendor()));
211:                    group.appendChild(container);
212:
213:                    // Child node of ejb-group: server-host
214:                    Element serverHost = doc.createElement("server-host");
215:                    serverHost.appendChild(doc.createTextNode(ejbGroup
216:                            .getServerHost()));
217:                    group.appendChild(serverHost);
218:
219:                    // Child node of ejb-group: iiop-port
220:                    Element iiop = doc.createElement("iiop-port");
221:                    iiop.appendChild(doc.createTextNode(Integer
222:                            .toString(ejbGroup.getIIOPPort())));
223:                    group.appendChild(iiop);
224:
225:                    // Child node of ejb-group: enterprise-beans
226:                    Element ejbs = doc.createElement("enterprise-beans");
227:                    group.appendChild(ejbs);
228:
229:                    // Child node of enterprise-beans: one per ejb
230:                    for (Iterator iter = ejbGroup.getSessionBeans().iterator(); iter
231:                            .hasNext();) {
232:                        EjbInfo ejbInfo = (EjbInfo) iter.next();
233:                        String tagName = "stateless-session";
234:                        if (!ejbInfo.isStatelessSessionBean())
235:                            tagName = "stateful-session";
236:
237:                        Element ejb = doc.createElement(tagName);
238:                        ejbs.appendChild(ejb);
239:
240:                        // Child node of stateless-session or stateful-session: jndi-name
241:                        Element jndiName = doc.createElement("jndi-name");
242:                        jndiName.appendChild(doc.createTextNode(ejbInfo
243:                                .getJNDIName()));
244:                        ejb.appendChild(jndiName);
245:
246:                        // Child node of stateless-session or stateful-session: ejb-name
247:                        Element ejbName = doc.createElement("ejb-name");
248:                        ejbName.appendChild(doc.createTextNode(ejbInfo
249:                                .getEjbName()));
250:                        ejb.appendChild(ejbName);
251:
252:                        // Child node of stateless-session or stateful-session: home
253:                        Element home = doc.createElement("home");
254:                        home.appendChild(doc.createTextNode(ejbInfo
255:                                .getHomeInterfaceName()));
256:                        ejb.appendChild(home);
257:
258:                        // Child node of stateless-session or stateful-session: remote
259:                        Element remote = doc.createElement("remote");
260:                        remote.appendChild(doc.createTextNode(ejbInfo
261:                                .getCompInterfaceName()));
262:                        ejb.appendChild(remote);
263:
264:                        // Child node of stateless-session or stateful-session: web-ejb-ref
265:                        Element webRef = doc.createElement("web-ejb-ref");
266:                        webRef.appendChild(doc.createTextNode(ejbInfo
267:                                .getWebEjbRef()));
268:                        ejb.appendChild(webRef);
269:                    }
270:
271:                    ErrorManager
272:                            .getDefault()
273:                            .getInstance(
274:                                    "org.netbeans.modules.visualweb.ejb.nodes.SessionBeanNode")
275:                            .log(ErrorManager.INFORMATIONAL,
276:                                    "new proj element for hard datasources created.");
277:
278:                    //ejbdatasourceElement.setAttribute( "value", "EJB-DATASOURCES GO HERE" ) ; // NOI18N
279:                    projectAux.putConfigurationFragment(ejbdatasourceElement,
280:                            false);
281:                } catch (javax.xml.parsers.ParserConfigurationException pce) {
282:                    // seriously screwed up.
283:                    ErrorManager
284:                            .getDefault()
285:                            .getInstance(
286:                                    "org.netbeans.modules.visualweb.ejb.nodes.SessionBeanNode")
287:                            .log(ErrorManager.ERROR,
288:                                    "could not create the document element for saving HC DS"); // NOI18N
289:                }
290:            }
291:
292:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.