当前位置: 首页 > news >正文

网站导航三角怎么做app在线生成平台 免费

网站导航三角怎么做,app在线生成平台 免费,海外网站建设教程,网站虚拟建设策划在Web应用程序开发期间#xff0c;经常需要发送电子邮件。 但是#xff0c;有时数据库中会包含来自生产的数据#xff0c;并且存在在电子邮件测试执行期间向真实客户发送电子邮件的风险。 这篇文章将解释如何避免在没有在发送电子邮件功能中明确编写代码的情况下避免这种情… 在Web应用程序开发期间经常需要发送电子邮件。 但是有时数据库中会包含来自生产的数据并且存在在电子邮件测试执行期间向真实客户发送电子邮件的风险。 这篇文章将解释如何避免在没有在发送电子邮件功能中明确编写代码的情况下避免这种情况。 我们将使用2种技术 Spring Profiles –一种指示运行环境是什么的机制即开发生产.. AOP –简而言之它是一种以解耦的方式在方法上编写附加逻辑的机制。 我假设您已经在项目中设置了Profiles并专注于Aspect方面。 在该示例中发送电子邮件的类是EmailSender其发送方法如下所示 public class EmailSender { //empty default constructor is a must due to AOP limitation public EmailSender() {}//Sending email function //EmailEntity - object which contains all data required for email sending (from, to, subject,..) public void send(EmailEntity emailEntity) { //logic to send email } } 现在我们将添加防止在未在代码上运行代码的客户发送电子邮件的逻辑。 为此我们将使用Aspects因此我们不必在send方法中编写它从而可以保持关注点分离的原则。 创建一个包含过滤方法的类 Aspect Component public class EmailFilterAspect {public EmailFilterAspect() {} } 然后创建一个PointCut来捕获send方法的执行 Pointcut(execution(public void com.mycompany.util.EmailSender.send(..)))public void sendEmail(){} 由于我们需要控制是否应执行该方法因此需要使用Arround批注。 Around(sendEmail()) public void emailFilterAdvice(ProceedingJoinPoint proceedingJoinPoint){try {proceedingJoinPoint.proceed(); //The send email method execution} catch (Throwable e) { e.printStackTrace();} } 最后一点我们需要访问send方法的输入参数即获取EmailEntity并确认我们没有在开发中向客户发送电子邮件。 Around(sendEmail())public void emailFilterAdvice(ProceedingJoinPoint proceedingJoinPoint){//Get current profile ProfileEnum profile ApplicationContextProvider.getActiveProfile();Object[] args proceedingJoinPoint.getArgs(); //get input parametersif (profile ! ProfileEnum.PRODUCTION){//verify only internal mails are allowedfor (Object object : args) {if (object instanceof EmailEntity){String to ((EmailEntity)object).getTo();if (to!null to.endsWith(mycompany.com)){//If not internal mail - Dont continue the method try {proceedingJoinPoint.proceed();} catch (Throwable e) {e.printStackTrace();}}}}}else{//In production dont restrict emailstry {proceedingJoinPoint.proceed();} catch (Throwable e) {e.printStackTrace();}} } 而已。 关于配置您需要在项目中包括纵横图罐。 在Maven中它看起来像这样 org.aspectjaspectjrt${org.aspectj.version}org.aspectjaspectjweaver${org.aspectj.version}runtime 在您的spring应用程序配置xml文件中您需要具有以下内容 祝好运 参考来自Gal Levinsky博客博客的JCG合作伙伴 Gal Levinsky 使用Aspect和Spring Profile进行电子邮件过滤 。 翻译自: https://www.javacodegeeks.com/2012/07/email-filtering-using-aspect-and-spring.html
http://www.yutouwan.com/news/501491/

相关文章:

  • 计算机专业网站开发开题报告青岛做网站建设价格
  • ps制作网站效果图手机网站二级域名
  • 排名好的网站关键词优化企业做最好的网站
  • 北京的做网站的公司网站建设iis配置
  • 网站问责建设书wordpress 下 刷文章
  • 互联网网站备案域名服务商平台
  • 天猫店铺装修做特效的网站76人vs猛龙
  • 怎样做网站管理京东短网址在线生成
  • 魔站网站开发wordpress标签加标题
  • 昭通网站建设公司网站开发技术是什么
  • 网站商城开发公司网站界面风格设计
  • 在百度上怎么建网站个人网站设计论文范文
  • 毕业设计可以做自己的网站吗机床网站建设
  • 开发一个企业网站需要多少钱辽宁建设厅投诉网站
  • 游戏开发与网站开发哪个难建筑公司网站董事长致辞
  • 手机网站链接微信免费网络电话在线拨打
  • 温州知名网站批量爆破wordpress
  • 网站开发项目需求网站开发需要的编程软件有哪些
  • PHP是做网站最好的网站开发 无代码
  • 广东微信网站推广哪家专业seo网站优化服务
  • 面向搜索引擎网站建设wordpress文章模型插件
  • pc网站建设怎么弄南京软件网站建设公司
  • 做娱乐新闻的网站有哪些成都公司注册流程完整版
  • 建筑工程找活网站wordpress主题教程 pdf
  • 哈尔滨网站建设王道下拉強做外贸用什么社交网站
  • 网站搭建手机郑州网站关键字优化
  • 做网站用c 还是php合肥专业做淘宝网站推广
  • 优质服务的网站建设无锡网络推广
  • 哈尔滨门户网站建设做网站开发有前途么
  • 山东企业建站系统信息梅州新农村建设网站