随笔分类 -  JAVA

Unit Testing of Spring MVC Controllers: Configuration
摘要:Original Link:http://www.petrikainulainen.net/programming/spring-framework/unit-testing-of-spring-mvc-controllers-configuration/Unit Testing of Spring MVC Controllers: ConfigurationbyPETRI KAINULAINENonJUNE 28, 2013Writing unit tests for Spring MVC controllers has traditionally been both simple and 阅读全文
posted @ 2013-10-13 00:47 ZimZz 阅读(3167) 评论(0) 推荐(0)
Chapter 7 -- Functional
摘要:Caveats说明As of Java 7, functional programming in Java can only be approximated through awkward and verbose use of anonymous classes. This is expected to change in Java 8, but Guava is currently aimed at users of Java 5 and above.在Java7中, 只能通过笨拙且啰嗦的使用匿名类来模拟函数式编程.在Java 8中这些亟待改变, 但Guava现在的目标是Java5及以上用户 阅读全文
posted @ 2013-10-12 16:22 ZimZz 阅读(1412) 评论(0) 推荐(0)
字符串文本替换程序
摘要:今天看到关于移到关于字符串查找和替换的题目, 如下:现有2个文件,地址在:http://***.com/sites/task3.propertieshttp://***.com/sites/task3.txt要求:根据properties中内容替换掉txt里$function(index)形式文字,将其还原成一本完整小说。其中function有4种函数,替换规则如下:1、natureOrder 自然排序,即文本中排列顺序2、indexOrder 索引排序,文本中每行第一个数字为索引3、charOrder 文本排序(Java默认的Unicode排序),java的字符排序4、charOrderDE 阅读全文
posted @ 2013-10-12 14:02 ZimZz 阅读(2438) 评论(0) 推荐(0)
Reloading Java Classes 301: Classloaders in Web Development — Tomcat, GlassFish, OSGi, Tapestry 5 and so on Translation
摘要:The Original link :http://zeroturnaround.com/rebellabs/rjc301/Copyright reserved by Rebel IncIn this article we’ll review how dynamic classloaders are used in real servers, containers and frameworks to reload Java classes and applications. We’ll also touch on how to get faster reloads and redeploys 阅读全文
posted @ 2013-10-11 15:32 ZimZz 阅读(847) 评论(0) 推荐(0)
Chapter 6 -- Caches
摘要:CachesExplainedExplanation for how to use Guava caches.explainedUpdatedJun 4, 2013bylowas...@google.comExampleLoadingCache graphs =CacheBuilder.newBuilder() .maximumSize(1000) .expireAfterWrite(10,TimeUnit.MINUTES) .removalListener(MY_LISTENER) .build( newCacheLoader(){ publicGraph ... 阅读全文
posted @ 2013-10-10 21:46 ZimZz 阅读(1605) 评论(0) 推荐(1)
SVN OPS发布总结
摘要:提示不需要手动将branch合并到trunk, 我们自己没有这个权限, 合并的操作是在beta版本发布完成以后, 使用这个btag来发布ops问题1. 由于trunk版本长时间没有发不过ops版本, 发布ops版本(基于prod4的branch版本)后造成svn认为trunk版本比branch版本更新, branch版本在发QA的时候bds提示需要将trunk合并到branch, QA发布失败2. 在将trunk合并到branch的过程中, 出现大量树冲突(原因不明: 个人认为既然是用prod4发的OPS, 那么bds就不应该认为trunk比prod4还新. 而且我对出现冲突的文件做过比较, 阅读全文
posted @ 2013-10-10 19:06 ZimZz 阅读(298) 评论(0) 推荐(0)
Chapter 5 -- ImmutableCollections
摘要:Examplepublicstatic final ImmutableSet COLOR_NAMES =ImmutableSet.of( "red", "orange", "yellow", "green", "blue", "purple");classFoo{ Set bars; Foo(Set bars){ this.bars =ImmutableSet.copyOf(bars);// defensive copy! }}Why?Immutable objects ha 阅读全文
posted @ 2013-10-08 11:40 ZimZz 阅读(741) 评论(0) 推荐(0)
Guava Enums
摘要:概述Enums提供了几个操作Enum的便利方法常用方法Field getField(Enum enumValue):返回变量名为enumValue变量值的Field> Function valueOfFunction(Class enumClass): 返回一个可以将enum名字字符串转换成指定类型的enum的,如果enum不存在时,Function将返回nullOptional getIfPresent(Class enumClass, String value):使用Enum.valueOf()来返回指定名称和class的Enum的Optional,如果不存在则返回Absent, 常 阅读全文
posted @ 2013-09-30 00:10 ZimZz 阅读(3039) 评论(0) 推荐(0)
Guava CharMatcher
摘要:概述CharMatcher提供了多种对字符串处理的方法, 它的主要意图有:1. 找到匹配的字符2. 处理匹配的字符CharMatcher内部主要实现包括两部分:1. 实现了大量公用内部类, 用来方便用户对字符串做匹配: 例如 JAVA_DIGIT 匹配数字, JAVA_LETTER 匹配字母等等.2. 实现了大量处理字符串的方法, 使用特定的CharMatcher可以对匹配到的字符串做出多种处理, 例如 remove(), replace(), trim(), retain()等等CharMatcher本身是一个抽象类, 其中一些操作方法是抽象方法, 他主要依靠内部继承CharMatcher的 阅读全文
posted @ 2013-09-29 00:54 ZimZz 阅读(5317) 评论(0) 推荐(0)
Guava CaseFormat
摘要:概述CaseFormat用来转换各种不同的编程语言间的变量名命名格式, 主要用到的方法只有一个 CaseFormat.to(CaseFormat from, String s) CaseFormat fromFormat = CaseFormat.LOWER_CAMEL; CaseFormat toFormat = CaseFormat.UPPER_CAMEL; String s = "lowerCamel"; System.out.println(fromFormat.to(toFormat, s));输出lowerCamelLower... 阅读全文
posted @ 2013-09-27 11:40 ZimZz 阅读(3351) 评论(0) 推荐(1)
HotSpot Generations
摘要:本文主要介绍HotSpot JVM的 Generations 机制,原文来自 Oracle 文档 Java SE 6 HotSpot[tm] Virtual Machine Garbage Collection Tuning 第三,四章 -- Generations & Performance Co... 阅读全文
posted @ 2013-09-27 01:03 ZimZz 阅读(413) 评论(0) 推荐(0)
Java Run-Time Data Areas
摘要:前言本文主要介绍JVM的运行时数据区来自Oracle文档Java Virtual Machine Specification--Chapter2.The Structure of the Java Virtual Machine 2.5Link :http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-2.html#jvms-2.5---------------------------------------------------------------------------------------------------------- 阅读全文
posted @ 2013-09-26 21:17 ZimZz 阅读(607) 评论(0) 推荐(0)
Reloading Java Classes 201: How do ClassLoader leaks happen? Translation
摘要:The original link :http://zeroturnaround.com/rebellabs/rjc201/From ClassLoaders to Classes从ClassLoader到ClassesIf you have programmed in Java for some time you know that memory leaks do happen. Usually it’s the case of a collection somewhere with references to objects (e.g. listeners) that should hav 阅读全文
posted @ 2013-09-26 10:44 ZimZz 阅读(595) 评论(0) 推荐(0)
Guava BiMap AbstractBiMap
摘要:BiMapBiMap是一个结构,他定义了一个Map结构,代表这个Map的key和value都具有唯一性, 并且可以生成相互联系的反向视图, 反向视图的数据会随着本体BiMap的变更而变更/* * Copyright (C) 2007 The Guava Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a c 阅读全文
posted @ 2013-09-25 19:36 ZimZz 阅读(1245) 评论(0) 推荐(0)
Reloading Java Classes 101: Objects, Classes and ClassLoaders Translation
摘要:The original link:http://zeroturnaround.com/rebellabs/reloading-objects-classes-classloaders/A Bird's Eye View鸟瞰The first thing to understand when talking about reloading Java code is the relation between classes and objects. All Java code is associated with methods contained in classes. Simplif 阅读全文
posted @ 2013-09-25 01:07 ZimZz 阅读(464) 评论(0) 推荐(0)
Guava CompoundOrdering
摘要:概述CompoundOrdering是Ordering的子类,它用来存储比较器链, Ordering的compound()内部实现就是使用CompoundOrdering(Comparator primary, Comparator secondary)方法来实现的代码/** An ordering that tries several comparators in order. */@GwtCompatible(serializable = true)final class CompoundOrdering extends Ordering imple... 阅读全文
posted @ 2013-09-24 20:54 ZimZz 阅读(786) 评论(0) 推荐(0)
Chapter 4 -- Throwables
摘要:TODO: rewrite with more examplesGuava'sThrowablesutility can frequently simplify dealing with exceptions.Propagation 传播Sometimes, when you catch an exception, you want to throw it back up to the next try/catch block. This is frequently the case forRuntimeExceptionorErrorinstances, which do not r 阅读全文
posted @ 2013-09-24 18:13 ZimZz 阅读(930) 评论(0) 推荐(0)
Guava ClassToInstanceMap
摘要:概述ClassToInstanceMap提供了一种是用Class作为Key, 对应实例作为Value的途径.他定义了T getInstance(Class)和T putInstance(Class T)两个方法, 这两个方法消除了元素类型转换的过程并保证了元素在Map中是类型安全的.ClassToInstanceMap有一个独立的类型参数, 一般命名为B. 它对应着Map的元素的类型的最大上界.例如ClassToInstanceMap numberDefaults = MutableClassToInstanceMap.create();numberDefaults.putInstance(I 阅读全文
posted @ 2013-09-24 00:49 ZimZz 阅读(3153) 评论(0) 推荐(0)
Chapter 3 -- Ordering
摘要:Guava's fluent comparator class, Ordering, explained.explainedUpdatedJun 27, 2013bycpov...@google.comExample 例子assertTrue(byLengthOrdering.reverse().isOrdered(list));Overview 总览Orderingis Guava's "fluent"Comparatorclass, which can be used to build complex comparators and apply them 阅读全文
posted @ 2013-09-23 16:27 ZimZz 阅读(451) 评论(0) 推荐(1)
Chapter 2 -- Preconditions
摘要:Using Guava's precondition checking utilities, explained.explainedUpdatedApr 23, 2012bywasserman.louisPreconditionsGuava provides a number of precondition checking utilities. We strongly recommend importing these statically. (How to do this easily in Eclipse.)Guava提供了一系列precondition检查工具. 我们强烈推荐你 阅读全文
posted @ 2013-09-23 15:07 ZimZz 阅读(517) 评论(0) 推荐(1)