Returns a singleton instance of the given class (if any)
@throws NoSuchElementException if it is not possible to find a service for the given class
429629
@SuppressWarnings("unchecked")
    public <T> T get(Class<T> cls) {
        T runtimeInstance = (T) runtimeServices.computeIfAbsent(cls, this::createRuntimeInstance);
        if (runtimeInstance == null) {
            throw new NoSuchElementException(cls.getName());
        } else {
            return runtimeInstance;
        }
    }
777260
static <T> T getInstance(Class<T> clazz) {
        @SuppressWarnings("unchecked")
        final T casted = (T) instanceCache.computeIfAbsent(clazz, type -> {
            try {
                return getInstance0(clazz);
            } catch (Exception e) {
                throw new IllegalStateException("A class must have an accessible default constructor: " +
                                                clazz.getName(), e);
            }
        });
        return casted;
    }
1271134
public static DomUtil getInstance() {

    if (instance == null) {
      synchronized (DomUtilImpl.class) {
        if (instance == null) {
          DomUtilImpl util = new DomUtilImpl();
          util.initialize();
          instance = util;
        }
      }
    }
    return instance;
  }
918987
final public static function getInstance() {
	
		if (NULL == self::$instance) {
			self::$instance = new self();
			self::$instance->startChrono();
		}
		
		return self::$instance;
	
	}
823249
def singleton(class_):
    
    instances = {}

    def get_instance(*args, **kwargs):
        if class_ not in instances:
            instances[class_] = class_(*args, **kwargs)
        return instances[class_]
    return get_instance
255134
def singleton(the_class):
    
    class_instances = {}

    def get_instance(*args, **kwargs):
        """
        Creating or just return the one and only class instance.

        The singleton depends on the parameters used in __init__
        @type args: list
        @param args: positional arguments of the constructor.
        @type kwargs: dict
        @param kwargs: named parameters of the constructor.
        @rtype: decorated class type
        @return: singleton instance of decorated class.
        """
        key = (the_class, args, str(kwargs))
        if key not in class_instances:
            class_instances[key] = the_class(*args, **kwargs)
        return class_instances[key]

    return get_instance
1155000
@SuppressWarnings("unchecked")
	public T getInstance() {
		if(beanClassName == null) {
			return null;
		} else try {
			T beanInstance;
			Class<T> beanClass = null;
			try {
				try {
					ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
					beanClass = (Class<T>)Class.forName(beanClassName, true, classLoader);
				} catch(ClassNotFoundException cnfe) {
					throw new RuntimeException("Unknown class " + beanClassName, cnfe);
				}
				// Instancjonowanie i inicjalizcja w oparciu o konstruktor inicjujący:
				Constructor<T> constructor = (Constructor<T>)beanClass.getConstructor(Collection.class);
				beanInstance = constructor.newInstance(properties);
			} catch(NoSuchMethodException nsme) {
				// Instancjonowanie i inicjalizacja w oparciu o konstruktor bezargumentowy
				// i publiczne setter'y Java Beans:
				beanInstance = beanClass.newInstance();

				if(properties != null && !properties.isEmpty()) {
					BeanInfo validatorInfo = Introspector.getBeanInfo(beanClass);
					PropertyDescriptor[] propertyDescriptors = validatorInfo.getPropertyDescriptors();
					for(BeanProperty beanProperty : properties) {
						String propertyName = beanProperty.getPropertyName();
						Method writeMethod = null;
						for(PropertyDescriptor propertyDescriptor : propertyDescriptors) {
							if(propertyDescriptor.getName().equals(propertyName)) {
								writeMethod = propertyDescriptor.getWriteMethod();
								break;
							}
						}
						if(writeMethod == null) {
							throw new RuntimeException("No public setter found for property '" + propertyName + "' "
									+ "in validator class " + beanClass.getCanonicalName());
						}
						Class<?> parameterType = writeMethod.getParameterTypes()[0];
						if(BeanProperty.class.equals(parameterType)) {
							writeMethod.invoke(beanInstance, beanProperty);
						} else if(String.class.equals(parameterType)) {
							if(beanProperty.hasAttributes()) {
								throw new RuntimeException("BeanProperty '" + propertyName + "' setter should has "
										+ Parameter.class.getSimpleName() + " type parameter");
							}
							writeMethod.invoke(beanInstance, beanProperty.getPropertyValue());
						}
					}
				}
			}
			return beanInstance;
		} catch(Exception e) {
			throw new RuntimeException(e);
		}
	}
