锘??xml version="1.0" encoding="utf-8" standalone="yes"?>99国产精品国产精品毛片,久久激情婷婷,av网站无病毒在线http://www.aygfsteel.com/musiclover/zh-cnFri, 20 Jun 2025 01:49:58 GMTFri, 20 Jun 2025 01:49:58 GMT60鐢⊿truts2瀹炵幇鍦ㄧ嚎閾惰浠樻http://www.aygfsteel.com/musiclover/archive/2009/10/13/298099.htmlJxiJxiTue, 13 Oct 2009 10:27:00 GMThttp://www.aygfsteel.com/musiclover/archive/2009/10/13/298099.htmlhttp://www.aygfsteel.com/musiclover/comments/298099.htmlhttp://www.aygfsteel.com/musiclover/archive/2009/10/13/298099.html#Feedback2http://www.aygfsteel.com/musiclover/comments/commentRss/298099.htmlhttp://www.aygfsteel.com/musiclover/services/trackbacks/298099.html闃呰鍏ㄦ枃

Jxi 2009-10-13 18:27 鍙戣〃璇勮
]]>
SSH鍩虹鎼緩http://www.aygfsteel.com/musiclover/archive/2009/09/30/297020.htmlJxiJxiWed, 30 Sep 2009 07:29:00 GMThttp://www.aygfsteel.com/musiclover/archive/2009/09/30/297020.htmlhttp://www.aygfsteel.com/musiclover/comments/297020.htmlhttp://www.aygfsteel.com/musiclover/archive/2009/09/30/297020.html#Feedback0http://www.aygfsteel.com/musiclover/comments/commentRss/297020.htmlhttp://www.aygfsteel.com/musiclover/services/trackbacks/297020.html 

                           Struts2+Hibernate3.0+Spring鐨勫熀鏈惌寤?闈炲父鍩虹鐨?

鍏蜂綋鎿嶄綔姝ラ鎴浘瑙侀檮浠?婧愪唬鐮佷笉鍖呭惈lib鍖?:S2SH鎴浘
闄や簡鎿嶄綔鐨勯厤緗唬鐮?
WEB-INF涓嬬殑web.xml鐨勯厤緗?

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
 3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
 5     http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
 6     <!-- 閰嶇疆Struts 2妗嗘灦鐨勬牳蹇僃ilter -->
 7     <filter>
 8         <filter-name>struts</filter-name>
 9         <filter-class>
