Building a lightweight Java EE framework that supports AJAX

Source: Internet
Author: User
Tags final log net return string stub
Ajax|j2ee

Say Buffalo is the surname of write, support under homebred! Come on, first, top one.
Buffalo processing Ajax has a lot of cows, hey, I really did not serious the whole. I'm ashamed to try to study it well recently.
Buffalo support and spring consolidation. Hey, this is also a bright spot. The light is a little uncomfortable. Why?

If you use Spring+struts+hibernate to build a lightweight Java EE framework, spring and Struts are integrated in several ways, one way not to talk about it.



The above code is also familiar with it. Here's the problem, Buffalo support Spring is

contextConfigLocation

/web-inf/applicationcontext.xml



context
org.springframework.web.context.ContextLoaderServlet
1

Part of the code above is Buffalo support spring must.
If spring and struts are integrated in a plugin way, that is, spring to manage the action (management action is good or bad first). Buffalo and spring consolidation again in Web.xml Configuration spring's Dongdong, always feel strange.
Buffalo get Webapplicationcontext is obtained by webapplicationcontextutils.getwebapplicationcontext (context).
Feel wasted ...
So I want Buffalo to put the Webapplicationcontext in ServletContext in spring (contextloaderplugin The implementation puts the Webapplicationcontext instance in the ServletContext).
So a buffaloplugin is realized in the buffalo. The code is as follows: (written not standard, make it look)
。。。。
/**
*
* @Descripted Buffalo+Spring+Struts+Hibernate/B>
*


* @author Meconsea
* @Company
* @IM: msn:meconsea@hotmail.com
* qq:75147664
* e-mail:meconsea@163.com
* @date 2006-11-16
* @Version 1.0Beta
*/
public class Buffaloplugin implements PlugIn {

public static final Logger log = Logger.getlogger (Buffaloplugin.class);

public static final String Servlet_context_prefix = ContextLoaderPlugIn.class.getName () + ". Context. ";
public static final String Buffalo_context_prefix = BuffaloPlugIn.class.getName () + ". Context. ";

Private Moduleconfig moduleconfig;
Private Actionservlet Actionservlet;
public void Destroy () {
TODO auto-generated Method Stub

}

Protected final String Getmoduleconfigprefix () {
return This.moduleConfig.getPrefix ();
}
Protected final Actionservlet Getactionservlet () {
return this.actionservlet;
}

Public String Getservletcontextattributenameforbuffalo () {
return buffalo_context_prefix;
}
Public String GETSERVLETCONTEXTATTRIBUTENAMEFORSCP () {
return Servlet_context_prefix+getmoduleconfigprefix ();
}

public void Init (Actionservlet as, Moduleconfig MC)
Throws Servletexception {
TODO auto-generated Method Stub
Log.info ("Buffaloplugin init begin ...");
This.actionservlet = as;
This.moduleconfig = MC;
As.getservletcontext (). setattribute (Getservletcontextattributenameforbuffalo (), GETSERVLETCONTEXTATTRIBUTENAMEFORSCP ());
Log.info ("Init end");
}
}

The webapplicationcontext of the springfactory and Springutil in Buffalo are modified as follows:
To add a method to the Springutil:
/**
* Get Webapplicationcontext
* @param context
* @return
*/
public static Webapplicationcontext Getwebapplicationcontext (ServletContext context) {
Webapplicationcontext WAC = null;
Log.info ("Get WAC begin ...");

if (context = = null) {
Log.info ("context is null REUTRN null");
return null;
}
String wacattrname = (string) context.getattribute (Buffaloplugin.buffalo_context_prefix);
Log.info ("Wacattrname = =" +wacattrname);

if (wacattrname!= null) {
WAC = (webapplicationcontext) context.getattribute (wacattrname);
}

if (WAC = = null) {
Log.info ("WAC is null, obtain Webapplicationcontext by Webapplicationcontextutils again");
WAC = Webapplicationcontextutils.getwebapplicationcontext (context);
}
return WAC;
}

....//
Webapplicationcontext Appctx = getwebapplicationcontext (context);// Webapplicationcontextutils.getwebapplicationcontext (context);
All right, that's the change.
Increase in Struts-config.xml

It's OK. Only configured in Web.xml

bfapp
net.buffalo.web.servlet.ApplicationServlet

Spring is fully supported.
Of course it is built on the basis of the lightweight framework built by Spring+struts.

haha do not know if I can read. This sign off! Flash!!!!!
For the remembrance of their own stay.
Note: Spring2.0 Struts1.3 Hibernate3.0



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.