Java Code Examples for org.springframework.util.ClassUtils#getAllInterfacesForClass()

The following examples show how to use org.springframework.util.ClassUtils#getAllInterfacesForClass() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InterfaceBasedMBeanInfoAssembler.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Checks to see if the given method is declared in a managed
 * interface for the given bean.
 */
private boolean isDeclaredInInterface(Method method, String beanKey) {
	Class<?>[] ifaces = null;

	if (this.resolvedInterfaceMappings != null) {
		ifaces = this.resolvedInterfaceMappings.get(beanKey);
	}

	if (ifaces == null) {
		ifaces = this.managedInterfaces;
		if (ifaces == null) {
			ifaces = ClassUtils.getAllInterfacesForClass(method.getDeclaringClass());
		}
	}

	for (Class<?> ifc : ifaces) {
		for (Method ifcMethod : ifc.getMethods()) {
			if (ifcMethod.getName().equals(method.getName()) &&
					Arrays.equals(ifcMethod.getParameterTypes(), method.getParameterTypes())) {
				return true;
			}
		}
	}

	return false;
}
 
Example 2
Source File: Projection.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
private Class<?> determineCommonType(Class<?> oldType, Class<?> newType) {
	if (oldType == null) {
		return newType;
	}
	if (oldType.isAssignableFrom(newType)) {
		return oldType;
	}
	Class<?> nextType = newType;
	while (nextType != Object.class) {
		if (nextType.isAssignableFrom(oldType)) {
			return nextType;
		}
		nextType = nextType.getSuperclass();
	}
	Class<?>[] interfaces = ClassUtils.getAllInterfacesForClass(newType);
	for (Class<?> nextInterface : interfaces) {
		if (nextInterface.isAssignableFrom(oldType)) {
			return nextInterface;
		}
	}
	return Object.class;
}
 
Example 3
Source File: InterfaceBasedMBeanInfoAssembler.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Checks to see if the given method is declared in a managed
 * interface for the given bean.
 */
private boolean isDeclaredInInterface(Method method, String beanKey) {
	Class<?>[] ifaces = null;

	if (this.resolvedInterfaceMappings != null) {
		ifaces = this.resolvedInterfaceMappings.get(beanKey);
	}

	if (ifaces == null) {
		ifaces = this.managedInterfaces;
		if (ifaces == null) {
			ifaces = ClassUtils.getAllInterfacesForClass(method.getDeclaringClass());
		}
	}

	for (Class<?> ifc : ifaces) {
		for (Method ifcMethod : ifc.getMethods()) {
			if (ifcMethod.getName().equals(method.getName()) &&
					Arrays.equals(ifcMethod.getParameterTypes(), method.getParameterTypes())) {
				return true;
			}
		}
	}

	return false;
}
 
Example 4
Source File: BridgeMethodResolver.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Searches for the generic {@link Method} declaration whose erased signature
 * matches that of the supplied bridge method.
 * @throws IllegalStateException if the generic declaration cannot be found
 */
@Nullable
private static Method findGenericDeclaration(Method bridgeMethod) {
	// Search parent types for method that has same signature as bridge.
	Class<?> superclass = bridgeMethod.getDeclaringClass().getSuperclass();
	while (superclass != null && Object.class != superclass) {
		Method method = searchForMatch(superclass, bridgeMethod);
		if (method != null && !method.isBridge()) {
			return method;
		}
		superclass = superclass.getSuperclass();
	}

	Class<?>[] interfaces = ClassUtils.getAllInterfacesForClass(bridgeMethod.getDeclaringClass());
	return searchInterfaces(interfaces, bridgeMethod);
}
 
Example 5
Source File: ScriptFactoryPostProcessor.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Create a refreshable proxy for the given AOP TargetSource.
 * @param ts the refreshable TargetSource
 * @param interfaces the proxy interfaces (may be {@code null} to
 * indicate proxying of all interfaces implemented by the target class)
 * @return the generated proxy
 * @see RefreshableScriptTargetSource
 */
