承接上文

抽象对象和子对象


.net篇(环境为vs2012+Spring.Core.dll v1.31

    public class parent    {
public string Name { get; set; }
public int Age { get;set; }
}
public class chlid {
public string Name { get; set; }
public int Age { get; set; }
}
  <object id="p" type="SpringBase.parent,SpringBase">
<property name="Name" value="cnljli-p0" />
<property name="Age" value="1" />
</object>
<object id="c" parent="p" type="SpringBase.chlid,SpringBase">
<property name="Age" value="2" />
</object>
<object id="p1">
<property name="Name" value="cnljli-p1" />
<property name="Age" value="2" />
</object>
<object id="c1" parent="p1" type="SpringBase.chlid,SpringBase">
<property name="Age" value="3" />
</object>
<object id="p2" type="SpringBase.chlid,SpringBase" abstract="true">
<property name="Name" value="cnljli-p2" />
<property name="Age" value="3" />
</object>
<object id="c2" parent="p2" type="SpringBase.chlid,SpringBase">
<property name="Age" value="4" />
</object>
  1. 可以在不声明一个类的情况下直接写一个Object来做模板

java篇(环境为Maven+Jdk1.7+IntelliJ IDEA 12.1.4

package springdemo;
public class Parent {
private String name;
private Integer age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
}
class Chlid{
private String name;
private Integer age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
}
    <bean id="p" class="springdemo.Parent">
<property name="name" value="cnljli-p0" />
<property name="age" value="1" />
</bean>
<bean id="c" parent="p" class="springdemo.Chlid">
<property name="age" value="2" />
</bean>
<bean id="p1" class="springdemo.Parent" abstract="true">
<property name="name" value="cnljli-p2" />
<property name="age" value="3" />
</bean>
<bean id="c1" parent="p1" class="springdemo.Chlid">
<property name="age" value="4" />
</bean>

javaCsharp的共同点

  1. 用其他类做父类,子类不一定继承父类,但是必须要包含父类的属性
  2. 可以用自己本身做为模板,当设置参数abstract为true的时候这个对象通过id调用的
    时候返回会报错
  3. 子类会覆盖父类中某些属性的方法,不过不会覆盖属性为
    depends-on(依赖)、dependency-check(依赖检查)、autowire(自动装配模式)、
    singleton(单例)和lazy-init(延迟加载)

Ⅷ.spring的点点滴滴--抽象对象和子对象的更多相关文章

  1. Ⅶ.spring的点点滴滴--自定义对象行为

    承接上文 自定义对象行为 .net篇(环境为vs2012+Spring.Core.dll v1.31) public class lifeCycle : Spring.Objects.Factory. ...

  2. Ⅹ.spring的点点滴滴--IObjectPostProcessor(对象后处理器)

    承接上文 IObjectPostProcessor(对象后处理器) 前提是实现接口的对象注册给当前容器 C#: 通过继承AbstractObjectFactory对象的AddObjectPostPro ...

  3. Ⅸ.spring的点点滴滴--IObjectFactory与IFactoryObject的杂谈

    承接上文 ObjectFactory与IFactoryObject的杂谈 .net篇(环境为vs2012+Spring.Core.dll v1.31) public class parent { pu ...

  4. XI.spring的点点滴滴--IObjectFactoryPostProcessor(工厂后处理器)

    承接上文 IObjectFactoryPostProcessor(工厂后处理器)) 前提是实现接口的对象注册给当前容器 直接继承的对象调用这个postProcessBeanFactory方法,参数为工 ...

  5. Ⅵ.spring的点点滴滴--自定义类型转换器

    承接上文 自定义类型转换器 .net篇(环境为vs2012+Spring.Core.dll v1.31) public class CustomeConverter : TypeConverter{ ...

  6. Ⅱ.spring的点点滴滴--对象

    承接上文 对象的各种实例化 .net篇(环境为vs2012+Spring.Core.dll) 修改原来的PersonDao对象为 public class PersonDao : IPersonDao ...

  7. Ⅴ.spring的点点滴滴--引用其他对象或类型的成员

    承接上文 引用其他对象或类型的成员 .net篇(环境为vs2012+Spring.Core.dll v1.31) public class Person { public string Name { ...

  8. Ⅳspring的点点滴滴--方法和事件

    承接上文 方法和事件 .net篇(环境为vs2012+Spring.Core.dll v1.31) public abstract class MethodDemo { protected abstr ...

  9. Ⅲ.spring的点点滴滴--赋值

    承接上文 对象的赋值(调用方式都一样不再阐述) .net篇(环境为vs2012+Spring.Core.dll v1.31) public class PropertyDemo{ public Sys ...

随机推荐

  1. xcode 中添加pch文件

    xcode6以后去掉了pch文件,据说苹果是觉得把头文件加在pch中,会让编译变慢,但是作为我们程序员来说难不倒我们,所以我们手动来添加一下pch文件即可   首先创建一个工程,然后创建一个pch文件 ...

  2. 一个简单的php分页类代码(转载)

    入门级php分页类 原文地址:http://www.xfcodes.com/php/fenye/3608.htm 时间:2015-12-16 20:52:00来源:网络 php分页类. 复制代码代码如 ...

  3. javascript-代码复用模式

    代码复用模式 1)使用原型继承            函数对象中自身声明的方法和属性与prototype声名的对象有什么不同:      自身声明的方法和属性是静态的, 也就是说你在声明后,试图再去增 ...

  4. asp.net(c#)有关 Session 操作的几个误区

    1. this.Session["username"] = null  HttpSessionState 内部使 用 NameObjectCollection 类型的集合对象来存储 ...

  5. WINDOWS 2008 SERVER域用户自动登陆

    The user I wanted to auto-logon as didn’t have a password, this reg hack worked instead: HKEY_LOCAL_ ...

  6. CHANGE DEFAULT FTP PORT FOR VSFTP

    http://twincreations.co.uk/change-default-ftp-port-for-vsftp/ http://www.cnblogs.com/kuliuheng/p/320 ...

  7. ffmpeg编译 --enable :没有命令

    参照官方推荐的编译:http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/ build_config.sh总是不过, 问题原因:./config ...

  8. Android TextView中的ellipsize属性

    TextView中有个ellipsize属性,作用是当文字过长时,该控件该如何显示,解释如下: android:ellipsize=”start”—–省略号显示在开头 android:ellipsiz ...

  9. simplified build configuration

    http://blogs.msdn.com/b/saraford/archive/2005/08/16/452411.aspx Did you know… That you can hide the ...

  10. Find the capitals

    Find the capitals Description: Instructions Write a function that takes a single string (word) as ar ...