Discover the instance state manager for the specific object instance. Will fail by exception rather than
returning null.

@param instance the object instance on which to look
@return the discovered state manager
485753
private ISMgr findInstanceStateManager(Object instance) {
		Class<?> clazz = typeDescriptor.getReloadableType().getClazz();
		try {
			Field fieldAccessorField = clazz.getField(Constants.fInstanceFieldsName);
			if (fieldAccessorField == null) {
				throw new IllegalStateException("Cant find field accessor for type " + clazz.getName());
			}
			ISMgr stateManager = (ISMgr) fieldAccessorField.get(instance);
			if (stateManager == null) {
				// Looks to not have been initialized yet, this can happen if a non standard ctor was used.
				// We could push this step into the generated ctors...
				ISMgr instanceStateManager = new ISMgr(instance, typeDescriptor.getReloadableType());
				fieldAccessorField.set(instance, instanceStateManager);
				stateManager = (ISMgr) fieldAccessorField.get(instance);
				// For some reason it didn't stick!
				if (stateManager == null) {
					throw new IllegalStateException("The class '" + clazz.getName()
							+ "' has a null instance state manager object, instance is " + instance);
				}
			}
			return stateManager;
		}
		catch (Exception e) {
			throw new IllegalStateException("Unexpectedly unable to find instance state manager on class "
					+ clazz.getName(), e);
		}
	}
267221
@Override
    public ManagedObject<T> createManagedObject(T existingInstance, ManagedObjectInvocationContext<T> invocationContext) {
        if (existingInstance == null) {
            throw new IllegalArgumentException("Existing instance must not be null");
        }
        return new ManagedObjectImpl<T>(existingInstance);
    }
1231515
public static ClassFinder instance(Context context) {
        ClassFinder instance = context.get(classFinderKey);
        if (instance == null)
            instance = new ClassFinder(context);
        return instance;
    }
561068
public static State getStateImpl() {
        State s = null;
        try {
             DiscoverClass dc = new DiscoverClass();
             s = (State) dc.newInstance(
             State.class,
             State.DEFAULT_STATE_IMPL);
        } catch (Exception ex) {
             // ignore as default implementation will be used.
        }
        return s;
    }
213942
public static Class<?> getInstanceClass(Object instance) {
        Class<?> clazz = instance.getClass();      
        return (instance instanceof Hooked) ? clazz.getSuperclass() : clazz;
    }
670569
public static ConfigurationManager getInstance()
		throws ConfigurationException
	{

		if (instance == null) {
			throw ErrorFactory
					.createConfigurationException(ErrorKeys.CONFIGURATION_CONFIGURATIONMANAGER_NOT_INITIALIZED);
		}
		return instance;
	}
160405
def getInstance(cls, *args):
        '''
        
        '''
        if not cls.__singleton:
            cls.__singleton = DriverManager(*args)
        return cls.__singleton
822921
public com.google.appengine.v1.InstanceOrBuilder getInstancesOrBuilder(
      int index) {
    return instances_.get(index);
  }
63175
public function getProperties($id, & $state_cache = null)
	{
		if ($id === null || $id === array()) {
			throw new InstanceDoesNotExistException('State machine instance does not exist (null ID).');
		}

		$q = $this->createQueryBuilder()
			->select(null)
			->limit(1);

		$this->queryAddPropertiesSelect($q);
		$this->queryAddPrimaryKeyWhere($q, $id);

		if ($this->load_state_with_properties) {
			$this->queryAddStateSelect($q);
		}

		$r = $q->query();
		$props = $r->fetch(\PDO::FETCH_ASSOC);
		$r->closeCursor();

		if ($props === false) {
			throw new InstanceDoesNotExistException('State machine instance not found: '
				.json_encode($id, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE| JSON_NUMERIC_CHECK));
		}

		if ($this->load_state_with_properties) {
			$state_cache = array_pop($props);
		}

		return $this->decodeProperties($props);
	}
669558
public Instance getInstance() {
    System.out.println("\nGet Instance");
    // [START bigtable_get_instance]
    Instance instance = null;
    try {
      instance = adminClient.getInstance(instanceId);
      System.out.println("Instance ID: " + instance.getId());
      System.out.println("Display Name: " + instance.getDisplayName());
      System.out.print("Labels: ");
      Map<String, String> labels = instance.getLabels();
      for (String key : labels.keySet()) {
        System.out.printf("%s - %s", key, labels.get(key));
      }
      System.out.println("\nState: " + instance.getState());
      System.out.println("Type: " + instance.getType());
    } catch (NotFoundException e) {
      System.err.println("Failed to get non-existent instance: " + e.getMessage());
    }
    // [END bigtable_get_instance]
    return instance;
  }
524572
public static function objectsManager($instance = null)
    {
        if (!$instance) {
            $className = get_called_class();
            $instance = new $className();
        }

        if (class_exists($managerClass = self::getManagerClass())) {
            return new $managerClass($instance, $instance->getConnection());
        }

        return new TreeManager($instance, $instance->getConnection());
    }
1295580
@VisibleForTesting
	@Nullable
	public Instance getInstance(ResourceID resourceId) {
		for (Instance instance : allInstances) {
			if (Objects.equals(resourceId, instance.getTaskManagerID())) {
				return instance;
			}
		}
		return null;
	}
1021295
public static synchronized ServiceDiscoveryManager getInstanceFor(XMPPConnection connection) {
        ServiceDiscoveryManager sdm = instances.get(connection);
        if (sdm == null) {
            sdm = new ServiceDiscoveryManager(connection);
            // Register the new instance and associate it with the connection
            instances.put(connection, sdm);
        }
        return sdm;
    }
108197
def get_instance_signature(instance):
    
    with suppress(AttributeError):
        return instance._getsate_bucketcache_()

    with suppress(AttributeError):
        return instance.__getstate__()

    return instance.__dict__
109697
public static Instance findInstanceByPath( Instance rootInstance, String instancePath ) {

		Application tempApplication = new Application( new ApplicationTemplate());
		if( rootInstance != null )
			tempApplication.getRootInstances().add( rootInstance );

		return findInstanceByPath( tempApplication, instancePath );
	}
1111967
private InstanceContext findAgentContext( Application application, Instance instance ) {

		Instance scopedInstance = InstanceHelpers.findScopedInstance( instance );
		return new InstanceContext( application, scopedInstance );
	}
1205569
private void updateState(final ResourceInstanceEntity instance)
	{
		ResourceInstanceState actual = azure.determineState(instance);

		instance.setState(actual);
	}