??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲一区二区免费视频,亚洲国产婷婷综合在线精品,亚洲?v无码国产在丝袜线观看http://www.tkk7.com/usherlight/category/8573.html天^׃白云泉,云自无心水自闌Ӏ何必奔冲山下去Q更LL向人间Q?/description>zh-cnThu, 08 Sep 2016 09:04:14 GMTThu, 08 Sep 2016 09:04:14 GMT60Selenium 下蝲文ghttp://www.tkk7.com/usherlight/archive/2016/01/28/429241.html云自无心水自?/dc:creator>云自无心水自?/author>Thu, 28 Jan 2016 10:06:00 GMThttp://www.tkk7.com/usherlight/archive/2016/01/28/429241.htmlhttp://www.tkk7.com/usherlight/comments/429241.htmlhttp://www.tkk7.com/usherlight/archive/2016/01/28/429241.html#Feedback0http://www.tkk7.com/usherlight/comments/commentRss/429241.htmlhttp://www.tkk7.com/usherlight/services/trackbacks/429241.html
我在|上搜烦了一下如何用Selenium下蝲文gQ其中确实有几篇文g介绍了实现的Ҏ(gu)?br />但是其主要思想都是使用httpClient或者URL获得InputStream, 然后保存到文件中?br />但是Q其中的问题是用L录的Session不能l持?br />
我发C一个简单的Ҏ(gu)?br />直接使用WebDriver.get, CZ如下Q?br />
webDriver.get("https://website.com/login");
WebElement element = driver.findElement( By.id( "userID" ) );
element.sendKeys( "user01" );

element = driver.findElement( By.id( "passwd" ) );
element.sendKeys( "password" );

element = driver.findElement( By.name( "Login" ) );
element.submit();

webDriver.get("https://website.cm/download.do?start=xx&end=yy");
String source = webDriver.getPageSource();

q个source是我们想保存的要下载的内容?br />只要把这个String写到一个文件中Q就实现了文件下载的目的

]]>
openpgp 验证{֐http://www.tkk7.com/usherlight/archive/2015/12/11/428624.html云自无心水自?/dc:creator>云自无心水自?/author>Fri, 11 Dec 2015 13:40:00 GMThttp://www.tkk7.com/usherlight/archive/2015/12/11/428624.htmlhttp://www.tkk7.com/usherlight/comments/428624.htmlhttp://www.tkk7.com/usherlight/archive/2015/12/11/428624.html#Feedback0http://www.tkk7.com/usherlight/comments/commentRss/428624.htmlhttp://www.tkk7.com/usherlight/services/trackbacks/428624.html加密解密的基本操作流E是Q用户用公钥对明文q行加密Q解密方使用U钥对密文进行解密?

在实际应用中Q除了加密保证文本内容不泄露外,同时q要考虑能够验证密文发送方的n份,比较普遍使用的方法就是签名?
本文主要对具体的Ҏ(gu)q行介绍q上源代码?nbsp; 阅读全文

]]>
单介l如何用PowerMock和Mockito来mock 1. 构造函?2. 静态函?3. 枚D实现的单?4. 选择参数值做为函数的q回?/title><link>http://www.tkk7.com/usherlight/archive/2015/06/16/425740.html</link><dc:creator>云自无心水自?/dc:creator><author>云自无心水自?/author><pubDate>Tue, 16 Jun 2015 13:27:00 GMT</pubDate><guid>http://www.tkk7.com/usherlight/archive/2015/06/16/425740.html</guid><wfw:comment>http://www.tkk7.com/usherlight/comments/425740.html</wfw:comment><comments>http://www.tkk7.com/usherlight/archive/2015/06/16/425740.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/usherlight/comments/commentRss/425740.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/usherlight/services/trackbacks/425740.html</trackback:ping><description><![CDATA[本文简单介l如何用PowerMock和Mockito来mock<br /> 1. 构造函?br /> 2. 静态函?br /> 3. 枚D实现的单?br /> 4. 选择参数值做为函数的q回?br /> 5. 在调用mock出来的方法中,改变Ҏ(gu)参数的?br /> <br /> 一点简要说明:Mockito其实已经可以满大部分的需求,但是它的实现机制是用cglib来动态创建接口的cȝ实例。但是这U实现方式不能用于构造函数和静态函敎ͼ因ؓ那需要用类的字节码Q比如用javassist). 所以我们才需要结合用PowerMock.<br /> <br /> 1. mock构造函? 如果有代码没有用DI注入依赖实例Q在单元试中可以用PowerMock来模拟创建对象?br /> 注意的开始两行的2个注?@RunWith ?@PrepareForTest<br /> @RunWith比较单,后面始终是PowerMockRunner.class<br /> @PrepareForText后面需要加的是调用构造函数的cdQ而不是有构造函数的cLw?br /> 在下面的例子中,我们要测试的cLQHelper, 在HelpercM调用了Somthingcȝ构造函数来创徏实例?br /> <div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #000000; ">@RunWith(PowerMockRunner.</span><span style="color: #0000FF; ">class</span><span style="color: #000000; ">)<br /> @PrepareForTest(Helper.</span><span style="color: #0000FF; ">class</span><span style="color: #000000; ">)<br /> </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">class</span><span style="color: #000000; "> HelperTest {<br />   @Mock<br />   </span><span style="color: #0000FF; ">private</span><span style="color: #000000; "> Something mockSomething;<br />       <br />   @InjectMocks<br />   </span><span style="color: #0000FF; ">private</span><span style="color: #000000; "> Helper helper;<br />       <br />   @Test<br />   </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">void</span><span style="color: #000000; "> doSomething() </span><span style="color: #0000FF; ">throws</span><span style="color: #000000; "> Exception {<br />       String argument </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #000000; ">"</span><span style="color: #000000; ">arg</span><span style="color: #000000; ">"</span><span style="color: #000000; ">;<br />           <br />       PowerMockito.whenNew(Something.</span><span style="color: #0000FF; ">class</span><span style="color: #000000; ">).withArguments(argument).thenReturn(mockSomething);<br />           <br />       // 调用需要测试方?br />       helper.doSomething(argument);<br />           <br />       // q行验证<br />       verify(mockSomething).doIt();<br />   }<br /> }<br /> <br /> <br /> <div>public class Helper ?br />   public void doSomething(String arg) {<br />       Something something = new Something(arg);<br />       something.doit();<br />   }<br /> }</div> <br /> </span></div> <br /> 2Qmock 静态函敎ͼ 单例模式是一个典型的会调用静态函数的例子?注意要点与mock构造函数相同?br /> <div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%; word-break: break-all;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #0000FF; ">class</span><span style="color: #000000; "> ClassWithStatics {<br />   </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">static</span><span style="color: #000000; "> String getString() {<br />     </span><span style="color: #0000FF; ">return</span><span style="color: #000000; "> </span><span style="color: #000000; ">"</span><span style="color: #000000; ">String</span><span style="color: #000000; ">"</span><span style="color: #000000; ">;<br />   }<br /> <br />   </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">static</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">int</span><span style="color: #000000; "> getInt() {<br />     </span><span style="color: #0000FF; ">return</span><span style="color: #000000; "> </span><span style="color: #000000; ">1</span><span style="color: #000000; ">;<br />   }<br /> }<br /> <br /> @RunWith(PowerMockRunner.</span><span style="color: #0000FF; ">class</span><span style="color: #000000; ">)<br /> @PrepareForTest(ClassWithStatics.</span><span style="color: #0000FF; ">class</span><span style="color: #000000; ">)<br /> </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">class</span><span style="color: #000000; "> StubJustOneStatic {<br />   @Test<br />   </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">void</span><span style="color: #000000; "> test() {<br />     PowerMockito.mockStatic(ClassWithStatics.</span><span style="color: #0000FF; ">class</span><span style="color: #000000; ">);<br /> <br />     when(ClassWithStatics.getString()).thenReturn(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">Hello!</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);<br /> <br />     System.out.println(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">String: </span><span style="color: #000000; ">"</span><span style="color: #000000; "> </span><span style="color: #000000; ">+</span><span style="color: #000000; "> ClassWithStatics.getString());<br />     System.out.println(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">Int: </span><span style="color: #000000; ">"</span><span style="color: #000000; "> </span><span style="color: #000000; ">+</span><span style="color: #000000; "> ClassWithStatics.getInt());<br />   }<br /> }</span></div> <br /> 3。mock枚D实现的单?br /> <div> SingletonObject.java <br /> <pre prettyprint="" prettyprinted"="" style="margin: 0px 0px 1em; padding: 5px; border: 0px; font-size: 13px; overflow: auto; width: auto; max-height: 600px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; display: block; color: #393318; word-wrap: normal; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #eeeeee;"><code style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit; background-color: #eeeeee;"><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #00008b;">public</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #00008b;">enum</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #2b91af;">SingletonObject</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">{</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;"> <br />    INSTANCE</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">;</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #00008b;"><br />    private</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #00008b;">int</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;"> num</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">;</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #00008b;"><br />    protected</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #00008b;">void</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;"> setNum</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">(</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #00008b;">int</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;"> num</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">)</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">{</span> <br />        <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #00008b;">this</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">.</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">num </span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">=</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;"> num</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">;</span> <br />    <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">}</span> <br />    <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #00008b;">public</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #00008b;">int</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;"> getNum</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">()</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">{</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #00008b;"><br />        return</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;"> num</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">;</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;"><br />    }</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;"> <br /></span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">}<br /> <span style="font-family: verdana, 'courier new'; font-size: 14px;">SingletonConsumer.java</span> </span></code></pre> <br /> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #00008b;">public</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #00008b;">class</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #2b91af;">SingletonConsumer</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">{</span> <br /> <pre prettyprint="" prettyprinted"="" style="margin: 0px 0px 1em; padding: 5px; border: 0px; font-size: 13px; overflow: auto; width: auto; max-height: 600px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; display: block; color: #393318; word-wrap: normal; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #eeeeee;"><code style="margin: 0px; padding: 0px; border: 0px none; font-size: 13px; font-family: Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif; white-space: inherit; background-color: #eeeeee;">    <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #00008b;">public</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #2b91af;">String</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;"> consumeSingletonObject</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">()</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">{</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #00008b;"><br />         return</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #2b91af;">String</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">.</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">valueOf</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">(</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #2b91af;">SingletonObject</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">.</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">INSTANCE</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">.</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">getNum</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">());</span> <br />     <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">}</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;"> <br /></span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">}<br /> <div>SingletonConsumerTest.java</div></span></code></pre><pre prettyprint="" prettyprinted"="" style="margin: 0px 0px 1em; padding: 5px; border: 0px none; font-size: 13px; overflow: auto; width: auto; max-height: 600px; font-family: Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif; display: block; color: #393318; word-wrap: normal; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: left; text-indent: 0px; text-transform: none; widows: 1; word-spacing: 0px; background-color: #eeeeee;"><code style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit; background-color: #eeeeee;"><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #800000;">@RunWith</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">(</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #2b91af;">PowerMockRunner</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">.</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #00008b;">class</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">)</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;"> <br /></span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #800000;">@PrepareForTest</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">({</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #2b91af;">SingletonObject</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">.</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #00008b;">class</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">})</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;"> <br /></span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #00008b;">public</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #00008b;">class</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #2b91af;">SingletonConsumerTest</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">{</span> <br />    <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #800000;">@Test</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #00008b;">public</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #00008b;">void</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;"> testConsumeSingletonObject</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">()</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #00008b;">throws</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #2b91af;">Exception</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">{</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #2b91af;"><br />        SingletonObject</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;"> mockInstance </span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">=</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;"> mock</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">(</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #2b91af;">SingletonObject</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">.</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #00008b;">class</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">);</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #2b91af;"><br />        Whitebox</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">.</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">setInternalState</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">(</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #2b91af;">SingletonObject</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">.</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #00008b;">class</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">,</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #800000;">"INSTANCE"</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">,</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;"> mockInstance</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">);</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;"> <br />        when</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">(</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">mockInstance</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">.</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">getNum</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">()).</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">thenReturn</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">(</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #800000;">42</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">);</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;"> <br />        assertEquals</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">(</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #800000;">"42"</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">,</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #00008b;">new</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #2b91af;">SingletonConsumer</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">().</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">consumeSingletonObject</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">());</span> <br />    <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">}</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;"> <br /></span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">}</span></code></pre> </div> 4。返回参数值做为函数返回倹{?br /> mockito 1.9.5之后Q提供一个方便的Ҏ(gu)来实现这个需要,在这之前可以使用一个匿名函数来q回一个answer来实现?br /> <div> <pre prettyprint="" prettyprinted"="" style="margin: 0px 0px 1em; padding: 5px; border: 0px; font-size: 13px; overflow: auto; width: auto; max-height: 600px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; display: block; color: #393318; word-wrap: normal; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #eeeeee;"><code style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit; background-color: #eeeeee;"><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">when</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">(</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">myMock</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">.</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">myFunction</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">(</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">anyString</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">())).</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">then</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">(</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">returnsFirstArg</span><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; color: #000000;">());</span></code></pre> </div> 其中returnsFirstArg()是org.mockito.AdditionalAnswers中的一个静态方法?br /> 在这个类中还有其他的一些类似方?br /> returnsSecondArg()<br /> <div>returnsLastArg()</div> <div>ReturnsArgumentAt(int position)</div> <br /> <div>5. 在调用mock出来的方法中,改变Ҏ(gu)参数的?br /> <div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%; word-break: break-all;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #000000; ">when( myMock.someMethod( any( List.</span><span style="color: #0000FF; ">class</span><span style="color: #000000; "> ) ) ).thenAnswer( ( </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> Answer</span><span style="color: #000000; "><</span><span style="color: #000000; ">Void</span><span style="color: #000000; ">></span><span style="color: #000000; ">() {<br />     @Override<br />     </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> Void answer( InvocationOnMock invocation )<br />             </span><span style="color: #0000FF; ">throws</span><span style="color: #000000; "> Throwable {<br />         Object[] args </span><span style="color: #000000; ">=</span><span style="color: #000000; "> invocation.getArguments();<br />         List arg1 </span><span style="color: #000000; ">=</span><span style="color: #000000; "> (List)args[</span><span style="color: #000000; ">0</span><span style="color: #000000; ">];<br />         arg1.add(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">12345</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);<br />         </span><span style="color: #0000FF; ">return</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">null</span><span style="color: #000000; ">;<br />     }<br /> } ) );<br /> <br /> </span></div> </div> <br /> <br /> <div>Verifying with generic parameters<br /> <span style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit; font-size: 13px; margin: 0px; padding: 0px; border: 0px; background-color: #eeeeee;">verify</span><span style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit; font-size: 13px; margin: 0px; padding: 0px; border: 0px; background-color: #eeeeee;">(</span><span style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit; font-size: 13px; margin: 0px; padding: 0px; border: 0px; background-color: #eeeeee;">someService</span><span style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit; font-size: 13px; margin: 0px; padding: 0px; border: 0px; background-color: #eeeeee;">).</span><span style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit; font-size: 13px; margin: 0px; padding: 0px; border: 0px; background-color: #eeeeee;">process</span><span style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit; font-size: 13px; margin: 0px; padding: 0px; border: 0px; background-color: #eeeeee;">(</span><span style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit; font-size: 13px; margin: 0px; padding: 0px; border: 0px; color: #2b91af; background-color: #eeeeee;">Matchers</span><span style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit; font-size: 13px; margin: 0px; padding: 0px; border: 0px; background-color: #eeeeee;">.<</span><span style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit; font-size: 13px; margin: 0px; padding: 0px; border: 0px; color: #2b91af; background-color: #eeeeee;">Collection</span><span style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit; font-size: 13px; margin: 0px; padding: 0px; border: 0px; background-color: #eeeeee;"><</span><span style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit; font-size: 13px; margin: 0px; padding: 0px; border: 0px; color: #2b91af; background-color: #eeeeee;">Person</span><span style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit; font-size: 13px; margin: 0px; padding: 0px; border: 0px; background-color: #eeeeee;">>></span><span style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit; font-size: 13px; margin: 0px; padding: 0px; border: 0px; background-color: #eeeeee;">any</span><span style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit; font-size: 13px; margin: 0px; padding: 0px; border: 0px; background-color: #eeeeee;">());<br /><div>verify(adunoMasterBaseProcessor).processBinFiles( anyListOf(File.class) );</div></span></div><img src ="http://www.tkk7.com/usherlight/aggbug/425740.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/usherlight/" target="_blank">云自无心水自?/a> 2015-06-16 21:27 <a href="http://www.tkk7.com/usherlight/archive/2015/06/16/425740.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>要说明如何在eclipse中的tomcat中进行配|用springloaded在热加蝲更改的类http://www.tkk7.com/usherlight/archive/2015/06/11/425640.html云自无心水自?/dc:creator>云自无心水自?/author>Thu, 11 Jun 2015 13:59:00 GMThttp://www.tkk7.com/usherlight/archive/2015/06/11/425640.htmlhttp://www.tkk7.com/usherlight/comments/425640.htmlhttp://www.tkk7.com/usherlight/archive/2015/06/11/425640.html#Feedback0http://www.tkk7.com/usherlight/comments/commentRss/425640.htmlhttp://www.tkk7.com/usherlight/services/trackbacks/425640.htmlTomcat都需要重新启动来使得刚才的更改生效?br />而JRebel和springloaded都能有效地解册个问题。其中springloaded是开源YӞ可以免费使用Q尤光得?br />其主:https://github.com/spring-projects/spring-loaded
在官斚w面的单介l中Q作者只讲述了如何在javaE序中应用springloadedQ而没有说明如何在tomcat中进行配|?br />本文简要进行介l?br />
1Q下载springloaded到本地目录,比如Qc:\temp\springloaded-1.2.3.RELEASE.jar

