use of org.apache.servicecomb.registry.definition.MicroserviceNameParser in project java-chassis by ServiceComb.
the class SwaggerLoader method registerSwagger.
public void registerSwagger(String microserviceName, String schemaId, Swagger swagger) {
MicroserviceNameParser parser = new MicroserviceNameParser(RegistrationManager.INSTANCE.getMicroservice().getAppId(), microserviceName);
registerSwagger(parser.getAppId(), parser.getShortName(), schemaId, swagger);
}
use of org.apache.servicecomb.registry.definition.MicroserviceNameParser in project java-chassis by ServiceComb.
the class RegistrationManager method registerMicroserviceMapping.
/**
* <p>
* Register a third party service if not registered before, and set it's instances into
* {@linkplain StaticMicroserviceVersions StaticMicroserviceVersions}.
* </p>
* <p>
* The registered third party service has the same {@code appId} and {@code environment} as this microservice instance has,
* and there is only one schema represented by {@code schemaIntfCls}, whose name is the same as {@code microserviceName}.
* </p>
* <em>
* This method is for initializing 3rd party service endpoint config.
* i.e. If this service has not been registered before, this service will be registered and the instances will be set;
* otherwise, NOTHING will happen.
* </em>
*
* @param microserviceName name of the 3rd party service, and this param also specifies the schemaId
* @param version version of this 3rd party service
* @param instances the instances of this 3rd party service. Users only need to specify the endpoint information, other
* necessary information will be generate and set in the implementation of this method.
* @param schemaIntfCls the producer interface of the service. This interface is used to generate swagger schema and
* can also be used for the proxy interface of RPC style invocation.
*/
public void registerMicroserviceMapping(String microserviceName, String version, List<MicroserviceInstance> instances, Class<?> schemaIntfCls) {
MicroserviceNameParser parser = new MicroserviceNameParser(getAppId(), microserviceName);
MicroserviceManager microserviceManager = DiscoveryManager.INSTANCE.getAppManager().getOrCreateMicroserviceManager(parser.getAppId());
microserviceManager.getVersionsByName().computeIfAbsent(microserviceName, svcName -> new StaticMicroserviceVersions(DiscoveryManager.INSTANCE.getAppManager(), parser.getAppId(), microserviceName).init(schemaIntfCls, version, instances));
}
Aggregations