Skip to content
xquan edited this page Oct 10, 2016 · 8 revisions

Navigation

中文

Home

Introduction

Service profile can make the framework decide which services can be loaded or which services should be excluded when loading service.

Tag

Each service can define one or more Tags. For example:

@Service
@Tag({"p1", "p2"})
public class Service1 { ... }

Configure Profile

To enable service profile feature, we need tell the framework which services can be loaded and which service can't be loaded, so we will configure profile. In configuration file, we can define one or more profile, for example:

profiles:
    - name: profile1
      model: exclude
      matching: satisfy-all
      tags:
        - p1
        - p2
    - name: profile2
      model: include
      matching: satisfy-any
      tags:
        - p2
        - p3

There are two profile is defined in above configuration file, one is named profile1, and the other is named profile2. Next we need specific which profile is active at run-time, we can specified the profile in the command line parameter like:

profile=profile1

The the profile1 will be active at run-time.

Profile Configuration Detail

Each profile has 4 configurable properties: name, model, matching, tags

name

The name property specific the name of the profile, the name must be unique, an exception will be thrown if there are more than one profile has same name.

model

The model property is a enumeration property, available value are: include and exclude, the property is case insensitive.

  • The include means that the service is matched tags and matching rule which are defined in profile, the service will be considered satisfied, then the service will be loaded by framework, otherwise the service will not be loaded.
  • The exclude means that the service is matched tags and matching rule which are defined in profile, the service will be considered satisfied, then the service will not be loaded by framework, otherwise the service will be loaded.

matching

The matching property is a enumeration property, available value are: satisfy-all and satisfy-any, the property is case insensitive.

  • The satisfy-all means all tags which are defined in the profile must be matched with the tags which are defined in service, then the service is considered satisfied, otherwise the service is considered unsatisfied.
  • The satisfy-any means any of tags which are defined in the profile matched with the tags which are defined in service, then the service is considered satisfied, otherwise the service is considered unsatisfied.

tags

The tags property can define one or more Tag.

Configuration

Configurable Path Configuration Type Description Is Required Default Value (Behavior)
app.active-profile String Specified currently active profile for the application No Default profile will load all of services
profiles List Including one or more profile definition No No

Clone this wiki locally