Builds mapping of robot keywords to actual bean names in spring context.

@param context Spring application context.
@return mapping of robot keywords to bean names
352303
public static Map<String, String> getKeywordMap(ApplicationContext context) {
        Map<String, String> keywordToBeanMap = new HashMap<String, String>();

        // Retrieve beans implementing the Keyword interface.
        String[] beanNames = context.getBeanNamesForType(Keyword.class);

        for (String beanName : beanNames) {
            Object bean = context.getBean(beanName);

            // Retrieve keyword information
            KeywordInfo keywordInfo = AnnotationUtils.findAnnotation(bean.getClass(), KeywordInfo.class);

            // Set keyword name as specified in the keyword info, or if information is not available, use bean name.
            String keywordName = keywordInfo != null ? keywordInfo.name() : beanName;

            if (keywordToBeanMap.put(keywordName, beanName) != null) {
                // If map already contains the keyword name, throw an exception. Keywords should be unique.
                throw new RuntimeException("Multiple definitions for keyword '" + keywordName + "' exists.");
            }
        }

        return keywordToBeanMap;
    }
990577
@Override
    @SuppressWarnings("unchecked")
    public <T> T get(Contextual<T> contextual, CreationalContext<T> creationalContext) {
        Bean bean = (Bean) contextual;
        // you can store the bean somewhere
        if (somewhere.containsKey(bean.getName())) {
            return (T) somewhere.get(bean.getName());
        } else {
            T t = (T) bean.create(creationalContext);
            somewhere.put(bean.getName(), t);
            return t;
        }
    }
1153042
public static <T> T getBean(Class<T> clazz) {
        return getSenBotContext().context.getBean(clazz);
    }
11883
public void setContextProperties(Map<String, String> contextProperties)
   {
      if (contextProperties != null) {
         this.contextProperties = new HashMap<String, String>(4);
         this.contextProperties.putAll(contextProperties);
      }
   }
519215
public static Config autoConfigure(String context) {
    Config config = new Config();
    return autoConfigure(config, context);
  }
1027957
public static <T> Map<String, T> getBeansOfType(ApplicationContext appContext, Class<T> clazz) {
        try {
            return appContext.getBeansOfType(clazz);
        } catch (BeansException e) {
            return new HashMap<String, T>();
        }
    }
431251
public static <T> T registerBeanIntoApplicationContext(final ConfigurableApplicationContext applicationContext,
                                                           final Class<T> beanClazz, final String beanId) {
        val beanFactory = applicationContext.getBeanFactory();
        val provider = beanFactory.createBean(beanClazz);
        beanFactory.initializeBean(provider, beanId);
        beanFactory.autowireBean(provider);
        beanFactory.registerSingleton(beanId, provider);
        return provider;
    }
745208
public static Map<String, Object> getBeansWithAnnotation(ApplicationContext appContext,
            Class<? extends Annotation> annotationType) {
        try {
            return appContext.getBeansWithAnnotation(annotationType);
        } catch (BeansException e) {
            return new HashMap<String, Object>();
        }
    }
129845
private static Map<String, String> findServiceBeanDefinitions(ConfigurableListableBeanFactory beanFactory) {
		final Map<String, String> serviceBeanNames = new HashMap<>();
		
		for (String beanName : beanFactory.getBeanDefinitionNames()) {
			AutoJsonRpcServiceImpl autoJsonRpcServiceImplAnnotation = beanFactory.findAnnotationOnBean(beanName, AutoJsonRpcServiceImpl.class);
			JsonRpcService jsonRpcServiceAnnotation = beanFactory.findAnnotationOnBean(beanName, JsonRpcService.class);
			
			if (null != autoJsonRpcServiceImplAnnotation) {
				
				if (null == jsonRpcServiceAnnotation) {
					throw new IllegalStateException("on the bean [" + beanName + "], @" +
							AutoJsonRpcServiceImpl.class.getSimpleName() + " was found, but not @" +
							JsonRpcService.class.getSimpleName() + " -- both are required");
				}
				
				List<String> paths = new ArrayList<>();
				Collections.addAll(paths, autoJsonRpcServiceImplAnnotation.additionalPaths());
				paths.add(jsonRpcServiceAnnotation.value());
				
				for (String path : paths) {
					if (!PATTERN_JSONRPC_PATH.matcher(path).matches()) {
						throw new RuntimeException("the path [" + path + "] for the bean [" + beanName + "] is not valid");
					}
					
					logger.info("exporting bean [{}] ---> [{}]", beanName, path);
					if (isNotDuplicateService(serviceBeanNames, beanName, path)) {
                        serviceBeanNames.put(path, beanName);
                    }
				}
				
			}
		}
		
		collectFromParentBeans(beanFactory, serviceBeanNames);
		return serviceBeanNames;
	}
