KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > share > configbean > customizers > ejbmodule > StatefulEjbCustomizer


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  * StatefulEjbCustomizer.java October 22, 2003, 12:50 PM
21  *
22  */

23 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.ejbmodule;
24
25 import java.util.ArrayList JavaDoc;
26 import java.util.Collection JavaDoc;
27
28 import javax.swing.event.TableModelListener JavaDoc;
29
30 //DEPLOYMENT API
31
import javax.enterprise.deploy.spi.DConfigBean JavaDoc;
32
33 import org.netbeans.modules.j2ee.sun.dd.api.ejb.BeanCache;
34 import org.netbeans.modules.j2ee.sun.dd.api.ejb.BeanPool;
35 import org.netbeans.modules.j2ee.sun.share.configbean.BaseEjb;
36 import org.netbeans.modules.j2ee.sun.share.configbean.SessionEjb;
37 import org.netbeans.modules.j2ee.sun.share.configbean.StatefulEjb;
38
39 /**
40  *
41  * @author Rajeshwar Patil
42  * @version %I%, %G%
43  */

44 public class StatefulEjbCustomizer extends SessionEjbCustomizer
45             implements TableModelListener JavaDoc {
46
47     private StatefulEjb theBean;
48     private StatefulEjbPanel statefulEjbPanel;
49     private BeanPoolPanel beanPoolPanel;
50     private BeanCachePanel beanCachePanel;
51     private CheckpointAtEndOfMethodPanel checkpointAtEndOfMethodPanel;
52
53
54
55     /** Creates a new instance of StatefulEjbCustomizer */
56     public StatefulEjbCustomizer() {
57     }
58     
59     public void setObject(Object JavaDoc bean) {
60         super.setObject(bean);
61         
62         // Only do this if the bean is actually changing.
63
if(theBean != bean) {
64             if(bean instanceof StatefulEjb) {
65                 theBean = (StatefulEjb) bean;
66             }
67         }
68     }
69
70
71     //get the bean specific panel
72
protected javax.swing.JPanel JavaDoc getBeanPanel(){
73         statefulEjbPanel = new StatefulEjbPanel(this);
74         return statefulEjbPanel;
75     }
76
77
78     //initialize all the elements in the bean specific panel
79
protected void initializeBeanPanel(BaseEjb theBean){
80         if(!(theBean instanceof StatefulEjb)){
81             assert(false);
82         }
83         StatefulEjb statefulEjb = (StatefulEjb)theBean;
84         String JavaDoc availabilityEnabled = statefulEjb.getAvailabilityEnabled();
85         if(availabilityEnabled != null){
86             statefulEjbPanel.setAvailabilityEnabled(availabilityEnabled);
87         }
88     };
89
90
91     protected void addTabbedBeanPanels() {
92         super.addTabbedBeanPanels();
93         beanPoolPanel = new BeanPoolPanel(this);
94         beanPoolPanel.getAccessibleContext().setAccessibleName(bundle.getString("BeanPool_Acsbl_Name")); //NOI18N
95
beanPoolPanel.getAccessibleContext().setAccessibleDescription(bundle.getString("BeanPool_Acsbl_Desc")); //NOI18N
96
tabbedPanel.insertTab(bundle.getString("LBL_BeanPool"), null, beanPoolPanel, null, 0); // NOI18N
97

98         beanCachePanel = new BeanCachePanel(this);
99         beanCachePanel.getAccessibleContext().setAccessibleName(bundle.getString("BeanCache_Acsbl_Name")); //NOI18N
100
beanCachePanel.getAccessibleContext().setAccessibleDescription(bundle.getString("BeanCache_Acsbl_Desc")); //NOI18N
101
tabbedPanel.addTab(bundle.getString("LBL_BeanCache"), // NOI18N
102
beanCachePanel);
103
104          checkpointAtEndOfMethodPanel = new CheckpointAtEndOfMethodPanel(theBean, this);
105         checkpointAtEndOfMethodPanel.addTableModelListener(this);
106         tabbedPanel.addTab(bundle.getString("LBL_Checkpoint_At_End_Of_Method"), // NOI18N
107
checkpointAtEndOfMethodPanel);
108         
109         //Select Bean Pool Panel
110
tabbedPanel.setSelectedIndex(tabbedPanel.indexOfTab(bundle.getString("LBL_BeanPool"))); //NOI18N
111

112     }
113
114
115     protected void initializeTabbedBeanPanels(BaseEjb theBean) {
116         super.initializeTabbedBeanPanels(theBean);
117         if(!(theBean instanceof StatefulEjb)){
118             assert(false);
119         }
120         StatefulEjb statefulEjb = (StatefulEjb)theBean;
121         BeanPool beanPool = statefulEjb.getBeanPool();
122         beanPoolPanel.setValues(beanPool);
123
124         BeanCache beanCache = statefulEjb.getBeanCache();
125         beanCachePanel.setValues(beanCache);
126         
127         checkpointAtEndOfMethodPanel.setData(statefulEjb);
128     }
129
130
131     public Collection JavaDoc getErrors(){
132         ArrayList JavaDoc errors = null;
133         if(validationSupport == null) assert(false);
134         errors = (ArrayList JavaDoc)super.getErrors();
135
136         //Stateful Session Ejb field Validations
137
//Stateful Ejb field Validations
138
String JavaDoc property = statefulEjbPanel.getAvailabilityEnabled();
139         errors.addAll(validationSupport.validate(property,
140             "/sun-ejb-jar/enterprise-beans/ejb/availability-enabled", //NOI18N
141
bundle.getString("LBL_Availability_Enabled"))); //NOI18N
142
return errors;
143     }
144
145
146     public void validateEntries(){
147         super.validateEntries();
148     }
149
150
151     public String JavaDoc getHelpId() {
152         return "AS_CFG_StatefulEjb"; //NOI18N
153
}
154
155
156     //Stateful Ejb update methods
157
void updateAvailabilityEnabled(String JavaDoc availabilityEnabled){
158         if(theBean != null){
159             try{
160                 theBean.setAvailabilityEnabled(availabilityEnabled);
161             }catch(java.beans.PropertyVetoException JavaDoc exception){
162             }
163             notifyChange();
164         }
165     }
166 }
167
Popular Tags