EzyFox Annotations
Updated at 1685686754000Common Annotations
Annotation | Scopes | Description | |
1 | EzyAutoImpl | Interface | Indicates the annotated interface will be implemented by framework |
2 | EzyFeature | Class, Method | Maps a feature name to a class or a method |
3 | EzyId | Class, Field, Method | Indicates the class will be a id class for a entity. With a field and a method, they will be the id property for an entity |
4 | EzyImport | Class | To import classses to the bean management |
5 | EzyKeyValue | Annotation | To provides a property for a bean |
6 | EzyManagement | Class | Indicate the annotated class will be a management class |
7 | EzyPackagesToScan | Class | Provides packages to scan |
8 | EzyPayment | Class, Method | Indicates the annotated class or method will be pyament |
9 | EzyProperty | Field, Method | Map a property to a field or a setter method |
Bean Management Annotations
Annotation | Scopes | Description | |
1 | EzyAutoBind | Field, Method, Constructor | Bind a bean to a field, a method or bind beans to a contructor |
2 | EzyBeanPackagesToScan | Class | Provides packages to scan |
3 | EzyConfiguration | Class, Field, Method | Indicates the class will be a configuration class, the instance of a class that's annotated with EzyConfiguration annotation will run after EzyConfigurationBefore and before EzyConfigurationAfter |
4 | EzyConfigurationAfter | Class | Indicates the class will be a configuration class, the instance of a class that's annotated with EzyConfigurationAfter annotation will run after EzyConfigurationBefore and EzyConfiguration |
5 | EzyConfigurationBefore | Annotation | Indicates the class will be a configuration class, the instance of a class that's annotated with EzyConfigurationBefore annotation will run before EzyConfiguration and EzyConfigurationAfter |
6 | EzyDisableAutoConfiguration | Class | Allows disable auto configuration |
7 | EzyExclusiveClassesConfiguration | Class | To exclude classes from bean management |
8 | EzyPostInit | Method | Call after a bean initialized |
9 | EzyPropertiesBean | Class | Indicates the annotated class or value class is mapped to a properties |
10 | EzyPropertiesBeans | Class | Provides a list of EzyPropertiesBean annotations |
11 | EzyPropertiesSources | Class | Provides a list of properties files |
12 | EzyPrototype | Class, Field, Method | Indicates instance of the annotated class, field, method will be prototype |
13 | EzySingleton | Class, Field, Method | Indicates instance of the annotated class, field, method will be singleton |
Data Binding Annotations
Annotation | Scopes | Description | |
1 | EzyArrayBinding | Class | Indicates the annotated class will be bound to an array |
2 | EzyBindingPackagesToScan | Class | Provides packages to scan for binding context |
3 | EzyConfiguration | Class | Configuration for binding context |
4 | EzyIgnore | Field, Method | Ignore the annotated field and method from binding |
5 | EzyIndex | Field, Method | Provides index for array binding |
6 | EzyObjectBinding | Class | Indicates the annotated class will be bound to an object |
7 | EzyPostRead | Method | Call after a binding |
8 | EzyReader | Field, Method | Specifics reader for a field or a method. |
9 | EzyReaderImpl | Class | Indicates the annotated class is a reader class |
10 | EzyTemplateImpl | Class | Indicates the annotated class is a reader or writer class or the both |
11 | EzyValue | Field, Method | Provides key name for object binding |
12 | EzyWriter | Field, Method | Specifics writer for a field or a method |
13 | EzyWriterImpl | Class | Indicates the annotated class is a writer class |
Database Annotations
Annotation | Scopes | Description | |
1 | EzyCollection | Class | Indicates the annotated clas will be an entity class for NoSQL like MongoDB |
2 | EzyCollectionId | Class, Field | Indicates the annotated class will be an entity's id class, or the annotated filed will be an id field |
3 | EzyMapstore | Class | Indicates the class will be a map store class (store data to a database or somewhere) |
4 | EzyNamedQuery | Class | Map a named query to a result class |
5 | EzyQuery | Method | Map a query to a repository's method |
6 | EzyManagement | Class | Indicate the annotated class will be a management class |
7 | EzyQueryResult | Class | Indicates the annotated class will be a query result class |
8 | EzyRepository | Class or Interface | Indicates the annotated class or interface will be a repository |
9 | EzyResultDeserialized | Class | Indicates the annotated will be a result deserializer class |
10 | EzyTransactional | Method | Indicates the annotated method will be run in a transaction |
1. EzyAutoImpl
When you annotate a interface with EzyAutoImpl
annotation, a framework will recognize this interface and implement it automatically. In this example ChatMessageRepo will be implemented by ezydata-mongodb.
@EzyAutoImpl("messageRepo") public interface ChatMessageRepo extends EzyMongoRepository {}
2. EzyFeature
When you want to map a feature name with an API, a method or a class (apply for all methods in the class), you can use EzyFeature
annotation. In MetricsController every APIs will be mapped with a feature name:
@Controller public class MetricsController implements ManagementController { @EzyFeature(DEFAULT_FEATURE_NAME) @DoGet("/management/start-time") public long getStartTime() {} }
3. EzyId
When you have a composite id in an entity, you can use EzyId
annotation for the id class, example ChatChannelUserId:
@EzyId public class ChatChannelUserId { private long channelId; private String user; }
If you want to indicate a field or a methods (getter/setter) is the id property of an entity, you can use this annotation, example ChatChannel:
@EzyId public class ChatChannelUserId { private long channelId; private String user; }
4. EzyImport
Sometimes, you don't want to scan a package, you just want to include some classes to the bean management, you can use EzyImport
annotation, example:
@EzyImport(DatabaseConfiguration.class) public class Configuration {}
5. EzyKeyValue
If you want to add some additional properties to a bean, you can use EzyKeyValue
annotation, example:
@EzySingleton(properties = { @EzyKeyValue(key = "type", value = "request_listener"), @EzyKeyValue(key = "cmd", value = "1"), @EzyKeyValue(key = "priority", value = "1") }) public class HelloRequestHandler {}
6. EzyManagement
If you want to indicate an API or a method or a class (apply to all methods in the classes) is management, you can use EzyManagement
annotation, example:
@Controller("/api/v1") public class MetricsController { @EzyManagement @DoGet("/metrics") public Object metricsGet() {} }
7. EzyPackagesToScan
Sometimes you will need include one or more packages to scan beans. you can use EzyPackagesToScan
, example:
@EzyPackagesToScan("com.example.app.api") public class GlobalConfig {}
8. EzyPayment
If you want to indicate an API or a method or a class (apply to all methods in the classes) is payment, you can use EzyPayment
annotation, example:
@EzyPayment @Controller("/api/v1.2.2") public class PaymentController { @DoGet("/get-something") public void getSomeThing() {} @DoGet("/get-and-buy-something") public void getAndBuySomeThing() {} }
9. EzyProperty
When you want to map a property value or system property value or system environment value to a field or setter method, you can use EzyProperty
annotation like this:
@Setter public class GameProperty { @EzyProperty("game.max_room") private int maxRoom; @EzyProperty("game.max_player") private int maxPlayers; }