public ManagedObject inject(final Object target) throws InjectionException
  {
      final String METHOD_NAME="inject";
      
       if (TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) {
           logger.entering(CLASS_NAME, METHOD_NAME, target);
       }
      
        ManagedObject r = null;  
        try {
            if (null != managedObjectService){
                
                // Make sure the class is know to the injection engine
                processDynamicInjectionMetaData(target.getClass());
                ManagedObject mo;
               
                try {
                    ModuleMetaData moduleMetaData = getModuleMetaData();
                    ManagedObjectFactory<Object> mof = (ManagedObjectFactory<Object>) managedObjectService.createManagedObjectFactory(moduleMetaData, target.getClass(), false);
                    mo = mof.createManagedObject(target, null);
                } catch (ManagedObjectException moe){
                    
                    if (TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) {
                        logger.logp(Level.FINE, CLASS_NAME, METHOD_NAME, "IllegalStateException from managed object service:" + moe );
                     }   
                    
                     mo = new WCManagedObjectImpl(target);
                 }
              
                r = mo;
                mo.inject(this.referenceContext);
           }
        } catch (ManagedObjectException e) {
            throw new InjectionException(e.getCause());
        }
        
        if (TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) {
            logger.exiting(CLASS_NAME, METHOD_NAME, r);
        }
        return r;
  }
public ManagedObject inject ( final Object target ) throws InjectionException { final String METHOD_NAME = "inject" ; if ( TraceComponent . isAnyTracingEnabled ( ) && logger . isLoggable ( Level . FINE ) ) { logger . entering ( CLASS_NAME , METHOD_NAME , target ) ; } ManagedObject r = null ; try { if ( null != managedObjectService ) { processDynamicInjectionMetaData ( target . getClass ( ) ) ; ManagedObject mo ; try { ModuleMetaData moduleMetaData = getModuleMetaData ( ) ; ManagedObjectFactory < Object > mof = ( ManagedObjectFactory < Object > ) managedObjectService . createManagedObjectFactory ( moduleMetaData , target . getClass ( ) , false ) ; mo = mof . createManagedObject ( target , null ) ; } catch ( ManagedObjectException moe ) { if ( TraceComponent . isAnyTracingEnabled ( ) && logger . isLoggable ( Level . FINE ) ) { logger . logp ( Level . FINE , CLASS_NAME , METHOD_NAME , "IllegalStateException from managed object service:" + moe ) ; } mo = new WCManagedObjectImpl ( target ) ; } r = mo ; mo . inject ( this . referenceContext ) ; } } catch ( ManagedObjectException e ) { throw new InjectionException ( e . getCause ( ) ) ; } if ( TraceComponent . isAnyTracingEnabled ( ) && logger . isLoggable ( Level . FINE ) ) { logger . exiting ( CLASS_NAME , METHOD_NAME , r ) ; } return r ; }
This method injects the target which is typically a servlet, filter or a event listener and returns the ManagedObject associated with it.
The ManagedObject is in turn released in the destroy/constextDestroyed lifecycle method of the target.

@param target the filter, servlet or listener that is being injected into
@return  This method will either return the managed object if the injection was successful or throw the exception that resulted during the inject
@throws InjectionException if there was an error during the injection