1 22 package org.jboss.metadata; 23 24 26 import java.util.StringTokenizer ; 27 28 import org.jboss.deployment.DeploymentException; 29 import org.w3c.dom.Element ; 30 31 36 public class EjbPortComponentMetaData 37 { 38 private SessionMetaData sessionMetaData; 39 40 private String portComponentName; 41 private String portComponentURI; 42 private String authMethod; 43 private String transportGuarantee; 44 45 public EjbPortComponentMetaData(SessionMetaData sessionMetaData) 46 { 47 this.sessionMetaData = sessionMetaData; 48 portComponentURI = "/" + sessionMetaData.getEjbName(); 49 } 50 51 public String getPortComponentName() 52 { 53 return portComponentName; 54 } 55 56 public String getPortComponentURI() 57 { 58 return portComponentURI; 59 } 60 61 public String getURLPattern() 62 { 63 String pattern = "/*"; 64 if (portComponentURI != null) 65 { 66 return portComponentURI; 67 } 68 return pattern; 69 } 70 71 public String getAuthMethod() 72 { 73 return authMethod; 74 } 75 76 public String getTransportGuarantee() 77 { 78 return transportGuarantee; 79 } 80 81 public void setPortComponentName(String portComponentName) 82 { 83 this.portComponentName = portComponentName; 84 } 85 86 public void setPortComponentURI(String portComponentURI) 87 { 88 ApplicationMetaData appMetaData = sessionMetaData.getApplicationMetaData(); 89 String contextRoot = appMetaData.getWebServiceContextRoot(); 90 91 if(portComponentURI.charAt(0) != '/') 92 { 93 portComponentURI = "/" + portComponentURI; 94 } 95 96 if(contextRoot == null) 97 { 98 StringTokenizer st = new StringTokenizer (portComponentURI, "/"); 100 if(st.countTokens() < 2) 101 { 102 throw new IllegalStateException ("Expected at least two tokens <port-component-uri>"); 103 } 104 105 contextRoot = "/" + st.nextToken(); 106 String prevContextRoot = contextRoot; 107 if(prevContextRoot != null && prevContextRoot.equals(contextRoot) == false) 108 { 109 throw new IllegalStateException ("Invalid <port-component-uri>, expected to start with: " + prevContextRoot); 110 } 111 112 appMetaData.setWebServiceContextRoot(contextRoot); 113 portComponentURI = portComponentURI.substring(portComponentURI.indexOf('/', 1)); 114 } 115 else if(portComponentURI.startsWith(contextRoot)) 116 { 117 portComponentURI = portComponentURI.substring(contextRoot.length()); 118 } 119 } 120 121 public void setAuthMethod(String authMethod) 122 { 123 this.authMethod = authMethod; 124 } 125 126 public void setTransportGuarantee(String transportGuarantee) 127 { 128 this.transportGuarantee = transportGuarantee; 129 } 130 131 public void importStandardXml(Element element) 132 throws DeploymentException 133 { 134 } 135 136 140 public void importJBossXml(Element element) throws DeploymentException 141 { 142 portComponentName = MetaData.getUniqueChildContent(element, "port-component-name"); 144 145 portComponentURI = MetaData.getOptionalChildContent(element, "port-component-uri"); 147 if(portComponentURI != null) 148 { 149 setPortComponentURI(portComponentURI); 150 } 151 else 152 { 153 portComponentURI = "/" + sessionMetaData.getEjbName(); 154 } 156 157 authMethod = MetaData.getOptionalChildContent(element, "auth-method"); 159 transportGuarantee = MetaData.getOptionalChildContent(element, "transport-guarantee"); 161 162 if (MetaData.getOptionalChildContent(element, "port-uri") != null) 164 throw new DeploymentException("Deprecated element <port-uri>, use <port-component-uri> instead"); 165 } 166 } 167 | Popular Tags |