clone()方法复制Spring容器中的bean,比如SessionFactory,那么这个克隆的对象,会受到Spring容器管理吗?求大虾指教!!!比如:
ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
StudentService studentService = (StudentService) context.getBean("studentServiceBean");
StudentService newStudentService = null ;try {
     newStudentService = studentService.clone();
} catch (CloneNotSupportedException e) {
     e.printStackTrace();
}Student s = newStudentService.find(1);我通过clone()获得的newStudentService ,它受到Spring容器管理吗?就好比我克隆Spring容器中的SessionFactory,由于SessionFactory的close()是spring执行的,所以我需要了解,是克隆的对象也会受spring容器管理!

解决方案 »

  1.   

    2L朋友的意思就是,也收到Spring容易管理咯...我就不太清楚,这个有什么方式调试,测试没...头痛啊...
      

  2.   

    不受其管理,用spring的AOP可以测试。我没试过,谁有兴趣试下告诉我答案
      

  3.   

    你要知道clone在你没有override的情况下只是浅拷贝
      

  4.   

    ls的朋友的意思是,只要是@override的拷贝应该是要受到spring管理咯...为什么大家都比较含糊哇...不懂了...难道这样才能体现大神与菜鸟的区别?
      

  5.   

    后来测试下了...结果表明,clone()的SpringBean并不受到Spring管理...具体测试内容如下:
    http://blog.csdn.net/eclipser1987/archive/2010/01/28/5265940.aspx