KickJava   Java API By Example, From Geeks To Geeks.

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


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.util.ArrayList JavaDoc;
23 import java.util.Collection JavaDoc;
24 import java.util.HashMap JavaDoc;
25 import java.util.Map JavaDoc;
26
27 import javax.enterprise.deploy.spi.DConfigBean JavaDoc;
28 import javax.enterprise.deploy.spi.exceptions.ConfigurationException JavaDoc;
29 import javax.enterprise.deploy.model.DDBean JavaDoc;
30
31 import org.netbeans.modules.j2ee.sun.dd.api.CommonDDBean;
32 import org.netbeans.modules.j2ee.sun.dd.api.ejb.CheckpointAtEndOfMethod;
33 import org.netbeans.modules.j2ee.sun.dd.api.ejb.Ejb;
34 import org.netbeans.modules.j2ee.sun.dd.api.ejb.Method;
35
36 /**
37  *
38  * @author vkraemer
39  */

40 public class StatefulEjb extends SessionEjb {
41
42     /** Creates a new instance of SunONEStatelessEjbDConfigBean */
43     public StatefulEjb() {
44     }
45
46     private String JavaDoc availabilityEnabled;
47
48
49     private CheckpointAtEndOfMethod checkpointAtEndOfMethod;
50     
51     
52     /* ------------------------------------------------------------------------
53      * XPath to Factory mapping support
54      */

55 /*
56     private HashMap statefulEjbFactoryMap;
57     
58     protected Map getXPathToFactoryMap() {
59         if(statefulEjbFactoryMap == null) {
60                 statefulEjbFactoryMap = (HashMap) super.getXPathToFactoryMap();
61
62                 // add child DCB's specific to Stateful Session Beans
63         }
64
65         return statefulEjbFactoryMap;
66     }
67  */

68
69     /* ------------------------------------------------------------------------
70      * Persistence support. Loads DConfigBeans from previously saved Deployment
71      * plan file.
72      */

73     protected class StatefulEjbSnippet extends BaseEjb.BaseEjbSnippet {
74         public CommonDDBean getDDSnippet() {
75             Ejb ejb = (Ejb) super.getDDSnippet();
76             String JavaDoc version = getAppServerVersion().getEjbJarVersionAsString();
77
78             if(availabilityEnabled != null){
79                 try{
80                     if(availabilityEnabled.length() > 0){
81                         ejb.setAvailabilityEnabled(availabilityEnabled);
82                     }else{
83                         ejb.setAvailabilityEnabled(null);
84                     }
85                 }catch(org.netbeans.modules.j2ee.sun.dd.api.VersionNotSupportedException e){
86                     //System.out.println("Not Supported Version"); //NOI18N
87
}
88             }
89
90             if(null != checkpointAtEndOfMethod){
91                 try{
92                     ejb.setCheckpointAtEndOfMethod((CheckpointAtEndOfMethod)checkpointAtEndOfMethod.cloneVersion(version));
93                 }catch(org.netbeans.modules.j2ee.sun.dd.api.VersionNotSupportedException e){
94                     //System.out.println("Not Supported Version"); //NOI18N
95
}
96             }
97
98             return ejb;
99         }
100
101         public boolean hasDDSnippet() {
102             if(super.hasDDSnippet()){
103                 return true;
104             }
105
106             if (null != availabilityEnabled) {
107                 return true;
108             }
109
110             if (null != checkpointAtEndOfMethod) {
111                 return true;
112             }
113             return false;
114         }
115     }
116
117
118     java.util.Collection JavaDoc getSnippets() {
119         Collection JavaDoc snippets = new ArrayList JavaDoc();
120         snippets.add(new StatefulEjbSnippet());
121         return snippets;
122     }
123
124
125     protected void loadEjbProperties(Ejb savedEjb) {
126         super.loadEjbProperties(savedEjb);
127         try{
128             availabilityEnabled = savedEjb.getAvailabilityEnabled();
129         }catch(org.netbeans.modules.j2ee.sun.dd.api.VersionNotSupportedException e){
130             //System.out.println("Not Supported Version"); //NOI18N
131
}
132
133         CheckpointAtEndOfMethod checkpointAtEndOfMethod = null;
134         try{
135             checkpointAtEndOfMethod = savedEjb.getCheckpointAtEndOfMethod();
136         }catch(org.netbeans.modules.j2ee.sun.dd.api.VersionNotSupportedException e){
137             //System.out.println("Not Supported Version"); //NOI18N
138
}
139
140         if(null != checkpointAtEndOfMethod){
141             this.checkpointAtEndOfMethod = checkpointAtEndOfMethod;
142         }
143     }
144
145     protected void clearProperties() {
146         super.clearProperties();
147         
148         availabilityEnabled = null;
149         checkpointAtEndOfMethod = null;
150     }
151     
152
153     public String JavaDoc getAvailabilityEnabled() {
154         return this.availabilityEnabled;
155     }
156
157
158     public void setAvailabilityEnabled(String JavaDoc availabilityEnabled) throws java.beans.PropertyVetoException JavaDoc {
159         String JavaDoc oldAvailabilityEnabled = this.availabilityEnabled; //NOI18N
160
getVCS().fireVetoableChange("availabilityEnabled", oldAvailabilityEnabled, availabilityEnabled); //NOI18N
161
this.availabilityEnabled = availabilityEnabled; //NOI18N
162
getPCS().firePropertyChange("availabilityEnabled", oldAvailabilityEnabled, availabilityEnabled); //NOI18N
163
}
164
165
166     public CheckpointAtEndOfMethod getCheckpointAtEndOfMethod() {
167             return this.checkpointAtEndOfMethod;
168     }
169
170
171     public void setCheckpointAtEndOfMethod(CheckpointAtEndOfMethod checkpointAtEndOfMethod) throws java.beans.PropertyVetoException JavaDoc {
172             CheckpointAtEndOfMethod oldCheckpointAtEndOfMethod = this.checkpointAtEndOfMethod;
173             getVCS().fireVetoableChange("checkpointAtEndOfMethod", oldCheckpointAtEndOfMethod, checkpointAtEndOfMethod); //NOI18N
174
this.checkpointAtEndOfMethod = checkpointAtEndOfMethod;
175             getPCS().firePropertyChange("checkpoint at end of method", oldCheckpointAtEndOfMethod, checkpointAtEndOfMethod); //NOI18N
176
}
177
178
179     public void addMethod(Method method){
180         if(null == checkpointAtEndOfMethod){
181             checkpointAtEndOfMethod = getConfig().getStorageFactory().createCheckpointAtEndOfMethod();
182         }
183         checkpointAtEndOfMethod.addMethod(method);
184     }
185
186
187     public void removeMethod(Method method){
188         if(null != checkpointAtEndOfMethod){
189             checkpointAtEndOfMethod.removeMethod(method);
190         }
191     }
192
193
194     public String JavaDoc getHelpId() {
195         return "AS_CFG_StatefulEjb"; //NOI18N
196
}
197 }
198
Popular Tags