@SuppressWarnings( "unchecked" )
public Object provideInjection( InjectionContext context )
throws InjectionProviderException
{
UsesInstance uses = context.uses();
Class injectionType = dependency.rawInjectionType();
Object usesObject = uses.useForType( injectionType );
if( usesObject == null && !dependency.optional())
{
// No @Uses object provided
// Try instantiating a Transient or Object for the given type
ModuleInstance moduleInstance = context.module();
try
{
if (context.instance() != null)
uses = uses.use( context.instance() );
usesObject = moduleInstance.newTransient( injectionType, uses.toArray() );
} catch( NoSuchCompositeException e )
{
try
{
usesObject = moduleInstance.newObject( injectionType, uses.toArray() );
} catch( NoSuchObjectException e1 )
{
// Could not instantiate an instance - to try instantiate as plain class
try
{