Skip to main content

dawdler-service-core

Module introduction​

The service core module.

1. Add the dependency to the pom​

<groupId>club.dawdler</groupId>
<artifactId>dawdler-service-core</artifactId>

2. About @Service​

@Service marks a class as a service; it can be placed on an implementation class or on an interface.

@Retention(value = RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE })
public @interface Service {

String value() default "";// Effective on the caller side; specifies the name of the service deployed on the server side.

String serviceName() default "";// The class name of the service; defaults to empty, in which case the fully qualified name of the class or interface where the annotation is placed is used (class first).

boolean single() default true;// Effective on the server side; whether the implementation class of a service is a singleton. Singleton by default.

int timeout() default 120;// Effective on the caller side; the timeout for calling the remote service, in seconds, 120 seconds by default.

boolean fuzzy() default true;// Effective on the caller side; whether to match the method fuzzily, true by default; fuzzy matching matches by method name and parameter count, while non-fuzzy matching matches exactly by method name and parameter types. Fuzzy matching is more efficient; if a service implementation class contains methods with the same name and the same parameter count, set this parameter to false for exact matching.

String loadBalance() default "roundRobin";// Effective on the caller side; load-balancing strategy.

}

Example:

@Service("order-service")
public interface OrderService {

/**
*
* Queries order information by order number
* @author srchen
* @version 1.0
* @param orderId order ID
*/
BaseResult<Order> selectByPrimaryKey(Integer orderId);
}