2. 修改tomcat的应用,止tomcat自己的热加蝲Q方法是在META-INF目录下创建context.xml文gQ里面包含如下语句,关键便是其中讄reloadable为false
<?xml version="1.0" encoding="UTF-8"?>
<Context antiResourceLocking="false" privileged="true" useHttpOnly="true" reloadable="false" />

3.在运行环境中dspringloaded的jar文gQ在eclipse中右键点击项目,run as->run configuration
在弹出的H口中,选择Arguments标签Q在vm arguments的末添加:
-javaagent:C:\temp\springloaded-1.2.3.RELEASE.jar -noverify
点击应用按钮?br />
以上便完成了所有的配置Q步骤ƈ不复杂?br />

]]>
使用VisualVM来监控包装ؓwindows服务的javaE序http://www.tkk7.com/usherlight/archive/2015/06/11/425624.html云自无心水自?/dc:creator>云自无心水自?/author>Thu, 11 Jun 2015 06:09:00 GMThttp://www.tkk7.com/usherlight/archive/2015/06/11/425624.htmlhttp://www.tkk7.com/usherlight/comments/425624.htmlhttp://www.tkk7.com/usherlight/archive/2015/06/11/425624.html#Feedback0http://www.tkk7.com/usherlight/comments/commentRss/425624.htmlhttp://www.tkk7.com/usherlight/services/trackbacks/425624.htmlq且可以通过单的配置来允怋用visualVMq行监控?br />
配置Ҏ(gu)Q?br />在wrapper.conf中添加如??br />
wrapper.java.additional.1=-Dcom.sun.management.jmxremote.port=9898 Q这里的端口号可以自行选择?br />wrapper.java.additional.2=-Dcom.sun.management.jmxremote.ssl=false
wrapper.java.additional.3=-Dcom.sun.management.jmxremote.authenticate=false

修改完毕保存后重新启动服务?br />
打开visualVM, 在菜单中选择 file->Add JMX Connection?br />在弹出窗口中Qconnection一中输入Q?localhost:9898 卛_?br />
此配|对于jconsole也同h效?img src ="http://www.tkk7.com/usherlight/aggbug/425624.html" width = "1" height = "1" />

]]>
java.util.logging的日志统一输出到slf4j的框架中http://www.tkk7.com/usherlight/archive/2015/04/27/424701.html云自无心水自?/dc:creator>云自无心水自?/author>Mon, 27 Apr 2015 07:31:00 GMThttp://www.tkk7.com/usherlight/archive/2015/04/27/424701.htmlhttp://www.tkk7.com/usherlight/comments/424701.htmlhttp://www.tkk7.com/usherlight/archive/2015/04/27/424701.html#Feedback0http://www.tkk7.com/usherlight/comments/commentRss/424701.htmlhttp://www.tkk7.com/usherlight/services/trackbacks/424701.html可以使用slf4j提供的类来{接这部分的日志输出?br />
Ҏ(gu)Q?br />1、类路径中添?br />    slf4j-api-1.7.10.jar
    jul-to-slf4j.1.7.10.jar ( 用于java.util.logging的日志桥接到slf4j中)
    logback-core.1.1.2.jar
    logback-classic-1.1.2.jar

2、在代码中添加:
         // Optionally remove existing handlers attached to j.u.l root logger
         SLF4JBridgeHandler.removeHandlersForRootLogger();  // (since SLF4J 1.6.5)

         // add SLF4JBridgeHandler to j.u.l's root logger, should be done once during
         // the initialization phase of your application
         SLF4JBridgeHandler.install();

