1 19 20 package org.netbeans.modules.j2ee.sun.share.configbean; 21 22 import java.util.ArrayList ; 23 import java.util.Collection ; 24 import java.util.HashMap ; 25 import java.util.Map ; 26 27 import javax.enterprise.deploy.spi.DConfigBean ; 28 import javax.enterprise.deploy.spi.exceptions.ConfigurationException ; 29 import javax.enterprise.deploy.model.DDBean ; 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 40 public class StatefulEjb extends SessionEjb { 41 42 43 public StatefulEjb() { 44 } 45 46 private String availabilityEnabled; 47 48 49 private CheckpointAtEndOfMethod checkpointAtEndOfMethod; 50 51 52 55 68 69 73 protected class StatefulEjbSnippet extends BaseEjb.BaseEjbSnippet { 74 public CommonDDBean getDDSnippet() { 75 Ejb ejb = (Ejb) super.getDDSnippet(); 76 String 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 } 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 } 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 getSnippets() { 119 Collection snippets = new ArrayList (); 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 } 132 133 CheckpointAtEndOfMethod checkpointAtEndOfMethod = null; 134 try{ 135 checkpointAtEndOfMethod = savedEjb.getCheckpointAtEndOfMethod(); 136 }catch(org.netbeans.modules.j2ee.sun.dd.api.VersionNotSupportedException e){ 137 } 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 getAvailabilityEnabled() { 154 return this.availabilityEnabled; 155 } 156 157 158 public void setAvailabilityEnabled(String availabilityEnabled) throws java.beans.PropertyVetoException { 159 String oldAvailabilityEnabled = this.availabilityEnabled; getVCS().fireVetoableChange("availabilityEnabled", oldAvailabilityEnabled, availabilityEnabled); this.availabilityEnabled = availabilityEnabled; getPCS().firePropertyChange("availabilityEnabled", oldAvailabilityEnabled, availabilityEnabled); } 164 165 166 public CheckpointAtEndOfMethod getCheckpointAtEndOfMethod() { 167 return this.checkpointAtEndOfMethod; 168 } 169 170 171 public void setCheckpointAtEndOfMethod(CheckpointAtEndOfMethod checkpointAtEndOfMethod) throws java.beans.PropertyVetoException { 172 CheckpointAtEndOfMethod oldCheckpointAtEndOfMethod = this.checkpointAtEndOfMethod; 173 getVCS().fireVetoableChange("checkpointAtEndOfMethod", oldCheckpointAtEndOfMethod, checkpointAtEndOfMethod); this.checkpointAtEndOfMethod = checkpointAtEndOfMethod; 175 getPCS().firePropertyChange("checkpoint at end of method", oldCheckpointAtEndOfMethod, checkpointAtEndOfMethod); } 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 getHelpId() { 195 return "AS_CFG_StatefulEjb"; } 197 } 198 | Popular Tags |