protected Object createRefreshableProxy(TargetSource ts, Class<?>[] interfaces, boolean proxyTargetClass) {
	ProxyFactory proxyFactory = new ProxyFactory();
	proxyFactory.setTargetSource(ts);
	ClassLoader classLoader = this.beanClassLoader;

	if (interfaces == null) {
		interfaces = ClassUtils.getAllInterfacesForClass(ts.getTargetClass(), this.beanClassLoader);
	}
	proxyFactory.setInterfaces(interfaces);
	if (proxyTargetClass) {
		classLoader = null;  // force use of Class.getClassLoader()
		proxyFactory.setProxyTargetClass(true);
	}

	DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(ts);
	introduction.suppressInterface(TargetSource.class);
	proxyFactory.addAdvice(introduction);

	return proxyFactory.getProxy(classLoader);
}
 
Example 6
Source File: TestController.java    From saluki with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "getAllService", method = RequestMethod.GET)
public List<Map<String, Object>> getAllService() throws Exception {
  List<Map<String, Object>> services = Lists.newArrayList();
  try {
    Collection<Object> instances = getTypedBeansWithAnnotation(SalukiService.class);
    for (Object instance : instances) {
      Object target = GrpcAop.getTarget(instance);
      Class<?>[] interfaces = ClassUtils.getAllInterfacesForClass(target.getClass());
      Class<?> clzz = interfaces[0];
      Map<String, Object> serviceMap = Maps.newHashMap();
      serviceMap.put("simpleName", clzz.getSimpleName());
      serviceMap.put("name", clzz.getName());
      ServiceDefinition sd = Jaket.build(clzz);
      List<MethodDefinition> methodDefines = sd.getMethods();
      List<String> functions = Lists.newArrayList();
      for (MethodDefinition methodDefine : methodDefines) {
        functions.add(methodDefine.getName());
      }
      serviceMap.put("functions", functions);
      services.add(serviceMap);
    }
    return services;
  } catch (Exception e) {
    throw e;
  }
}
 
Example 7
Source File: ScriptFactoryPostProcessor.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a refreshable proxy for the given AOP TargetSource.
 * @param ts the refreshable TargetSource
 * @param interfaces the proxy interfaces (may be {@code null} to
 * indicate proxying of all interfaces implemented by the target class)
 * @return the generated proxy
 * @see RefreshableScriptTargetSource
 */
protected Object createRefreshableProxy(TargetSource ts, Class<?>[] interfaces, boolean proxyTargetClass) {
	ProxyFactory proxyFactory = new ProxyFactory();
	proxyFactory.setTargetSource(ts);
	ClassLoader classLoader = this.beanClassLoader;

	if (interfaces == null) {
		interfaces = ClassUtils.getAllInterfacesForClass(ts.getTargetClass(), this.beanClassLoader);
	}
	proxyFactory.setInterfaces(interfaces);
	if (proxyTargetClass) {
		classLoader = null;  // force use of Class.getClassLoader()
		proxyFactory.setProxyTargetClass(true);
	}

	DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(ts);
	introduction.suppressInterface(TargetSource.class);
	proxyFactory.addAdvice(introduction);

	return proxyFactory.getProxy(classLoader);
}
 
Example 8
Source File: InterfaceBasedMBeanInfoAssembler.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Checks to see if the given method is declared in a managed
 * interface for the given bean.
 */
private boolean isDeclaredInInterface(Method method, String beanKey) {
	Class<?>[] ifaces = null;

	if (this.resolvedInterfaceMappings != null) {
		ifaces = this.resolvedInterfaceMappings.get(beanKey);
	}

	if (ifaces == null) {
		ifaces = this.managedInterfaces;
		if (ifaces == null) {
			ifaces = ClassUtils.getAllInterfacesForClass(method.getDeclaringClass());
		}
	}

	for (Class<?> ifc : ifaces) {
		for (Method ifcMethod : ifc.getMethods()) {
			if (ifcMethod.getName().equals(method.getName()) &&
					Arrays.equals(ifcMethod.getParameterTypes(), method.getParameterTypes())) {
				return true;
			}
		}
	}

	return false;
}
 
