Skip to content

Commit

Permalink
Merge Other APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
mercyblitz committed Sep 14, 2018
1 parent 978bb02 commit 05b5425
Show file tree
Hide file tree
Showing 22 changed files with 599 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.nacos.client.config.common;
package com.alibaba.nacos.api.common;

/**
* Constant
Expand Down
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;

}
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;

}
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 {
}
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;

}
Loading

0 comments on commit 05b5425

Please sign in to comment.