}
public Object newInstance( InjectionContext injectionContext )
{
Object mixin;
CompositeInstance compositeInstance = injectionContext.compositeInstance();
mixin = constructorsModel.newInstance( injectionContext );
if( FragmentClassLoader.isGenerated( instantiationClass ) )
{
try
{
instantiationClass.getDeclaredField( "_instance" ).set( mixin,
injectionContext.compositeInstance() );
}
catch( IllegalAccessException e )
{
e.printStackTrace();
}
catch( NoSuchFieldException e )
{
e.printStackTrace();
}
}
injectedFieldsModel.inject( injectionContext, mixin );
injectedMethodsModel.inject( injectionContext, mixin );
if( mixin instanceof Initializable )
{
try
{
( (Initializable) mixin ).initialize();
}
catch( InitializationException e )
{
List<Class<?>> compositeType = toList( compositeInstance.types() );
String message = "Unable to initialize " + mixinClass + " in composite " + compositeType;
throw new ConstructionException( message, e );
}
}
return mixin;