注意事项Q?br />1、这个桥接可以会造成性能问题?br />和其他的桥接实现Q比如:log4j, commons logging)不同Q这个模块ƈ不真正的完全替代java.util.loggingc,因ؓq个java.util.logging是java自带的?br />所以只是把原来的日志对象进行了转换Q简单的_q个转换q程是有开销的?br />关键在于Q不日志语句有没有Ҏ(gu)日志U别被关闭,q个转换无法避免?br />
2、不能在c\径中攑օ
slf4j-jkd14.jar
jul-toslf4j.jar


]]>
AngularJS中的依赖注入和服?service)http://www.tkk7.com/usherlight/archive/2015/02/09/422835.html云自无心水自?/dc:creator>云自无心水自?/author>Mon, 09 Feb 2015 11:28:00 GMThttp://www.tkk7.com/usherlight/archive/2015/02/09/422835.htmlhttp://www.tkk7.com/usherlight/comments/422835.htmlhttp://www.tkk7.com/usherlight/archive/2015/02/09/422835.html#Feedback0http://www.tkk7.com/usherlight/comments/commentRss/422835.htmlhttp://www.tkk7.com/usherlight/services/trackbacks/422835.html
在前文(http://www.tkk7.com/usherlight/archive/2015/02/01/422633.htmlQ中我们曄介绍q,定义controllerӞ需?个参敎ͼW一个参数是controller的名UͼW二个参数是一个数l,数组的最后一个元素将是controller的函敎ͼ前面的参数是controller的依赖项。我们现在就来仔l分析一下其中的具体q程?br />
先给一个例子:
angular. module('notesApp' , [])
 . controller('MainCtrl' , ['$log' , function($log) {
 var self = this;
 self. logStuff = function() {
 $log. log('The button was pressed' );
 };
 }])

在这个例子中可以看到Q我们在W一个参C用字W串Q服务名Uͼd了一个依赖项。当我们通过字符串声明了q一个服务之后,我们可以把它当作一个变量注入到函数中。AngularJS会自动查扑֭W串名称对应的服务名Q按照顺序将其注入到函数中?br />
myModule.controller("MainCtrl",  ["$log", "$window", function($l, $w) {}]);
在这个例子中Q?log, $windows是AngularJS自带的两个服务,在数l中通过名称声明后,会被注入到函数的两个参数中?br />比较常用的AngularJS自带的服务有Q?window, $location, $http{?br />
从上面的例子中可以看出,AngularJS的设计思想是不要在函C自己d例化或者通过其它途径来获取服务的实例Q而是声明需要的对象Q由AngularJS来注入具体的实例?br />
创徏自己的服?br />什么时候应该创建服务,而不是controller呢?
1?需要重用的时?br />2。需要保留应用的状态。这是非帔R要的一点,controller是会不断地被创徏和销毁的Q如果需要保存应用的状态,需要用service
3。和面昄无关
4。需要和W三Ҏ(gu)务整?br />5。缓?br />
服务是会被gq加载的Q也是说只有在W一ơ被引用的时候,才会被创建?br />服务会被定义一ơ,也只会被实例化一ơ?br />


]]>
AngularJS的一些用方法和技巧(2Q?/title><link>http://www.tkk7.com/usherlight/archive/2015/02/03/422713.html</link><dc:creator>云自无心水自?/dc:creator><author>云自无心水自?/author><pubDate>Tue, 03 Feb 2015 11:36:00 GMT</pubDate><guid>http://www.tkk7.com/usherlight/archive/2015/02/03/422713.html</guid><wfw:comment>http://www.tkk7.com/usherlight/comments/422713.html</wfw:comment><comments>http://www.tkk7.com/usherlight/archive/2015/02/03/422713.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.tkk7.com/usherlight/comments/commentRss/422713.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/usherlight/services/trackbacks/422713.html</trackback:ping><description><![CDATA[<div>07. ng-repeart</div><div><span style="white-space:pre"> </span>a. 在@环map的时候,会自动根据键D行排序?/div><div><span style="white-space:pre"> </span>b. 一些自带的变量Q?first(是否是第一?, $last(是否是最后一?, $middle(是否是中间的), $index(下标Q根据键值排序后的下?, $even, $odd</div><div>08. 自己定义新变量时不要使用$$开头?/div><div>09. 可以使用track-by表达式来优化对DOM的操作,对DOM对象使用从数据库取得的ID来进行标讎ͼq样的话Q当我们重复多次从数据库中取出相同的数据的时候,DOM对象p够被重用?/div><div>10. 数据双向l定的好?/div><div><span style="white-space:pre"> </span>a. 如果我们x变页面Form中的数|我们不需要在Javascript中,Ҏ(gu)ID或者名U来查找相应的Form控gQ只需要改变Controller变量的|不需要JQuery的Selector,也不需要findElementByID</div><div><span style="white-space:pre"> </span>b. 如果我们惛_javascript中获取Form控g的|在控件的变量中就能直接获得?/div><div>11. 使用ng-submit比在button上用ng-click要好一些。HTML的表单的提交有多U方式,比如在输入域中按回R键就会触发ng-submitQ而不会触发button的ng-click事g?/div><div>12. 在ng-model中,可以直接引用一个对?比如Q?lt;input type="text" ng-model="ctrl.user.name">Q而不需要事先在model中以self.user={}定义。在AngularJS中,使用了ng-model的话QAngularJS在初始化数据l定的时候,自动创徏其中的对象和键倹{在刚才的例子中Q一旦用户开始在输入域中键入W一个字母,用户user׃被自动创建?/div><div>13. 推荐使用相x据集中到一个对象的方式来进行数据绑定,比如Q用户名和密码,推荐使用Q?/div><div><span style="white-space:pre"> </span><input type="text" ng-model="ctrl.user.name"></div><div><span style="white-space:pre"> </span><input type="text" ng-model="ctrl.user.password"></div><div>而不是:</div><div><span style="white-space:pre"> </span><input type="text" ng-model="ctrl.name"></div><div><span style="white-space:pre"> </span><input type="text" ng-model="ctrl.password"></div><div></div><img src ="http://www.tkk7.com/usherlight/aggbug/422713.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/usherlight/" target="_blank">云自无心水自?/a> 2015-02-03 19:36 <a href="http://www.tkk7.com/usherlight/archive/2015/02/03/422713.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>AngularJS的一些用方法和技巧(1Q?/title><link>http://www.tkk7.com/usherlight/archive/2015/02/01/422633.html</link><dc:creator>云自无心水自?/dc:creator><author>云自无心水自?/author><pubDate>Sun, 01 Feb 2015 11:19:00 GMT</pubDate><guid>http://www.tkk7.com/usherlight/archive/2015/02/01/422633.html</guid><wfw:comment>http://www.tkk7.com/usherlight/comments/422633.html</wfw:comment><comments>http://www.tkk7.com/usherlight/archive/2015/02/01/422633.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.tkk7.com/usherlight/comments/commentRss/422633.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/usherlight/services/trackbacks/422633.html</trackback:ping><description><![CDATA[<div>1. AngularJS的module函数有两U用法,</div> <div><span style="white-space:pre"> </span>a. 定义一个module, 需要传?个参敎ͼmodule('moduleName', []), W一个参数是新的module名称Q第二个参数是新module所依赖的module数组?/div> <div><span style="white-space:pre"> </span>b. 载入一个module, 只需?个参敎ͼmodule('moduleName'), 唯一的一个参数指定要载入的module名称?/div> <div>2. 使用controller函数来定义一个控制器(controller), 用ng-controller控制器l定到具体的HTMLlg上。定义控制器的controller函数也需?个参敎ͼW一个是控制器名UͼW二个参数同样也是一个数l,数组的最后一个元素就是controller本n的函敎ͼ前面的元素用字符串的形式指定光要的依赖V如果没有依赖项Q那只需要定义函数。比如:</div> <div><span style="white-space:pre"> </span>angular.module('app1', [])</div> <div><span style="white-space:pre"> </span>.controller('mainControl', [function() {</div> <div><span style="white-space:pre"> </span>console.log('controller created.');</div> <div><span style="white-space:pre"> </span>}]);</div> <div>3. 在controller函数中用var定义的局部变量,在HTML中是不可见的?/div> <div>4. 推荐在controller函数中尽量避免直接引用this, 比较好的做法是用代理。原因是一个函C的this关键词在被外部调用的时候,是会被覆盖掉的。这L话,在函数内部和外部的this会是完全不同两个对象?/div> <div>代理用法CZQ?/div> <div><span style="white-space:pre"> </span>angular.module('app1', [])</div> <div><span style="white-space:pre"> </span>.controller('mainControl', [function() {</div> <div><span style="white-space:pre"> </span>var self = this;</div> <div><span style="white-space:pre"> </span>self.message = 'Hello world';</div> <div><span style="white-space:pre"> </span>self.changeMessage = function() {</div> <div><span style="white-space:pre"> </span>self.message = 'Goodbye.';</div> <div><span style="white-space:pre"> </span>};</div> <div><span style="white-space:pre"> </span>}]);</div> <div>5. ng-bind与双大括L区别, ng-bind和{{}}可以说基本上是可以互相替换的Q但是也有区别。区别在于:AngularJS在启动的时候就会执行ng-bind, 而{{}}的替换时间会E晚一些。有可能发现面在加载的时候,双括可一闪而过地替换掉Q只在页面初ơ加载的时候发生)。但是ng-bind没有这个问题?br /> 6. ng-cloak可以用于解决双括号闪现的问题?/div><img src ="http://www.tkk7.com/usherlight/aggbug/422633.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/usherlight/" target="_blank">云自无心水自?/a> 2015-02-01 19:19 <a href="http://www.tkk7.com/usherlight/archive/2015/02/01/422633.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>OpenPGP加密解密文g http://www.tkk7.com/usherlight/archive/2014/12/10/421238.html云自无心水自?/dc:creator>云自无心水自?/author>Tue, 09 Dec 2014 22:50:00 GMThttp://www.tkk7.com/usherlight/archive/2014/12/10/421238.htmlhttp://www.tkk7.com/usherlight/comments/421238.htmlhttp://www.tkk7.com/usherlight/archive/2014/12/10/421238.html#Feedback5http://www.tkk7.com/usherlight/comments/commentRss/421238.htmlhttp://www.tkk7.com/usherlight/services/trackbacks/421238.htmlOpenPGP L是世界上使用最q泛的邮件加密标?  OpenPGP is the most widely used email encryption standard in the world. ( http://www.openpgp.org/ )
q篇例子介绍如何使用q个标准q行文g的加密解?(https://www.bouncycastle.org/latest_releases.html, 需要下? bcprov-jdk15on-151.jar, bcpg-jdk15on-151.jar).

主要是用bouncycastle提供的OpenPGP的库来完成这个功能,参照了其提供的示例程序,q行了部分改?( Bouncy Castle 是一U用?Java q_的开放源码的轻量U密码术包。它支持大量的密码术法Qƈ提供 JCE 1.2.1 的实现。因?Bouncy Castle 被设计成轻量U的Q所以从 J2SE 1.4 ?J2MEQ包?MIDPQ^収ͼ它都可以q行。它是在 MIDP 上运行的唯一完整的密码术包?
1. d循环遍历来查扄一个可用的message
2. 需要注意的是在main函数中的Q?span>如果不添加这一句的?Security.addProvider(new BouncyCastleProvider()); E序q行中会报错QNo such Provider "BC"
3. 错误Exception in thread "main" java.security.InvalidKeyException: Illegal key size or default parameters , q是因ؓjava~省的库支持的key长度比较短,需要到oracle的网站上M载一个支持更长key的库覆盖原有的库文g
<JAVA_HOME>/lib/securty/ 目录下的两个jar文g
local_policy.jar and US_export_policy.jar
搜烦q个文g: Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files
下蝲面(以JDK6Z)Q?a >http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html

package org.bouncycastle.openpgp.examples;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.NoSuchProviderException;
import java.security.SecureRandom;
import java.security.Security;
import java.util.Iterator;

import org.bouncycastle.bcpg.ArmoredOutputStream;
import org.bouncycastle.bcpg.CompressionAlgorithmTags;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.openpgp.PGPCompressedData;
import org.bouncycastle.openpgp.PGPEncryptedData;
import org.bouncycastle.openpgp.PGPEncryptedDataGenerator;
import org.bouncycastle.openpgp.PGPEncryptedDataList;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPLiteralData;
import org.bouncycastle.openpgp.PGPOnePassSignatureList;
import org.bouncycastle.openpgp.PGPPrivateKey;
import org.bouncycastle.openpgp.PGPPublicKey;
import org.bouncycastle.openpgp.PGPPublicKeyEncryptedData;
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
import org.bouncycastle.openpgp.PGPSignatureList;
import org.bouncycastle.openpgp.PGPUtil;
import org.bouncycastle.openpgp.jcajce.JcaPGPObjectFactory;
import org.bouncycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator;
import org.bouncycastle.openpgp.operator.jcajce.JcePGPDataEncryptorBuilder;
import org.bouncycastle.openpgp.operator.jcajce.JcePublicKeyDataDecryptorFactoryBuilder;
import org.bouncycastle.openpgp.operator.jcajce.JcePublicKeyKeyEncryptionMethodGenerator;
import org.bouncycastle.util.io.Streams;

/**
 * A simple utility class that encrypts/decrypts public key based
 * encryption files.
 * <p>
 * To encrypt a file: KeyBasedFileProcessor -e [-a|-ai] fileName publicKeyFile.<br>
 * If -a is specified the output file will be "ascii-armored".
 * If -i is specified the output file will be have integrity checking added.
 * <p>
 * To decrypt: KeyBasedFileProcessor -d fileName secretKeyFile passPhrase.
 * <p>
 * Note 1: this example will silently overwrite files, nor does it pay any attention to
 * the specification of "_CONSOLE" in the filename. It also expects that a single pass phrase
 * will have been used.
 * <p>
 * Note 2: if an empty file name has been specified in the literal data object contained in the
 * encrypted packet a file with the name filename.out will be generated in the current working directory.
 
*/
public class KeyBasedFileProcessor
{
    private static void decryptFile(
        String inputFileName,
        String keyFileName,
        char[] passwd,
        String defaultFileName)
        throws IOException, NoSuchProviderException
    {
        InputStream in = new BufferedInputStream(new FileInputStream(inputFileName));
        InputStream keyIn = new BufferedInputStream(new FileInputStream(keyFileName));
        decryptFile(in, keyIn, passwd, defaultFileName);
        keyIn.close();
        in.close();
    }

    /**
     * decrypt the passed in message stream
     
*/
    private static void decryptFile(
        InputStream in,
        InputStream keyIn,
        char[]      passwd,
        String      defaultFileName)
        throws IOException, NoSuchProviderException
    {
        in = PGPUtil.getDecoderStream(in);
        
        try
        {
            JcaPGPObjectFactory pgpF = new JcaPGPObjectFactory(in);
            PGPEncryptedDataList    enc;

            Object                  o = pgpF.nextObject();
            //
            
// the first object might be a PGP marker packet.
            
//
            if (o instanceof PGPEncryptedDataList)
            {
                enc = (PGPEncryptedDataList)o;
            }
            else
            {
                enc = (PGPEncryptedDataList)pgpF.nextObject();
            }
            
            //
            
// find the secret key
            
//
            Iterator                    it = enc.getEncryptedDataObjects();
            PGPPrivateKey               sKey = null;
            PGPPublicKeyEncryptedData   pbe = null;
            PGPSecretKeyRingCollection  pgpSec = new PGPSecretKeyRingCollection(
                PGPUtil.getDecoderStream(keyIn), new JcaKeyFingerprintCalculator());

            while (sKey == null && it.hasNext())
            {
                pbe = (PGPPublicKeyEncryptedData)it.next();
                
                sKey = PGPExampleUtil.findSecretKey(pgpSec, pbe.getKeyID(), passwd);
            }
            
            if (sKey == null)
            {
                throw new IllegalArgumentException("secret key for message not found.");
            }
    
            InputStream         clear = pbe.getDataStream(new JcePublicKeyDataDecryptorFactoryBuilder().setProvider("BC").build(sKey));
            
            JcaPGPObjectFactory    plainFact = new JcaPGPObjectFactory(clear);
            
            Object              message = plainFact.nextObject();
    
            while ( true ) {
                if (message instanceof PGPCompressedData)
                {
                    PGPCompressedData   cData = (PGPCompressedData)message;
                    JcaPGPObjectFactory    pgpFact = new JcaPGPObjectFactory(cData.getDataStream());
                    
                    message = pgpFact.nextObject();
                }
                
                if (message instanceof PGPLiteralData)
                {
                    PGPLiteralData ld = (PGPLiteralData)message;

                    String outFileName = ld.getFileName();
                    if (outFileName.length() == 0)
                    {
                        outFileName = defaultFileName;
                    }

                    InputStream unc = ld.getInputStream();
                    OutputStream fOut = new BufferedOutputStream(new FileOutputStream(outFileName));

                    Streams.pipeAll(unc, fOut);

                    fOut.close();
                    break;
                }
                else if (message instanceof PGPOnePassSignatureList)
                {
                    System.out.println("encrypted message contains a signed message - not literal data.");
                }
                else if (message instanceof PGPSignatureList)
                {
                    System.out.println("encrypted message contains a signed message - not literal data.");
                }
                else
                {
                    throw new PGPException("message is not a simple encrypted file - type unknown.");
                }
                message = plainFact.nextObject();
            }
            
            if (pbe.isIntegrityProtected())
            {
                if (!pbe.verify())
                {
                    System.err.println("message failed integrity check");
                }
                else
                {
                    System.err.println("message integrity check passed");
                }
            }
            else
            {
                System.err.println("no message integrity check");
            }
        }
        catch (PGPException e)
        {
            System.err.println(e);
            if (e.getUnderlyingException() != null)
            {
                e.getUnderlyingException().printStackTrace();
            }
        }
    }

    private static void encryptFile(
        String          outputFileName,
        String          inputFileName,
        String          encKeyFileName,
        boolean         armor,
        boolean         withIntegrityCheck)
        throws IOException, NoSuchProviderException, PGPException
    {
        OutputStream out = new BufferedOutputStream(new FileOutputStream(outputFileName));
        PGPPublicKey encKey = PGPExampleUtil.readPublicKey(encKeyFileName);
        encryptFile(out, inputFileName, encKey, armor, withIntegrityCheck);
        out.close();
    }

    private static void encryptFile(
        OutputStream    out,
        String          fileName,
        PGPPublicKey    encKey,
        boolean         armor,
        boolean         withIntegrityCheck)
        throws IOException, NoSuchProviderException
    {
        if (armor)
        {
            out = new ArmoredOutputStream(out);
        }

        try
        {
            byte[] bytes = PGPExampleUtil.compressFile(fileName, CompressionAlgorithmTags.ZIP);

            PGPEncryptedDataGenerator encGen = new PGPEncryptedDataGenerator(
                new JcePGPDataEncryptorBuilder(PGPEncryptedData.CAST5).setWithIntegrityPacket(withIntegrityCheck).setSecureRandom(new SecureRandom()).setProvider("BC"));

            encGen.addMethod(new JcePublicKeyKeyEncryptionMethodGenerator(encKey).setProvider("BC"));

            OutputStream cOut = encGen.open(out, bytes.length);

            cOut.write(bytes);
            cOut.close();

            if (armor)
            {
                out.close();
            }
        }
        catch (PGPException e)
        {
            System.err.println(e);
            if (e.getUnderlyingException() != null)
            {
                e.getUnderlyingException().printStackTrace();
            }
        }
    }

    public static void main(
        String[] args)
        throws Exception
    {
        Security.addProvider(new BouncyCastleProvider());

        if (args.length == 0)
        {
            System.err.println("usage: KeyBasedFileProcessor -e|-d [-a|ai] file [secretKeyFile passPhrase|pubKeyFile]");
            return;
        }

        if (args[0].equals("-e"))
        {
            if (args[1].equals("-a") || args[1].equals("-ai") || args[1].equals("-ia"))
            {
                encryptFile(args[2] + ".asc", args[2], args[3], true, (args[1].indexOf('i') > 0));
            }
            else if (args[1].equals("-i"))
            {
                encryptFile(args[2] + ".bpg", args[2], args[3], falsetrue);
            }
            else
            {
                encryptFile(args[1] + ".bpg", args[1], args[2], falsefalse);
            }
        }
        else if (args[0].equals("-d"))
        {
            decryptFile(args[1], args[2], args[3].toCharArray(), new File(args[1]).getName() + ".out");
        }
        else
        {
            System.err.println("usage: KeyBasedFileProcessor -d|-e [-a|ai] file [secretKeyFile passPhrase|pubKeyFile]");
        }
    }
}


asdf

]]>
Nettyhttp://www.tkk7.com/usherlight/archive/2014/11/27/420676.html云自无心水自?/dc:creator>云自无心水自?/author>Wed, 26 Nov 2014 23:36:00 GMThttp://www.tkk7.com/usherlight/archive/2014/11/27/420676.htmlhttp://www.tkk7.com/usherlight/comments/420676.htmlhttp://www.tkk7.com/usherlight/archive/2014/11/27/420676.html#Feedback0http://www.tkk7.com/usherlight/comments/commentRss/420676.htmlhttp://www.tkk7.com/usherlight/services/trackbacks/420676.html
在Netty in Action中是q样描述的:
While the I/O thread must not be blocked at all, thus prohibiting any direct blocking operations within your ChannelHandler, there is a way to implement this requirement. 
You can specify an EventExecutorGroup when adding ChannelHandlers to the ChannelPipeline. 
This EventExecutorGroup will then be used to obtain an EventExecutor, which will execute all the methods of the ChannelHandler. 
This EventExecutor will use a different thread from the I/O thread, thus freeing up the EventLoop.
IQOU程是不允许被阻塞的Q也是不能在ChannelHandler中进行Q何阻塞式的处理,但是Ҏ(gu)我们也有相应的解x?
是在把ChannelHandersd到ChannelPipeline的时候,指定一个EventExecutorGroupQChannelHandler中所有的Ҏ(gu)都将会在q个指定的EventExecutorGroup中运行?/div>
而这个EVentExecutorGroupq行的线E与I/OU程不同Q达CdIQO的目的?nbsp;
E序CZ如下Q?/div>
Channel ch = ...;
ChannelPipeline p = ch.pipeline();
EventExecutor e1 = new DefaultEventExecutorGroup(16);
EventExecutor e2 = new DefaultEventExecutorGroup(8);
 
p.addLast(new MyProtocolCodec());
p.addLast(e1, new MyDatabaseAccessingHandler());
p.addLast(e2, new MyHardDiskAccessingHandler());
需要补充说明一下,上面的示例程序似乎有炚w题。用上q方法添加ChannelHandler到pipeline中以后,channelHandler的所有方法确实什么在一个单独的U程中被处理?br />但是Q每ơDefaultEventExcutorGroupU程池中的线E不能被重用Q每ơ都会生成一个新的线E,然后在新的线E中调用ChannelHandler, 在visualvm可以看到U程数量直线增长?br />
解决的方法是Q不能用局部变量Ş式的DefaultEventExecutorGroup。而用类静态成员变量:
static final EventExecutor e1 = new DefaultEventExecutorGroup(16);

我分析原因可能是Q在新的q接到来Q创建ChannelPipelinel新Channel的时候,如果不用静态的׃n变量Q而用局部变量的话,造成DefaultEventExecutorGroup被多ơ重复创建。因此,虽然一个DefaultEventExecutorGroup中的Thread数量是固定的Q但是却产生了多余的DefaultEventExecutorGroup。从VisualVM中也可以看到QDefaultEventExecutorGroupU程的名字会是:
xxx-2-1
xxx-3-1
xxx-4-1
xxx-n-1
说明是Group的数量(W一个数字)在增多,而不是Group中的U程数量(W二个数字)在增?/div>
Ҏ(gu)静态变量后Q线E名会是Q?/div>
xxx-2-1
xxx-2-2
xxx-2-3
xxx-2-n
最后一个n是在创建DefaultEventExecutorGroup时候,传入的线E个数参数的大小?/div>


]]>Spring MVC + Spring Security + Spring JDBC中注入dataSourceL为Null的原因和解决http://www.tkk7.com/usherlight/archive/2011/08/26/357316.html云自无心水自?/dc:creator>云自无心水自?/author>Fri, 26 Aug 2011 00:57:00 GMThttp://www.tkk7.com/usherlight/archive/2011/08/26/357316.htmlhttp://www.tkk7.com/usherlight/comments/357316.htmlhttp://www.tkk7.com/usherlight/archive/2011/08/26/357316.html#Feedback0http://www.tkk7.com/usherlight/comments/commentRss/357316.htmlhttp://www.tkk7.com/usherlight/services/trackbacks/357316.html
在applicationContext.xml中定义了一个DataSourceQ?lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" />
但是在代码中Q用anotationq行注入的时候,却L找不到这个dataSource.

    @Autowired
    public void setDataSource(DataSource dataSource) {
        jdbcTemplate = new JdbcTemplate(dataSource);
        jdbcInsert = new SimpleJdbcInsert(dataSource);
    }

