将AspectJ集成到基于Eclipse + Lomboz + XmlBuddy的Web应用中去

2016-02-19 14:02 1 1 收藏

在这个颜值当道,屌丝闪边的时代,拼不过颜值拼内涵,只有知识丰富才能提升一个人的内在气质和修养,所谓人丑就要多学习,今天图老师给大家分享将AspectJ集成到基于Eclipse + Lomboz + XmlBuddy的Web应用中去,希望可以对大家能有小小的帮助。

【 tulaoshi.com - 编程语言 】

一、       配置eclipes开发环境

首先,下载需要的插件:

eclipse-SDK-3.0.2-win32

Eclipse IDE

官方下载地址:

http://download.eclipse.org/downloads/drops/R-3.0.2-200503110845/eclipse-SDK-3.0.2-win32.zi

XMLbuddy_2.0.62

用于xml开发,可以用来编辑web.xml文件

官方下载地址:http://www.xmlbuddy.com/

org.objectweb.lomboz_3.0.1.N20050106

用于web开发,支持jsp,servlet等等的高亮显示和编辑

官方下载地址:http://forge.objectweb.org/projects/lomboz/

ajdt_1.2_for_eclipse_3.0

用于ASPectJ开发,专为eclipse开发的AspectJ插件

官方下载地址:http://www.xmlbuddy.com/

VE-runtime-1.0.2.2

  安装以上两个插件时必备,一个相关的类包含在此插件中。The Eclipse Visual Editor project is a vendor-neutral, open development platform supplying frameworks for creating GUI builders, and exemplary, extensible tool implementations for Swing/JFC and SWT/RCP. These tools are exemplary in that they verify the utility of the Eclipse Visual Editor frameworks, illustrate the appropriate use of those frameworks, and support the development and maintenance of the Eclipse Visual Editor Platform itself.

官方下载地址:http://www.xmlbuddy.com/

GEF-runtime-3.0.1

安装VE时必备,The Graphical Editing Framework (GEF) allows developers to take an existing application model and quickly create a rich graphical editor.

官方下载地址:

http://download.eclipse.org/tools/gef/downloads/drops/R-3.0.1-200408311615/GEF-runtime-3.0.1.zip

emf-sdo-runtime-2.0.2

安装VE时必备,EMF is a modeling framework and code generation facility for building tools and other applications based on a strUCtured data model. From a model specification described in XMI, EMF provides tools and runtime support to produce a set of Java classes for the model, a set of adapter classes that enable viewing and command-based editing of the model, and a basic editor. Models can be specified using annotated Java, XML documents, or modeling tools like Rational Rose, then imported into EMF. Most important of all, EMF provides the foundation for interoperability with other EMF-based tools and applications.

官方下载地址:

http://download.eclipse.org/tools/emf/downloads/drops/2.0.2/R200503151315/emf-sdo-runtime-2.0.2.zip

[说明] 现在最高版本的ajdt支持到eclipse3.0.2,所以相应的其他插件都选择与eclipse相对应的最高版本。

2、下载完成后解压进行安装:help - softwareupdate - find and install - from local.

3、进行配置window - perspective

配置aspectj:

       不需要非凡配置

配置lomboz:

A、设置jdk tools.jar位置,为安装的j2sdk目录

B、配置server definition:选择Apache Tomcat : tomcat5.0.x,设置其Server lib和project lib,可以把%tomcat_home%/common/lib一些相关的包都放进去,有可能是必须放,注重,某些版本据说可能是5.0.27,需要修改目录E:eclipse3.0.2pluginscom.objectlearn.jdt.j2ee_3.0.1

servers,tomcat5.0.x配置文件tomcat50x.server文件,将两处-Djava.endorsed.dirs=,

修改为如下:

-Djava.endorsed.dirs="${serverRootDirectory}/common/endorsed"

4、配置window - customize perspective,将aspectj和lomboz相关的项目都给添加到new中,这样就可以通过新建来建立相应的工程文件。

二、       集成AspectJ到Web工程中

5、新建一个AspectJ工程

6、在此工程中新建一个Lomboz J2EE Module

7、新建一个Servlet,并设置其url-mapping

/*

 * Created on 2005-8-3 ,test

 *

 * @Author:Jonathan Q. Bo from tju.MSNrl

 * MyBlog:http://blog.csdn.net/jonathan_q_bo

 *

 */

package org.tju.msnrl.jonathan.aspectj;

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

import java.io.IOException;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.ServletOutputStream;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

/**

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

 * @author Administrator

 * 2005-8-3 14:46:22

 */

public class HelloWorld extends HttpServlet {

