code: protected static void lookupFieldResource(javax.naming.Context context, 
              Object instance, Field field, String name)
          throws NamingException, IllegalAccessException {
      
          Object lookedupResource = null;
          boolean accessibility = false;
          
          String normalizedName = normalize(name);
          
          if ((normalizedName != null) && (normalizedName.length() > 0)) {
              lookedupResource = context.lookup(normalizedName);
          } else {
          	if(field.getClass().getName().startsWith("javax.servlet.sip")) {
          		lookedupResource = context.lookup("sip/" + instance.getClass().getName() + "/" + field.getName());
          	} else {
          		lookedupResource = context.lookup(instance.getClass().getName() + "/" + field.getName());
          	}
          }
          
          accessibility = field.isAccessible();
          field.setAccessible(true);
          field.set(instance, lookedupResource);
          field.setAccessible(accessibility);
      }
docs: Inject resources in specified field.