最后终于想明白了,原因大概是这LQ用autowired的时候,默认是根据类型来匚w的,在xml中定义的cd是:BasicDataSourceQ而不是接口DataSourceQ所以默认情况下q样是无法自动装配的。解军_法是指o使用名字来进行bean的匹配,也就是用Qualifier指定bean的id.

    @Autowired
    public void setDataSource(@Qualifier("dataSource") DataSource dataSource) {
        jdbcTemplate = new JdbcTemplate(dataSource);
        jdbcInsert = new SimpleJdbcInsert(dataSource);
    }


另外一点,在网上搜索的q程中发现有不少人都有类似的问题Q但是他们的原因是没有正用spring的注入,而是自己在代码中new了一个Dao的实例,q样的话Qspring是无法将dataSource注入到dao的实例中?/div>


]]>
我觉得最好用的mysql客户端工PHeidiSqlhttp://www.tkk7.com/usherlight/archive/2011/08/08/355998.html云自无心水自?/dc:creator>云自无心水自?/author>Mon, 08 Aug 2011 02:36:00 GMThttp://www.tkk7.com/usherlight/archive/2011/08/08/355998.htmlhttp://www.tkk7.com/usherlight/comments/355998.htmlhttp://www.tkk7.com/usherlight/archive/2011/08/08/355998.html#Feedback4http://www.tkk7.com/usherlight/comments/commentRss/355998.htmlhttp://www.tkk7.com/usherlight/services/trackbacks/355998.html
HeidiSql是一家d国公司研发的轻量U的Q开源mysql客户端工兗体U十分小巧,可是十分实用?br />
我之所以喜Ƣ的原因Q?br />1Q有导入Q导出的功能Q可以将数据直接从文本文件中导入到数据库的数据表中?br />2Q可以将选中的数据导出成为sql语句
3Q界面布|十分合理,操作?/div>

]]>
打开有密码保护(但是没有加密Q的excel文ghttp://www.tkk7.com/usherlight/archive/2011/05/30/351313.html云自无心水自?/dc:creator>云自无心水自?/author>Mon, 30 May 2011 02:42:00 GMThttp://www.tkk7.com/usherlight/archive/2011/05/30/351313.htmlhttp://www.tkk7.com/usherlight/comments/351313.htmlhttp://www.tkk7.com/usherlight/archive/2011/05/30/351313.html#Feedback0http://www.tkk7.com/usherlight/comments/commentRss/351313.htmlhttp://www.tkk7.com/usherlight/services/trackbacks/351313.html
主要是用:
Biff8EncryptionKey.setCurrentUserPassword(password);
在打开workbook之前
HSSFWorkbook workbook = new HSSFWorkbook(inp);
注意事项Q这个应该是只适用于xls,而不是xlsx


]]>java串口~程需要注意的几个地方http://www.tkk7.com/usherlight/archive/2011/02/07/343929.html云自无心水自?/dc:creator>云自无心水自?/author>Mon, 07 Feb 2011 05:22:00 GMThttp://www.tkk7.com/usherlight/archive/2011/02/07/343929.htmlhttp://www.tkk7.com/usherlight/comments/343929.htmlhttp://www.tkk7.com/usherlight/archive/2011/02/07/343929.html#Feedback0http://www.tkk7.com/usherlight/comments/commentRss/343929.htmlhttp://www.tkk7.com/usherlight/services/trackbacks/343929.html
我用的是sun提供的javax.comm包,不确定其他的comm支持包(比如Qrxtx)行ؓ与之相同
1、事仉动的数据d
需要注意的是:一个SerialPort只能注册一个事件监听程序,因此Q有时候有会发玎ͼ你的事g监听处理E序会变得非常庞?/div>
另外Q要注意的就是事件处理如果比较耗时的话Q最好是在单独的U程中运行,否则会阻塞数据的接收?/div>
串口接收到数据后Q默认在U程: Win32SerialPort Notification thread中运行。如果不及时释放的话Q会造成数据无法d?/div>
我的做法是,接收到数据后Q先判断数据的合法和完整性,如果没有接收到完整的数据Q则在缓存数据后Q马上返?/div>
如果数据完整而且合法Q则另开一个线E,q行数据处理
2、数据的发?/div>
单独使用一个线E来发送数据,目的q是Z防止dQ有一个技巧就是用OUTPUT_BUFFER_EMPTY事g来发送?/div>

]]>Tapestry的一些最新动?/title><link>http://www.tkk7.com/usherlight/archive/2010/11/24/338872.html</link><dc:creator>云自无心水自?/dc:creator><author>云自无心水自?/author><pubDate>Tue, 23 Nov 2010 22:08:00 GMT</pubDate><guid>http://www.tkk7.com/usherlight/archive/2010/11/24/338872.html</guid><wfw:comment>http://www.tkk7.com/usherlight/comments/338872.html</wfw:comment><comments>http://www.tkk7.com/usherlight/archive/2010/11/24/338872.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.tkk7.com/usherlight/comments/commentRss/338872.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/usherlight/services/trackbacks/338872.html</trackback:ping><description><![CDATA[<br /> 1、Tapestry5.2.4的发布,Tapestry5.2.3版本在内部投中被否冻I主要是因Z用maven快速创建的原型有问题)Q所以在被否决的3天后便发布了5.2.4,相对5.2.2来说Q变动ƈ不大Q只?个错误修复和5个功能改q。但是至说明Tapestry的项目还在顺利的q行中?br /> 2、Tapestry主页的全新改版。主要是完善了文档。这一Ҏ(gu)非常重要的,Tapestry目l的成员也承认Tapestry在推销自己或者是在市场推q方面做得非常失?very bad in marketing)Q所以最q也采取了一些措施来q行改变Q比如,预计明年会发行Tapestry5 in action一书等{?br /> 3、还有一件事需要提及的是:appfuse的作者最q对web框架q行了一番对比http://raibledesigns.com/rd/entry/my_comparing_jvm_web_frameworksQTapestry?3个框架中名列W?Q刚好是中间的位|。Tapestry目的成员颇有不满,认ؓ作者Matt Raible对Tapestry不够了解Q有误导观众之嫌。Tapestry目成员I(y)gor E. Poteryaev认ؓMatt?认识度,开发效率,目健康度,试友好性,scalability{方面严重低CTapestry的能力?br /><img src ="http://www.tkk7.com/usherlight/aggbug/338872.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/usherlight/" target="_blank">云自无心水自?/a> 2010-11-24 06:08 <a href="http://www.tkk7.com/usherlight/archive/2010/11/24/338872.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Mybatis的一些新动?/title><link>http://www.tkk7.com/usherlight/archive/2010/11/02/336750.html</link><dc:creator>云自无心水自?/dc:creator><author>云自无心水自?/author><pubDate>Tue, 02 Nov 2010 00:10:00 GMT</pubDate><guid>http://www.tkk7.com/usherlight/archive/2010/11/02/336750.html</guid><wfw:comment>http://www.tkk7.com/usherlight/comments/336750.html</wfw:comment><comments>http://www.tkk7.com/usherlight/archive/2010/11/02/336750.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.tkk7.com/usherlight/comments/commentRss/336750.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/usherlight/services/trackbacks/336750.html</trackback:ping><description><![CDATA[1、发布了MyBatis3.0.3, 具体内容不详Q没有能够发现release notes.<br /> 2、发布了mybatis-generator 1.3.0, q是一个能够根据数据库的表自动生成mybatis?br />         sqlmap xml文g<br />         与数据表对应的java class<br />         使用上两个文件的javac?br /> 我下载后Q尝试着使用了一下,发现需要有一个配|文Ӟ我觉得应该是用于提供数据库连接的信息。但是配|文件的格式不详?br /> 现在发现mybatis的文档比较成问题Q很多东襉K没有说明Q用v来很困难啊?br /> 3、新增了两个中方译文档<br />         # MyBatis 3 User Guide Simplified Chinese.pdf<br />         # MyBatis-Spring Reference Simplied Chinese.pdf<br /> 4、发布了mybatis-spring-1.0.0-RC2<br /> 5、发布了mybatis-guice-1.0.0-RC3<img src ="http://www.tkk7.com/usherlight/aggbug/336750.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/usherlight/" target="_blank">云自无心水自?/a> 2010-11-02 08:10 <a href="http://www.tkk7.com/usherlight/archive/2010/11/02/336750.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Tapestry5.2.2(Beta Release)发布?/title><link>http://www.tkk7.com/usherlight/archive/2010/11/02/336747.html</link><dc:creator>云自无心水自?/dc:creator><author>云自无心水自?/author><pubDate>Mon, 01 Nov 2010 23:58:00 GMT</pubDate><guid>http://www.tkk7.com/usherlight/archive/2010/11/02/336747.html</guid><wfw:comment>http://www.tkk7.com/usherlight/comments/336747.html</wfw:comment><comments>http://www.tkk7.com/usherlight/archive/2010/11/02/336747.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/usherlight/comments/commentRss/336747.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/usherlight/services/trackbacks/336747.html</trackback:ping><description><![CDATA[主要是一些bug修复和改q,最重要的一Ҏ(gu)能够从link对象生成l对路径了?br /> q主要是便于ajax的用?br /> <br /> <p>Bug</p> <p>    *  Element.forceAttribute uses the element's namespace to match the attribute.<br />     *  Element.attribute(String name, String value) adds elements that already exist<br />     *  Element#addClassName can create an additional new 'class' attribute<br />     *  Properties defined in an Interface are not exposed by PropertyAccess for abstract classes that do not directly implement the methods<br />     *  Some services require a notification that they have been reloaded, so they can clean up external dependencies<br />     *  Whitespaces in SymbolConstants.SUPPORTED_LOCALES cause that locales are not persised<br />     *  Validation macros do not work when used in @Validate annotation<br />     *  Client-side validation of @Pattern is broken<br />     *  Linking a Form to a Zone will no longer work unless the Form contains validated fields<br />     *  When using PropertyShadowBuilder to build a service, if the property is null, an immediate exception is needed (rather than a NullPointerException)<br />     *  When using a MultiZoneUpdate, Tapestry will clear the referenced zone</p> <p>Improvement</p> <p>    *  Add the facility to optionally disable on-focus-change triggered validation while retaining the on-form-submit validation<br />     *  Form component should be able to render a secure URL even on an insecure page<br />     *  New annotations @Decorate and @Advise to identify methods that decorate or annotate services<br />     *  Extend Link with new methods for producing absolute URLs (that include scheme, hostname, etc.)<br />     *  Simplify connecting a link or form to an (enclosing) Zone<br />     *  BeanBlockContribution should be split into two sub-classes: EditBlockContribution and DisplayBlockContribution<br />     *  Define a special CSS class to prevent a client-side form from submitting normally (for Ajax use cases)<br />     *  Additional method for Link: addParameterValue(String,Object) that uses ContextPathEncoder to encode object value to a string<br />     *  SeleniumTestCase should expose the underlying CommandProcessor, to allow execution of commands not defined by the Selenium interface<br />     *  Allow individual SeleniumTestCases to run w/o configuring SeleniumLauncher<br /> </p><img src ="http://www.tkk7.com/usherlight/aggbug/336747.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/usherlight/" target="_blank">云自无心水自?/a> 2010-11-02 07:58 <a href="http://www.tkk7.com/usherlight/archive/2010/11/02/336747.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Tapestry5.2.1 Beta已经发布http://www.tkk7.com/usherlight/archive/2010/10/20/335644.html云自无心水自?/dc:creator>云自无心水自?/author>Tue, 19 Oct 2010 23:38:00 GMThttp://www.tkk7.com/usherlight/archive/2010/10/20/335644.htmlhttp://www.tkk7.com/usherlight/comments/335644.htmlhttp://www.tkk7.com/usherlight/archive/2010/10/20/335644.html#Feedback0http://www.tkk7.com/usherlight/comments/commentRss/335644.htmlhttp://www.tkk7.com/usherlight/services/trackbacks/335644.html今天在网上{了{Q发现Tapestry又有了新动作?br /> 1、从5.2.0alpha??1日发布到现在Q终于发?.2.1Beta版了。这个版本主要是修改alpha版本中的bug.
5.2相对?.1q行了许多重大的改进Q详l内容可见:Tapestry5.2的新变化
2、据U在5.3版中引入大量的新功能,具体内容不详?br /> 3、以往最令h诟病的文档问题,目前开发小l也在努力解冟?br />      首先Q徏立了新的文档|页Qhttp://people.apache.org/~uli/tapestry-site/Q不q目前这个网站还没有完全完成Q只能算是预览版Q但是这毕竟是在正确的道路上前进?br />      其次QTapestry 5 in action一书正在写作中Q已l完?0%Q预计明q一季度能够出版?br /> 我相信,随着功能的不断完善和补充Q再加上文档的逐渐充实QTapestry完全有理p吸引更多的开发者来x和用?/p>

]]>
mybatis3.0.2已经发布http://www.tkk7.com/usherlight/archive/2010/09/13/331886.html云自无心水自?/dc:creator>云自无心水自?/author>Mon, 13 Sep 2010 04:42:00 GMThttp://www.tkk7.com/usherlight/archive/2010/09/13/331886.htmlhttp://www.tkk7.com/usherlight/comments/331886.htmlhttp://www.tkk7.com/usherlight/archive/2010/09/13/331886.html#Feedback1http://www.tkk7.com/usherlight/comments/commentRss/331886.htmlhttp://www.tkk7.com/usherlight/services/trackbacks/331886.htmlq是mybatis从ibatis更名q来后,发布的第2个版本(W?个版本是3.0.1)?br /> 在这个版本中只修复了4个bug(感觉数目有点,N是因Z一个版本的bug真的如此之少?)Q增加了一个小功能.
作者的话:管只有5个修改,但我q是觉得值得为此发布一个新版本?br /> q?个修Ҏ(gu)Q?br /> 1、在org.apache.ibatis.Session中增加了一个新Ҏ(gu)Qvoid select(String statement, ResultHandler handler);
原来只有Q?br />  void select(String statement, Object parameter, ResultHandler handler);
 void select(String statement, Object parameter, RowBounds rowBounds, ResultHandler handler);

