1 22 package org.jboss.metadata; 23 24 import java.util.HashMap ; 25 26 import org.jboss.deployment.DeploymentException; 27 import org.w3c.dom.Element ; 28 29 36 public class SessionMetaData extends BeanMetaData 37 { 38 public static final String DEFAULT_STATEFUL_INVOKER = "stateful-unified-invoker"; 40 public static final String DEFAULT_CLUSTERED_STATEFUL_INVOKER = "clustered-stateful-rmi-invoker"; 41 public static final String DEFAULT_STATELESS_INVOKER = "stateless-unified-invoker"; 42 public static final String DEFAULT_CLUSTERED_STATELESS_INVOKER = "clustered-stateless-rmi-invoker"; 43 44 46 private boolean stateful; 47 48 50 public SessionMetaData(ApplicationMetaData app) 52 { 53 super(app, BeanMetaData.SESSION_TYPE); 54 } 55 56 public boolean isStateful() 58 { 59 return stateful; 60 } 61 62 public void setStateful(boolean stateful) 63 { 64 this.stateful = stateful; 65 } 66 67 public boolean isStateless() 68 { 69 return !stateful; 70 } 71 72 public String getDefaultConfigurationName() 73 { 74 if (isStateful()) 75 { 76 if (this.isClustered()) 77 return ConfigurationMetaData.CLUSTERED_STATEFUL_13; 78 else 79 return ConfigurationMetaData.STATEFUL_13; 80 } 81 else 82 { 83 if (this.isClustered()) 84 return ConfigurationMetaData.CLUSTERED_STATELESS_13; 85 else 86 return ConfigurationMetaData.STATELESS_13; 87 } 88 } 89 90 protected void defaultInvokerBindings() 91 { 92 invokerBindings = new HashMap (); 93 if (isClustered()) 94 { 95 if (stateful) 96 { 97 invokerBindings.put(DEFAULT_CLUSTERED_STATEFUL_INVOKER, 98 getJndiName()); 99 } 100 else 101 { 102 invokerBindings.put(DEFAULT_CLUSTERED_STATELESS_INVOKER, 103 getJndiName()); 104 } 105 } 106 else 107 { 108 if (stateful) 109 { 110 invokerBindings.put(DEFAULT_STATEFUL_INVOKER, getJndiName()); 111 } 112 else 113 { 114 invokerBindings.put(DEFAULT_STATELESS_INVOKER, getJndiName()); 115 } 116 } 117 } 118 119 public void importEjbJarXml(Element element) throws DeploymentException 120 { 121 super.importEjbJarXml(element); 122 123 String sessionType = getElementContent(getUniqueChild(element, "session-type")); 125 if (sessionType.equals("Stateful")) 126 { 127 stateful = true; 128 } 129 else if (sessionType.equals("Stateless")) 130 { 131 stateful = false; 132 } 133 else 134 { 135 throw new DeploymentException("session type should be 'Stateful' or 'Stateless'"); 136 } 137 138 String transactionType = getElementContent(getUniqueChild(element, "transaction-type")); 140 if (transactionType.equals("Bean")) 141 { 142 containerManagedTx = false; 143 } 144 else if (transactionType.equals("Container")) 145 { 146 containerManagedTx = true; 147 } 148 else 149 { 150 throw new DeploymentException("transaction type should be 'Bean' or 'Container'"); 151 } 152 153 serviceEndpointClass = getElementContent(getOptionalChild(element, "service-endpoint")); 154 } 155 156 public void importJbossXml(Element element) throws DeploymentException 157 { 158 super.importJbossXml(element); 159 Element portElement = getOptionalChild(element, "port-component"); 161 if (portElement != null) 162 { 163 portComponent = new EjbPortComponentMetaData(this); 164 portComponent.importJBossXml(portElement); 165 } 166 } 167 168 } 169 | Popular Tags |