Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.
This annotation is used to decorate methods that are to be invoked in an asynchronous way.

Note that the piece of code inside such methods will be automatically protected so to avoid concurrency issues. Though, other parts of the code inside the same class will be not.
In order to prevent unexpected behaviors, it is advisable to avoid using the same class fields (unless immutable) in protected and non-protected code, or to call synchronous methods through the framework as well.

This annotation allows to identify the method through a constant, thus avoiding issues when running obfuscation tools.
For example, the following code:


         public class MyClass {

             public static final String METHOD_NAME = "get";

             public int getOne() {

                 return 1;
allows to asynchronously call the method independently from its original name like:

         JRoutine.on(new MyClass()).boundMethod(MyClass.METHOD_NAME).callAsync();

The same considerations apply to static class methods.

Finally, be aware that a method might need to be made accessible in order to be called. That means that, in case a java.lang.SecurityManager is installed, a security exception might be raised based on the specific policy implemented.

Remember also that, in order for the annotation to properly work at run time, you will need to add the following rules to your Proguard file (if employing it for shrinking or obfuscation):


         -keepattributes RuntimeVisibleAnnotations

         -keepclassmembers class ** {

Created by davide on 1/22/15.

public @interface Bind {

The name used to identify the method independently from its original signature.

the name.
    String value();
New to GrepCode? Check out our FAQ X