tags:

views:

22

answers:

1

hi!,

I have seen strange behavior when I marked an object as abstract="true". how the object will behave when I marked an object as abstract="true"? what is abstract="true".

when to use abstract="true"? becuase I can inherit the property by using parent="object id" without marked parent object as abstract="true".

the strange behaviour:

When I am refering the abstract marked object, spring is throwing an error (Inner Exception: Spring.Core.TypeMismatchException: Cannot convert property value of type [Spring.Objects.Factory.Support.RootObjectDefinitio n] to required type)

but when I run my unit test and injecting the dependency via autowire by type using " Spring.Testing.NUnit.AbstractDependencyInjectionSp ringContextTests " then the spring is injecting the abstract marked object properly which is strange.

I have no idea what is going on?

e.g.

public class Vehicle
{
public int NoOfTyre { get; set; }
public string Color { get; set; }
public string EngineType { get; set; }
public string GearType { get; set; }
public string DrivingStyle { get; set; }
public string Manufacture { get; set; }
}

public class Car : Vehicle
{
public string DoorType { get; set; }
}

public class Scooter : Vehicle
{
public string ScooterType { get; set; }
}

Please help!

Cheers, Milind

+3  A: 

when to use abstract="true"? becuase I can inherit the property by using parent="object id" without marked parent object as abstract="true"

The section on object definition inheritance in the Sprint.Net documentation explains it pretty well.

You use abstract="true" when you will use the object definition only to create child definitions. This may be the case because you know the definition is incomplete, because there is no corresponding .NET class, or simply to express your intent that the definition is merely a reusable template.

Wim Coenen
Thanks. I got it.