Helper method that creates a Velocity context and initialises it
with a reference to the ReportNG utils, report metadata and localised messages.
@return An initialised Velocity context.
547788
protected VelocityContext createContext()
    {
        VelocityContext context = new VelocityContext();
        context.put(META_KEY, META);
        context.put(UTILS_KEY, UTILS);
        context.put(MESSAGES_KEY, MESSAGES);
        return context;
    }
860746
@Override
    public ManagedObjectContext createContext() {
        Bean<T> bean = null;

        EjbDescriptor<T> ejbDescriptor = getEjbDescriptor();
        //in the case of an MDB, the bean should be null, in which case the creational context will be non-contextual
        if (!ejbDescriptor.isMessageDriven()) {
            bean = getBean();
        }

        WeldManager beanManager = getBeanManager();
        WeldCreationalContext<T> creationalContext = beanManager.createCreationalContext(bean);

        ManagedObjectContext managedObjectContext = new CDIManagedObjectState(creationalContext);

        return managedObjectContext;
    }
626869
public static MessageDispatcherServlet createMessageDispatcherServlet(Class... contextConfigLocation) {
        StringBuilder items = new StringBuilder();
        for (Class aClass : contextConfigLocation) {
            items.append( aClass.getName());
            items.append(",");
        }
        MessageDispatcherServlet messageDispatcherServlet = new MessageDispatcherServlet();
        messageDispatcherServlet.setContextClass(AnnotationConfigWebApplicationContext.class);
        messageDispatcherServlet.setContextConfigLocation(removeEnd(items.toString(), "," ));
        messageDispatcherServlet.setTransformWsdlLocations(true);
        return messageDispatcherServlet;
    }
777508
private ContextModel getOrCreateContext(final HttpContext httpContext) {
		// org.osgi.service.http.HttpContext -> org.ops4j.pax.web.service.WebContainerContext
		final WebContainerContext context;
		if (httpContext == null) {
			context = createDefaultHttpContext();
		} else if (!(httpContext instanceof WebContainerContext)) {
			context = new WebContainerContextWrapper(serviceBundle, httpContext);
		} else {
			context = (WebContainerContext) httpContext;
		}

		// sanity check - non shared context should be associated to single bundle
		serverModel.associateHttpContext(context, serviceBundle, httpContext instanceof SharedWebContainerContext);

		ContextModel contextModel = serviceModel.getContextModel(context);
		if (contextModel == null) {
			contextModel = new ContextModel(context, serviceBundle,
					bundleClassLoader);
			contextModel.setVirtualHosts(serverController.getConfiguration()
					.getVirtualHosts());
		}
		return contextModel;
	}
282343
public static RequestContext get() {
        if (CURRENT_CONTEXT.get() == null) {
            synchronized (RequestContext.class) {
                if (CURRENT_CONTEXT.get() == null) {
                    createContext();
                }
            }
        }

        // ensure that RequestContextV1 is also initialized for this request
        RequestContextV1.get();

        return CURRENT_CONTEXT.get();
    }
769562
public ContextData contextData(Object[] swaggerMethodArguments) {
        Object firstArg = swaggerMethodArguments != null && swaggerMethodArguments.length > 0 ? swaggerMethodArguments[0] : null;
        if (firstArg instanceof ContextData) {
            return (ContextData) firstArg;
        } else {
            return ContextData.NONE;
        }
    }
1101751
public BaseMessageHeader createMessageHeader()
    {
        Map<String,Object> properties = ((PropertiesField)this.getField(MessageLog.MESSAGE_HEADER_PROPERTIES)).getProperties();
        BaseMessageHeader messageHeader = null;
        String strMessageHeaderClassName = this.getField(MessageLog.MESSAGE_HEADER_CLASS_NAME).toString();
        String strQueueName = this.getField(MessageLog.MESSAGE_QUEUE_NAME).toString();
        String strQueueType = this.getField(MessageLog.MESSAGE_QUEUE_TYPE).toString();
        Object source = null;
        messageHeader = BaseMessageHeader.createMessageHeader(strMessageHeaderClassName, strQueueName, strQueueType, source, properties);
        if (messageHeader == null)
            messageHeader = new TrxMessageHeader(null, properties);
        if (messageHeader instanceof TrxMessageHeader)
        {
            properties = ((PropertiesField)this.getField(MessageLog.MESSAGE_INFO_PROPERTIES)).getProperties();
            ((TrxMessageHeader)messageHeader).setMessageInfoMap(properties);
            properties = ((PropertiesField)this.getField(MessageLog.MESSAGE_TRANSPORT_PROPERTIES)).getProperties();
            ((TrxMessageHeader)messageHeader).setMessageTransportMap(properties);
            ((TrxMessageHeader)messageHeader).put(TrxMessageHeader.LOG_TRX_ID, this.getCounterField().toString());  // Should be there
        }
        return messageHeader;
    }
