1 // Copyright 2012 Google Inc. All Rights Reserved.
3 package com
.google
.appengine
.api
.datastore
;
5 import java
.lang
.annotation
.ElementType
;
6 import java
.lang
.annotation
.Retention
;
7 import java
.lang
.annotation
.RetentionPolicy
;
8 import java
.lang
.annotation
.Target
;
11 * Identifies a callback method to be invoked before an {@link Entity} of any
12 * of the specified kinds is fetched from the datastore via a get() rpc. If
13 * {@link #kinds()} is not provided the callback will execute for all kinds.
14 * Methods with this annotation must return {@code void}, must accept a single
15 * argument of type {@link PreGetContext}, must not throw any checked
16 * exceptions, must not be static, and must belong to a class with a no-arg
17 * constructor. Neither the method nor the no-arg constructor of the class to
18 * which it belongs are required to be public. Methods with this annotation
19 * are free to throw any unchecked exception they like. Throwing an unchecked
20 * exception will prevent callbacks that have not yet been executed from
21 * running, and the exception will propagate to the code that invoked the
22 * datastore operation that resulted in the invocation of the callback.
23 * Throwing an unchecked exception from a callback will prevent the datastore
24 * operation from executing.
27 @Target(ElementType
.METHOD
)
28 @Retention(RetentionPolicy
.RUNTIME
)
29 public @interface PreGet
{
32 * The kinds to which this callback applies. The default value is an empty
33 * array, which indicates that the callback should run for all kinds.
35 * @return The kinds to which this callback applies.
37 String
[] kinds() default {};