1 // Copyright 2011 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 written to the datastore. If {@link #kinds()} is
13 * not provided the callback will execute for all kinds. Methods with this
14 * annotation must return {@code void}, must accept a single argument of type
15 * {@link PutContext}, must not throw any checked exceptions, must not be
16 * static, and must belong to a class with a no-arg constructor. Neither the
17 * method nor the no-arg constructor of the class to which it belongs are
18 * required to be public. Methods with this annotation are free to throw any
19 * unchecked exception they like. Throwing an unchecked exception will prevent
20 * callbacks that have not yet been executed from running, and the exception
21 * will propagate to the code that invoked the datastore operation that
22 * resulted in the invocation of the callback. Throwing an unchecked exception
23 * from a callback will prevent the datastore operation from executing.
26 @Target(ElementType
.METHOD
)
27 @Retention(RetentionPolicy
.RUNTIME
)
28 public @interface PrePut
{
30 * The kinds to which this callback applies. The default value is an empty
31 * array, which indicates that the callback should run for all kinds.
33 * @return The kinds to which this callback applies.
35 String
[] kinds() default {};