1334217
public VelocityEngine createVelocityEngine() throws IOException, VelocityException {
		VelocityEngine velocityEngine = newVelocityEngine();
		Map<String, Object> props = new HashMap<String, Object>();

		// Load config file if set.
		if (this.configLocation != null) {
			if (logger.isInfoEnabled()) {
				logger.info("Loading Velocity config from [" + this.configLocation + "]");
			}
			CollectionUtils.mergePropertiesIntoMap(PropertiesLoaderUtils.loadProperties(this.configLocation), props);
		}

		// Merge local properties if set.
		if (!this.velocityProperties.isEmpty()) {
			props.putAll(this.velocityProperties);
		}

		// Set a resource loader path, if required.
		if (this.resourceLoaderPath != null) {
			initVelocityResourceLoader(velocityEngine, this.resourceLoaderPath);
		}

		// Log via Commons Logging?
		if (this.overrideLogging) {
			velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, new CommonsLogLogChute());
		}

		// Apply properties to VelocityEngine.
		for (Map.Entry<String, Object> entry : props.entrySet()) {
			velocityEngine.setProperty(entry.getKey(), entry.getValue());
		}

		postProcessVelocityEngine(velocityEngine);

		// Perform actual initialization.
		velocityEngine.init();

		return velocityEngine;
	}
1110322
public VelocityContext buildVelocityContext(Object bean) {
		VelocityContext context_ = new VelocityContext();
		ClassUtil.ClassInfo beanInfo = ClassUtil.getClassInfo(bean.getClass());
		String name = null;
		DateFormateMeta dataformat = null;

//		String charset = null;
		Object value = null;
//		Class type = null;

//		Method writeMethod = null;

		List<ClassUtil.PropertieDescription> attributes = beanInfo.getPropertyDescriptors();
		for (int i = 0; attributes != null && i < attributes.size(); i++) {
			ClassUtil.PropertieDescription property = attributes.get(i);
			ColumnWraper column = property.getColumn();
			if (column != null && (column.ignoreCUDbind() || column.ignorebind()))
				continue;

//			type = property.getPropertyType();


			try {
				if (property.canread()) {
					try {
						value = property.getValue(bean);
					} catch (InvocationTargetException e1) {
						log.error("Failed to get attribute[" + beanInfo.getClazz().getName() + "." + property.getName() + "] value:", e1.getTargetException());
					} catch (Exception e1) {
						log.error("Failed to get attribute[" + beanInfo.getClazz().getName() + "." + property.getName() + "] value:", e1);
					}

					name = property.getName();

					if (column != null) {
						ColumnEditorInf editor = column.editor();
						if (editor == null || editor instanceof ColumnToFieldEditor) {

							dataformat = column.getDateFormateMeta();

//							charset = column.charset();


						} else {
							Object cv = editor.toColumnValue(column, value);
							if (cv == null)
								throw new ElasticSearchException("转换属性[" + beanInfo.getClazz().getName() + "." + property.getName() + "]值失败：值为null时，转换器必须返回ColumnType类型的对象,用来指示表字段对应的java类型。");

							if (!(cv instanceof ColumnType)) {
								value = cv;
//								type = value.getClass();

							} else {
//								type = ((ColumnType) cv).getType();
							}
						}

					}
					/**
					 * since 5.0.6.0,去掉vm模板解析时变量的转义，因此在模板中的使用$aaa模式变量的情况时，需要注意转义的问题，如果存在转义问题，请使用#[]模式变量
					 * 	 日期也不做格式化转换，使用$aaa模式变量的情况下需要注意日期格式问题，如果存在日期，则需要使用#[]模式变量，这样bboss会根据bean属性配置的格式，或者变量中指定的格式
					 * 	 对日期进行格式化，如果不指定格式采用默认的格式和时区进行处理
					 */
					/**
					if (value == null) {
						context_.put(name, null);
					} else if (value instanceof Date) {
//						if(dataformat != null)
							context_.put(name, this.getDate((Date) value, dataformat));
//						else {
////							context_.put(name, ((Date) value).getTime());
//							context_.put(name, ((Date) value));
//						}
					} else if(value instanceof String){//提前转义
						CharEscapeUtil charEscapeUtil = new CharEscapeUtil();
						charEscapeUtil.writeString((String)value,false);
						context_.put(name, charEscapeUtil.toString());
					}
					else {
						context_.put(name, value);
					}
					 */
					context_.put(name, value);
//					params.addSQLParamWithDateFormateMeta(name, value, sqltype, dataformat,charset);

				}
				name = null;
				value = null;
				dataformat = null;

//				charset = null;


			} catch (SecurityException e) {
				throw new ElasticSearchException(e);
			} catch (IllegalArgumentException e) {
				throw new ElasticSearchException(e);
			}
//			catch (InvocationTargetException e) {
//				throw new ElasticSearchException(e.getTargetException());
//			}


			catch (Exception e) {
				throw new ElasticSearchException(e);
			}


		}


		return context_;

	}