2、修复了ManagedConnection中关闭连接的问题
3、修复了schema migration中,语句提交(statement commit)不正的问题
4、修复了延迟加蝲已经预读取属性时的问?br /> 5、修复了schema migration中,FileInputStream没有正确关闭的问?br />



]]>
批处理图?/title><link>http://www.tkk7.com/usherlight/archive/2010/08/20/329424.html</link><dc:creator>云自无心水自?/dc:creator><author>云自无心水自?/author><pubDate>Fri, 20 Aug 2010 00:51:00 GMT</pubDate><guid>http://www.tkk7.com/usherlight/archive/2010/08/20/329424.html</guid><wfw:comment>http://www.tkk7.com/usherlight/comments/329424.html</wfw:comment><comments>http://www.tkk7.com/usherlight/archive/2010/08/20/329424.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/usherlight/comments/commentRss/329424.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/usherlight/services/trackbacks/329424.html</trackback:ping><description><![CDATA[介绍一个用GIMP来批量处理图像的Ҏ(gu)?GIMP是一个免费的囑փ~辑工具Q功能非常强大。ƈ且提供了cM于firefox的插件机Ӟ可以通过d插g来不断地获得新功能?br /> 扚w处理囑փ是通过一个批处理插g来完成的。这个插件的下蝲地址Qhttp://members.ozemail.com.au/~hodsond/dbp.html<br /> 插g下蝲后,解压~,然后把dbp.exe攑֜plugin目录下,比如QC:\Program Files\GIMP-2.0\lib\gimp\2.0\plug-ins<br /> 启动GIMP,在菜?Filter 里会发现一个新的选项QBatch Process...<br /> 点击q个选项Q会弹出一个新H口Q这个就是批处理的操作界面了?br /> 通过q个插gQ我们可以完?扚w改变大小Q重命名Q旋转/锐化Q模p/调整亮度Q裁?q些功能?img src ="http://www.tkk7.com/usherlight/aggbug/329424.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/usherlight/" target="_blank">云自无心水自?/a> 2010-08-20 08:51 <a href="http://www.tkk7.com/usherlight/archive/2010/08/20/329424.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Tapestry5.2的新变化http://www.tkk7.com/usherlight/archive/2010/08/18/329170.html云自无心水自?/dc:creator>云自无心水自?/author>Tue, 17 Aug 2010 23:13:00 GMThttp://www.tkk7.com/usherlight/archive/2010/08/18/329170.htmlhttp://www.tkk7.com/usherlight/comments/329170.htmlhttp://www.tkk7.com/usherlight/archive/2010/08/18/329170.html#Feedback0http://www.tkk7.com/usherlight/comments/commentRss/329170.htmlhttp://www.tkk7.com/usherlight/services/trackbacks/329170.html 1、增Zclass reload的功能(我个Z认ؓq一Ҏ(gu)5.2版本最令hȀ动的改进Q,以前Tapestry和其他的web框架cMQ修攚w面不需要重新启动application server, 但是修改了类之后Q必重新启动应用服务器才行。但是在Tapestry5.2中,对这一点进行了修改Q如果只改变了接口的实现c,而不改变接口的方法签名,׃需要重新启动应用服务器
2、新增了若干个组Ӟ比如QError和Trigger?br /> Error和原有的ErrorscMQ但是Error用于l指定的lg昄验证错误信息?br /> Trigger提供了在L面q程中触发Q务事件的功能Q常常用于通过RenderSupport来给面dJavaScript代码
3、新的插?Mixin),包括RenderClientId, RenderNotification
4、集成了JSR-303 Bean的验证,现在可以在页面中使用JSR-303标准的注解来l字D|定需要的验证
5、新的注解,包括@Contribute,@RequestParameter, @ActivationRequestParameter, 使用后两个注解能很容易地获取request中的参数
6、新的页面生命周期事ӞpageReset
7、链接修饰过E中的新事g: decoratePageRenderLink, decoreateComponentEventLink
8、页面解析器的更换,原来使用StAXQ造成了对Google App Engine和对OSGI的不兼容Q?.2版本中用了标准的SAX解析?br /> 9、页面缓冲池的废除(我认?.2版本的一个相当大而且也是非常重要的一个变化,我认为页面缓冲池技术是tapestry学习曲线陡峭的一个重要原因)Q?.2版本中所有页面将只有一个实例(也就是lewis howard说的单例化)Q页面属性的值将会在每个U程中用一个Map来保存。这样一个页面实例可以在多个U程中用,而不会有同步问题?br /> 但是Q由于这是一个新的尝试,所以lewis也不定q样做的效果是否很好Q详见:http://tapestryjava.blogspot.com/2010/07/everyone-out-of-pool-tapestry-goes.htmlQ所以,?.2中可以通过配置恢复面~冲池的使用?img src ="http://www.tkk7.com/usherlight/aggbug/329170.html" width = "1" height = "1" />

]]>
prototype版的table filterhttp://www.tkk7.com/usherlight/archive/2010/07/28/327294.html云自无心水自?/dc:creator>云自无心水自?/author>Wed, 28 Jul 2010 03:02:00 GMThttp://www.tkk7.com/usherlight/archive/2010/07/28/327294.htmlhttp://www.tkk7.com/usherlight/comments/327294.htmlhttp://www.tkk7.com/usherlight/archive/2010/07/28/327294.html#Feedback1http://www.tkk7.com/usherlight/comments/commentRss/327294.htmlhttp://www.tkk7.com/usherlight/services/trackbacks/327294.htmljquery有一个很方便的插件UI Table Filter可以Ҏ(gu)输入的内定w藏显Cg相应的数据行?br /> 因ؓ目前使用的tapestry捆绑的是prototypeQ所以就自己写了一个类似的插g?/p>

