1 2 24 package com.sun.enterprise.tools.verifier.tests.webservices; 25 26 import com.sun.enterprise.deployment.*; 27 import com.sun.enterprise.tools.verifier.*; 28 import java.util.*; 29 import java.lang.reflect.*; 30 import com.sun.enterprise.tools.verifier.tests.*; 31 32 37 38 44 public class EndPointImplBeanClassChecker extends WSTest implements WSCheck { 45 46 private Class sei; 47 private Class bean; 48 private Result result; 49 private boolean isEjbEndpoint; 50 private String schemaVersion; 51 52 public EndPointImplBeanClassChecker (Class seiClz, Class beanClz, Result resultInst, String version ) { 53 54 sei = seiClz; 55 bean = beanClz; 56 result = resultInst; 57 isEjbEndpoint = true; 58 schemaVersion = version; 59 } 60 61 public EndPointImplBeanClassChecker (Class seiClz, Class beanClz, Result resultInst, 62 boolean isEjb) { 63 sei = seiClz; 64 bean = beanClz; 65 result = resultInst; 66 isEjbEndpoint = isEjb; 67 } 68 69 73 public Result check (WebServiceEndpoint descriptor) { 74 return null; 75 } 76 77 public boolean check (ComponentNameConstructor compName) { 78 79 boolean pass = true; 80 81 try { 83 bean.getConstructor(new Class [0]); 84 result.addGoodDetails(smh.getLocalString 86 ("tests.componentNameConstructor", 87 "For [ {0} ]", new Object [] {compName.toString()})); 88 result.passed(smh.getLocalString ( 89 "com.sun.enterprise.tools.verifier.tests.webservices.passed", "[{0}]", 90 new Object [] {"The Service Impl Bean has a public default Constructor"})); 91 92 }catch (NoSuchMethodException e) { 93 result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor", 95 "For [ {0} ]", new Object [] {compName.toString()})); 96 result.failed(smh.getLocalString 97 ("com.sun.enterprise.tools.verifier.tests.webservices.failed", "[{0}]", 98 new Object [] {"The Service Impl Bean does not have a default public Constructor"})); 99 pass = false; 100 }catch (LinkageError e){ 101 Verifier.debug(e); 102 pass = false; 103 addErrorDetails(result, compName); 104 result.failed(smh.getLocalString ( 105 "com.sun.enterprise.tools.verifier.tests.webservices.failed1", 106 "Error: [ {0} ] class used in [ {1} ] class cannot be found.", 107 new Object [] {e.getMessage().replace('/','.'), bean.getName()})); 108 } 109 110 int modifiers = bean.getModifiers(); 112 if (Modifier.isPublic(modifiers)) { 113 result.addGoodDetails(smh.getLocalString ("tests.componentNameConstructor", 115 "For [ {0} ]", new Object [] {compName.toString()})); 116 result.passed(smh.getLocalString ( 117 "com.sun.enterprise.tools.verifier.tests.webservices.passed", "[{0}]", 118 new Object [] {"The Service Impl Bean is public"})); 119 } 120 else { 121 result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor", 123 "For [ {0} ]", new Object [] {compName.toString()})); 124 result.failed(smh.getLocalString 125 ("com.sun.enterprise.tools.verifier.tests.webservices.failed", "[{0}]", 126 new Object [] {"The Service Impl Bean is not public"})); 127 pass = false; 128 } 129 130 if (Modifier.isFinal(modifiers)) { 131 result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor", 133 "For [ {0} ]", new Object [] {compName.toString()})); 134 result.failed(smh.getLocalString 135 ("com.sun.enterprise.tools.verifier.tests.webservices.failed", "[{0}]", 136 new Object [] {"The Service Impl Bean is does not implement SEI, but is decalred final"})); 137 pass = false; 138 } 139 else { 140 result.addGoodDetails(smh.getLocalString ("tests.componentNameConstructor", 142 "For [ {0} ]", new Object [] {compName.toString()})); 143 result.passed(smh.getLocalString ( 144 "com.sun.enterprise.tools.verifier.tests.webservices.passed", "[{0}]", 145 new Object [] {"The Service Impl Bean class is not declared final"})); 146 } 147 148 if (Modifier.isAbstract(modifiers)) { 149 result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor", 151 "For [ {0} ]", new Object [] {compName.toString()})); 152 result.failed(smh.getLocalString 153 ("com.sun.enterprise.tools.verifier.tests.webservices.failed", "[{0}]", 154 new Object [] {"The Service Impl Bean class is decalred final"})); 155 pass = false; 156 } 157 else { 158 result.addGoodDetails(smh.getLocalString ("tests.componentNameConstructor", 160 "For [ {0} ]", new Object [] {compName.toString()})); 161 result.passed(smh.getLocalString ( 162 "com.sun.enterprise.tools.verifier.tests.webservices.passed", "[{0}]", 163 new Object [] {"The Service Impl Bean class is not abstract"})); 164 } 165 166 try { 168 if (bean.getDeclaredMethod("finalize", new Class [0]) != null) { 169 result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor", 171 "For [ {0} ]", new Object [] {compName.toString()})); 172 result.failed(smh.getLocalString 173 ("com.sun.enterprise.tools.verifier.tests.webservices.failed", "[{0}]", 174 new Object [] {"The Service Impl Bean class defines finalize() method"})); 175 pass = false; 176 } 177 }catch(NoSuchMethodException e) { 178 result.addGoodDetails(smh.getLocalString ("tests.componentNameConstructor", 180 "For [ {0} ]", new Object [] {compName.toString()})); 181 result.passed(smh.getLocalString ( 182 "com.sun.enterprise.tools.verifier.tests.webservices.passed", "[{0}]", 183 new Object [] {"The Service Impl Bean class does not define finalize() method"})); 184 }catch (LinkageError e){ 185 Verifier.debug(e); 186 pass = false; 187 addErrorDetails(result, compName); 188 result.failed(smh.getLocalString ( 189 "com.sun.enterprise.tools.verifier.tests.webservices.failed1", 190 "Error: [ {0} ] class used in [ {1} ] class cannot be found.", 191 new Object [] {e.getMessage().replace('/','.'), bean.getName()})); 192 } 193 if (isEjbEndpoint && !(schemaVersion.compareTo("1.1")>0)) { 194 try { 196 if (bean.getDeclaredMethod("ejbCreate", new Class [0]) != null) { 197 result.addGoodDetails(smh.getLocalString ("tests.componentNameConstructor", 199 "For [ {0} ]", new Object [] {compName.toString()})); 200 result.passed(smh.getLocalString ( 201 "com.sun.enterprise.tools.verifier.tests.webservices.passed", "[{0}]", 202 new Object [] {"The Service Impl Bean class defines ejbCreate()"})); 203 } 204 }catch(NoSuchMethodException e) { 205 result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor", 207 "For [ {0} ]", new Object [] {compName.toString()})); 208 result.failed(smh.getLocalString 209 ("com.sun.enterprise.tools.verifier.tests.webservices.failed", "[{0}]", 210 new Object [] {"The Service Impl Bean class has no ejbCreate()"})); 211 pass = false; 212 }catch (LinkageError e){ 213 Verifier.debug(e); 214 pass = false; 215 addErrorDetails(result, compName); 216 result.failed(smh.getLocalString ( 217 "com.sun.enterprise.tools.verifier.tests.webservices.failed1", 218 "Error: [ {0} ] class used in [ {1} ] class cannot be found.", 219 new Object [] {e.getMessage().replace('/','.'), bean.getName()})); 220 } 221 try { 223 if (bean.getDeclaredMethod("ejbRemove", new Class [0]) != null) { 224 result.addGoodDetails(smh.getLocalString ("tests.componentNameConstructor", 226 "For [ {0} ]", new Object [] {compName.toString()})); 227 result.passed(smh.getLocalString ( 228 "com.sun.enterprise.tools.verifier.tests.webservices.passed", "[{0}]", 229 new Object [] {"The Service Impl Bean class defines ejbRemove()"})); 230 } 231 }catch(NoSuchMethodException e) { 232 result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor", 234 "For [ {0} ]", new Object [] {compName.toString()})); 235 result.failed(smh.getLocalString 236 ("com.sun.enterprise.tools.verifier.tests.webservices.failed", "[{0}]", 237 new Object [] {"The Service Impl Bean class has no ejbRemove()"})); 238 pass = false; 239 }catch (LinkageError e){ 240 Verifier.debug(e); 241 pass = false; 242 addErrorDetails(result, compName); 243 result.failed(smh.getLocalString ( 244 "com.sun.enterprise.tools.verifier.tests.webservices.failed1", 245 "Error: [ {0} ] class used in [ {1} ] class cannot be found.", 246 new Object [] {e.getMessage().replace('/','.'), bean.getName()})); 247 } 248 } 249 250 return pass; 251 } 252 253 public Vector getSEIMethodsNotImplemented() { 254 255 Vector<String > ret = new Vector<String >(); 256 Method[] beanPubMethods = bean.getMethods(); 258 Method[] seiMethods = sei.getMethods(); 259 for ( int i=0; i < seiMethods.length; i++) { 260 if (!hasMatchingMethod(seiMethods[i], beanPubMethods)) { 261 ret.add(seiMethods[i].toString()); 263 } 264 } 265 return ret; 266 } 267 268 private boolean hasMatchingMethod(Method meth, Method[] tobeChecked) { 269 270 for (int i=0; i < tobeChecked.length; i++) { 271 if (WSTest.matchesSignatureAndReturn(meth, tobeChecked[i])) 272 return true; 273 } 274 return false; 275 } 276 } 277 278 | Popular Tags |