Skip to content

Commit

Permalink
Polish #2235
Browse files Browse the repository at this point in the history
  • Loading branch information
mercyblitz committed Oct 17, 2018
1 parent 2e826a6 commit 3571ea4
Show file tree
Hide file tree
Showing 18 changed files with 685 additions and 711 deletions.
11 changes: 11 additions & 0 deletions dependencies-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
<jaxb_version>2.2.7</jaxb_version>
<activation_version>1.2.0</activation_version>
<hessian_lite_version>3.2.4</hessian_lite_version>
<alibaba_spring_context_support_version>1.0.1</alibaba_spring_context_support_version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -358,6 +359,16 @@
<artifactId>hessian-lite</artifactId>
<version>${hessian_lite_version}</version>
</dependency>

<!-- Alibaba extensions -->

<!-- Spring Context Support -->
<dependency>
<groupId>com.alibaba.spring</groupId>
<artifactId>spring-context-support</artifactId>
<version>${alibaba_spring_context_support_version}</version>
</dependency>

<!-- Test lib -->
<dependency>
<groupId>org.apache.curator</groupId>
Expand Down
7 changes: 6 additions & 1 deletion dubbo-config/dubbo-config-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.alibaba</groupId>
Expand Down Expand Up @@ -51,6 +52,10 @@
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.spring</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,16 @@
*/
package com.alibaba.dubbo.config.spring;

import com.alibaba.dubbo.config.ApplicationConfig;
import com.alibaba.dubbo.config.ModuleConfig;
import com.alibaba.dubbo.config.MonitorConfig;
import com.alibaba.dubbo.config.ProtocolConfig;
import com.alibaba.dubbo.config.ProviderConfig;
import com.alibaba.dubbo.config.RegistryConfig;
import com.alibaba.dubbo.config.ServiceConfig;
import com.alibaba.dubbo.config.*;
import com.alibaba.dubbo.config.annotation.Service;
import com.alibaba.dubbo.config.spring.context.event.ServiceBeanExportedEvent;
import com.alibaba.dubbo.config.spring.extension.SpringExtensionFactory;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationListener;
import org.springframework.context.*;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.support.AbstractApplicationContext;

Expand All @@ -46,7 +39,9 @@
*
* @export
*/
public class ServiceBean<T> extends ServiceConfig<T> implements InitializingBean, DisposableBean, ApplicationContextAware, ApplicationListener<ContextRefreshedEvent>, BeanNameAware {
public class ServiceBean<T> extends ServiceConfig<T> implements InitializingBean, DisposableBean,
ApplicationContextAware, ApplicationListener<ContextRefreshedEvent>, BeanNameAware,
ApplicationEventPublisherAware {

private static final long serialVersionUID = 213195494150089726L;

Expand All @@ -60,6 +55,8 @@ public class ServiceBean<T> extends ServiceConfig<T> implements InitializingBean

private transient boolean supportedApplicationListener;

private ApplicationEventPublisher applicationEventPublisher;

public ServiceBean() {
super();
this.service = null;
Expand Down Expand Up @@ -265,6 +262,34 @@ && getInterface() != null && getInterface().length() > 0
}
}

/**
* Get the name of {@link ServiceBean}
*
* @return {@link ServiceBean}'s name
* @since 2.6.5
*/
public String getBeanName() {
return this.beanName;
}

/**
* @since 2.6.5
*/
@Override
public void export() {
super.export();
// Publish ServiceBeanExportedEvent
publishExportEvent();
}

/**
* @since 2.6.5
*/
private void publishExportEvent() {
ServiceBeanExportedEvent exportEvent = new ServiceBeanExportedEvent(this);
applicationEventPublisher.publishEvent(exportEvent);
}

@Override
public void destroy() throws Exception {
// This will only be called for singleton scope bean, and expected to be called by spring shutdown hook when BeanFactory/ApplicationContext destroys.
Expand All @@ -280,4 +305,13 @@ protected Class getServiceClass(T ref) {
}
return super.getServiceClass(ref);
}

/**
* @param applicationEventPublisher
* @since 2.6.5
*/
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.applicationEventPublisher = applicationEventPublisher;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
*/
package com.alibaba.dubbo.config.spring.beans.factory.annotation;

import com.alibaba.dubbo.config.AbstractInterfaceConfig;
import com.alibaba.dubbo.config.ApplicationConfig;
import com.alibaba.dubbo.config.ModuleConfig;
import com.alibaba.dubbo.config.MonitorConfig;
import com.alibaba.dubbo.config.RegistryConfig;
import com.alibaba.dubbo.config.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;
Expand All @@ -34,6 +30,7 @@

/**
* Abstract Configurable {@link Annotation} Bean Builder
*
* @since 2.5.7
*/
abstract class AbstractAnnotationConfigBeanBuilder<A extends Annotation, B extends AbstractInterfaceConfig> {
Expand Down Expand Up @@ -76,7 +73,7 @@ public final B build() throws Exception {
configureBean(bean);

if (logger.isInfoEnabled()) {
logger.info(bean + " has been built.");
logger.info("The bean[type:" + bean.getClass().getSimpleName() + "] has been built.");
}

return bean;
Expand Down
Loading

0 comments on commit 3571ea4

Please sign in to comment.