究竟什么是Java中的语境? [英] What exactly is a Context in Java?

查看:183
本文介绍了究竟什么是Java中的语境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用Google搜索这一点,并阅读Java文档,但我是一个有点困惑。有人可以请解释一下什么是上下文是用简单的英语?

I Googled this and read the Java documentation, but I'm a bit confused. Can somebody please explain what a Context is in plain English?

推荐答案

在编程方面,这是更大的周围部分可具有的在当前工作单位的行为的任何的影响。例如。正在运行的环境中使用,环境变量,实例变量,局部变量,其他类的状态,当前的环境状况,等等。

In programming terms, it's the larger surrounding part which can have any influence on the behaviour of the current unit of work. E.g. the running environment used, the environment variables, instance variables, local variables, state of other classes, state of the current environment, etcetera.

在一些API的,你看这个名字早在一个接口/类,如servlet的<一个href="http://download.oracle.com/javaee/5/api/javax/servlet/ServletContext.html"><$c$c>ServletContext, JSF的<一个href="http://download.oracle.com/javaee/6/api/javax/faces/context/FacesContext.html"><$c$c>FacesContext, Spring的<一个href="http://static.springsource.org/spring/docs/2.0.x/api/org/springframework/context/ApplicationContext.html"><$c$c>ApplicationContext, Android的 上下文 ,JNDI的<一个href="http://download.oracle.com/javase/6/docs/api/javax/naming/InitialContext.html"><$c$c>InitialContext,等他们都经常跟随 外观模式 进行抽象的环境细节的最终用户不需要了解远在一个单一的接口/类。

In some API's you see this name back in an interface/class, e.g. Servlet's ServletContext, JSF's FacesContext, Spring's ApplicationContext, Android's Context, JNDI's InitialContext, etc. They all often follow the Facade Pattern which abstracts the environmental details the enduser doesn't need to know about away in a single interface/class.

这篇关于究竟什么是Java中的语境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