BeanDefinition interface exposes initMethodName and destroyMethodName

Also includes setters for role and description.

Issue: SPR-17275
This commit is contained in:
Juergen Hoeller
2018-09-13 20:24:36 +02:00
parent 77887ef739
commit 97cea7f36e
4 changed files with 80 additions and 39 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -242,6 +242,65 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement {
return !getPropertyValues().isEmpty();
}
/**
* Set the name of the initializer method.
* @since 5.1
*/
void setInitMethodName(@Nullable String initMethodName);
/**
* Return the name of the initializer method.
* @since 5.1
*/
@Nullable
String getInitMethodName();
/**
* Set the name of the destroy method.
* @since 5.1
*/
void setDestroyMethodName(@Nullable String destroyMethodName);
/**
* Return the name of the destroy method.
* @since 5.1
*/
@Nullable
String getDestroyMethodName();
/**
* Set the role hint for this {@code BeanDefinition}. The role hint
* provides the frameworks as well as tools with an indication of
* the role and importance of a particular {@code BeanDefinition}.
* @since 5.1
* @see #ROLE_APPLICATION
* @see #ROLE_SUPPORT
* @see #ROLE_INFRASTRUCTURE
*/
void setRole(int role);
/**
* Get the role hint for this {@code BeanDefinition}. The role hint
* provides the frameworks as well as tools with an indication of
* the role and importance of a particular {@code BeanDefinition}.
* @see #ROLE_APPLICATION
* @see #ROLE_SUPPORT
* @see #ROLE_INFRASTRUCTURE
*/
int getRole();
/**
* Set a human-readable description of this bean definition.
* @since 5.1
*/
void setDescription(@Nullable String description);
/**
* Return a human-readable description of this bean definition.
*/
@Nullable
String getDescription();
// Read-only attributes
@@ -265,22 +324,6 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement {
*/
boolean isAbstract();
/**
* Get the role hint for this {@code BeanDefinition}. The role hint
* provides the frameworks as well as tools with an indication of
* the role and importance of a particular {@code BeanDefinition}.
* @see #ROLE_APPLICATION
* @see #ROLE_SUPPORT
* @see #ROLE_INFRASTRUCTURE
*/
int getRole();
/**
* Return a human-readable description of this bean definition.
*/
@Nullable
String getDescription();
/**
* Return a description of the resource that this bean definition
* came from (for the purpose of showing context in case of errors).

View File

@@ -878,6 +878,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
* Set the name of the initializer method.
* <p>The default is {@code null} in which case there is no initializer method.
*/
@Override
public void setInitMethodName(@Nullable String initMethodName) {
this.initMethodName = initMethodName;
}
@@ -885,6 +886,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
/**
* Return the name of the initializer method.
*/
@Override
@Nullable
public String getInitMethodName() {
return this.initMethodName;
@@ -911,6 +913,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
* Set the name of the destroy method.
* <p>The default is {@code null} in which case there is no destroy method.
*/
@Override
public void setDestroyMethodName(@Nullable String destroyMethodName) {
this.destroyMethodName = destroyMethodName;
}
@@ -918,6 +921,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
/**
* Return the name of the destroy method.
*/
@Override
@Nullable
public String getDestroyMethodName() {
return this.destroyMethodName;
@@ -960,6 +964,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
/**
* Set the role hint for this {@code BeanDefinition}.
*/
@Override
public void setRole(int role) {
this.role = role;
}
@@ -975,6 +980,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
/**
* Set a human-readable description of this bean definition.
*/
@Override
public void setDescription(@Nullable String description) {
this.description = description;
}