121225
private Object createRuntimeInstance(Class<?> c) {
        KieRuntimeService kieRuntimeService =
                ServiceRegistry.getInstance()
                        .get(KieRuntimes.class)
                        .getRuntimes()
                        .get(c.getName());
        if (kieRuntimeService == null) {
            return null;
        } else {
            return kieRuntimeService.newKieRuntime(kieBase);
        }
    }
791578
@SuppressWarnings("all")
	protected Object newInstance(String className) {
		log.debug("Loading class: {}", className);
		Object instance = null;
		Class<?> clazz = null;
		if ("".equals(className) || className == null)
			return instance;
		try {
			// check for special DS class aliases
			if (className.length() == 3) {
				className = classAliases.get(className);
			}
			if (className.startsWith("flex.")) {
				// Use Red5 compatibility class instead
				className = "org.red5.compatibility." + className;
				log.debug("Modified classname: {}", className);
			}
			if (!classAllowed(className)) {
				log.error("Class creation is not allowed {}", className);
			} else {
				clazz = Thread.currentThread().getContextClassLoader()
						.loadClass(className);
				instance = clazz.newInstance();
			}
		} catch (InstantiationException iex) {
			try {
				// check for default ctor
				clazz.getConstructor(null);
				log.error("Error loading class: {}", className);
			} catch (NoSuchMethodException nse) {
				log.error(
						"Error loading class: {}; this can be resolved by adding a default constructor to your class",
						className);
			}
			log.debug("Exception was: {}", iex);
		} catch (Exception ex) {
			log.error("Error loading class: {}", className);
			log.debug("Exception was: {}", ex);
		}
		return instance;
	}
790922
private function getService(string $class): ServiceInterface
    {
        if (!array_key_exists($class, $this->services)) {
            $this->services[$class] = new $class($this->client, $this->modelFactory);
        }

        return $this->services[$class];
    }
1192474
public static final synchronized StateManager getInstance(Object context) {
		
		return (instance == null)? 
				(instance = new StateService(ContextUtils.asApplication(context))) :instance;
	}
1077765
@Override
  public I get()
  {
    I instance = _instance;
    
    if (instance == null || instance.isModified()) {
      _instance = instance = service().get();
    }
    
    return instance;
  }
107826
public static ClasspathScanner getInstance() {

    if (instance == null) {
      synchronized (AbstractClasspathScanner.class) {
        if (instance == null) {
          ClasspathScannerImpl impl = new ClasspathScannerImpl();
          impl.initialize();
        }
      }
    }
    return instance;
  }
614506
public static TimeSource getInstance(String className) {
        try {
            Class<?> c = Class.forName(className);
            Method m = c.getMethod("getInstance");
            return (TimeSource) m.invoke(null);
        } catch (Exception e) {
            throw new RuntimeException("Error getting TimeSource instance for class \"" + className + "\"", e);
        }
    }
1212673
def getInstance(cls, *args):
        '''
        
        '''
        if not cls.__singleton:
            cls.__singleton = Config(*args)
        return cls.__singleton
1166945
protected function getClassService()
    {
        if (is_null($this->service)) {
            $this->service = TemplateAssemblyService::singleton();
        }
        return $this->service;
    }
864796
public static function getInstance() {
        if( is_null(self::$_oInstance) ) {
            $c = __CLASS__;
            self::$_oInstance = new $c;
        }
        return self::$_oInstance;
    }