Example 9
Source File: Projection.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private Class<?> determineCommonType(Class<?> oldType, Class<?> newType) {
	if (oldType == null) {
		return newType;
	}
	if (oldType.isAssignableFrom(newType)) {
		return oldType;
	}
	Class<?> nextType = newType;
	while (nextType != Object.class) {
		if (nextType.isAssignableFrom(oldType)) {
			return nextType;
		}
		nextType = nextType.getSuperclass();
	}
	Class<?>[] interfaces = ClassUtils.getAllInterfacesForClass(newType);
	for (Class<?> nextInterface : interfaces) {
		if (nextInterface.isAssignableFrom(oldType)) {
			return nextInterface;
		}
	}
	return Object.class;
}
 
Example 10
Source File: InterfaceBasedMBeanInfoAssembler.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Checks to see if the given method is declared in a managed
 * interface for the given bean.
 */
private boolean isDeclaredInInterface(Method method, String beanKey) {
	Class<?>[] ifaces = null;

	if (this.resolvedInterfaceMappings != null) {
		ifaces = this.resolvedInterfaceMappings.get(beanKey);
	}

	if (ifaces == null) {
		ifaces = this.managedInterfaces;
		if (ifaces == null) {
			ifaces = ClassUtils.getAllInterfacesForClass(method.getDeclaringClass());
		}
	}

	if (ifaces != null) {
		for (Class<?> ifc : ifaces) {
			for (Method ifcMethod : ifc.getMethods()) {
				if (ifcMethod.getName().equals(method.getName()) &&
						Arrays.equals(ifcMethod.getParameterTypes(), method.getParameterTypes())) {
					return true;
				}
			}
		}
	}

	return false;
}
 
Example 11
Source File: JndiObjectFactoryBean.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private static Object createJndiObjectProxy(JndiObjectFactoryBean jof) throws NamingException {
	// Create a JndiObjectTargetSource that mirrors the JndiObjectFactoryBean's configuration.
	JndiObjectTargetSource targetSource = new JndiObjectTargetSource();
	targetSource.setJndiTemplate(jof.getJndiTemplate());
	String jndiName = jof.getJndiName();
	Assert.state(jndiName != null, "No JNDI name specified");
	targetSource.setJndiName(jndiName);
	targetSource.setExpectedType(jof.getExpectedType());
	targetSource.setResourceRef(jof.isResourceRef());
	targetSource.setLookupOnStartup(jof.lookupOnStartup);
	targetSource.setCache(jof.cache);
	targetSource.afterPropertiesSet();

	// Create a proxy with JndiObjectFactoryBean's proxy interface and the JndiObjectTargetSource.
	ProxyFactory proxyFactory = new ProxyFactory();
	if (jof.proxyInterfaces != null) {
		proxyFactory.setInterfaces(jof.proxyInterfaces);
	}
	else {
		Class<?> targetClass = targetSource.getTargetClass();
		if (targetClass == null) {
			throw new IllegalStateException(
					"Cannot deactivate 'lookupOnStartup' without specifying a 'proxyInterface' or 'expectedType'");
		}
		Class<?>[] ifcs = ClassUtils.getAllInterfacesForClass(targetClass, jof.beanClassLoader);
		for (Class<?> ifc : ifcs) {
			if (Modifier.isPublic(ifc.getModifiers())) {
				proxyFactory.addInterface(ifc);
			}
		}
	}
	if (jof.exposeAccessContext) {
		proxyFactory.addAdvice(new JndiContextExposingInterceptor(jof.getJndiTemplate()));
	}
	proxyFactory.setTargetSource(targetSource);
	return proxyFactory.getProxy(jof.beanClassLoader);
}
 