400499
@Override
    protected WeldCreationalContext<T> getCreationalContext(ManagedObjectInvocationContext<T> invocationContext) throws ManagedObjectException {
        return getCreationalContext(invocationContext, false);
    }
961973
public static VelocityEngine newEngine(String templateDir, String charset) {
		final VelocityEngine ve = new VelocityEngine();

		ve.setProperty(Velocity.FILE_RESOURCE_LOADER_CACHE, true); // 使用缓存
		ve.init(_newInitedProp(templateDir, charset));

		return ve;
	}
880452
public ThreadDelegatedContext getContext()
    {
        ThreadDelegatedContext context = threadLocal.get();
        if (context == null) {
            context = new ThreadDelegatedContext();
            threadLocal.set(context);
        }
        return context;
    }
227479
public static IbanLengthMapSharedConstants create() {
    if (ibanLengthMapConstants == null) { // NOPMD it's thread save!
      synchronized (IbanLengthMapConstantsClient.class) {
        if (ibanLengthMapConstants == null) {
          final IbanLengthMapConstants ibanLengthMap = GWT.create(IbanLengthMapConstants.class);
          ibanLengthMapConstants = new IbanLengthMapConstantsClient(ibanLengthMap.ibanLengths());
        }
      }
    }
    return ibanLengthMapConstants;
  }
7514
public void init (RuntimeServices rsvc)
    {
        // if we weren't constructed with a servlet context, try to obtain
        // one via the application context
        if (_sctx == null) {
            // first look for the servlet context directly
            _sctx = (ServletContext)rsvc.getApplicationAttribute("ServletContext");
        }

        // if that didn't work, look for an application
        if (_sctx == null) {
            // first look for an application
            Application app = (Application)
                rsvc.getApplicationAttribute(Application.VELOCITY_ATTR_KEY);
            if (app != null) {
                _sctx = app.getServletContext();
            }
        }

        // if we still don't have one, complain
        if (_sctx == null) {
            rsvc.getLog().warn("ServletContextLogger: servlet context was not supplied. A user " +
                               "of the servlet context logger must call " +
                               "Velocity.setApplicationAttribute(\"ServletContext\", " +
                               "getServletContext()).");
        }
    }
954703
public static TaxNumberMapSharedConstants create() {
    if (taxNumberMapConstants == null) { // NOPMD it's thread save!
      synchronized (TaxNumberMapConstants.class) {
        if (taxNumberMapConstants == null) {
          taxNumberMapConstants = GWT.create(TaxNumberMapConstants.class);
        }
      }
    }
    return taxNumberMapConstants;
  }
981878
@NonNull public Context createContext(@NonNull Object key, @NonNull Context baseContext) {
    return new FlowContextWrapper(keyManager.findServices(key), baseContext);
  }
907700
public JavaVisitorContext newVisitorContext() {
        return new JavaVisitorContext(
                processingEnv,
                messager,
                elementUtils,
                this,
                types,
                modelUtils,
                filer,
                visitorAttributes
        );
    }