/razweb/src/com/razie/pub/lightsoa/SoaMethod.java

http://razpub.googlecode.com/ · Java · 87 lines · 21 code · 7 blank · 59 comment · 0 complexity · 248055999c245643328c213cce731a7e MD5 · raw file

  1. /**
  2. * Razvan's public code. Copyright 2008 based on Apache license (share alike) see LICENSE.txt for
  3. * details.
  4. */
  5. package com.razie.pub.lightsoa;
  6. import java.lang.annotation.Documented;
  7. import java.lang.annotation.ElementType;
  8. import java.lang.annotation.Inherited;
  9. import java.lang.annotation.Retention;
  10. import java.lang.annotation.RetentionPolicy;
  11. import java.lang.annotation.Target;
  12. import razie.base.AttrAccess;
  13. import razie.base.ActionItem;
  14. import com.razie.pub.comms.PermType;
  15. import com.razie.pub.http.SoaNotHtml;
  16. /**
  17. * mark the methods callable from by the lightsoa framework, on a service class
  18. *
  19. * service-method ulrs are <code>PREFIX/SERVICE/METHOD?parms=values&</code>
  20. *
  21. * <pre>
  22. * class ClassA {
  23. * ...
  24. * &#064;SoaMethod (descr=&quot;the name of the component&quot;)
  25. * public SoaResponse getName() {
  26. * }
  27. * ...
  28. * &#064;SoaMethod (descr=&quot;the name of the component&quot;, args = {&quot;name&quot;})
  29. * public SoaResponse setName(String name) {
  30. * }
  31. * ...
  32. * &#064;SoaMethod (descr=&quot;simple string method&quot;)
  33. * public String sayHello() {
  34. * }
  35. * }
  36. * </pre>
  37. *
  38. * These methods can take arguments - limit yourself to String arguments for now. These however will
  39. * be escaped properly and un-escaped properly by each binding, that's a requirement for te binding
  40. * since the method doesn't know which binding will wrap it.
  41. *
  42. * You can return anything. Most protocols will just make that .toString(). If a protocol (UPNP)
  43. * supports returning multiple arguments, please return a SoaResponse
  44. *
  45. * <b>Annotate with {@link SoaStreamable} if your method can stream a longer reply back. OR if you
  46. * need to change the reply mime-type and processing - see {@link SampleService}
  47. *
  48. * <p>
  49. * Annotate with @SoaAllParms if you want all parms in an array
  50. *
  51. * <p>
  52. * annotate with @SoaMethodSink if this is the sink for all unknown method names
  53. *
  54. * <p>
  55. * You can access the request's httpattrs inside the call by calling
  56. * <code>AttrAccess httpattrs = (AttrAccess)ThreadContext.instance().getAttr ("httpattrs")</code>
  57. *
  58. * @author razvanc99
  59. */
  60. @Documented
  61. @Retention(RetentionPolicy.RUNTIME)
  62. @Target( { ElementType.METHOD })
  63. @Inherited
  64. public @interface SoaMethod {
  65. /** the value is a description of the method */
  66. String descr();
  67. /**
  68. * if defined, put here the permission to check - the framework will check the current connection
  69. * and user for this permission and throw AuthException if not permitted
  70. */
  71. PermType perm() default PermType.WRITE;
  72. /**
  73. * action type may dictate if it's ACT/GET/POST/PUT/DELETE
  74. *
  75. * TODO did i actually end up using this?
  76. */
  77. ActionItem.ActionType actionType() default ActionItem.ActionType.R;
  78. /** the list of arguments */
  79. String[] args() default {};
  80. }