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

深圳全网站建设公司哪个网站可以免费做音乐相册

深圳全网站建设公司,哪个网站可以免费做音乐相册,网站开发合同里的坑,视频交易类网页Spring框架有几个提供一系列服务的模块#xff0c;其中许多模块仅可用于托管对象#xff08;Spring Bean#xff09;。有关这些服务的一些示例是依赖注入#xff0c;事务管理#xff0c;AOP服务等。当我们使用时#xff0c;一切都很好对象即服务#xff0c;因此由Spring… Spring框架有几个提供一系列服务的模块其中许多模块仅可用于托管对象Spring Bean。有关这些服务的一些示例是依赖注入事务管理AOP服务等。当我们使用时一切都很好对象即服务因此由Spring在特定范围内进行管理。 但是有时候我们需要我们的领域对象拥有这些服务。 通常域对象是使用new关键字创建的因此默认情况下无法使用spring对其进行管理。 在我的上一篇文章 如何在Spring 3.x中使用事件 中我们有一个名称为Order的域对象。 对于对象之间的解耦我们使用了事件。 但是只有受管bean才能在Spring框架中引发事件可能是您知道并具有此功能的每个框架。 Spring引入了一个名为Configurable的注释。 在我们的域对象上使用此注释使它们由spring管理。 但是它是如何工作的出于其目的可配置需要AspectJ Compiler您的类需要在编译时或加载时提高字节码直到可以满足您的要求。 我想带给您一个有关如何在应用程序中配置和使用可配置电源的简单示例。 最好让环境对象使所有系统都可以访问其属性以捕获有关系统的信息。 例如我们需要知道系统的当前时间简单的解决方案是使用Calendar.getInstance().getTime()或new Date() 但是有一些缺陷您的代码对于需要测试日期断言的部分将无法进行测试我将尽快编写一系列后测试和可测试代码。 另一个问题是当您希望系统使用伪时钟时。 例如您的客户希望在假期最后一个非假期日期使用系统。 因此为这些需求提供一种机制很有价值。 作为此示例中的一个简单解决方案我将创建一个环境接口该接口具有一个方法getCurrentTime。 如果我需要系统时间则代码中的每个地方都将使用此方法。 在我可以愉快地使用此方法之前必须将环境接口注入到我的对象中。 Spring bean对使用Environment没有任何问题但是在我们的域对象中我们必须使用Configurable Annotation。 如果使用Maven则需要将以下依赖项添加到pom中 groupIdorg.springframework/groupId artifactIdspring-aspects/artifactId version3.1.1.RELEASE/versiondependency groupIdorg.aspectj/groupId artifactIdaspectjrt/artifactId version1.6.8/version /dependency dependency groupIdorg.aspectj/groupId artifactIdaspectjweaver/artifactId version1.6.8/version /dependency dependency groupIdorg.aspectj/groupId artifactIdaspectjtools/artifactId version1.6.8/version /dependency 要使用maven编译应用程序可以使用以下Aspectj-maven-plugin配置 buildpluginsplugingroupIdorg.codehaus.mojo/groupIdartifactIdaspectj-maven-plugin/artifactIdversion1.4/versionconfigurationshowWeaveInfotrue/showWeaveInfosource1.6/sourcetarget1.6/targetXlintignore/XlintcomplianceLevel1.6/complianceLevelencodingUTF-8/encodingverbosefalse/verboseaspectLibrariesaspectLibrarygroupIdorg.springframework/groupIdartifactIdspring-aspects/artifactId/aspectLibrary/aspectLibraries/configurationexecutionsexecutiongoalsgoalcompile/goalgoaltest-compile/goal/goals/execution/executionsdependenciesdependencygroupIdorg.aspectj/groupIdartifactIdaspectjrt/artifactIdversion1.6.8/version/dependencydependencygroupIdorg.aspectj/groupIdartifactIdaspectjtools/artifactIdversion1.6.11/version/dependency/dependencies/plugin/plugins/build 如果使用IDE编译代码请不要忘记将其编译器更改为AspectJ。 您可以在AspectJrt目录中的本地Maven存储库中找到它。 假设有一个Product类我们想知道其创建日期以及销售日期。 Configurable(preConstruction true)public class Product {private final String name;private final String description;private final Date createDate;private Status status;private Date saleDate;Autowiredprivate Environment environment;public Product(String name, String description) {this.name name;this.description description;this.status Status.PENDING;this.createDate environment.getCurrentDate();}public void sell() {this.status Status.SALE;this.saleDate environment.getCurrentDate();}public Date getCreateDate() {return createDate;}public Date getSaleDate() {return saleDate;}public static enum Status {PENDING, SALE;}} 产品是一个非常简单的类我们使用preConstruction true是因为我们的产品构造需要使用环境。 环境及其实现也非常简单 public interface Environment {Date getCurrentDate();}public class DefaultEnvironment implements Environment {Overridepublic Date getCurrentDate() {return new Date();}}public class MockEnvironment implements Environment {private Date date;Overridepublic Date getCurrentDate() {return this.date;}public void setCurrentDate(Date date){this.date date;}} MockEnvironment是在测试包中创建的因为我们仅在测试中需要此类。 除了使用此类之外您还可以使用一些模拟库作为Mocktio及其扩展Springockito。 但是在此示例中我们的重点不在它们上。 我们的测试也非常简单 ContextConfiguration({classpath*:context.xml,classpath*:test-context.xml})public class ProductTest extends AbstractJUnit4SpringContextTests {final Date time Calendar.getInstance().getTime();AutowiredEnvironment environment;Beforepublic void before() {((MockEnvironment) this.environment).setCurrentDate(time);}Testpublic void created_product_should_have_current_environment_date() {final Product product new Product(, );Assert.assertEquals(time, product.getCreateDate());}Testpublic void sell_should_set_createDate_to_now(){final Product product new Product(, );product.sell();Assert.assertEquals(time, product.getSaleDate());}} 您可以从以下网址下载源代码 https : //github.com/psycho-ir/Spring-Configurable.git 参考 Just另一个Java博客博客中的JCG合作伙伴 Soroosh Sarabadani的Spring可配置魔术 。 翻译自: https://www.javacodegeeks.com/2013/09/spring-configurable-magic.html
http://www.zqtcl.cn/news/401697/