<html>
<head>
<script src="prototype-1.6.0.2.js" type="text/javascript"></script>
<script language="javaScript">
 Event.observe(window, 'load', function() {
  Event.observe('filter', 'keyup', filterTable);
 });
 function filterTable() {
  var filterCaseElement = document.getElementById('filterCase');
  var caseSensitive = filterCaseElement.checked;
  
  $$('tr').each(function(trElement, ind) {
   var val = $('filter').value;
   
   if ( ! caseSensitive ) {
    val = val.toLowerCase();
   }
       
   trElement.childElements().each(function(tdElememt) {
     var tdText = tdElement.innerText;
    if ( ! caseSensitive ) {
     tdText = tdText.toLowerCase();
    }
    if (tdText.include(val)) {
     trElement.show();
    } else if ( ind > 0 ) {
     trElement.hide();
    }
   });
  });
 }
</script>

</head>

 <body>
  filter: <input type="text" id="filter" name="filter"/> <input type="checkbox" id="filterCase" onchange="javaScript:filterTable();"/> Case-Sensitive
  <table border="1">
   <thead>
    <tr>
     <th>name</th>
     <th>column1</th>
     <th>column2</th>
     <th>column3</th>
     <th>column4</th>
     <th>column5</th>
     <th>column6</th>
    </tr>
   </thead>
   <tr>
    <td>TEST</td>
    <td>00150002331</td>
    <td>238156</td>
    <td>075</td>
    <td>001</td>
    <td>172.16.14.20</td>
    <td>1-1-05</td>
   </tr>
   <tr>
    <td>TEST-2</td>
    <td>00150002332</td>
    <td>238157</td>
    <td>075</td>
    <td>002</td>
    <td>172.16.14.21</td>
    <td>1-1-05</td>
   </tr>
   <tr>
    <td>TEST</td>
    <td>00150002333</td>
    <td>238158</td>
    <td>075</td>
    <td>003</td>
    <td>172.16.14.23</td>
    <td>1-1-05</td>
   </tr>
   <tr>
    <td>TEST</td>
    <td>00150002341</td>
    <td>238159</td>
    <td>075</td>
    <td>004</td>
    <td>172.16.14.24</td>
    <td>1-1-05</td>
   </tr>
   <tr>
    <td>TEST</td>
    <td>00150002339</td>
    <td>238186</td>
    <td>075</td>
    <td>006</td>
    <td>172.16.14.26</td>
    <td>1-1-06</td>
   </tr>
  </table>
 </body>
  </html>

