forked from alibaba/nacos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
978bb02
commit 05b5425
Showing
22 changed files
with
599 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
api/src/main/java/com/alibaba/nacos/api/config/annotation/NacosConfigListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alibaba.nacos.api.config.annotation; | ||
|
||
import com.alibaba.nacos.api.common.Constants; | ||
import com.alibaba.nacos.api.config.convert.NacosConfigConverter; | ||
|
||
import java.lang.annotation.*; | ||
|
||
import static com.alibaba.nacos.api.common.Constants.DEFAULT_GROUP; | ||
|
||
/** | ||
* Annotation that marks a method as a listener for Nacos Config change. | ||
* | ||
* @author <a href="mailto:[email protected]">Mercy</a> | ||
* @since 0.1.0 | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.METHOD) | ||
@Documented | ||
public @interface NacosConfigListener { | ||
|
||
/** | ||
* Nacos Group ID | ||
* | ||
* @return default value {@link Constants#DEFAULT_GROUP}; | ||
*/ | ||
String groupId() default DEFAULT_GROUP; | ||
|
||
/** | ||
* Nacos Data ID | ||
* | ||
* @return required value. | ||
*/ | ||
String dataId(); | ||
|
||
/** | ||
* Specify {@link NacosConfigConverter Nacos configuraion convertor} class to convert target type instance. | ||
* | ||
* @return The implementation class of {@link NacosConfigConverter} | ||
*/ | ||
Class<? extends NacosConfigConverter> converter() default NacosConfigConverter.class; | ||
|
||
/** | ||
* The {@link NacosProperties} attribute, If not specified, it will use | ||
* global Nacos Properties. | ||
* | ||
* @return the default value is {@link NacosProperties} | ||
*/ | ||
NacosProperties properties() default @NacosProperties; | ||
|
||
/** | ||
* Maximum timeout value of execution in milliseconds, which is used to prevent long-time blocking execution | ||
* impacting others. | ||
* | ||
* @return default value is 1000 | ||
*/ | ||
long timeout() default 1000L; | ||
|
||
} |
104 changes: 104 additions & 0 deletions
104
api/src/main/java/com/alibaba/nacos/api/config/annotation/NacosConfigurationProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alibaba.nacos.api.config.annotation; | ||
|
||
import com.alibaba.nacos.api.PropertyKeyConst; | ||
import com.alibaba.nacos.api.common.Constants; | ||
|
||
import java.lang.annotation.*; | ||
|
||
import static com.alibaba.nacos.api.common.Constants.DEFAULT_GROUP; | ||
|
||
|
||
/** | ||
* An annotation for Nacos configuration Properties for binding POJO as Properties Object. | ||
* | ||
* @author <a href="mailto:[email protected]">Mercy</a> | ||
* @see PropertyKeyConst | ||
* @since 0.1.0 | ||
*/ | ||
@Target({ElementType.TYPE}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Documented | ||
public @interface NacosConfigurationProperties { | ||
|
||
/** | ||
* Nacos Group ID | ||
* | ||
* @return default value {@link Constants#DEFAULT_GROUP}; | ||
*/ | ||
String groupId() default DEFAULT_GROUP; | ||
|
||
/** | ||
* Nacos Data ID | ||
* | ||
* @return required value. | ||
*/ | ||
String dataId(); | ||
|
||
/** | ||
* It indicates the properties of current doBind bean is auto-refreshed | ||
* when Nacos configuration is changed. | ||
* | ||
* @return default value is <code>false</code> | ||
*/ | ||
boolean autoRefreshed() default false; | ||
|
||
|
||
/** | ||
* Flag to indicate that when binding to this object invalid fields should be ignored. | ||
* Invalid means invalid according to the binder that is used, and usually this means | ||
* fields of the wrong type (or that cannot be coerced into the correct type). | ||
* | ||
* @return the flag value (default false) | ||
*/ | ||
boolean ignoreInvalidFields() default false; | ||
|
||
/** | ||
* Flag to indicate that when binding to this object fields with periods in their | ||
* names should be ignored. | ||
* | ||
* @return the flag value (default false) | ||
*/ | ||
boolean ignoreNestedProperties() default false; | ||
|
||
/** | ||
* Flag to indicate that when binding to this object unknown fields should be ignored. | ||
* An unknown field could be a sign of a mistake in the Properties. | ||
* | ||
* @return the flag value (default true) | ||
*/ | ||
boolean ignoreUnknownFields() default true; | ||
|
||
/** | ||
* Flag to indicate that an exception should be raised if a Validator is available and | ||
* validation fails. If it is set to false, validation errors will be swallowed. They | ||
* will be logged, but not propagated to the caller. | ||
* | ||
* @return the flag value (default true) | ||
*/ | ||
boolean exceptionIfInvalid() default true; | ||
|
||
/** | ||
* The {@link NacosProperties} attribute, If not specified, it will use | ||
* global Nacos Properties. | ||
* | ||
* @return the default value is {@link NacosProperties} | ||
*/ | ||
NacosProperties properties() default @NacosProperties; | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
api/src/main/java/com/alibaba/nacos/api/config/annotation/NacosIgnore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alibaba.nacos.api.config.annotation; | ||
|
||
import java.lang.annotation.*; | ||
|
||
/** | ||
* An annotation for ignore field from annotated | ||
* {@link NacosConfigurationProperties} Properties Object. | ||
* | ||
* @author <a href="mailto:[email protected]">Mercy</a> | ||
* @see NacosConfigurationProperties | ||
* @see NacosProperty | ||
* @since 0.1.0 | ||
*/ | ||
@Target({ElementType.FIELD}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Documented | ||
public @interface NacosIgnore { | ||
} |
47 changes: 47 additions & 0 deletions
47
api/src/main/java/com/alibaba/nacos/api/config/annotation/NacosInjected.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alibaba.nacos.api.config.annotation; | ||
|
||
import com.alibaba.nacos.api.PropertyKeyConst; | ||
import com.alibaba.nacos.api.config.ConfigService; | ||
import com.alibaba.nacos.api.naming.NamingService; | ||
|
||
import java.lang.annotation.*; | ||
|
||
/** | ||
* An annotation to inject {@link ConfigService} or {@link NamingService} instance into the target Bean. | ||
* | ||
* @author <a href="mailto:[email protected]">Mercy</a> | ||
* @see ConfigService | ||
* @see NamingService | ||
* @see PropertyKeyConst | ||
* @since 0.1.0 | ||
*/ | ||
@Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD, ElementType.ANNOTATION_TYPE}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Documented | ||
public @interface NacosInjected { | ||
|
||
/** | ||
* The {@link NacosProperties} attribute, If not specified, it will use | ||
* global Nacos Properties global Nacos Properties}. | ||
* | ||
* @return the default value is {@link NacosProperties} | ||
*/ | ||
NacosProperties properties() default @NacosProperties; | ||
|
||
} |
Oops, something went wrong.