相关文章:

  • 临海城市建设网站石家庄做网站的公司有哪些
  • 东光网站建设淘宝店铺装修开个送快餐网站怎么做
  • 建设网站有哪些怎么自学室内设计与装修
  • 苏州建设工程协会网站汶上网站建设哪家便宜
  • 湖南手机版建站系统信息做360网站优化
  • 为什么学网站开发中国猎头公司排行榜
  • 怎么给网站做api做设计找参考的设计网站有那些
  • vultr服务器做网站广州做seo整站优化公司
  • 怎么做一个门户网站婚介网站怎么做
  • 惠州做网站电话柳市哪里有做网站推广
  • 成都公司的网站制作网站建设网店名字
  • 网站备案医疗保健审批号是什么基于asp.net网站开发
  • 生活做爰网站如何用织梦做网站
  • 网站拒绝被百度收录c#+开发网站开发
  • 营销网站竞品分析报告东莞网页制作网站
  • 东莞手机手机端网站建设云企网站
  • 网站中弹出广告怎么做网站建设实践报告
  • 站长工具seo综合查询隐私查询导航网站诚信备案
  • 亳州做网站哪家好网站开发的现实意义
  • 创意视觉网站济南网站建设招标
  • 厦门市建设局报表网站南通网站建设计划书
  • 深圳网站建设_模板网站seo
  • 云虚拟主机做网站简单的电商网站开发
  • 注销网站和取消接入深圳建设工程信息价
  • 上海专业网站建设公司站霸网络中国住房和城乡建设部
  • 邯郸做移动网站找谁广西茶叶学会 网站建设
  • 湛江建设网站美乐乐网站首页如何修改
  • 小刘网站建设网络推广和优化是什么意思
  • 特卖网站设计seo优化关键词挖掘
  • 绍兴市交通建设有限公司网站陕西建设分行网站