    public void doGet(HttpServletRequest request,

            HttpServletResponse response) throws ServletException, IOException {

        //TODO Method stub generated by Lomboz

        ServletOutputStream out = response.getOutputStream( );

        out.println("h1Hello World from an aspect-oriented Servlet!/h1");

    }

}

8、新建一个Aspect,拦截其doGet(..),在其执行之前和之后作相应的advice

/*

 * Created on 2005-8-3 ,test

 *

 * @Author:Jonathan Q. Bo from tju.msnrl

 * MyBlog:http://blog.csdn.net/jonathan_q_bo

 *

 */

package org.tju.msnrl.jonathan.aspectj;

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

import java.io.IOException;

import javax.servlet.ServletOutputStream;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

/**

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

 * @author Administrator

 * 2005-8-3 15:43:54

 */

public aspect HelloWorldAspect {

       public pointcut captureHttpRequest(HttpServletRequest request,

            HttpServletResponse response) :

            execution(public void HelloWorld.doGet(HttpServletRequest,

                                        HttpServletResponse)) &&

            args(request, response);

           

        before(HttpServletRequest request, HttpServletResponse response)

        throws IOException :

        captureHttpRequest(request, response)

        {

        response.setContentType("text/Html");

        ServletOutputStream out = response.getOutputStream( );

        out.println("html");

        out.println("headtitleAdding a title using AspectJ!/title/head");

        out.println("body");

        }

       

        after(HttpServletRequest request, HttpServletResponse response)

        throws IOException :

        captureHttpRequest(request, response)

        {

        ServletOutputStream out = response.getOutputStream( );

        out.println("/body");

        out.println("/html");

        }

   

}

9、部署工程,默认会将工程打包成war文件部署,试验发现,war文件执行时会报错,所以,需要改写build.xml文件,原build.xml文件将编译好的文件统一放到dist文件夹中,然后对其打包war,简单修改,只需要将打包过程去掉,将dist文件夹直接拷贝到tomcat_home/webapps/下就可以了

project name="webmodulebuilder"  default="deploy"  basedir="."

  !-- set global properties for this build --

  property file="build.properties"/

  property name="dist" value="../../dist" /

  property name="deploy.dir" value="C:/Program Files/Apache Software Foundation/Tomcat 5.0/webapps/rbac" /

  property name="web" value="../" /

 

  

  target name="init"

    !-- Create the dist directory structure used by compile

         and copy the deployment descriptors into it--

    mkdir dir="${dist}"/

  

来源:https://www.tulaoshi.com/n/20160219/1606040.html

延伸阅读
标签: Web开发
前面已经提到,通过XSL,我们可以把相同的数据以不同的数据形式提交给终端客户,一个XSL文件描述了数据的显示方式,你可以把许多XSL和同一个XML文档相连来提供不同的基于HTML的表示,这样事实上,我们就可以建立基于XML的桌面应用程序。基于Windows体系结构的一个图形表示如下所示: 采用这种方法主要有两个优点,首先,你...
标签: autocad教程
关键字: AutoCAD 2009 Photoshop手绘 AutoCAD对象 中望CAD AutoCAD三维造型介绍了PDM系统的集成框架。详细地阐述了基于PDM实现应用集成的3个层次,并对PDM系统集成的一般步骤作了简要的说明。在此基础上,列举了UGNX2与PDM系统集成的部分实例。 0 引言 随着企业信息化进程的发展,企业所使用的应用软件越来越多,信息集成的深...
标签: Web开发
在配置Eclipse之前,首先需要一个Apache+PHP的基础环境, 可以装wampp或php home,它们都是集成化安装,比较方便,下载地址如下: wampp2.2 php home 建议装wampp2.2,集成Apache,MySQL,Perl,PHP。而且解压缩就可用,我就用它挺方便的。 下面我就以安装wampp2.2为例,一步一步的讲解一下,如何去配置基于Eclipse...
标签: Java JAVA基础
Hibernate是对JDBC的轻量级对象封装,Hibernate本身是不具备Transaction处理功能的,Hibernate的Transaction实际上是底层的JDBC Transaction的封装,或者是JTA Transaction的封装,下面我们详细的分析: Hibernate可以配置为JDBCTransaction或者是JTATransaction,这取决于你在hibernate.properties中的配置: #hibe...
标签: Web开发
1)怎样将 Dreamweaver 集成到 IE 浏览器? Dreamweaver 安装程序会在上下文选单增加一个“ Edit with Dreamweaver ”命令,我们还可以修改 Windows 的注册表使它与 IE 集成。就象 MS word 、 FrontPage 和 Notepad 一样,通过 IE 工具栏的编辑按钮来调用 Dreamweaver 打开当前网页。 将下面文本的最后一行要改为你自己的 Drea...

经验教程

75

收藏

17
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部