Introspectors

Introspector is just a factory of PropertyAccessor, MethodInvocation and InstanceCreator components. That components provide such operations as getting/setting a property's value, invoking a method on an instance. InstanceCreator, as you guessed, creates an instance of the requested class. Each introspector supplies corresponding instance creator.

Currently Nomin provides the following introspectors

  • ReflectionIntrospector

    It performs getting/setting properties using accessor methods which are called through the Java reflection mechanism. ReflectionIntrospector uses supplied NamingPolicy instance to determine accessor methods. JbNamingPolicy is used by default, this implementation cerresponds the JavaBeans convention. Its InstanceCreator named ReflectionInstanceCreator instantiates objects using Class.newInstance().

  • ExplodingIntrospector

    It performs getting/setting properties using a class field immediately through through the Java reflection mechanism and may be useful in case when domain object don't provide accessors for their properties. Supplied instance creator is ReflectionInstanceCreator.

  • FastIntrospector

    It performs getting/setting properties and invoking methods using CGLIB FastMethods. It uses supplied NamingPolicy instance to determine accessor methods. FastInstanceCreator instantiates objects using CGLIB FastConstructor. Using FastIntrospector/FastInstanceCreator ensure for increasing performance up to 50% approximately (depends on harware).

    FastIntrospector is not created for you automatically, you have to instantiate it and then you can use created instance in mapping. It was done so not to enforce users to depend on CGLIB. If you are intended to use FastIntrospector just provide CGLIB package on the classpath.

Predefined introspectors are exploding, jb and fast. In a mapping we can choose any introspector as follows

  mappingFor a: Class1, b: Class2
  introspector exploding // or jb or fast

  introspector new SpecificIntrospector()

It is possible to set default introspector to be used widely in all mappings as shown below

  NominMappper nomin = new Nomin(...).defaultIntrospector(Mapping.fast);

You are absolutely free to implement an introspector/instance creator for your own needs.