Example 12
Source File: JndiObjectFactoryBean.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private static Object createJndiObjectProxy(JndiObjectFactoryBean jof) throws NamingException {
	// Create a JndiObjectTargetSource that mirrors the JndiObjectFactoryBean's configuration.
	JndiObjectTargetSource targetSource = new JndiObjectTargetSource();
	targetSource.setJndiTemplate(jof.getJndiTemplate());
	targetSource.setJndiName(jof.getJndiName());
	targetSource.setExpectedType(jof.getExpectedType());
	targetSource.setResourceRef(jof.isResourceRef());
	targetSource.setLookupOnStartup(jof.lookupOnStartup);
	targetSource.setCache(jof.cache);
	targetSource.afterPropertiesSet();

	// Create a proxy with JndiObjectFactoryBean's proxy interface and the JndiObjectTargetSource.
	ProxyFactory proxyFactory = new ProxyFactory();
	if (jof.proxyInterfaces != null) {
		proxyFactory.setInterfaces(jof.proxyInterfaces);
	}
	else {
		Class<?> targetClass = targetSource.getTargetClass();
		if (targetClass == null) {
			throw new IllegalStateException(
					"Cannot deactivate 'lookupOnStartup' without specifying a 'proxyInterface' or 'expectedType'");
		}
		Class<?>[] ifcs = ClassUtils.getAllInterfacesForClass(targetClass, jof.beanClassLoader);
		for (Class<?> ifc : ifcs) {
			if (Modifier.isPublic(ifc.getModifiers())) {
				proxyFactory.addInterface(ifc);
			}
		}
	}
	if (jof.exposeAccessContext) {
		proxyFactory.addAdvice(new JndiContextExposingInterceptor(jof.getJndiTemplate()));
	}
	proxyFactory.setTargetSource(targetSource);
	return proxyFactory.getProxy(jof.beanClassLoader);
}
 
Example 13
Source File: TransactionAwarePersistenceManagerFactoryProxy.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
	// Invocation on PersistenceManagerFactory interface coming in...

	if (method.getName().equals("equals")) {
		// Only consider equal when proxies are identical.
		return (proxy == args[0]);
	}
	else if (method.getName().equals("hashCode")) {
		// Use hashCode of PersistenceManagerFactory proxy.
		return System.identityHashCode(proxy);
	}
	else if (method.getName().equals("getPersistenceManager")) {
		PersistenceManagerFactory target = getTargetPersistenceManagerFactory();
		PersistenceManager pm =
				PersistenceManagerFactoryUtils.doGetPersistenceManager(target, isAllowCreate());
		Class<?>[] ifcs = ClassUtils.getAllInterfacesForClass(pm.getClass(), pm.getClass().getClassLoader());
		return Proxy.newProxyInstance(
				pm.getClass().getClassLoader(), ifcs, new PersistenceManagerInvocationHandler(pm, target));
	}

	// Invoke method on target PersistenceManagerFactory.
	try {
		return method.invoke(getTargetPersistenceManagerFactory(), args);
	}
	catch (InvocationTargetException ex) {
		throw ex.getTargetException();
	}
}
 
Example 14
Source File: TransactionAwarePersistenceManagerFactoryProxy.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the target JDO PersistenceManagerFactory that this proxy should
 * delegate to. This should be the raw PersistenceManagerFactory, as
 * accessed by JdoTransactionManager.
 * @see org.springframework.orm.jdo.JdoTransactionManager
 */
public void setTargetPersistenceManagerFactory(PersistenceManagerFactory target) {
	Assert.notNull(target, "Target PersistenceManagerFactory must not be null");
	this.target = target;
	Class<?>[] ifcs = ClassUtils.getAllInterfacesForClass(target.getClass(), target.getClass().getClassLoader());
	this.proxy = (PersistenceManagerFactory) Proxy.newProxyInstance(
			target.getClass().getClassLoader(), ifcs, new PersistenceManagerFactoryInvocationHandler());
}
 
