Java javax.servlet.jsp.JspFactory 代码实例

作者:无名 - 开发 -

以下是展示如何使用javax.servlet.jsp.jspfactory的最佳示例。 我们使用了代码质量辨别算法从开源项目中提取出了最佳的优秀示例。

实例 1


public synchronized static void init(servletcontext servletcontext) {

jspapplicationcontext jac = jspfactory.getdefaultfactory().getjspapplicationcontext(servletcontext);

if (jspapplicationcontext != jac) {

jspapplicationcontext = jac;

jspapplicationcontext.addelresolver(new modelrecordelresolver());

}

}

实例 2


public weldapplication(application application) {

this.application = application;

beanmanager beanmanager = getbeanmanager();

if (beanmanager != null) {

application.addelcontextlistener(util.lt;elcontextlistenergt;newinstance(

"org.jboss.weld.el.weldelcontextlistener"));

application.addelresolver(beanmanager.getelresolver());

jspapplicationcontext jspappcontext = jspfactory.getdefaultfactory().

getjspapplicationcontext((servletcontext)facescontext.getcurrentinstance().getexternalcontext().getcontext());

this.expressionfactory = beanmanager.wrapexpressionfactory(jspappcontext.getexpressionfactory());

((jspapplicationcontextimpl)jspappcontext).setexpressionfactory(this.expressionfactory);

}

}

实例 3


@override

public void contextinitialized(servletcontextevent sce) {

servletcontext context = sce.getservletcontext();

cdicontainer = (cdicontainer) context.getattribute("org.ops4j.pax.cdi.container");

cdicontainer.start(context);

weldmanager manager = cdicontainer.unwrap(weldmanager.class);

cdiinstancefactorybuilder builder = new cdiinstancefactorybuilder(manager);

@suppresswarnings("unchecked")

maplt;string, objectgt; attributes = (maplt;string, objectgt;) context

.getattribute("org.ops4j.pax.web.attributes");

if (attributes != null) {

attributes.put("org.ops4j.pax.cdi.classintrospecter", builder);

log.info("registered cdiinstancefactorybuilder for undertow");

}

context.setattribute("org.ops4j.pax.cdi.beanmanager", cdicontainer.getbeanmanager());

jspfactory jspfactory = jspfactory.getdefaultfactory();

if (jspfactory != null) {

jspapplicationcontext jspapplicationcontext = jspfactory

.getjspapplicationcontext(context);

jspapplicationcontext.addelresolver(manager.getelresolver());

jspapplicationcontext.addelcontextlistener(new weldelcontextlistener());

}

super.contextinitialized(sce);

}

实例 4


@override

public elcontext getelcontext() {

if (elcontext == null) {

jspapplicationcontext jspctx = jspfactory.getdefaultfactory().getjspapplicationcontext(getservletcontext());

if (jspctx instanceof freemarkerjspapplicationcontext) {

elcontext = ((freemarkerjspapplicationcontext) jspctx).createnewelcontext(this);

elcontext.putcontext(jspcontext.class, this);

} else {

throw new unsupportedoperationexception(

"can not create an elcontext using a foreign jspapplicationcontext (of class "

+ classutil.getshortclassnameofobject(jspctx) + ").n" +

"hint: the cause of this is often that you are trying to use jstl tags/functions in ftl. "

+ "in that case, know that that's not really suppored, and you are supposed to use ftl "

+ "constrcuts instead, like #list instead of jstl's foreach, etc.");

}

}

return elcontext;

}

实例 5


public void verifyelresolverchainiscorrectlyconfigured(actionevent e) {

string result = null;

final facescontext context = facescontext.getcurrentinstance();

stringbuilder message = bean.getbuilder(context);

message.append("lt;br /gt;lt;br /gt;nnlt;h1gt;faceselresolverforfaceslt;/h1gt;lt;br /gt;lt;br /gt;nn");

// faceselresolver chain

context.getapplication().getelresolver().getvalue(context.getelcontext(), null,

new object() {

@override

public string tostring() {

bean.capturestacktrace(context);

return "traceresolution";

}

});

message.append("lt;br /gt;lt;br /gt;nnlt;h1gt;faceselresolverforjsplt;/h1gt;lt;br /gt;lt;br /gt;nn");

jspfactory factory = jspfactory.getdefaultfactory();

jspapplicationcontext jspcontext = factory.

getjspapplicationcontext((servletcontext)

context.getexternalcontext().getcontext());

expressionfactory elfactory = jspcontext.getexpressionfactory();

valueexpression ve = elfactory.createvalueexpression(context.getelcontext(), "#{traceresolution}",

object.class);

ve.getvalue(context.getelcontext());

}

实例 6


