1 18 package org.apache.beehive.wsm.model.jsr181; 19 20 import java.util.ArrayList ; 21 import java.util.Arrays ; 22 import java.util.Collection ; 23 import java.util.Collections ; 24 import java.util.HashMap ; 25 import java.util.Map ; 26 27 import javax.jws.soap.InitParam; 28 import javax.jws.soap.SOAPMessageHandler; 29 30 import org.apache.beehive.wsm.model.BeehiveWsSOAPMessageHandlerInfo; 31 32 public class SOAPMessageHandlerInfo implements java.io.Serializable , BeehiveWsSOAPMessageHandlerInfo { 33 34 private static final long serialVersionUID = 1L; 35 36 String name; 37 String className; 38 HashMap <String , String > parameterMap = new HashMap <String , String >(); 39 Collection <String > roles = new ArrayList <String >(); 40 Collection <String > headers = new ArrayList <String >(); 41 42 45 public SOAPMessageHandlerInfo(SOAPMessageHandler annotation) { 46 47 String className = annotation.className(); 49 if (0 == className.length()) { 50 throw new IllegalArgumentException ("className required to configure a SOAPMessageHandler"); 51 } 52 53 setClassName(className); 55 setName((0 < annotation.name().length()) ? annotation.name() : className); 56 for (InitParam p : annotation.initParams()) { 57 addInitParam(p.name(), p.value()); 58 } 59 addRoles(Arrays.asList(annotation.roles())); 60 for (String s : annotation.headers()) { 61 addHeader(s); 62 } 63 } 64 65 public SOAPMessageHandlerInfo( 66 String handlerClassName, 67 String handlerName, 68 Map <String , String > initParams, 69 Collection <String > roles, 70 Collection <String > headers 71 ) { 72 setClassName(handlerClassName); 73 setName((handlerName != null && handlerName.length() > 0) 74 ? handlerName : handlerClassName); 75 addInitParams(initParams); 76 addRoles(roles); 77 addHeaders(headers); 78 } 79 80 83 public String getClassName() { 84 return className; 85 } 86 87 90 public void setClassName(String className) { 91 this.className = className; 92 } 93 94 97 public String getName() { 98 return name; 99 } 100 101 104 public void setName(String name) { 105 this.name = name; 106 } 107 108 111 public Collection <String > getHeaders() { 112 return Collections.unmodifiableCollection(headers); 113 } 114 115 public void addHeader(String header) { 116 this.headers.add(header); 117 } 118 119 122 private void addHeaders(Collection <String > headers) { 123 this.headers.addAll(headers); 124 } 125 126 129 public Map <String , String > getParameterMap() { 130 return Collections.unmodifiableMap(parameterMap); 131 } 132 133 public void addInitParam(String key, String value) { 134 parameterMap.put(key, value); 135 } 136 137 public void addInitParams(Map <String , String > params) { 138 parameterMap.putAll(params); 139 } 140 141 144 public Collection <String > getRoles() { 145 return Collections.unmodifiableCollection(roles); 146 } 147 148 public void addRole(String role) { 149 this.roles.add(role); 150 } 151 152 public void addRoles(Collection <String > roles) { 153 this.roles.addAll(roles); 154 } 155 156 } 157 | Popular Tags |