10             org.apache.struts2.dispatcher.FilterDispatcher
11         </filter-class>
12     </filter>
13 
14     <!-- 閰嶇疆Filter鎷︽埅鐨刄RL -->
15     <filter-mapping>
16         <filter-name>struts</filter-name>
17         <url-pattern>/*</url-pattern>
18     </filter-mapping>
19     <!-- 閰嶇疆Spring -->
20 <context-param>
21  <param-name>contextConfigLocation</param-name>
22  <param-value>classpath:applicationContext.xml</param-value>
23 </context-param>
24 
25 <listener>
26    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
27 </listener>
28 
29     <welcome-file-list>
30         <welcome-file>index.jsp</welcome-file>
31     </welcome-file-list>
32 </web-app>
33 

applicationContext.xml:
 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans
 3     xmlns="http://www.springframework.org/schema/beans"
 4     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 5     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
 6 <!-- Spring 椋庢牸鐨凥ibernate鐨勯厤緗?nbsp;-->
 7 <!-- 浣跨敤澶栭儴灞炴ф枃浠?/span>/WEB-INF/jdbc.properties -->
 8 <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
 9      <property name="location" value="/WEB-INF/jdbc.properties"></property>
10 </bean>
11     <!-- 閰嶇疆鏁版嵁婧?nbsp;-->
12 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
13  destroy-method="close" >
14           <property name="driverClassName" value="${jdbc.driverClassName}"></property>
15           <property name="url" value="${jdbc.url}"></property>
16           <property name="username" value="${jdbc.username}"></property>
17           <property name="password" value="${jdbc.password}"></property>     
18 </bean>
19 
20 
21 <!-- 鍒涘緩SessionFactory瀹炰緥 -->
22 <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
23 <property name="dataSource" ref="dataSource"></property><!-- 鏁版嵁婧?nbsp;-->
24 
25 <property name="mappingResources">
26    <list>
27     
28    </list>
29 
30 </property>
31 
32 
33 <!-- 閰嶇疆鏁版嵁搴撴柟璦 -->
34 <property name="hibernateProperties">
35      <props>
36           <prop key="hibernate.dialect">
37             ${hibernate.dialect}
38           </prop>
39           <prop key="hibernate.show_sql">true</prop>
40           <prop key="hibernate.generate_satistices">true</prop>
41      </props>
42 </property>
43 </bean>
44 
45 
46  <!-- 浣跨敤Hibernate3浜嬪姟綆$悊閰嶇疆 -->
47  <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
48     <property name="sessionFactory" ref="sessionFactory"></property>
49  </bean>
50 
51 
52 <!-- 閰嶇疆HibernateTemplate -->
53 <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
54    <property name="sessionFactory" ref="sessionFactory"></property>
55 </bean>
56 
57 
58 </beans>

struts.xml:
 1 <?xml version="1.0" encoding="UTF-8" ?>
 2 <!DOCTYPE struts PUBLIC
 3     "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
 4     "http://struts.apache.org/dtds/struts-2.0.dtd">
 5 <struts>
 6   <!-- 鍖呭惈澶栭儴struts鐨勯厤緗?nbsp;-->
 7  <!--  <include file="filename"></include>  -->
 8  
 9  <!-- 閰嶇疆UTF-8 -->
10 <constant name="struts.i18n.encoding" value="utf-8"></constant>
11  <package name="struts2" extends="struts-default">
12  
13  <!-- 鍐橝ction鐨勯厤緗?nbsp; -->
14   
15  
16  </package>
17   
18 </struts>
hibernate.cfg.xml:浠涔堥兘鍋氾紝鍏ㄤ氦緇橲pring綆$悊
 1 <?xml version='1.0' encoding='UTF-8'?>
 2 <!DOCTYPE hibernate-configuration PUBLIC
 3           "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
 4           "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
 5 
 6 <!-- Generated by MyEclipse Hibernate Tools.                   -->
 7 <hibernate-configuration>
 8 
 9     <session-factory>
10     
11     </session-factory>
12 
13 </hibernate-configuration>
WEB-INF涓嬬殑鏁版嵁搴撻厤緗枃浠?jdbc.properties
1 hibernate.dialect= org.hibernate.dialect.MySQLDialect
2 jdbc.driverClassName=com.mysql.jdbc.Driver
3 jdbc.url=jdbc\:mysql\://localhost\:3306/bookbooks
4 jdbc.username=root
5 jdbc.password=123456
6 





Jxi 2009-09-30 15:29 鍙戣〃璇勮
]]>
Spring @AspectJhttp://www.aygfsteel.com/musiclover/archive/2009/09/14/295059.htmlJxiJxiMon, 14 Sep 2009 12:01:00 GMThttp://www.aygfsteel.com/musiclover/archive/2009/09/14/295059.htmlhttp://www.aygfsteel.com/musiclover/comments/295059.htmlhttp://www.aygfsteel.com/musiclover/archive/2009/09/14/295059.html#Feedback0http://www.aygfsteel.com/musiclover/comments/commentRss/295059.htmlhttp://www.aygfsteel.com/musiclover/services/trackbacks/295059.html鍑嗗宸ヤ綔:闇瑕?nbsp; spring/lib/asm 涓嬬殑3涓寘:asm.jar  asm-commons.jar asm-util.jar
spring/lib/aspectj  涓嬬殑2涓寘 aspectjrt.jar  鍜宎spectjweaver.jar
浣跨敤@AspectJ鐨勫皬渚嬪瓙:

public interface Company {
  
public void descript();
  
public void ss();
}

public class stockCompany implements Company{

    
public void descript() {
        System.out.print(
"This is a stock market");
    }

    
//鍙﹀娣誨姞涓涓唴宓宒escript()鐨勫嚱鏁?nbsp;璋冪敤鍚庝笉浼氭嫤鎴噷闈㈢殑descript鍑芥暟
    public void ss(){
        System.out.println(
"鍦ㄥ彟澶栦竴涓嚱鏁拌皟鐢ㄧ殑");
        descript();
    }

}

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;


@Aspect
public class PreDescriptAspect {
@Before(
"execution(* descript(..))")
 
public void beforeDescript(){
     System.out.print(
"Here Is My Company Description!");
 }

}

import org.springframework.aop.aspectj.annotation.AspectJProxyFactory;

public class stockCompanyTest {
 
public static void main(String[] args){
 Company target
=new stockCompany();
 AspectJProxyFactory factory
=new AspectJProxyFactory();
 factory.setTarget(target);
 factory.addAspect(PreDescriptAspect.
class);
 Company proxy
=factory.getProxy();
 proxy.descript();
 proxy.ss();
 }

}





Jxi 2009-09-14 20:01 鍙戣〃璇勮
]]>
Spring AOP 瀛︿範絎旇http://www.aygfsteel.com/musiclover/archive/2009/08/23/292311.htmlJxiJxiSun, 23 Aug 2009 14:52:00 GMThttp://www.aygfsteel.com/musiclover/archive/2009/08/23/292311.htmlhttp://www.aygfsteel.com/musiclover/comments/292311.htmlhttp://www.aygfsteel.com/musiclover/archive/2009/08/23/292311.html#Feedback0http://www.aygfsteel.com/musiclover/comments/commentRss/292311.htmlhttp://www.aygfsteel.com/musiclover/services/trackbacks/292311.htmlAOP  Aspect Oriented Programing  闈㈠悜鏂歸潰緙栫▼
AOP 鏈
榪炴帴鐐?(Joinpoint)    紼嬪簭鎵ц鐨勭壒瀹氫綅緗?綾誨紑濮嬪垵濮嬪寲鍓嶃佺被鍒濆鍖栧悗銆佽皟鐢ㄥ墠鍚庛佸紓甯告姏鍑哄悗)
鍒囩偣:   (PointCut)     紼嬪簭綾諱腑瀹㈣瀛樺湪鐨勪簨鐗╋紙綾諱腑鐨勬柟娉曪級
澧炲己 :  (Advice)        緗叆鍒扮洰鏍囩被Joinpint鐨勪竴孌典唬鐮?br /> 鐩爣瀵硅薄:(Target)   寮曚粙(Introduction)  緇囧叆(Weaving)  浠g悊(Proxy) 鍒囬潰(Aspect):鍒囩偣鍜屽寮虹殑緇勬垚 
 
鍩虹鐭ヨ瘑: Spring Aop :浣跨敤鍔ㄦ佷唬鐞嗘妧鏈湪榪愯鏈熼棿緇囧叆澧炲己浠g爜
ProxyFactory 浠g悊宸ュ巶閲囩敤JDK浠g悊鎴朇GLib浠g悊鎶鏈?br /> JDK 鍔ㄦ佷唬鐞?
1.瀹氫箟UserService鎺ュ彛鍑芥暟:
public interface UserService {
public void addUser(int id);
 }

2.UserServiceImpl
public class UserServiceImpl implements UserService{
 
public void addUser(int id){
     System.out.println(
"娣誨姞涓涓敤鎴蜂腑 錛?/span>"+id);
 }

}

3.ProxyHandler
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;


public class ProxyHandler implements InvocationHandler{
   
private Object target;
   
public  ProxyHandler(Object target){
       
this.target=target;
   }

   
public Object invoke(Object proxy, Method method, Object[] args)
        
throws Throwable {
       System.out.println(
"娣誨姞鐢ㄦ埛鍓?/span>");
       Object obj
=method.invoke(target,args);
       System.out.println(
"娣誨姞鐢ㄦ埛鍚?/span>");
       
return obj;
}

}

TestProxyHandler
import java.lang.reflect.Proxy;

public class ProxyHandlerTest {
  
public static void main(String args[]){
      UserService target
=new UserServiceImpl();
      ProxyHandler handler
=new ProxyHandler(target);
      UserService proxy
=(UserService)Proxy.newProxyInstance(
        target.getClass().getClassLoader(),
        target.getClass().getInterfaces(),
        handler);
      proxy.addUser(
100);
  }

}

CGLib 浠g悊:
AddUserService鎺ュ彛:
package CGlib.Text.Service;

public interface AddUserService {
 
public void addUser(int id);
}

AddUserServiceImpl 瀹炵幇綾?
package CGlib.Text.Service;

public class AddUserServiceImpl implements AddUserService {

    
public void addUser(int id) {
        System.out.println(
"娣誨姞鐢ㄦ埛ID涓?"+id);
    }
}
CglibProxy 浠g悊綾?
package CGlib.Text.Service;



import java.lang.reflect.Method;

import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

public class CglibProxy implements MethodInterceptor{
    
private Enhancer enhancer=new Enhancer();
    @SuppressWarnings(
"unchecked")
    
public Object getProxy(Class clazz){
        enhancer.setSuperclass(clazz);
        enhancer.setCallback(
this);
        
return enhancer.create();        
    }


    
public Object intercept(Object obj, Method method, Object[] args,
            MethodProxy proxy) 
throws Throwable {
        System.out.println(
"娣誨姞鐢ㄦ埛涔嬪墠");
        System.out.print(method.getName());
        System.out.print(obj.getClass().getName()
+"澶栧姞");
        System.out.print(args.getClass().getName());
        Object result
=proxy.invokeSuper(obj, args);
        System.out.println(
"澶栧姞鐨勫弬鏁?/span>"+args.toString());
        System.out.println(
"娣誨姞鐢ㄦ埛涔嬪悗");
        
// TODO Auto-generated method stub
        return result;
    }

    

}


CglibProxyTest:嫻嬭瘯綾?br />
package CGlib.Text.Service;

public class CglibProxyTest {
    
public static void main(String[] args){
        CglibProxy proxy
=new CglibProxy();
        AddUserServiceImpl userService
=
            (AddUserServiceImpl)proxy.getProxy(AddUserServiceImpl.
class);
      userService.addUser(
100);        
    }


}


瀵笿DK鍔ㄦ佷唬鐞嗗拰Cglib鍔ㄦ佷唬鐞嗙殑鐞嗚В錛?br /> JDK   浠g悊鏃舵ц兘楂橈紝浣嗙敓鎴愪唬鐞嗗璞℃椂榪愯鎬ц兘杈冧綆
Cglib 浠g悊鏃舵ц兘浣庯紝浣嗙敓鎴愪唬鐞嗗璞℃椂榪愯鎬ц兘杈冮珮
鎵浠ワ細鍗曚緥Singleton 鏃墮噰鐢–GLib浠g悊銆?br />


Jxi 2009-08-23 22:52 鍙戣〃璇勮
]]>
Spring http://www.aygfsteel.com/musiclover/archive/2009/07/25/288336.htmlJxiJxiSat, 25 Jul 2009 06:57:00 GMThttp://www.aygfsteel.com/musiclover/archive/2009/07/25/288336.htmlhttp://www.aygfsteel.com/musiclover/comments/288336.htmlhttp://www.aygfsteel.com/musiclover/archive/2009/07/25/288336.html#Feedback0http://www.aygfsteel.com/musiclover/comments/commentRss/288336.htmlhttp://www.aygfsteel.com/musiclover/services/trackbacks/288336.htmlSpring

Important 

Spring is an application framework. Unlike single-tier frameworks such as Struts or Hibernate, Spring aims to help structure whole applications in a consistent, productive manner, pulling together best-of-breed single-tier frameworks to create a coherent architecture.

Problems with the Traditional Approach to J2EE

浼犵粺J2EE鏂規硶瀛樺湪鐨勯棶棰?/span>

  • J2EE applications tend to contain excessive amounts of "plumbing" code.澶?/span>
  • Many J2EE applications use a distributed object model where this is inappropriate.鏉?/span>
  • The EJB component model is unduly complex.涓嶅綋
  • EJB is overused.榪囧害浣跨敤
  • Many "J2EE design patterns" are not, in fact, design patterns, but workarounds for technology limitations.鎶鏈窡涓嶄笂
  • J2EE applications are hard to unit test.嫻嬭瘯闅?/span>
  • Certain J2EE technologies have simply failed.

Enter Spring

鎺ヨЕSpring

  • Inversion of Control container:鍊掔疆鎺у埗
  • Aspect-Oriented Programming (AOP) framework:
  • Data access abstraction:
  • JDBC simplification:
  • Transaction management:
  • MVC web framework:
  • Simplification for working with JNDI, JTA, and other J2EE APIs:
  • Lightweight remoting:
  • JMS support:
  • JMX support:
  • Support for a comprehensive testing strategy for application developers:

The key Spring values can be summarized as follows:

·         Spring is a non-invasive framework.闈炰鏡鍏?

·         Spring provides a consistent programming model, usable in any environment.

·         Spring aims to promote code reuse.澶嶇敤

·         Spring aims to facilitate Object Oriented design in J2EE applications.

·         Spring aims to facilitate good programming practice, such as programming to interfaces, rather than classes.闈㈠悜鎺ュ彛

·         Spring promotes pluggability.鎬ц兘

·         Spring facilitates the extraction of configuration values from Java code into XML or properties files.

·         Spring is designed so that applications using it are as easy as possible to test.

·         Spring is consistent.

·         Spring promotes architectural choice.

·         Spring does not reinvent the wheel.



Jxi 2009-07-25 14:57 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 华宁县| 阿瓦提县| 丹阳市| 新巴尔虎右旗| 二连浩特市| 嘉禾县| 黑山县| 宝丰县| 平顺县| 宣化县| 海晏县| 涟水县| 罗甸县| 杂多县| 阿克陶县| 沂南县| 东方市| 泊头市| 沿河| 灌云县| 阿克| 本溪| 北川| 菏泽市| 新余市| 喀喇沁旗| 平顺县| 武功县| 隆林| 望江县| 额济纳旗| 开远市| 驻马店市| 二手房| 嘉鱼县| 南木林县| 泰宁县| 郑州市| 博白县| 北海市| 正宁县|