如果面中多个表|而只需要对其中的一个表格的数据q行qo的话Q简单地把其中:$$('tr').each(function(ele, index) Ҏ(gu) $$('#tableId, tr').each(function(ele, index) p了,其中的tableId是表格的id

]]>
使用GIMP图片背景透明?/title><link>http://www.tkk7.com/usherlight/archive/2010/07/14/326050.html</link><dc:creator>云自无心水自?/dc:creator><author>云自无心水自?/author><pubDate>Wed, 14 Jul 2010 01:33:00 GMT</pubDate><guid>http://www.tkk7.com/usherlight/archive/2010/07/14/326050.html</guid><wfw:comment>http://www.tkk7.com/usherlight/comments/326050.html</wfw:comment><comments>http://www.tkk7.com/usherlight/archive/2010/07/14/326050.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/usherlight/comments/commentRss/326050.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/usherlight/services/trackbacks/326050.html</trackback:ping><description><![CDATA[GIMP(http://www.gimp.org/)是一个开源的囑Ş处理工具Q功能与PHOTOSHOP相比也ƈ不相差太多?br /> 1、选择要保留的囑ŞQ?br /> ?U办法,W一U就是直接用术工h选择Q但一般来说这部分囑Ş的色彩比较复杂,选择h相对困难<br /> W?U办法是先选择背景Q然后?#8220;反向选择”?br /> 友情提示Q在使用术的时候,?U模式,可以利用其中的添加,减少来不断地修正选择的范?br /> 2、打开囑ֱ面板<br /> 3、菜单:选择->动Q在囑ֱ面板中可以看到多一个Q动的囑ֱQ但是现在图层里q没有东?br /> 4、菜单:囑ֱ->创徏Q这时候就可以看到Q在刚才多出来的动囑ֱ中出C选择好的要保留的囑փ<br /> 5、去除背景图层,点击背景囑ֱ前面的眼睛,使得背景囑ֱ不可?br /> 保存Q生成透明背景的新囑փ<img src ="http://www.tkk7.com/usherlight/aggbug/326050.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/usherlight/" target="_blank">云自无心水自?/a> 2010-07-14 09:33 <a href="http://www.tkk7.com/usherlight/archive/2010/07/14/326050.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java Swing 布局理?/title><link>http://www.tkk7.com/usherlight/archive/2010/07/05/325258.html</link><dc:creator>云自无心水自?/dc:creator><author>云自无心水自?/author><pubDate>Mon, 05 Jul 2010 01:38:00 GMT</pubDate><guid>http://www.tkk7.com/usherlight/archive/2010/07/05/325258.html</guid><wfw:comment>http://www.tkk7.com/usherlight/comments/325258.html</wfw:comment><comments>http://www.tkk7.com/usherlight/archive/2010/07/05/325258.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.tkk7.com/usherlight/comments/commentRss/325258.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/usherlight/services/trackbacks/325258.html</trackback:ping><description><![CDATA[<p>CardLayout布局理器能够帮助用户处理两个以x多的成员׃n同一昄I间,它把容器分成许多?每层的显C空间占据整个容器的大小,但是每层只允许放|一个组?当然每层都可以利用Panel来实现复杂的用户界面.布局理器(CardLayoutQ就象一副叠得整整齐齐的扑克牌一??4 张牌,但是你只能看见最上面的一张牌,每一张牌q当于布局理器中的每一?</p> <p>式布局理器把容器看成一个行集,好象qx在一张纸上写字一P一行写满就换下一行。行高是用一行中的控仉度决定的。FlowLayout是所?JApplet/JApplet的默认布局。在生成式布局时能够指定显C的寚w方式Q默认情况下是居中(FlowLayout.CENTERQ?/p> <p>GridLayout 成员按|格型排列,每个成员可能地占据|格的空_每个|格也同样尽可能地占据空_从而各个成员按一定的大小比例攄。如果你改变大小Q?GridLayout相应地改变每个|格的大,以各个|格可能地大,占据Container容器全部的空间?br /> 基本布局{略是把容器的空间划分成若干行乘若干列的|格区域Q组件就位于q些划分出来的小区域中,所有的区域大小一栗组件按从左到右Q从上到下的Ҏ(gu)加入?/p> <p>BoxLayout布局能够允许控件按照X_从左到右Q或者Y_从上CQ方向来摆放Q而且沿着主u能够讄不同寸?/p><img src ="http://www.tkk7.com/usherlight/aggbug/325258.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/usherlight/" target="_blank">云自无心水自?/a> 2010-07-05 09:38 <a href="http://www.tkk7.com/usherlight/archive/2010/07/05/325258.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>HTTP协议q回代码的含?/title><link>http://www.tkk7.com/usherlight/archive/2010/06/23/324225.html</link><dc:creator>云自无心水自?/dc:creator><author>云自无心水自?/author><pubDate>Tue, 22 Jun 2010 23:16:00 GMT</pubDate><guid>http://www.tkk7.com/usherlight/archive/2010/06/23/324225.html</guid><wfw:comment>http://www.tkk7.com/usherlight/comments/324225.html</wfw:comment><comments>http://www.tkk7.com/usherlight/archive/2010/06/23/324225.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/usherlight/comments/commentRss/324225.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/usherlight/services/trackbacks/324225.html</trackback:ping><description><![CDATA[<h1 class="articletitle">HTTP Status Codes Explained</h1> <div id="mbwpdve" class="pageintro">All valid HTTP 1.1 Status Codes simply explained. </div> <div class="ntcobgs" id="article"><!-- google_ad_section_start --> <p>HTTP, Hypertext Transfer Protocol, is the method by which clients (i.e. you) and servers communicate. When someone clicks a link, types in a URL or submits out a form, their browser sends a request to a server for information. It might be asking for a page, or sending data, but either way, that is called an HTTP Request. When a server receives that request, it sends back an HTTP Response, with information for the client. Usually, this is invisible, though I'm sure you've seen one of the very common Response codes - 404, indicating a page was not found. There are a fair few more status codes sent by servers, and the following is a list of the current ones in HTTP 1.1, along with an explanation of their meanings.</p> <p>A more technical breakdown of HTTP 1.1 status codes and their meanings is available at <a >http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html</a>. There are several versions of HTTP, but currently HTTP 1.1 is the most widely used.</p> <h3>Informational</h3> <ul> <li id="ovwecqc" class="reference"><strong>100 - Continue</strong><br /> A status code of 100 indicates that (usually the first) part of a request has been received without any problems, and that the rest of the request should now be sent.</li> <li id="xqhuzyx" class="reference"><strong>101 - Switching Protocols</strong><br /> HTTP 1.1 is just one type of protocol for transferring data on the web, and a status code of 101 indicates that the server is changing to the protocol it defines in the "Upgrade" header it returns to the client. For example, when requesting a page, a browser might receive a statis code of 101, followed by an "Upgrade" header showing that the server is changing to a different version of HTTP.</li> </ul> <h3>Successful</h3> <ul> <li id="fcarazy" class="reference"><strong>200 - OK</strong><br /> The 200 status code is by far the most common returned. It means, simply, that the request was received and understood and is being processed.</li> <li id="jomdqpd" class="reference"><strong>201 - Created</strong><br /> A 201 status code indicates that a request was successful and as a result, a resource has been created (for example a new page).</li> <li id="txoizgq" class="reference"><strong>202 - Accepted</strong><br /> The status code 202 indicates that server has received and understood the request, and that it has been accepted for processing, although it may not be processed immediately.</li> <li id="spjwqts" class="reference"><strong>203 - Non-Authoritative Information</strong><br /> A 203 status code means that the request was received and understood, and that information sent back about the response is from a third party, rather than the original server. This is virtually identical in meaning to a 200 status code.</li> <li id="ozmouxh" class="reference"><strong>204 - No Content</strong><br /> The 204 status code means that the request was received and understood, but that there is no need to send any data back.</li> <li id="eylyphk" class="reference"><strong>205 - Reset Content</strong><br /> The 205 status code is a request from the server to the client to reset the document from which the original request was sent. For example, if a user fills out a form, and submits it, a status code of 205 means the server is asking the browser to clear the form.</li> <li id="tmzbznq" class="reference"><strong>206 - Partial Content</strong><br /> A status code of 206 is a response to a request for part of a document. This is used by advanced caching tools, when a user agent requests only a small part of a page, and just that section is returned.</li> </ul> <h3>Redirection</h3> <ul> <li id="exkikue" class="reference"><strong>300 - Multiple Choices</strong><br /> The 300 status code indicates that a resource has moved. The response will also include a list of locations from which the user agent can select the most appropriate.</li> <li id="ygtrazu" class="reference"><strong>301 - Moved Permanently</strong><br /> A status code of 301 tells a client that the resource they asked for has permanently moved to a new location. The response should also include this location. It tells the client to use the new URL the next time it wants to fetch the same resource.</li> <li id="lmziogf" class="reference"><strong>302 - Found</strong><br /> A status code of 302 tells a client that the resource they asked for has temporarily moved to a new location. The response should also include this location. It tells the client that it should carry on using the same URL to access this resource.</li> <li id="eugmsrq" class="reference"><strong>303 - See Other</strong><br /> A 303 status code indicates that the response to the request can be found at the specified URL, and should be retrieved from there. It does not mean that something has moved - it is simply specifying the address at which the response to the request can be found.</li> <li id="ygikfiw" class="reference"><strong>304 - Not Modified</strong><br /> The 304 status code is sent in response to a request (for a document) that asked for the document only if it was newer than the one the client already had. Normally, when a document is cached, the date it was cached is stored. The next time the document is viewed, the client asks the server if the document has changed. If not, the client just reloads the document from the cache.</li> <li id="vsfduil" class="reference"><strong>305 - Use Proxy</strong><br /> A 305 status code tells the client that the requested resource has to be reached through a proxy, which will be specified in the response.</li> <li id="wljlrux" class="reference"><strong>307 - Temporary Redirect</strong><br /> 307 is the status code that is sent when a document is temporarily available at a different URL, which is also returned. There is very little difference between a 302 status code and a 307 status code. 307 was created as another, less ambiguous, version of the 302 status code.</li> </ul> <h3>Client Error</h3> <ul> <li id="buaviaz" class="reference"><strong>400 - Bad Request</strong><br /> A status code of 400 indicates that the server did not understand the request due to bad syntax.</li> <li id="lbzflor" class="reference"><strong>401 - Unauthorized</strong><br /> A 401 status code indicates that before a resource can be accessed, the client must be authorised by the server.</li> <li id="jvmoftw" class="reference"><strong>402 - Payment Required</strong><br /> The 402 status code is not currently in use, being listed as "reserved for future use".</li> <li id="qgxgilz" class="reference"><strong>403 - Forbidden</strong><br /> A 403 status code indicates that the client cannot access the requested resource. That might mean that the wrong username and password were sent in the request, or that the permissions on the server do not allow what was being asked.</li> <li id="roinwcf" class="reference"><strong>404 - Not Found</strong><br /> The best known of them all, the 404 status code indicates that the requested resource was not found at the URL given, and the server has no idea how long for.</li> <li id="qrtgxad" class="reference"><strong>405 - Method Not Allowed</strong><br /> A 405 status code is returned when the client has tried to use a request method that the server does not allow. Request methods that are allowed should be sent with the response (common request methods are POST and GET).</li> <li id="ejlypdj" class="reference"><strong>406 - Not Acceptable</strong><br /> The 406 status code means that, although the server understood and processed the request, the response is of a form the client cannot understand. A client sends, as part of a request, headers indicating what types of data it can use, and a 406 error is returned when the response is of a type not i that list.</li> <li id="ksqhyma" class="reference"><strong>407 - Proxy Authentication Required</strong><br /> The 407 status code is very similar to the 401 status code, and means that the client must be authorised by the proxy before the request can proceed.</li> <li id="qctzbed" class="reference"><strong>408 - Request Timeout</strong><br /> A 408 status code means that the client did not produce a request quickly enough. A server is set to only wait a certain amount of time for responses from clients, and a 408 status code indicates that time has passed.</li> <li id="qcaudyi" class="reference"><strong>409 - Conflict</strong><br /> A 409 status code indicates that the server was unable to complete the request, often because a file would need to be editted, created or deleted, and that file cannot be editted, created or deleted.</li> <li id="rzxomak" class="reference"><strong>410 - Gone</strong><br /> A 410 status code is the 404's lesser known cousin. It indicates that a resource has permanently gone (a 404 status code gives no indication if a resource has gine permanently or temporarily), and no new address is known for it.</li> <li id="ebduwvf" class="reference"><strong>411 - Length Required</strong><br /> The 411 status code occurs when a server refuses to process a request because a content length was not specified.</li> <li id="owjarbe" class="reference"><strong>412 - Precondition Failed</strong><br /> A 412 status code indicates that one of the conditions the request was made under has failed.</li> <li id="mjldhzr" class="reference"><strong>413 - Request Entity Too Large</strong><br /> The 413 status code indicates that the request was larger than the server is able to handle, either due to physical constraints or to settings. Usually, this occurs when a file is sent using the POST method from a form, and the file is larger than the maximum size allowed in the server settings.</li> <li id="olcauml" class="reference"><strong>414 - Request-URI Too Long</strong><br /> The 414 status code indicates the the URL requested by the client was longer than it can process.</li> <li id="cdjlneh" class="reference"><strong>415 - Unsupported Media Type</strong><br /> A 415 status code is returned by a server to indicate that part of the request was in an unsupported format.</li> <li id="zececmh" class="reference"><strong>416 - Requested Range Not Satisfiable</strong><br /> A 416 status code indicates that the server was unable to fulfill the request. This may be, for example, because the client asked for the 800th-900th bytes of a document, but the document was only 200 bytes long.</li> <li id="nsuwjpo" class="reference"><strong>417 - Expectation Failed</strong><br /> The 417 status code means that the server was unable to properly complete the request. One of the headers sent to the server, the "Expect" header, indicated an expectation the server could not meet.</li> </ul> <h3>Server Error</h3> <ul> <li id="dtrikjm" class="reference"><strong>500 - Internal Server Error</strong><br /> A 500 status code (all too often seen by Perl programmers) indicates that the server encountered something it didn't expect and was unable to complete the request.</li> <li id="kwnegjx" class="reference"><strong>501 - Not Implemented</strong><br /> The 501 status code indicates that the server does not support all that is needed for the request to be completed.</li> <li id="muljscb" class="reference"><strong>502 - Bad Gateway</strong><br /> A 502 status code indicates that a server, while acting as a proxy, received a response from a server further upstream that it judged invalid.</li> <li id="eulypsg" class="reference"><strong>503 - Service Unavailable</strong><br /> A 503 status code is most often seen on extremely busy servers, and it indicates that the server was unable to complete the request due to a server overload.</li> <li id="emouldj" class="reference"><strong>504 - Gateway Timeout</strong><br /> A 504 status code is returned when a server acting as a proxy has waited too long for a response from a server further upstream.</li> <li id="yvtvqtw" class="reference"><strong>505 - HTTP Version Not Supported</strong><br /> A 505 status code is returned when the HTTP version indicated in the request is no supported. The response should indicate which HTTP versions are supported.</li> </ul> </div><img src ="http://www.tkk7.com/usherlight/aggbug/324225.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/usherlight/" target="_blank">云自无心水自?/a> 2010-06-23 07:16 <a href="http://www.tkk7.com/usherlight/archive/2010/06/23/324225.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java comm操作串口http://www.tkk7.com/usherlight/archive/2010/06/18/323829.html云自无心水自?/dc:creator>云自无心水自?/author>Fri, 18 Jun 2010 09:06:00 GMThttp://www.tkk7.com/usherlight/archive/2010/06/18/323829.htmlhttp://www.tkk7.com/usherlight/comments/323829.htmlhttp://www.tkk7.com/usherlight/archive/2010/06/18/323829.html#Feedback0http://www.tkk7.com/usherlight/comments/commentRss/323829.htmlhttp://www.tkk7.com/usherlight/services/trackbacks/323829.html阅读全文

]]>
在myeclipse8.5中安装反~译插g(java decompiler)http://www.tkk7.com/usherlight/archive/2010/06/17/323676.html云自无心水自?/dc:creator>云自无心水自?/author>Wed, 16 Jun 2010 22:18:00 GMThttp://www.tkk7.com/usherlight/archive/2010/06/17/323676.htmlhttp://www.tkk7.com/usherlight/comments/323676.htmlhttp://www.tkk7.com/usherlight/archive/2010/06/17/323676.html#Feedback0http://www.tkk7.com/usherlight/comments/commentRss/323676.htmlhttp://www.tkk7.com/usherlight/services/trackbacks/323676.html"java decompiler"是一个非常出色的java反编译工P详见主页Qhttp://java.decompiler.free.fr/