public void contextinitialized(servletcontextevent event) {

// apf-1379: prevent npe when using tomcat maven plugin

try {

class.forname("org.apache.jasper.compiler.jspruntimecontext");

} catch (classnotfoundexception cnfe) {

// ignore

}

jspfactory.getdefaultfactory()

.getjspapplicationcontext(event.getservletcontext())

.addelresolver(new escapexmlelresolver());

}

实例 7


@override

protected attributeevaluatorfactory createattributeevaluatorfactory(applicationcontext context,

localeresolver resolver) {

attributeevaluator evaluator;

if (tileselpresent amp;amp; jspfactory.getdefaultfactory() != null) {

servletcontext servletcontext = (servletcontext) context.getcontext();

evaluator = new tileselactivator().createevaluator(servletcontext);

} else {

evaluator = new directattributeevaluator();

}

return new basicattributeevaluatorfactory(evaluator);

}

实例 8


/**

* initializes the servlet.primarily, this sets the pagemanager to the

* correct jspmanager.

*/

@override

public void init(servletconfig conf)

throws servletexception

{

super.init(conf);

jspmanager manager = new jspmanager();

webapp webapp = (webapp) getservletcontext();

manager.setxml(_isxml);

manager.setloadtldoninit(_loadtldoninit

|| webapp.createjsp().isloadtldoninit());

manager.setpagecachemax(_pagecachemax);

manager.initwebapp(webapp);

setmanager(manager);

manager.init();

if (jspfactory.getdefaultfactory() == null)

jspfactory.setdefaultfactory(new qjspfactory());

}

实例 9


/**

* starts the resource.

*/

public void start()

{

if (! _lifecycle.toactive())

return;

// jspmanager manager = new jspmanager(_webapp);

if (jspfactory.getdefaultfactory() == null)

jspfactory.setdefaultfactory(new qjspfactory());

arraylistlt;pathgt; paths = _fileset.getpaths();

arraylistlt;stringgt; classes = new arraylistlt;stringgt;();

for (int i = 0; i lt; _threadcount; i++) {

compiletask task = new compiletask(paths, classes);

threadpool.getthreadpool().schedule(task);

}

long expire = alarm.getcurrenttime() + 60000;

synchronized (this) {

while (_completecount lt; _threadcount) {

try {

long timeout = expire - alarm.getcurrenttime();

if (timeout lt;= 0)

return;

wait(timeout);

} catch (exception e) {

}

}

}

}

实例 10


@before

public void setup() {

pagecontext = createmock(pagecontext.class);

elcontext = createmock(elcontext.class);

vm = createmock(variablemapper.class);

expect(pagecontext.getelcontext()).andstubreturn(elcontext);

expect(pagecontext.getservletcontext()).andstubreturn(null);

expect(elcontext.getvariablemapper()).andstubreturn(vm);

bean = new bean();

expressionfactory expressionfactory = createmock(expressionfactory.class);

jspapplicationcontext applicationcontext = createmock(jspapplicationcontext.class);

jspfactory jspfactory = createmock(jspfactory.class);

expect(expressionfactory.coercetotype(value, string.class)).andstubreturn(value);

expect(expressionfactory.coercetotype(null, string.class)).andstubreturn(null);

expect(applicationcontext.getexpressionfactory()).andstubreturn(expressionfactory);

expect(jspfactory.getjspapplicationcontext(null)).andstubreturn(applicationcontext);

replay(jspfactory, applicationcontext, expressionfactory);

jspfactory.setdefaultfactory(jspfactory);

}

实例 11


protected mockjspwriter configurejspfactory(servletcontext httpcontext,

httpservletrequest httprequest, httpsession httpsession) {

pagecontext = new mockpagecontext();

pagecontext.setrequest(httprequest);

pagecontext.setservletcontext(httpcontext);

pagecontext.setsession(httpsession);

mockjspwriter jspwriter = new mockjspwriter();

pagecontext.setjspwriter(jspwriter);

jspfactory.setdefaultfactory(new mockjspfactory(pagecontext));

return jspwriter;

}

实例 12


protected mockjspwriter configurejspfactory(servletcontext httpcontext,

httpservletrequest httprequest, httpsession httpsession) {

mockjspwriter jspwriter = new mockjspwriter();

pagecontext = configurepagecontext(httpcontext, httprequest,

httpsession, jspwriter);

jspfactory.setdefaultfactory(new mockjspfactory(pagecontext));

return jspwriter;

}

实例 13


/**

*

* some versions of jspfactory do class.forname, which probably won't work in an

* osgi environment.

*/

public void fixjspfactory ()

{

try

{

classlt;javax.servlet.servletcontextgt; servletcontextclass = javax.servlet.servletcontext.class;

// bug #299733

jspfactory fact = jspfactory.getdefaultfactory();

if (fact == null)

{ // bug #299733

// jspfactory does a simple

// class.getforname("org.apache.jasper.runtime.jspfactoryimpl")

// however its bundles does not import the jasper package

// so it fails. let's help things out:

fact = (jspfactory) jettybootstrapactivator.class.getclassloader().loadclass(default_jsp_factory_impl_class).newinstance();

jspfactory.setdefaultfactory(fact);

}

}

catch (exception e)

{

log.warn("unable to set the jspfactory: jsp support incomplete.", e);

}

}

