Polish spring-cloud-incubator/spring-cloud-alibaba#538 : Add Production-Ready features for Dubbo Spring Cloud
parent
e912820387
commit
f2fa0addf8
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.springframework.cloud.alibaba.dubbo.actuate;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
|
import org.springframework.cloud.alibaba.dubbo.actuate.endpoint.DubboRestMetadataEndpoint;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dubbo Metadata Endpoints Auto-{@link Configuration}
|
||||||
|
*/
|
||||||
|
@ConditionalOnClass(name = "org.springframework.boot.actuate.endpoint.annotation.Endpoint")
|
||||||
|
@PropertySource(value = "classpath:/META-INF/dubbo/default/actuator-endpoints.properties")
|
||||||
|
@ManagementContextConfiguration
|
||||||
|
public class DubboMetadataEndpointAutoConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
@ConditionalOnEnabledEndpoint
|
||||||
|
public DubboRestMetadataEndpoint dubboRestMetadataEndpoint() {
|
||||||
|
return new DubboRestMetadataEndpoint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.springframework.cloud.alibaba.dubbo.actuate.endpoint;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||||
|
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
||||||
|
import org.springframework.cloud.alibaba.dubbo.service.DubboMetadataConfigService;
|
||||||
|
|
||||||
|
import static org.springframework.http.MediaType.APPLICATION_JSON_UTF8_VALUE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dubbo Rest Metadata {@link Endpoint}
|
||||||
|
*/
|
||||||
|
@Endpoint(id = "dubborestmetadata")
|
||||||
|
public class DubboRestMetadataEndpoint {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DubboMetadataConfigService dubboMetadataConfigService;
|
||||||
|
|
||||||
|
@ReadOperation(produces = APPLICATION_JSON_UTF8_VALUE)
|
||||||
|
public String get() {
|
||||||
|
return dubboMetadataConfigService.getServiceRestMetadata();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
# Dubbo Endpoints Default Properties is loaded by @PropertySource with low order,
|
||||||
|
# Set enabled for Dubbo Endpoints
|
||||||
|
management.endpoint.dubborestmetadata.enabled = true
|
||||||
|
|
||||||
|
# "management.endpoints.web.base-path" should not be configured in this file
|
||||||
|
# Re-defines path-mapping of Dubbo Web Endpoints
|
||||||
|
management.endpoints.web.path-mapping.dubborestmetadata = dubbo/rest/metadata
|
Loading…
Reference in New Issue