PageRenderTime 20ms CodeModel.GetById 16ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 1ms

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