实例 14


protected mockjspwriter configurejspfactory(servletcontext httpcontext,

httpservletrequest httprequest, httpsession httpsession) {

pagecontext = new mockpagecontext();

pagecontext.setrequest(httprequest);

pagecontext.setservletcontext(httpcontext);

pagecontext.setsession(httpsession);

mockjspwriter jspwriter = new mockjspwriter();

pagecontext.setjspwriter(jspwriter);

jspfactory.setdefaultfactory(new mockjspfactory(pagecontext));

return jspwriter;

}

实例 15


protected mockjspwriter configurejspfactory(servletcontext httpcontext,

httpservletrequest httprequest, httpsession httpsession) {

pagecontext = new mockpagecontext();

pagecontext.setrequest(httprequest);

pagecontext.setservletcontext(httpcontext);

pagecontext.setsession(httpsession);

mockjspwriter jspwriter = new mockjspwriter();

pagecontext.setjspwriter(jspwriter);

jspfactory.setdefaultfactory(new mockjspfactory(pagecontext));

return jspwriter;

}



IT人知识库 原文地址:http://www.itpeo.net/389615/4625316.html





标签 代码实例

Java org.apache.tika.Tika 代码实例

以下是展示如何使用org.apache.tika.tika的最佳示例。 我们使用了代码质量辨别算法从开源项目中提取出了最 ...

Python zmq.MessageTrackers 代码实例

以下是python模块zmq.messagetracker的代码最佳示例,显示该如何使用sys.stdout。 它们是从 ...

Java com.google.common.primitives.Primitives 代码实例

以下是展示如何使用com.google.common.primitives.primitives的最佳示例。 我们使用了 ...

Python zmq.SNDMOREs 代码实例

以下是python模块zmq.sndmore的代码最佳示例,显示该如何使用sys.stdout。 它们是从开源pytho ...

Python zmq.PAIRs 代码实例

以下是python模块zmq.pair的代码最佳示例,显示该如何使用sys.stdout。 它们是从开源python项目 ...

Java org.yaml.snakeyaml.representer.Representer 代码实例

以下是展示如何使用org.yaml.snakeyaml.representer.representer的最佳示例。 我们 ...

Java org.eclipse.gef.EditPartFactory 代码实例

以下是展示如何使用org.eclipse.gef.editpartfactory的最佳示例。 我们使用了代码质量辨别算法 ...

Python zmq.LINGERs 代码实例

以下是python模块zmq.linger的代码最佳示例,显示该如何使用sys.stdout。 它们是从开源python ...

Python ctypes.c_ulonglongs 代码实例

以下是python模块ctypes.c_ulonglong的代码最佳示例,显示该如何使用sys.stdout。 它们是从 ...

Java org.springframework.boot.test.TestRestTemplate 代码实例

以下是展示如何使用org.springframework.boot.test.testresttemplate的最佳示例 ...

Python os._exits 代码实例

以下是python模块os._exit的代码最佳示例,显示该如何使用sys.stdout。 它们是从开源python项目 ...

Java cpw.mods.fml.common.gameevent.InputEvent 代码实例

以下是展示如何使用cpw.mods.fml.common.gameevent.inputevent的最佳示例。 我们使用 ...

Python os.urandoms 代码实例

以下是python模块os.urandom的代码最佳示例,显示该如何使用sys.stdout。 它们是从开源python ...

如何在Debian8上安装node js

介绍在本指南中,你将在debian8服务器上安装node js ,debian 8在它默认存储库中包含一个版本的node ...

Java javafx.geometry.Pos 代码实例

以下是展示如何使用javafx.geometry.pos的最佳示例。 我们使用了代码质量辨别算法从开源项目中提取出了最佳 ...

Java org.eclipse.ui.application.IWorkbenchWindowConfigurer 代码实例

以下是展示如何使用org.eclipse.ui.application.iworkbenchwindowconfigur ...

Java com.google.android.gms.gcm.GoogleCloudMessaging 代码实例

以下是展示如何使用com.google.android.gms.gcm.googlecloudmessaging的最佳示 ...

Java javax.security.auth.spi.LoginModule 代码实例

以下是展示如何使用javax.security.auth.spi.loginmodule的最佳示例。 我们使用了代码质量 ...

Java com.google.android.gms.analytics.HitBuilders 代码实例

以下是展示如何使用com.google.android.gms.analytics.hitbuilders的最佳示例。 ...

Java org.eclipse.emf.ecore.EClassifier 代码实例

以下是展示如何使用org.eclipse.emf.ecore.eclassifier的最佳示例。 我们使用了代码质量辨别 ...