Example 15
Source File: AbstractConditionalEnumConverter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
	for (Class<?> interfaceType : ClassUtils.getAllInterfacesForClass(sourceType.getType())) {
		if (this.conversionService.canConvert(TypeDescriptor.valueOf(interfaceType), targetType)) {
			return false;
		}
	}
	return true;
}
 
Example 16
Source File: JndiObjectFactoryBean.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private static Object createJndiObjectProxy(JndiObjectFactoryBean jof) throws NamingException {
	// Create a JndiObjectTargetSource that mirrors the JndiObjectFactoryBean's configuration.
	JndiObjectTargetSource targetSource = new JndiObjectTargetSource();
	targetSource.setJndiTemplate(jof.getJndiTemplate());
	targetSource.setJndiName(jof.getJndiName());
	targetSource.setExpectedType(jof.getExpectedType());
	targetSource.setResourceRef(jof.isResourceRef());
	targetSource.setLookupOnStartup(jof.lookupOnStartup);
	targetSource.setCache(jof.cache);
	targetSource.afterPropertiesSet();

	// Create a proxy with JndiObjectFactoryBean's proxy interface and the JndiObjectTargetSource.
	ProxyFactory proxyFactory = new ProxyFactory();
	if (jof.proxyInterfaces != null) {
		proxyFactory.setInterfaces(jof.proxyInterfaces);
	}
	else {
		Class<?> targetClass = targetSource.getTargetClass();
		if (targetClass == null) {
			throw new IllegalStateException(
					"Cannot deactivate 'lookupOnStartup' without specifying a 'proxyInterface' or 'expectedType'");
		}
		Class<?>[] ifcs = ClassUtils.getAllInterfacesForClass(targetClass, jof.beanClassLoader);
		for (Class<?> ifc : ifcs) {
			if (Modifier.isPublic(ifc.getModifiers())) {
				proxyFactory.addInterface(ifc);
			}
		}
	}
	if (jof.exposeAccessContext) {
		proxyFactory.addAdvice(new JndiContextExposingInterceptor(jof.getJndiTemplate()));
	}
	proxyFactory.setTargetSource(targetSource);
	return proxyFactory.getProxy(jof.beanClassLoader);
}
 
Example 17
Source File: EnumToStringConverter.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
	for (Class<?> interfaceType : ClassUtils.getAllInterfacesForClass(sourceType.getType())) {
		if (conversionService.canConvert(TypeDescriptor.valueOf(interfaceType), targetType)) {
			return false;
		}
	}
	return true;
}
 
Example 18
Source File: AnnotationMBeanInfoAssembler.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Nonnull
private Class findJmxInterface(String beanKey, Class<?> beanClass) {
    Class cachedInterface = interfaceCache.get(beanKey);
    if (cachedInterface != null) {
        return cachedInterface;
    }

    Class mbeanInterface = JmxUtils.getMBeanInterface(beanClass);
    if (mbeanInterface != null) { // found with MBean ending
        interfaceCache.put(beanKey, mbeanInterface);
        return mbeanInterface;
    }

    Class[] ifaces = ClassUtils.getAllInterfacesForClass(beanClass);

    for (Class ifc : ifaces) {
        ManagedResource metadata = attributeSource.getManagedResource(ifc);
        if (metadata != null) { // found with @ManagedResource annotation
            interfaceCache.put(beanKey, ifc);
            return ifc;
        }
    }

    throw new IllegalArgumentException(String.format(
            "Bean %s doesn't implement management interfaces. Management interface should either follow naming scheme or be annotated by @ManagedResource",
            beanKey));
}
 