在myeclipse8.5中的安装也比较简单,下蝲Qhttp://java.decompiler.free.fr/jd-eclipse/update/jdeclipse_update_site.zip
然后把这个压~包解开攑֜myeclipse8.5的dropins目录下,比如QC:\Programs\Genuitec\MyEclipse-8.5\dropins\jdeclipse_update_site
重vmyeclipsep了,W一ơ打开class文gQ可能会E微有一Ҏ(gu)Q要{待一会才会反编译出来?br />

好像q有炚w?



]]>
Windows7下可以用的免费虚拟光驱软ghttp://www.tkk7.com/usherlight/archive/2010/06/16/323664.html云自无心水自?/dc:creator>云自无心水自?/author>Wed, 16 Jun 2010 12:08:00 GMThttp://www.tkk7.com/usherlight/archive/2010/06/16/323664.htmlhttp://www.tkk7.com/usherlight/comments/323664.htmlhttp://www.tkk7.com/usherlight/archive/2010/06/16/323664.html#Feedback0http://www.tkk7.com/usherlight/comments/commentRss/323664.htmlhttp://www.tkk7.com/usherlight/services/trackbacks/323664.htmlISO, CUE, NRG, MDS/MDF, CCD, IMG




]]>
Spring Security - Using custom Authentication Processing Filterhttp://www.tkk7.com/usherlight/archive/2010/06/11/323293.html云自无心水自?/dc:creator>云自无心水自?/author>Fri, 11 Jun 2010 00:12:00 GMThttp://www.tkk7.com/usherlight/archive/2010/06/11/323293.htmlhttp://www.tkk7.com/usherlight/comments/323293.htmlhttp://www.tkk7.com/usherlight/archive/2010/06/11/323293.html#Feedback0http://www.tkk7.com/usherlight/comments/commentRss/323293.htmlhttp://www.tkk7.com/usherlight/services/trackbacks/323293.html springSecurityFilterChain org.springframework.web.filter.DelegatingFilterProxy springSecurityFilterChain /* REQUEST INCLUDE FORWARD If you want to externalize all of your security related configuration into a separate file, you can do so and add that to your context location param. contextConfigLocation /WEB-INF/beans.xml , /WEB-INF/springSecurity.xml Now comes the part of security configuration for your application, Adding the URL security patterns is pretty simple and straight forward. Add all the URL patterns which you want to secure and add the wild card pattern at the end. You need to have some default principal and role even for non logged in users as you need to give access to pages like log in, register and forgot password kind of functionality even to non logged in users. I tried to add comments to pretty much every element which I am using here. As an example I added just a wild card intercept url which make every page of my application secure. You need to exclude different urls based on the roles. Following is my custom implementation of AuthenticationEntryPoint, which currently is not doing any thing except leveraging the commence to its super class which is the spring implementation of AuthenticationProcessingFilterEntryPoint. I hooked it to add any custom logic. public class CustomAuthenticationEntryPoint extends AuthenticationProcessingFilterEntryPoint { private static final Log logger = LogFactory.getLog(CustomAuthenticationEntryPoint.class); @Override public void commence(ServletRequest request, ServletResponse response, AuthenticationException authException) throws IOException, ServletException { super.commence(request, response, authException); } } This is my custom authentication manager which actually does the custom login of the user. It will throw an BadCredentialsException in case of invalid credentials or thorws a AuthenticationServiceException in case of a service error (Database error, SQL error or any other error). public class CustomAuthunticationManager implements AuthenticationManager { @Autowired UserManagerService userManagerService; public Authentication authenticate(Authentication authentication) throws AuthenticationException { if(StringUtils.isBlank((String) authentication.getPrincipal()) || StringUtils.isBlank((String) authentication.getCredentials())){ throw new BadCredentialsException("Invalid username/password"); } User user = null; GrantedAuthority[] grantedAuthorities = null; try{ user = userManagerService.getUser((String) authentication.getPrincipal(), (String) authentication.getCredentials()); } catch(InvalidCredentialsException ex){ throw new BadCredentialsException(ex.getMessage()); } catch(Exception e){ throw new AuthenticationServiceException("Currently we are unable to process your request. Kindly try again later."); } if (user != null) { List roles = user.getAssociatedRoles(); grantedAuthorities = new GrantedAuthority[roles.size()]; for (int i = 0; i < roles.size(); i++) { Role role = roles.get(i); GrantedAuthority authority = new GrantedAuthorityImpl(role.getRoleCode()); grantedAuthorities[i] = authority; } } else{ throw new BadCredentialsException("Invalid username/password"); } return new UsernamePasswordAuthenticationToken(user, authentication.getCredentials(), grantedAuthorities); } } At the client side (jsp), the simple configuration you need to do is post the request to"/j_spring_security_check" with parameters "j_username" and "j_password". That's pretty much all you need to do for enabling spring security to your existing web application. I will try to explain about doing the method security using ACL's and configuring the view using spring security tags in another post.

]]>
վ֩ģ壺 þù׾Ʒǿ| þþþƷƵѹۿ | ˳ŮƬ߲| 鶹avŮһ| ޳Ļ| ҹëƬavþþ | ԺȫƵƵ| Ʒһ| Ƶ߹ۿ| ҹŮëƬѹۿ| ѹ99þþ㽶| ߾ƷƵ| ɫվWWWþþž| ޹ۺһҳ| ޹av߹ۿ| þùѹۿƷ| ޾Ʒ˾þþ| ŷ޹Ʒ㽶| ˾Ʒһѿ| ߿ƬvѹۿƵ777| ޹Ʒ˾Ʒ| ޶·Ļ߿| ɫͷۺƵ| ëƬ벥 | һ˿wwwƵ| 4399ÿձߵӰ| AVþþƷ| AVһ| ߾Ʒ| ҹ޾ƷƬ| ޹Ʒ˾þõӰ| þùƷѹۿ| ȫԼƵ| žAV뾫ƷëƬ| 182tvƵ߹ۿ| þþþAVרվ| ҹ޾Ʒ| Ʒһvr| ҹδʮվ2| Ӱ߹ۿ| Ƶһ|