public class TestBeanWrapper {
private final Map extendProperties = new HashMap(); //只初始化一次,不能指向另一个引用
private BeanWrapperImpl beanWrapper;
private PropertyDescriptor[] descriptors;
private boolean hasReflected = false;
public static void main(String[] args) {
TestBeanWrapper tb=new TestBeanWrapper();
tb.test();
}
void test(){
BeanWrapperImpl bi=new BeanWrapperImpl(this);
PropertyDescriptor[] alldescriptors=bi.getPropertyDescriptors();
int length=alldescriptors.length;
List list = new ArrayList();
for (int i = 0; i < alldescriptors.length; i++) {
if (alldescriptors[i].getReadMethod() != null
&& alldescriptors[i].getWriteMethod() != null) {
list.add(alldescriptors[i]);
System.out.println(alldescriptors[i].getDisplayName()); //显示这个类的实例属性
}
}
PropertyDescriptor[] descriptors = (PropertyDescriptor[]) list
.toArray(new PropertyDescriptor[0]);
System.out.println(descriptors.length+" list.length="+list.size());
}
public BeanWrapperImpl getBeanWrapper() {
return beanWrapper;
}
public void setBeanWrapper(BeanWrapperImpl beanWrapper) {
this.beanWrapper = beanWrapper;
}
public PropertyDescriptor[] getDescriptors() {
return descriptors;
}
public void setDescriptors(PropertyDescriptor[] descriptors) {
this.descriptors = descriptors;
}
public boolean isHasReflected() {
return hasReflected;
}
public void setHasReflected(boolean hasReflected) {
this.hasReflected = hasReflected;
}
public Map getExtendProperties() {
return extendProperties;
}
}
分享到:
相关推荐
14. <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" /> 15. 16. <!-- 对模型视图名称的解析,即在模型视图名称添加前后缀 --> 17. <bean class="org....
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="suffix" value=".jsp" /> </bean> </beans> ``` 然后,创建一个简单的Controller,比如`HelloController...
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.context.event.EventListener; import org.spring...
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect <prop key="hibernate.show_sql">...
在本文中,我们将深入探讨如何将Spring 3.1.1框架与JPA2(Java Persistence API的第二版)以及Hibernate 4.0.0.Final实现整合,以创建一个Dynamic Web Project。这个项目旨在展示如何在Web应用程序中有效地管理...
<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager"> </bean> </beans> ``` **2. dispatcher-servlet.xml**: - 配置Spring MVC的相关组件。 - 示例...
-- <bean id="taskScheduler" class="org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler"> </bean> --> </beans> ``` 这里,`<task:annotation-driven />`启用基于注解的定时任务处理。 总结...
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import org....
- `org.springframework.beans-3.0.6.RELEASE.jar`: 支持Bean属性和事件处理。 - `org.springframework.context-3.0.6.RELEASE.jar`: 支持应用上下文的创建和管理。 - `org.springframework.core-3.0.6.RELEASE....
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class MessageSender { private final AmqpTemplate rabbitTemplate; ...
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.spring...
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import org...
1. **org.springframework.beans** 包:包含了Bean工厂和各种bean相关的类,如PropertyEditor、BeanWrapper等,用于属性设置和类型转换。 2. **org.springframework.context** 包:提供了ApplicationContext接口,...
<org.springframework.version>3.2.11.RELEASE</org.springframework.version> <org.hibernate.version>4.2.10.Final</org.hibernate.version> <org.aspectj-version>1.6.10</org.aspectj-version> <org.slf4j-...
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import ...
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; @Service public class ...
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="suffix" value=".jsp"/> </bean> <!-- 配置controller --> <bean id="controller...
<listener-class>org.springframework.web.context.ContextLoaderListener <servlet-name>springMVC <servlet-class>org.springframework.web.servlet.DispatcherServlet <param-name>...
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> </bean> <!-- SqlSessionFactory --> <bean id="sqlSessionFactory" class="org.mybatis.spring...
implementation 'org.springframework:spring-context:5.x.x.RELEASE' // 替换为实际版本 implementation 'org.springframework:spring-aop:5.x.x.RELEASE' // 替换为实际版本 ``` 4. **配置AOP**: 在Spring ...