Example 19
Source File: TransactionAwarePersistenceManagerFactoryProxy.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
	// Invocation on PersistenceManagerFactory interface coming in...

	if (method.getName().equals("equals")) {
		// Only consider equal when proxies are identical.
		return (proxy == args[0]);
	}
	else if (method.getName().equals("hashCode")) {
		// Use hashCode of PersistenceManagerFactory proxy.
		return System.identityHashCode(proxy);
	}
	else if (method.getName().equals("getPersistenceManager")) {
		PersistenceManagerFactory target = getTargetPersistenceManagerFactory();
		PersistenceManager pm =
				PersistenceManagerFactoryUtils.doGetPersistenceManager(target, isAllowCreate());
		Class<?>[] ifcs = ClassUtils.getAllInterfacesForClass(pm.getClass(), pm.getClass().getClassLoader());
		return Proxy.newProxyInstance(
				pm.getClass().getClassLoader(), ifcs, new PersistenceManagerInvocationHandler(pm, target));
	}

	// Invoke method on target PersistenceManagerFactory.
	try {
		return method.invoke(getTargetPersistenceManagerFactory(), args);
	}
	catch (InvocationTargetException ex) {
		throw ex.getTargetException();
	}
}
 
Example 20
Source File: GrpcServiceRunner.java    From saluki with Apache License 2.0 4 votes vote down vote up
@Override
public void run(String... arg0) throws Exception {
  System.out.println("Starting GRPC Server ...");
  RpcServiceConfig rpcSerivceConfig = new RpcServiceConfig();
  this.addRegistyAddress(rpcSerivceConfig);
  rpcSerivceConfig.setApplication(applicationName);
  this.addHostAndPort(rpcSerivceConfig);
  rpcSerivceConfig.setMonitorinterval(grpcProperties.getMonitorinterval());
  Collection<Object> instances = getTypedBeansWithAnnotation(SalukiService.class);
  if (instances.size() > 0) {
    try {
      for (Object instance : instances) {
        Object target = GrpcAop.getTarget(instance);
        SalukiService serviceAnnotation = target.getClass().getAnnotation(SalukiService.class);
        String serviceName = serviceAnnotation.service();
        Set<String> serviceNames = Sets.newHashSet();

        if (StringUtils.isBlank(serviceName)) {
          if (this.isGrpcServer(target)) {
            throw new java.lang.IllegalArgumentException(
                "you use grpc stub service,must set service name,service instance is" + target);
          } else {
            Class<?>[] interfaces = ClassUtils.getAllInterfacesForClass(target.getClass());
            for (Class<?> interfaceClass : interfaces) {
              String interfaceName = interfaceClass.getName();
              if (!StringUtils.startsWith(interfaceName, "org.springframework")) {
                serviceNames.add(interfaceName);
              }
            }
          }
        } else {
          serviceNames.add(serviceName);
        }
        for (String realServiceName : serviceNames) {
          rpcSerivceConfig.addServiceDefinition(realServiceName, getGroup(serviceAnnotation),
              getVersion(serviceAnnotation), instance);
        }
      }
    } finally {
      Object healthInstance = new HealthImpl(applicationContext);
      BeanDefinitionRegistry beanDefinitonRegistry =
          (BeanDefinitionRegistry) applicationContext.getBeanFactory();
      BeanDefinitionBuilder beanDefinitionBuilder =
          BeanDefinitionBuilder.genericBeanDefinition(Health.class);
      beanDefinitonRegistry.registerBeanDefinition(Health.class.getName(),
          beanDefinitionBuilder.getRawBeanDefinition());
      applicationContext.getBeanFactory().registerSingleton(Health.class.getName(),
          healthInstance);
      String group = grpcProperties.getGroup() != null ? grpcProperties.getGroup() : "default";
      String version =
          grpcProperties.getVersion() != null ? grpcProperties.getVersion() : "1.0.0";
      rpcSerivceConfig.addServiceDefinition(Health.class.getName(), group, version,
          healthInstance);
    }
  }
  this.rpcService = rpcSerivceConfig;
  rpcSerivceConfig.export();
  System.out.println("****************");
  System.out.println(String.format("GRPC server has started!You can do test by %s",
      "http://localhost:" + httpPort + "/doc"));
  System.out.println("****************");
  rpcSerivceConfig.await();
}