|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
对于一个大型项目,如果用java来作,可能需要9个月,并且可能需要翻阅10本以上的书,但如果用ruby来作,3个月,3本书就足够了,而.net网页编程也不过3,4本书足以,这就是区别。
packagecom.rx.spring.cglib;
publicclassUserManagerImpl{//implementsUserManager{
publicvoidaddUser(Stringusername,Stringpassword){
System.out.println("-------UserManagerImpl.addUser()----------");
}
publicvoiddeleteUser(intid){
System.out.println("-------UserManagerImpl.deleteUser()----------");
}
}
packagecom.rx.spring.cglib;
importorg.aspectj.lang.JoinPoint;
publicclassSecurityHandler{
privatevoidcheckSecurity(JoinPointjoinPoint){
Object[]args=joinPoint.getArgs();
for(inti=0;i<args.length;i++){
System.out.println(args);
}
System.out.println(joinPoint.getSignature().getName());
System.out.println("----------checkSecurity()---------------");
}
}
packagecom.rx.spring.cglib;
importorg.springframework.beans.factory.BeanFactory;
importorg.springframework.context.support.ClassPathXmlApplicationContext;
publicclassClient{
publicstaticvoidmain(String[]args){
BeanFactoryfactory=newClassPathXmlApplicationContext("applicationContextCglib.xml");
UserManagerImpluserManager=(UserManagerImpl)factory.getBean("userManager");
userManager.addUser("abc","123");
System.out.println("testing");
userManager.deleteUser(1);
}
}
<?xmlversion="1.0"encoding="UTF-8"?>
<beansxmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<!--
<aop:aspectj-autoproxyproxy-target-class="true"/>
-->
<beanid="securityHandler"class="com.rx.spring.cglib.SecurityHandler"/>
<beanid="userManager"class="com.rx.spring.cglib.UserManagerImpl"/>
<aop:config>
<aop:aspectid="security"ref="securityHandler">
<aop:pointcutid="allAddMethod"expression="execution(*com.rx.spring.cglib.UserManagerImpl.add*(..))"/>
<aop:beforemethod="checkSecurity"pointcut-ref="allAddMethod"/>
</aop:aspect>
</aop:config>
</beans>
<br>
他们对jsp,servlet,javabean进行封装就是为了展示他们的某个思想,与java的开发并没有必然的关系,也不见得在所以情况下,别人使用起来会简单。 |
|