653203
public static JsonObject buildConfig(InstanceContext context, Cluster cluster) {
    JsonObject config = context.component().config().copy();
    return config.putObject("__context__", Contexts.serialize(context));
  }
1336248
private MBeanPluginContext createMBeanPluginContext() {
        return new MBeanPluginContext() {
            public ObjectName registerMBean(Object pMBean, String... pOptionalName) throws MalformedObjectNameException, NotCompliantMBeanException, InstanceAlreadyExistsException {
                return MBeanServerHandler.this.registerMBean(pMBean, pOptionalName);
            }

            public void each(ObjectName pObjectName, MBeanEachCallback pCallback) throws IOException, ReflectionException, MBeanException {
                mBeanServerManager.each(pObjectName,pCallback);
            }

            public <R> R call(ObjectName pObjectName, MBeanAction<R> pMBeanAction, Object... pExtraArgs) throws IOException, ReflectionException, MBeanException, AttributeNotFoundException, InstanceNotFoundException {
                return mBeanServerManager.call(pObjectName,pMBeanAction,pExtraArgs);
            }

            public Set<ObjectName> queryNames(ObjectName pObjectName) throws IOException {
                return mBeanServerManager.queryNames(pObjectName);
            }

            public boolean hasMBeansListChangedSince(long pTimestamp) {
                return mBeanServerManager.hasMBeansListChangedSince(pTimestamp);
            }
        };
    }
431294
public static Map<String, EntryValue> convertBeanToEntryMap(Object bean) {
        Map<String, Object> buildAttributeValueMap = BeanUtilsExtended.buildObjectAttributeMap(bean);
        return Maps.transformEntries(buildAttributeValueMap, new ObjectToEntryValueTransformer());
    }
1178121
public static BeanMapping create(String mappingName) {
        BeanMappingObject config = BeanMappingConfigHelper.getInstance().getBeanMappingObject(mappingName);
        if (config == null) {
            throw new BeanMappingException("can not found mapping config for name[" + mappingName + "]");
        }

        return new BeanMapping(config);
    }
20683
public List<JavaResource> getProjectInjectionPointBeans(Project project)
   {
      final List<JavaResource> beans = new ArrayList<>();
      if (project != null)
      {
         project.getFacet(JavaSourceFacet.class).visitJavaSources(new JavaResourceVisitor()
         {
            @Override
            public void visit(VisitContext context, JavaResource resource)
            {
               try
               {
                  JavaSource<?> javaSource = resource.getJavaType();
                  if (javaSource.isClass()
                           // JPA
                           && !javaSource.hasAnnotation(Entity.class)
                           && !javaSource.hasAnnotation(MappedSuperclass.class)
                           && !javaSource.hasAnnotation(Embeddable.class)
                           // Bean Validation
                           && !javaSource.hasImport(Payload.class)
                  )
                  {
                     beans.add(resource);
                  }
               }
               catch (FileNotFoundException e)
               {
                  // ignore
               }
            }
         });
      }
      return beans;
   }
381382
public List<SpringCamelContext> getSpringCamelContexts() {
        List<SpringCamelContext> beans = new ArrayList<>();
        for (String name : applicationContext.getBeanNamesForType(SpringCamelContext.class)) {
            beans.add(applicationContext.getBean(name, SpringCamelContext.class));
        }

        return Collections.unmodifiableList(beans);
    }
314239
@com.fasterxml.jackson.annotation.JsonProperty("Context")
    public void setContext(String context) {
        this.context = context;
    }
1040779
public static ApplicationContext contextMergedBeans(Map<String, ?> extraBeans, Class<?> config) {
        final DefaultListableBeanFactory parentBeanFactory = buildListableBeanFactory(extraBeans);
        
        //loads the annotation classes and add definitions in the context
        GenericApplicationContext parentContext = new GenericApplicationContext(parentBeanFactory);
        AnnotatedBeanDefinitionReader annotationReader = new AnnotatedBeanDefinitionReader(parentContext);
        annotationReader.registerBean(config);
        
        //refreshed the context to create class and make autowires
        parentContext.refresh();
        
        //return the created context
        return parentContext;
    }