KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > share > configbean > SessionEjb


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.j2ee.sun.share.configbean;
21
22 import java.beans.PropertyVetoException JavaDoc;
23 import java.util.ArrayList JavaDoc;
24 import java.util.Collection JavaDoc;
25 import java.util.List JavaDoc;
26 import javax.enterprise.deploy.model.DDBean JavaDoc;
27 import javax.enterprise.deploy.model.XpathEvent JavaDoc;
28
29 import org.netbeans.modules.j2ee.sun.dd.api.CommonDDBean;
30 import org.netbeans.modules.j2ee.sun.dd.api.ejb.Ejb;
31
32 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.ejbmodule.DummyMethod;
33 import org.openide.ErrorManager;
34
35
36 /**
37  *
38  * @author rajeshwar patil
39  */

40 abstract public class SessionEjb extends BaseEjb implements WebserviceOperationListInterface {
41
42     /** Creates a new instance of SessionEjb */
43     public SessionEjb() {
44     }
45
46     
47     /* ------------------------------------------------------------------------
48      * Persistence support. Loads DConfigBeans from previously saved Deployment
49      * plan file.
50      */

51     protected class SessionEjbSnippet extends BaseEjb.BaseEjbSnippet {
52         public CommonDDBean getDDSnippet() {
53             Ejb ejb = (Ejb) super.getDDSnippet();
54             return ejb;
55         }
56
57         public boolean hasDDSnippet() {
58             if(super.hasDDSnippet()) {
59                 return true;
60             }
61             return false;
62         }
63     }
64
65     Collection JavaDoc getSnippets() {
66         Collection JavaDoc snippets = new ArrayList JavaDoc();
67         snippets.add(new SessionEjbSnippet());
68         return snippets;
69     }
70
71     protected void loadEjbProperties(Ejb savedEjb) {
72         super.loadEjbProperties(savedEjb);
73     }
74
75     protected void clearProperties() {
76         super.clearProperties();
77     }
78     
79     protected void setDefaultProperties() {
80         super.setDefaultProperties();
81     }
82     
83     public void fireXpathEvent(XpathEvent JavaDoc xpathEvent) {
84         super.fireXpathEvent(xpathEvent);
85 // dumpNotification("SessionEjb.fireXpathEvent", xpathEvent);
86

87         DDBean JavaDoc eventBean = xpathEvent.getBean();
88         String JavaDoc xpath = eventBean.getXpath();
89
90         if("/ejb-jar/enterprise-beans/session/remote".equals(xpath)) { // NOI18N
91
try {
92                 if(xpathEvent.isAddEvent()) {
93                     // Only set JNDI name automatically for pre-EJB 3.0 beans. We don't use
94
// requiresJndiName() here because that we only want to confirm the version
95
// and that method has more logic.
96
if(EjbJarVersion.EJBJAR_2_1.compareTo(getJ2EEModuleVersion()) >= 0 ) {
97                         setJndiName(getDefaultJndiName());
98                     }
99                 } else if(xpathEvent.isRemoveEvent()) {
100                     setJndiName(null);
101                 }
102             } catch(PropertyVetoException JavaDoc ex) {
103                 // should never happen.
104
ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
105             }
106         }
107     }
108     
109         //Methods of WebserviceOperationListInterface
110
//get all the mehods in the given webservice endpoint
111
public List JavaDoc getOperations(String JavaDoc portInfoName){
112             if(portInfoName.equals("first")){
113                 //XXX dummy impementation; replace by real one
114
//returning a list of java.lang.reflect.Method objects
115
//change later to return a list of real *Method* objects.
116
//*Method* objects could be netbeans Method object
117
ArrayList JavaDoc methods = new ArrayList JavaDoc();
118                 DummyMethod method = new DummyMethod();
119                 method.setName("FirstMethod");
120                 String JavaDoc[] params = {"int"};
121                 method.setParameterTypes(params);
122                 method.setIsMethod(true);
123                 methods.add(method);
124
125                 DummyMethod method2 = new DummyMethod();
126                 method2.setName("SecondMethod");
127                 String JavaDoc[] params2 = {"int", "String"};
128                 method2.setParameterTypes(params2);
129                 method2.setIsMethod(true);
130                 methods.add(method2);
131                 
132                 DummyMethod method3 = new DummyMethod();
133                 method3.setName("ThirdMethod");
134                 method3.setIsMethod(false);
135                 methods.add(method3);
136                 return methods;
137             }else{
138                 ArrayList JavaDoc methods = new ArrayList JavaDoc();
139                 DummyMethod method = new DummyMethod();
140                 method.setName("FirstMethod");
141                 String JavaDoc[] params = {"String"};
142                 method.setParameterTypes(params);
143                 methods.add(method);
144                 return methods;
145             }
146         }
147
148
149     /** Api to retrieve the interface definitions for this bean. Aids usability
150      * during configuration, as the editors can display the existing methds
151      * rather than have the user enter them manually.
152      */

153     public java.util.List JavaDoc/*ConfigQuery.MethodData*/ getServiceOperations(String JavaDoc portComponentName) {
154         /* !PW FIXME Temporary implementation values until plumbing in j2eeserver is worked out.
155          */

156         java.util.List JavaDoc operationList = new ArrayList JavaDoc();
157         operationList.add(new ConfigQuery.MethodData("ejb_ws_operation1", java.util.Arrays.asList(new String JavaDoc [] { "arg1", "arg2" } )));
158         operationList.add(new ConfigQuery.MethodData("ejb_ws_operation2", java.util.Arrays.asList(new String JavaDoc [] { "arg1" } )));
159         operationList.add(new ConfigQuery.MethodData("ejb_ws_operation3", java.util.Arrays.asList(new String JavaDoc [] { "arg1", "arg2", "arg3" } )));
160         return operationList;
161     }
162 }
163
Popular Tags