org.appcelerator.kroll.annotations
Annotation Type Kroll.method


@Documented
@Retention(value=SOURCE)
@Target(value=METHOD)
public static @interface Kroll.method

Declares a method to be exposed as part of this Kroll.proxy or Kroll.module.

Methods may optionally make their first argument a KrollInvocation object, and may also declare optional arguments.

Example:
 @Kroll.method
 public void execute(String action, @Kroll.argument(optional=true) KrollDict options) {
 }
 

See Also:
name(), converter(), runOnUiThread(), @Kroll.argument

Optional Element Summary
 java.lang.Class<? extends KrollNativeConverter> converter
          Converter of Java objects to Javascript objects suitable for use by the Rhino runtime
 java.lang.String name
          The method's name in the API.
 boolean runOnUiThread
          When set to true, this method will run on the UI thread, blocking the current thread until it finishes executing.
 

name

public abstract java.lang.String name
The method's name in the API.

Default Value:
The method's name in Java source.
Default:
"__default_name__"

converter

public abstract java.lang.Class<? extends KrollNativeConverter> converter
Converter of Java objects to Javascript objects suitable for use by the Rhino runtime

The value should be the fully qualified name of a class that implements KrollNativeConverter. The class must also implement a static instance getter called getInstance().

See Also:
KrollNativeConverter
Default:
org.appcelerator.kroll.KrollConverter.class

runOnUiThread

public abstract boolean runOnUiThread

When set to true, this method will run on the UI thread, blocking the current thread until it finishes executing. If the current thread is the UI thread, then this simply calls the method directly. This is functionally equivalent to:

 if (tiContext.isUIThread()) {
     return callMethod();
 } else {
     final AsyncResult result = new AsyncResult();
     tiContext.getActivity().runOnUiThread(new Runnable() {
         public void run() {
             result.setResult(callMethod());
         }
     });
     return result.getResult();
 }
 

Default:
false


Copyright © 2010 Appcelerator, Inc. Licensed under the Apache License 2.0