??xml version="1.0" encoding="utf-8" standalone="yes"?>欧美日韩精品中文字幕,日韩精品网站,手机在线一区二区三区 http://www.aygfsteel.com/toby/category/38380.htmlzh-cn Thu, 16 May 2013 06:34:47 GMT Thu, 16 May 2013 06:34:47 GMT 60 eclipse install record http://www.aygfsteel.com/toby/archive/2013/05/16/399347.htmltobyxiong tobyxiong Thu, 16 May 2013 03:31:00 GMT http://www.aygfsteel.com/toby/archive/2013/05/16/399347.html http://www.aygfsteel.com/toby/comments/399347.html http://www.aygfsteel.com/toby/archive/2013/05/16/399347.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/399347.html http://www.aygfsteel.com/toby/services/trackbacks/399347.html http://www.eclipse.org/downloads/
2.subclipse
http://subclipse.tigris.org/servlets/ProjectProcess?pageID=p4wYuA
3.startexplorer
http://basti1302.github.io/startexplorer/
4.m2eclipse
http://wiki.eclipse.org/Maven_Integration
5.sonar
http://dist.sonar-ide.codehaus.org/eclipse/
6.eclemma
http://update.eclemma.org/
]]>maven related knowledge http://www.aygfsteel.com/toby/archive/2013/05/06/398857.htmltobyxiong tobyxiong Mon, 06 May 2013 05:58:00 GMT http://www.aygfsteel.com/toby/archive/2013/05/06/398857.html http://www.aygfsteel.com/toby/comments/398857.html http://www.aygfsteel.com/toby/archive/2013/05/06/398857.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/398857.html http://www.aygfsteel.com/toby/services/trackbacks/398857.html 阅读全文 ]]> Subversion中的关键字替?/title> http://www.aygfsteel.com/toby/archive/2012/08/07/385005.htmltobyxiong tobyxiong Tue, 07 Aug 2012 10:06:00 GMT http://www.aygfsteel.com/toby/archive/2012/08/07/385005.html http://www.aygfsteel.com/toby/comments/385005.html http://www.aygfsteel.com/toby/archive/2012/08/07/385005.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/385005.html http://www.aygfsteel.com/toby/services/trackbacks/385005.html 1.先打开TortoiseSVN -> Settings -> General -> Subversion configuration file 点击Edit 2.*.java=svn:keywords=Author Date Id Rev URL 3.文g中用 $Author$ $Date$ $Id$ $Rev$ $URL$ 来替?br /> 4.CZQ?br /> * $Author: xweixio $
* $Date: 2012-08-07 18:12:14 +0800 (Tue, 07 Aug 2012) $
* $Id: Test.java 924070 2012-08-07 10:12:14Z xweixio $
* $Rev: 924070 $
* $URL: http://150.236.80.220/dev/dgc/adcampaign/releases/2.1.0-139/src/java/com/drutt/tpim/Test.java $
5.下面是完整写?br />
Subversion 中可以用的 Keyword 包括下面q些?/span>Id q是一U综合的格式Q例?#8220;$Id: V2EXCore.php 4 2005-10-29 23:08:09Z livid $”?/li>LastChangedDate 最后被修改的时_q个属性也可以~写?Date?/li>LastChangedBy 最后修改该源代码文件的用户名,q个属性也可以被羃写ؓ Author?/li>LastChangedRevision 最后修订的版本Pq个属性也可以被羃写ؓ Revision 或?Rev?/li>HeadURL 该源代码文g所位于?Repository 上的l对 URL 地址Q这个属性也可以被羃写ؓ URL?/li> ]]> 记录 http://www.aygfsteel.com/toby/archive/2012/03/31/373169.htmltobyxiong tobyxiong Sat, 31 Mar 2012 15:20:00 GMT http://www.aygfsteel.com/toby/archive/2012/03/31/373169.html http://www.aygfsteel.com/toby/comments/373169.html http://www.aygfsteel.com/toby/archive/2012/03/31/373169.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/373169.html http://www.aygfsteel.com/toby/services/trackbacks/373169.html 一、有没有写过自定义classloader 二、本地去更新q程服务器上容器代码的方?br />三、两个对象的hashcode一栯明就是同一个对象吗 四?/strong>java中关键字volatile的作?/strong>一般说?volatile用在如下的几个地方:
1、中断服务程序中修改的供其它E序的变量需要加volatile;
2、多d环境下各d间共享的标志应该加volatile;
3、存储器映射的硬件寄存器通常也要加volatile说明,因ؓ每次对它的读写都可能׃同意?
另外,以上q几U情늻常还要同时考虑数据的完整性(怺兌的几个标志读了一半被打断了重写),?中可以通过关中断来实现,2中可以禁止Q务调?3中则只能依靠g的良好设计了?br style="line-height: normal; " /> 其实Volatile是由于编译器优化所造成的一个Bug而引入的关键字?br style="line-height: normal; " />int a = 10; int b = a; int c = a; 理论上来讲每ơ用a的时候都应该从a的地址来读取变量|但是q存在一个效率问题,是每次使用a都要d存中取变量|然后再通过pȝȝ传到CPU 处理Q这样开销会很大。所以那些编译器优化者故作聪明,把a读进CPU的cache里,像上面的代码Q假如a在赋值期间没有被改变Q就直接从CPU?cache里取a的副本来q行赋倹{但是bug也显而易见,当a在赋lb之后Q可能a已经被另一个线E改变而重新写回了内存Q但q个U程q不知道Q依旧按 照原来的计划从CPU的cache里读a的副本进来赋值给cQ结果不q发生了?br style="line-height: normal; " />于是~译器的开发者ؓ了补救这一bugQ提供了一个Volatile让开发h员ؓ他们的过失埋单,或者说提供l开发h员了一个选择效率的权利。当变量加上了VolatileӞ~译器就老老实实的每次都从内存中读取这个变量|否则p按照优化的方案从cache里读
五、spring在项目中的应用,??br />六、maven的好?br />七、硬引用和Y引用区别 强引用和弱引用区?/strong>1Q强引用 本章前文介绍的引用实际上都是强引用,q是使用最普遍的引用。如果一个对象具有强引用Q那qg必不可少的生zȝ品,垃圾回收器绝不会回收它。当内存I?间不IJava 虚拟机宁愿抛出OutOfMemoryError错误QɽE序异常l止Q也不会靠随意回收具有强引用的对象来解决内存不问题?/p>
2QY引用QSoftReferenceQ?/strong>
如果一个对象只h软引用,那就cM于可有可物的生活用品。如果内存空间够,垃圾回收器就不会回收它,如果内存I间不了,׃回收q些对象的内存。只要垃圑֛收器没有回收它,该对象就可以被程序用。Y引用可用来实现内存敏感的高速缓存?br />软引用可以和一个引用队列(ReferenceQueueQ联合用,如果软引用所引用的对象被垃圾回收Q?a target="_blank" style="color: #5fa207; text-decoration: none; ">Java虚拟机就会把q个软引用加入到与之兌的引用队列中?/p>
3Q弱引用QWeakReferenceQ?/strong> 如果一个对象只h弱引用,那就cM于可有可物的生活用品。弱引用与Y引用的区别在于:只具有弱引用的对象拥有更短暂的生命周期。在垃圾回收器线E扫描它 所辖的内存区域的q程中,一旦发C只具有弱引用的对象,不管当前内存I间_与否Q都会回收它的内存。不q,׃垃圾回收器是一个优先很低的线E, 因此不一定会很快发现那些只具有弱引用的对象?nbsp; 弱引用可以和一个引用队列(ReferenceQueueQ联合用,如果弱引用所引用的对象被垃圾回收QJava虚拟机就会把q个弱引用加入到与之兌的引用队列中?/p>4Q虚引用QPhantomReferenceQ?/strong> "虚引?思义Q就是Ş同虚设,与其他几U引用都不同Q虚引用q不会决定对象的生命周期。如果一个对象仅持有虚引用,那么它就和没有Q何引用一P在Q何时候都可能被垃圑֛收?br />虚引用主要用来跟t对象被垃圾回收的活动。虚引用与Y引用和弱引用的一个区别在于:虚引用必d引用队列QReferenceQueueQ联合用。当?圑֛收器准备回收一个对象时Q如果发现它q有虚引用,׃在回收对象的内存之前Q把q个虚引用加入到与之兌的引用队列中。程序可以通过判断引用队列中是 否已l加入了虚引用,来了?/p> 被引用的对象是否要被垃圑֛收。程序如果发现某个虚引用已经被加入到引用队列Q那么就可以在所引用的对象的内存被回收之前采取必要的行动?br />
八、行业网关主要的业务是什?br />九、客L理发展的主要产品有哪?br />十、webservice服务端具体开?br /> String webserviceurl = "http://wt.lmobile.cn:6003/submitdata/MmsWebInterface.asmx";
MmsWebInterfaceLocator mwifl = new MmsWebInterfaceLocator();
MmsWebInterfaceSoap mwifs = mwifl.getMmsWebInterfaceSoap(new java.net.URL(webserviceurl));
http://apps.hi.baidu.com/share/detail/23852724
十一、java虚拟Z的内存模型及主要法。堆栈区?br />十二?net和java中传输基本类型时大端及小端避免办?br />十三、sessioin和cookie区别 十四、hash实现对key和value的排?br />十五、如何在代码中中断一个线EQ?br />十六、动态代理和cglig区别 十七、java中是g递还是引用传?br />十八、java中集合类底层数据l构 十九、threadlocal解释 二十、状态模式、责任链模式、适配器模式、观察者模式、工厂方法、抽象工厂,各属于创建型、行为型q是什么型 二十一、面象对象设计原?br />二十二、uml各图Q特别是时序?br />二十四、敏捷快发理?br />二十五、写一个编译器最快算?a+(b*c))*(d+e)正确Q?)a+c则出?br />二十六、linix中Y链接和硬链接区别Q?gt; >> 的区别,扑և一个文件中W四行和W五行的命o1. 软连接(W号链接Q?ln -s source target
2. 链?ln source target
知道了inode的作用就不难理解软硬链接的区别了?/span>
软连接相当于快捷方式Q如果打开q修改Yq接Q相应的文g也会随之改变。但是如果删除Yq接Q源文gq不会受到媄响?/span> 链接有点像引用和指针的l合Q当打开和修改它Ӟ相应的文仉之改变,但是所有这个文件的链接的内容也随之改变,q是因ؓ所有的链接都拥有唯一的一?inode P他们指向的是同一文g?/span> 软连接可以跨文gpȝ创徏Q也是可以在某个分Z创徏到另外一个分区的软连?/span> 链接则只能在本文gpȝ中用(xZ么?Q,其实原理很简单,因ؓ inode 是这个文件在当前分区中的索引|是相对于q个分区的,当然不能跨越文gpȝ了?/span> 最后一个区别是软连接可以连接Q何文件或者文件夹Q而硬链接则只能在文g之间创徏 > 输出重定向,内容会全部覆? >>是追?nbsp; sed -n '5,10p' filename q样你就可以只查看文件的W?行到W?0?/span> 二十七、java基础斚w书籍 二十八、加?br />二十九、jdk5和jdk6的新Ҏ?br /> netstat -ano | findstr "1433"
]]>
重构JDK中的decodeҎ http://www.aygfsteel.com/toby/archive/2012/03/20/372298.htmltobyxiong tobyxiong Tue, 20 Mar 2012 09:39:00 GMT http://www.aygfsteel.com/toby/archive/2012/03/20/372298.html http://www.aygfsteel.com/toby/comments/372298.html http://www.aygfsteel.com/toby/archive/2012/03/20/372298.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/372298.html http://www.aygfsteel.com/toby/services/trackbacks/372298.html 在实际用时会存?net语言中的encode。然后java中decode出来的结果不一P以下军_? /** * add by
* @param str
* @param enc
* @return
* @throws UnsupportedEncodingException
*/
public static String decode(String str, String enc) throws UnsupportedEncodingException{
if (enc.length() == 0) {
throw new UnsupportedEncodingException ("URLDecoder: empty string enc parameter");
}
List l = new LinkedList();
int strLen = str.length();
for(int i=0;i<strLen;++i){
char c = str.charAt(i);
switch (c) {
case '+':
l.add((byte)' ');
break;
case '%':
byte b = (byte)Integer.parseInt(str.substring(i+1, i+3),16);
l.add(b);
i+=2;
break;
default:
l.add((byte)str.charAt(i));
break;
}
}
byte[] bs = new byte[l.size()];
for(int i=0;i<l.size();++i)
bs[i] = (Byte)l.get(i);
return new String(bs,enc);
}
]]>另一U责任链实现模式 http://www.aygfsteel.com/toby/archive/2012/03/15/371916.htmltobyxiong tobyxiong Thu, 15 Mar 2012 03:18:00 GMT http://www.aygfsteel.com/toby/archive/2012/03/15/371916.html http://www.aygfsteel.com/toby/comments/371916.html http://www.aygfsteel.com/toby/archive/2012/03/15/371916.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/371916.html http://www.aygfsteel.com/toby/services/trackbacks/371916.html package com.toby.zerenliang;public interface IHandle { /** * 逻辑处理 * * @param mtMsg MT数据 * @return 成功q回true,否则false */ public boolean process(MtMsg mtMsg); /** * 增加下Handler.寄主Handler可以看情况调用该下Handler * * @param hdl 下Handler * @return 下Handler */ public IHandle addNextHandler(IHandle hdl); }package com.toby.zerenliang;
public class MtMsg {
public int age;
public String name;
}
package com.toby.zerenliang;
public class OneHandler
implements IHandle {
private IHandle nextHdl;
@Override
public IHandle addNextHandler(IHandle hdl) {
this .nextHdl = hdl;
return this .nextHdl;
}
@Override
public boolean process(MtMsg mtMsg) {
/** * 业务逻辑处理 */ System.out.println("业务逻辑处理one");
if (nextHdl !=
null )
return nextHdl.process(mtMsg);
else return true ;
}
}
package com.toby.zerenliang;
public class TwoHandler
implements IHandle {
private IHandle nextHdl;
@Override
public IHandle addNextHandler(IHandle hdl) {
this .nextHdl = hdl;
return this .nextHdl;
}
@Override
public boolean process(MtMsg mtMsg) {
/** * 业务逻辑处理 */ System.out.println("业务逻辑处理two");
if (nextHdl !=
null )
return nextHdl.process(mtMsg);
else return true ;
}
}
package com.toby.zerenliang;public class Test { /** * @param args */ public static void main(String[] args) { MtMsg mm = new MtMsg(); mm.age = 17; mm.name = "名字"; IHandle iHandle = new OneHandler(); iHandle.addNextHandler(new TwoHandler()); iHandle.process(mm); } }
]]>jstat,jmap,jconsole,jvisualvm,jps,jinfo{JDKpȝ监控、性能调优工具 http://www.aygfsteel.com/toby/archive/2012/02/07/369544.htmltobyxiong tobyxiong Tue, 07 Feb 2012 09:02:00 GMT http://www.aygfsteel.com/toby/archive/2012/02/07/369544.html http://www.aygfsteel.com/toby/comments/369544.html http://www.aygfsteel.com/toby/archive/2012/02/07/369544.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/369544.html http://www.aygfsteel.com/toby/services/trackbacks/369544.html jmap -heap:format=b pid bin格式 javaversion 1.5
jmap -dump:format=b,file=filename pid javaversion >1.6
工具名称QIBM HeapAnalyzer
JProfiler在javaE序性能调试方便表现优越Q推荐用。也可用下面jdk自己的一些工兗?/p>
所有工具都在JDK/bin目录下, jconsole和jvisualvm为GUI囑Ş化工P其他为命令行?/p>
jvisualvm: GUI工具Q可监控、性能评估、故障诊断主Z所有javaq程的cpuQ内存,U程使用情况Q类gJProfilerQ严重推荐?/p>
jinfo:可以输出q修改运行时的java q程的opts?/p>
jps:与unix上的pscMQ用来显C本地的javaq程Q可以查看本地运行着几个javaE序Qƈ昄他们的进E号?/p>
jstat:一个极强的监视VM内存工具。可以用来监视VM内存内的各种堆和非堆的大及其内存用量?/p>
jmap:打印出某个javaq程Q用pidQ内存内的,所?#8216;对象’的情况(如:产生那些对象Q及其数量)?/p>
jconsole:一个java GUI监视工具Q可以以图表化的形式昄各种数据。ƈ可通过q程q接监视q程的服务器VM?/p>
jstat工具特别强大Q有众多的可选项Q详l查看堆内各个部分的使用量,以及加蝲cȝ数量。用时Q需加上查看q程的进EidQ和所选参数。以下详l介l各个参数的意义?/p>
jstat -class pid:昄加蝲class的数量,及所占空间等信息?br />
jstat -compiler pid:昄VM实时~译的数量等信息?br />
jstat -gc pid:可以昄gc的信息,查看gc的次敎ͼ及时间。其中最后五,分别是young gc的次敎ͼyoung gc的时_full gc的次敎ͼfull gc的时_gc的L间?br />
jstat -gccapacity:可以昄QVM内存中三代(young,old,permQ对象的使用和占用大,如:PGCMN昄的是最perm的内存用量QPGCMX昄的是perm的内存最大用量QPGC是当前新生成的perm内存占用量,PC是但前perm内存占用量。其他的可以Ҏq个cLQ?OC是old内纯的占用量?br />
jstat -gcnew pid:new对象的信息?br />
jstat -gcnewcapacity pid:new对象的信息及其占用量?br />
jstat -gcold pid:old对象的信息?br />
jstat -gcoldcapacity pid:old对象的信息及其占用量?br />
jstat -gcpermcapacity pid: perm对象的信息及其占用量?br />
jstat -util pid:l计gc信息l计?br />
jstat -printcompilation pid:当前VM执行的信息?br />
除了以上一个参数外Q还可以同时加上 两个数字Q如Qjstat -printcompilation 3024 250 6是每250毫秒打印一ơ,一共打?ơ,q可以加?h3每三行显CZ下标题?/p>
jmap是一个可以输出所有内存中对象的工P甚至可以VM 中的heapQ以二进制输出成文本。用方?jmap -histo pid。如果连用SHELL jmap -histo pid>a.log可以其保存到文本中去,在一D|间后Q用文本对比工P可以Ҏ出GC回收了哪些对象。jmap -dump:format=b,file=String 3024可以?024q程的内存heap输出出来到String文g里?/p>
jinfo:的用处比较简单,是能输出ƈ修改q行时的javaq程的运行参数。用法是jinfo -opt pid 如:查看2788的MaxPerm大小可以?nbsp; jinfo -flag MaxPermSize 2788?/p>
jconsole是一个用java写的GUIE序Q用来监控VMQƈ可监控远E的VMQ非常易用,而且功能非常强。由于是GUIE序Q这里就不详l介l了Q不会的地方可以参考SQN的官Ҏ档?br />
使用ҎQ命令行里打 jconsoleQ选则q程可以了?/p>
SUN官方说明Q?/p>
jvisualvm: http://java.sun.com/javase/6/docs/technotes/tools/share/jvisualvm.html
jps:http://java.sun.com/javase/6/docs/technotes/tools/share/jps.html
jstat:http://java.sun.com/javase/6/docs/technotes/tools/share/jstat.html
jmap:http://java.sun.com/javase/6/docs/technotes/tools/share/jmap.html
jconsole:http://java.sun.com/javase/6/docs/technotes/tools/share/jconsole.html
在一ơ解决系ltomcat老是内存撑到_然后崩溃的问题时Q用到了jmap?
1 使用命o
在环境是linux+jdk1.5以上Q这个工h自带的,路径在JDK_HOME/bin/?
jmap -histo pid>a.log
2 输出l果摘要
Size Count Class description
-------------------------------------------------------
353371288 9652324 char[]
230711112 9612963 java.lang.String
139347160 114865 byte[]
76128096 3172004 java.util.Hashtable$Entry
75782280 3157595 com.test.util.IPSeeker$IPLocation
25724272 9115 java.util.Hashtable$Entry[]
9319968 166428 org.apache.tomcat.util.buf.MessageBytes
8533856 32889 int[]
发现有大量的String和自定义对象com.test.util.IPSeeker$IPLocation存在Q检查程序发现此处果然存在内存溢出。修改程序上U后再次用jmap抓取内存数据Q?
146881712 207163 byte[]
98976352 354285 char[]
42595272 53558 int[]
11515632 479818 java.util.HashMap$Entry
9521896 59808 java.util.HashMap$Entry[]
8887392 370308 com.test.bean.UnionIPEntry
8704808 155443 org.apache.tomcat.util.buf.MessageBytes
8066880 336120 java.lang.String
内存溢出问题消除?
注意Q?span style="color: red">q个jmap使用的时候jvm是处在假ȝ态的Q只能在服务瘫痪的时候ؓ了解决问题来使用Q否则会造成服务中断?/span>
@import url(http://www.aygfsteel.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css); ]]> mvn报错QNo goals have been specified for this build http://www.aygfsteel.com/toby/archive/2012/02/03/369314.htmltobyxiong tobyxiong Fri, 03 Feb 2012 03:32:00 GMT http://www.aygfsteel.com/toby/archive/2012/02/03/369314.html http://www.aygfsteel.com/toby/comments/369314.html http://www.aygfsteel.com/toby/archive/2012/02/03/369314.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/369314.html http://www.aygfsteel.com/toby/services/trackbacks/369314.html 选择【Run As?【Maven build】的时候,报:
[INFO] Scanning for projects…[INFO]
[INFO] BUILD FAILURE[INFO]
[INFO] Total time: 0.109s[INFO] Finished at: Wed Apr 13 11:04:20 CST 2011[INFO] Final Memory: 1M/4M[INFO]
ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources,
process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-
test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy,
pre-clean, clean, post-clean. -> [Help 1][ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.[ERROR] Re-run Maven using the -X switch to enable full debug logging.[ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles:[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException
eclipse安装的maven插g是m2eclipseQ在控制C用命令mvn compileq未报错。后在pom.xml文g<build>标签后面加上<defaultGoal>compile</defaultGoal>卛_?/p>
其实使用命o行时已l指定了phaseQ而用m2eclipse的【Run As?【Maven build】时q未为其指定goal或phaseQ所以才报这个错误?/p>
@import url(http://www.aygfsteel.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
]]>Remove @Override annotation错误提示 http://www.aygfsteel.com/toby/archive/2012/01/09/368153.htmltobyxiong tobyxiong Mon, 09 Jan 2012 08:49:00 GMT http://www.aygfsteel.com/toby/archive/2012/01/09/368153.html http://www.aygfsteel.com/toby/comments/368153.html http://www.aygfsteel.com/toby/archive/2012/01/09/368153.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/368153.html http://www.aygfsteel.com/toby/services/trackbacks/368153.html 因ؓ对于JDK5.0/1.5版本来说Q@Override annotation只能用与对超cȝҎ重写上,
而不能用在对接口Ҏ的实现方法上?/h2>
解决的方法是把JDK改ؓ1.6的或动手把注释@OverrideL?br />
You probably need to set the compiler compliance level in eclipse. This can be found in Window->Preferences->Java->Compiler
@import url(http://www.aygfsteel.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css); ]]> memcache存取数据注意事项 http://www.aygfsteel.com/toby/archive/2011/12/30/367562.htmltobyxiong tobyxiong Fri, 30 Dec 2011 03:14:00 GMT http://www.aygfsteel.com/toby/archive/2011/12/30/367562.html http://www.aygfsteel.com/toby/comments/367562.html http://www.aygfsteel.com/toby/archive/2011/12/30/367562.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/367562.html http://www.aygfsteel.com/toby/services/trackbacks/367562.html 问题描述
1.如果setqmemcache的entity的包l构攑֜com.ttt?br />
2.如果get出memcache的entity的包l构攑֜com.ooo?拿取不到数?br />
解决办法
1.l一get和set的entity包结?br />
原因分析
memcachejava的客Ljar包ؓ设计ZR入式Q?br />
以后可考虑Q自定义序列化算?存进d先序列化Q要先的时候获取出来后再反序列化@import url(http://www.aygfsteel.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css); ]]> 各数据交换的协议优劣比较 http://www.aygfsteel.com/toby/archive/2011/12/26/367165.htmltobyxiong tobyxiong Mon, 26 Dec 2011 02:57:00 GMT http://www.aygfsteel.com/toby/archive/2011/12/26/367165.html http://www.aygfsteel.com/toby/comments/367165.html http://www.aygfsteel.com/toby/archive/2011/12/26/367165.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/367165.html http://www.aygfsteel.com/toby/services/trackbacks/367165.html
如何选择数据交换协议
选择什么样的协议跟我们的应用场景有很大的关pR我们需要考虑我们开发是否方ѝ接口是否容易发布、是否需要考虑带宽占用成本、序列化和反序列化的性能、接口协议的扩展性等{。下面我们看下几个比较常用的交换协议实现?/p>
协议
实现
跨语a
性能
传输?/td>
RPC
xml
q泛
几乎所?/td>
?/td>
很大
NQ可实现Q?/td>
json
q泛
大量
一?/td>
一?/td>
NQ可实现Q?/td>
php serialize
PHPRPC
大量
一?/td>
一?/td>
Y
hessian
hessian
大量
一?/td>
?/td>
Y
thrift
thrift
大量
?/td>
?/td>
Y
protobuf
protobuf
大量
?/td>
?/td>
NQ可实现Q?/td>
ice
ice
大量
?/td>
?/td>
Y
avro
Apache Avro
量
?/td>
?/td>
Y
messagepack
messagepack
大量
?/td>
?/td>
Y
上面表格列出了一些常用数据交换协议的一些特性的比较。这里ƈ没有比较好坏Q只是想说明不同数据交换协议是有区别的,所以我们需要在我们的应用场景中q行选择?br />
messagepack 相关资料
http://pluto418.iteye.com/blog/1108457
优势Q?br />
1.序列化和反序列化所需要的旉。通过30000条的记录来测试,msgpack序列化的旉比用jason来序列化JSON的时间要三分之一Q而反序列化的旉则要一半?br />
2.生成的文件体U小。同样也是基?0000条记录来试Qmsgpack序列化后生成的二q制文g比用jason序列化出来的旉要少一半?/strong>
劣势Q?br />
1.msgpack对复杂的数据cdQList、MapQ支持的不够Q序列化没有问题Q但是反序列化回来就很麻烦,其是对于java开发h员?br />
2.在上面也提到q,msgpack是通过value的顺序来定位属性的Q那么需要在不同的语a中都要维护同L模型以及模型中属性的序。这个会让开发h员很困扰?br />
3.msgpack无法支持在模型中包含和嵌套其他自定义的模型(如weibo模型中包含comment的列表)?br />
@import url(http://www.aygfsteel.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css); ]]>jdk各版本下载地址 http://www.aygfsteel.com/toby/archive/2011/12/13/366202.htmltobyxiong tobyxiong Tue, 13 Dec 2011 02:08:00 GMT http://www.aygfsteel.com/toby/archive/2011/12/13/366202.html http://www.aygfsteel.com/toby/comments/366202.html http://www.aygfsteel.com/toby/archive/2011/12/13/366202.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/366202.html http://www.aygfsteel.com/toby/services/trackbacks/366202.html ]]>java复制文g或文件夹 http://www.aygfsteel.com/toby/archive/2011/12/05/365585.htmltobyxiong tobyxiong Mon, 05 Dec 2011 06:17:00 GMT http://www.aygfsteel.com/toby/archive/2011/12/05/365585.html http://www.aygfsteel.com/toby/comments/365585.html http://www.aygfsteel.com/toby/archive/2011/12/05/365585.html#Feedback 8 http://www.aygfsteel.com/toby/comments/commentRss/365585.html http://www.aygfsteel.com/toby/services/trackbacks/365585.html 阅读全文 ]]> 单例模式的一些版本及演变q程 http://www.aygfsteel.com/toby/archive/2011/11/21/364438.htmltobyxiong tobyxiong Mon, 21 Nov 2011 07:28:00 GMT http://www.aygfsteel.com/toby/archive/2011/11/21/364438.html http://www.aygfsteel.com/toby/comments/364438.html http://www.aygfsteel.com/toby/archive/2011/11/21/364438.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/364438.html http://www.aygfsteel.com/toby/services/trackbacks/364438.html
版本一:只支持单U程Q多U程W一ơ实例化会有两个实例生成
class Foo {
private Helper helper = null ;
public Helper getHelper() {
if (helper == null )
helper = new Helper();
return helper;
}
// other functions and members...
}
版本二:多线E版?每个U程q来都会到要到synchronized Ҏ块,q样处理效率较低.W一个初始化helper的时候需要locking(加锁)Q而后面取用helper的时候,Ҏ不需要线E同?/strong>
// Correct multithreaded version
class Foo {
private Helper helper = null ;
public synchronized Helper getHelper() {
if (helper == null )
helper = new Helper();
return helper;
}
// other functions and members...
}
版本三:解决每次新徏实例都要 synchronized的问题,q用双检锁来实现.此种Ҏ行不?/strong>
class Foo {
private Helper helper = null ;
public Helper getHelper() {
if (helper == null )
synchronized( this ) {
if (helper == null )
helper = new Helper();
}
return helper;
}
// other functions and members...
}
思\很简单,是我们只需要同步(synchronizeQ初始化helper的那部分代码从而代码既正又很有效率?/div>
q就是所谓的“双检?#8221;机制Q顾名思义Q?/div>
很可惜,q样的写法在很多q_和优化编译器上是错误的?/div>
原因在于Qhelper = new Helper()q行代码在不同编译器上的行ؓ是无法预知的。一个优化编译器可以合法地如下实现helper = new Helper():
1. helper = l新的实体分配内?/div>
2. 调用helper的构造函数来初始化helper的成员变?/div>
现在惌一下有U程A和B在调用getHelperQ线EA先进入,在执行到步骤1的时候被t出了cpu。然后线EBq入QB看到的是 helper已经不是null了(内存已经分配Q,于是它开始放心地使用helperQ但q个是错误的Q因为在q一时刻Qhelper的成员变量还都是~?省|Aq没有来得及执行步骤2来完成helper的初始化?/div>
当然~译器也可以q样实现Q?/div>
1. temp = 分配内存
2. 调用temp的构造函?/div>
3. helper = temp
如果~译器的行ؓ是这L话我们似乎就没有问题了,但事实却不是那么单,因ؓ我们无法知道某个~译器具体是怎么做的Q因为在Java?memory model里对q个问题没有定义QC++也一PQ而事实上有很多编译器都是用第一U方法(比如symantec的just-in-time compilerQ,因ؓW一U方法看h更自然?/div>
在上面的参考文章中q提C更复杂的修改ҎQ不q很可惜Q都是错误的
关于Out-of-order writes现象Q就?/div>
helper = new Helper();;
helper已经非空Q但对象q没完成实例化,即new new Helper()未完?/div>
详见Q?/div>
http://www.ibm.com/developerworks/java/library/j-dcl.html
版本四:目前知道最后版。实际应用时需验证一?/strong>
private volatile static Singleton instance;
public static Singleton getInstance() {
if (instance == null) {
synchronized(Singleton.class) { //1
if (instance == null) //2
instance = new Singleton(); //3
}
}
return instance;
}
因ؓ存在Out-of-order writes现象Q所以这里volatile关键字是在当instance被初始化lSingleton实例时保证多U程正确地处理instance变量Q那q里与线E间的可见性有兛_Q?/div>
我觉得与可见性无养I因ؓsynchronized block已经可以保证块内变量的可见性,q里应该是变量操作的原子?br />
http://en.wikipedia.org/wiki/Double-checked_locking
]]>手动d依赖的jar文g到maven仓库 http://www.aygfsteel.com/toby/archive/2011/11/02/362503.htmltobyxiong tobyxiong Wed, 02 Nov 2011 01:24:00 GMT http://www.aygfsteel.com/toby/archive/2011/11/02/362503.html http://www.aygfsteel.com/toby/comments/362503.html http://www.aygfsteel.com/toby/archive/2011/11/02/362503.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/362503.html http://www.aygfsteel.com/toby/services/trackbacks/362503.html 在编写maven目的程序时Q有时程序需要依赖于某一个类库jar文g。但是由于mavenq程仓库
q不含有该文Ӟ所以不能利用maven自n插g自动在其q程仓库下蝲。我们需要手动将其添?/p>
到本地的仓库中,q样才能~译依赖于这个类库的工程?/p>
-------------------------------------------------------------------------------------
是自q写的一个jar文gQ每ơ添加单个jar到maven本地仓库的操作如下:
# 建立一个新的文件夹Q将jar文g存放在该文g夹下?/p>
注意文g夹下最好只存放该文件?/p>
# 在该文g夹下建立一个pom.xml文gQ在pom文g中定义其maven坐标?/p>
# 在cmdH口中执行以下命令:
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
例如Q?/p>
mvn install:install-file -Dfile=/home/hjq/sms.jar -DgroupId=ufmobile -DartifactId=sms -Dversion=3.0 -Dpackaging=jar
如此一来,该jar便安装成功了?/p>
注意Q如若运行该命oQ前提是安装了一个非eclipse插g的maven?/p>
---------------------------------------------------------------------------------------
# 如果在其他project中用到该jarcd作ؓ依赖Q在其pom.xml中增加相应的依赖代码卛_?/p>
如下语句所C:
<dependency>
<groupId>ufmobile</groupId>
<artifactId>sms</artifactId>
<version>3.0</version>
</dependency>
备注Q很多h都曾l在|上发帖探讨q这个问题?/p>
有的把这个简单问题搞的很复杂?/p>
有的人则认ؓ上面的那个cmd命o行不通,原因可能是没有dpom文g?/p>
=============================================================================================
? 技巧:
# 其实如果可以在网上下载jar文g和其pom文gQ?/p>
则可以按以下步骤更方便:
jar和pom导入eclipse中作Z个新的工E,利用install命oq行该工E即?/p>
五、实际运行命?/span>
mvn install:install-file -Dfile=D:/玄武|关/|关模块/Ud|关CMPP/newcmpp/lib/newcomapi.jar -DgroupId=com.xuanwu -DartifactId=newcomapi -Dversion=1.0 -Dpackaging=jar q样的好处是要安装的jar文g的依赖会Ҏ其pom自动的安装。而不必手动的安装该jar文g的依赖?br />
@import url(http://www.aygfsteel.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css); ]]> maven实际应用 http://www.aygfsteel.com/toby/archive/2011/11/01/362460.htmltobyxiong tobyxiong Tue, 01 Nov 2011 09:22:00 GMT http://www.aygfsteel.com/toby/archive/2011/11/01/362460.html http://www.aygfsteel.com/toby/comments/362460.html http://www.aygfsteel.com/toby/archive/2011/11/01/362460.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/362460.html http://www.aygfsteel.com/toby/services/trackbacks/362460.html <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/200... 阅读全文 ]]> maven初步了解 http://www.aygfsteel.com/toby/archive/2011/11/01/362459.htmltobyxiong tobyxiong Tue, 01 Nov 2011 09:20:00 GMT http://www.aygfsteel.com/toby/archive/2011/11/01/362459.html http://www.aygfsteel.com/toby/comments/362459.html http://www.aygfsteel.com/toby/archive/2011/11/01/362459.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/362459.html http://www.aygfsteel.com/toby/services/trackbacks/362459.html 阅读全文 ]]> q行jar文g中某个类文g命o http://www.aygfsteel.com/toby/archive/2011/11/01/362439.htmltobyxiong tobyxiong Tue, 01 Nov 2011 06:22:00 GMT http://www.aygfsteel.com/toby/archive/2011/11/01/362439.html http://www.aygfsteel.com/toby/comments/362439.html http://www.aygfsteel.com/toby/archive/2011/11/01/362439.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/362439.html http://www.aygfsteel.com/toby/services/trackbacks/362439.html
2.java -jar target\hello-world-1.0-SNAPSHOT.jar@import url(http://www.aygfsteel.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css); ]]> eclipse自动排版讄 http://www.aygfsteel.com/toby/archive/2011/09/29/359790.htmltobyxiong tobyxiong Thu, 29 Sep 2011 07:47:00 GMT http://www.aygfsteel.com/toby/archive/2011/09/29/359790.html http://www.aygfsteel.com/toby/comments/359790.html http://www.aygfsteel.com/toby/archive/2011/09/29/359790.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/359790.html http://www.aygfsteel.com/toby/services/trackbacks/359790.html ]]>warning: sun.security.action.GetPropertyAction is Sun proprietary API and may be removed in a future release http://www.aygfsteel.com/toby/archive/2011/09/15/358678.htmltobyxiong tobyxiong Thu, 15 Sep 2011 02:14:00 GMT http://www.aygfsteel.com/toby/archive/2011/09/15/358678.html http://www.aygfsteel.com/toby/comments/358678.html http://www.aygfsteel.com/toby/archive/2011/09/15/358678.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/358678.html http://www.aygfsteel.com/toby/services/trackbacks/358678.html ]]>centos下安装was6.1 http://www.aygfsteel.com/toby/archive/2011/07/22/354867.htmltobyxiong tobyxiong Fri, 22 Jul 2011 09:13:00 GMT http://www.aygfsteel.com/toby/archive/2011/07/22/354867.html http://www.aygfsteel.com/toby/comments/354867.html http://www.aygfsteel.com/toby/archive/2011/07/22/354867.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/354867.html http://www.aygfsteel.com/toby/services/trackbacks/354867.html 1.下蝲was Q?a >https://www14.software.ibm.com/webapp/iwm/web/reg/download.do?source=was60&S_PKG=lnx61&S_TACT=109J84IW&S_CMP=web_dw_rt_swd&lang=en_US&cp=UTF-8&&&dlmethod=http#
用户名:
xiong_we_i@163.com 密码Q?23456
2. 取消 “启动第一步控制台”选项Q最后一步)。到此,已经完成?/span>WebSphere ȝ序的安装Q程序会自动创徏一个名?/span>AppSrv01 的“概要表”,Q注Q这里的“概要表”相当于 weblogic 中的一个?/span>domain-server ”)。点凅R完成】完成安?br />3.启动报错 [7/22/11 16:39:22:552 CST] 0000000a WsServerImpl E WSVR0009E: Error occurred during startup META-INF/ws-server-components.xml [7/22/11 16:39:22:580 CST] 0000000a WsServerImpl E WSVR0009E: Error occurred during startup com.ibm.ws.exception.ConfigurationError: com.ibm.ws.exception.ConfigurationError: javax.naming.ConfigurationException: Cannot get canonical host name for server 解决办法1.修改/etc/sysconfig/networ文g
# vi /etc/sysconfig/network NETWORKING=yes HOSTNAME=yourname Q在q修改hostnameQ把yourname换成你想用的名字Q?/p>
2.修改/etc/hosts里面的名?br />Q?vi /etc/hosts 127.0.0.1 localhost.localdomain localhost Q在q修改hostnameQ把末尾的localhost换成你想用的名字Q?/p>
3.最后在l端下执行: Qhostname ***** Q?****Z改后的hostnameQ即你想用的名字Q?br />特别提示 Q三处修改的名字要保持一_否则会出现问题。切记?br />4.启动 cd /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin [root@xiongwei2 bin]# ./startServer.sh server1 ADMU0116I: Tool information is being logged in file /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/server1/startServer.log ADMU0128I: Starting tool with the AppSrv01 profile ADMU3100I: Reading configuration for server: server1 ADMU3200I: Server launched. Waiting for initialization status. ADMU3000I: Server server1 open for e-business; process id is 35085.如果要卸?br /> [root@xiongwei2 uninstall]# pwd /opt/IBM/WebSphere/AppServer/uninstall 在这目录下命令卸载即?br />切不可通过pȝ工具卸蝲和删文g方式 6.讉K控制?br />https://192.168.0.189:9043/ibm/console/logon.jsp
]]>tomcat 5.5解压版到linix不能q行 http://www.aygfsteel.com/toby/archive/2011/07/15/354366.htmltobyxiong tobyxiong Fri, 15 Jul 2011 01:11:00 GMT http://www.aygfsteel.com/toby/archive/2011/07/15/354366.html http://www.aygfsteel.com/toby/comments/354366.html http://www.aygfsteel.com/toby/archive/2011/07/15/354366.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/354366.html http://www.aygfsteel.com/toby/services/trackbacks/354366.html 一.现象 Neither the JAVA_HOME nor the JRE_HOME environment variable is defined" echo "At least one of these environment variable is needed to run this program ?问题 linixpȝ中没有设|JAVA_HOME ?JRE_HOME 的环境变?br /> ?解决办法 1.讄pȝ的JAVA_HOME ?JRE_HOME 的环境变?br /> 2.catalina.sh和setclasspath.shq二个文仉部添?br />export JAVA_HOME=/usr/local/java export JRE_HOME=/usr/local/java/jre 以上二种办法任选其一卛_
]]> 枚DCZE序 http://www.aygfsteel.com/toby/archive/2011/05/23/350841.htmltobyxiong tobyxiong Mon, 23 May 2011 07:43:00 GMT http://www.aygfsteel.com/toby/archive/2011/05/23/350841.html http://www.aygfsteel.com/toby/comments/350841.html http://www.aygfsteel.com/toby/archive/2011/05/23/350841.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/350841.html http://www.aygfsteel.com/toby/services/trackbacks/350841.html
1
public
class
EnumTest
{
2
3
public
enum
MsgType
{
4
SMS(
"
this sms
"
), LONGSMS(
"
this is longsms
"
), MMS(
"
this is mms
"
), WAP_PUSH(
"
this is wap push
"
);
5
private
final
String index;
6
7
private
MsgType(String index)
{
8
this
.index
=
index;
9
}
10
11
/**/
/*
public int getIndex() {
12
return index;
13
}
*/
14
15
//
下面q段基本上不?/span>
16
public
static
MsgType getType(
int
index)
{
17
switch
(index)
{
18
case
0
:
19
return
SMS;
20
case
1
:
21
return
LONGSMS;
22
case
2
:
23
return
MMS;
24
case
3
:
25
return
WAP_PUSH;
26
default
:
27
return
SMS;
28
}
29
}
30
}
31
32
33
public
static
void
main(String []args)
{
34
System.out.println(MsgType.SMS);
35
System.out.println(MsgType.getType(
0
));
36
}
37
}
38
]]> 责Q链模?/title> http://www.aygfsteel.com/toby/archive/2011/05/18/350478.htmltobyxiong tobyxiong Wed, 18 May 2011 06:57:00 GMT http://www.aygfsteel.com/toby/archive/2011/05/18/350478.html http://www.aygfsteel.com/toby/comments/350478.html http://www.aygfsteel.com/toby/archive/2011/05/18/350478.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/350478.html http://www.aygfsteel.com/toby/services/trackbacks/350478.html 阅读全文 ]]> JAVAMAIL发送邮件程?/title> http://www.aygfsteel.com/toby/archive/2011/04/25/348979.htmltobyxiong tobyxiong Mon, 25 Apr 2011 08:12:00 GMT http://www.aygfsteel.com/toby/archive/2011/04/25/348979.html http://www.aygfsteel.com/toby/comments/348979.html http://www.aygfsteel.com/toby/archive/2011/04/25/348979.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/348979.html http://www.aygfsteel.com/toby/services/trackbacks/348979.html 阅读全文 ]]> eclipse 3.6.1 安装maven插gp|的解军_?/title> http://www.aygfsteel.com/toby/archive/2011/04/06/347713.htmltobyxiong tobyxiong Wed, 06 Apr 2011 08:44:00 GMT http://www.aygfsteel.com/toby/archive/2011/04/06/347713.html http://www.aygfsteel.com/toby/comments/347713.html http://www.aygfsteel.com/toby/archive/2011/04/06/347713.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/347713.html http://www.aygfsteel.com/toby/services/trackbacks/347713.html 一、eclipse 3.6.1下蝲地址[eclipse-jee-helios-SR1-win32.zip] http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/heliossr1 二、插件地址 1?strong>gef插g地址Q?http://download.eclipse.org/tools/gef/updates/interim/ 2?strong>subclipse插g地址Q?http://subclipse.tigris.org/update_1.6.x 3?strong>maven2插g地址Q? m2eclipse-core Update Site: http://m2eclipse.sonatype.org/sites/m2e m2eclipse-extras Update Site: http://m2eclipse.sonatype.org/sites/m2e-extras 注意 Q必M个插仉安装Q不安装extras 插gӞ点击“run as server”来q行目时会报错Q“the selected did not contain any resources that can run on server maven project? 三、安装时出现问题Q? 直接在线安装maven2 会出C赖插件找不到的问题,无法安装。必d安装gef 插g后才能安?strong>m2eclipse-core插gQ然而安?strong>m2eclipse-extras插g又依?strong>subclipse插g。所以,三个插g的正的安装序是:gef插g 》subclipse插g 》m2eclipse插g? m2eclipse-core插g ——依赖——>gef插g m2eclipse-extras插g ——依赖——>subclipse插g
]]>
servlet中实C载ؕ码解军_?/title> http://www.aygfsteel.com/toby/archive/2010/12/06/339902.htmltobyxiong tobyxiong Mon, 06 Dec 2010 07:42:00 GMT http://www.aygfsteel.com/toby/archive/2010/12/06/339902.html http://www.aygfsteel.com/toby/comments/339902.html http://www.aygfsteel.com/toby/archive/2010/12/06/339902.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/339902.html http://www.aygfsteel.com/toby/services/trackbacks/339902.html 下蝲文g名,最后改?ISO8859_1q种~码Q就ok?img src ="http://www.aygfsteel.com/toby/aggbug/339902.html" width = "1" height = "1" /> ]]> 定时器和取得c\?/title> http://www.aygfsteel.com/toby/archive/2010/10/13/334988.htmltobyxiong tobyxiong Wed, 13 Oct 2010 02:15:00 GMT http://www.aygfsteel.com/toby/archive/2010/10/13/334988.html http://www.aygfsteel.com/toby/comments/334988.html http://www.aygfsteel.com/toby/archive/2010/10/13/334988.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/334988.html http://www.aygfsteel.com/toby/services/trackbacks/334988.html 二、定时器 Timer timer = new Timer(); TimerTask task = new ReportThread(); timer.schedule(task, 1000L, 60*60*1000*12L);//默认?2时q行一ơ,可根据实际情况调?br />在ReportThread中可以通过this.scheduledExecutionTime()获得最q一ơ运行的旉 三、时?br />SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); sdf.parse(date) sdf.format(date); 当天的前一?br />Calendar yestoday = Calendar.getInstance(); yestoday.add(Calendar.DAY_OF_MONTH, -1); ]]> axis1 ?axis2 的简单?/title> http://www.aygfsteel.com/toby/archive/2010/10/08/333983.htmltobyxiong tobyxiong Fri, 08 Oct 2010 08:17:00 GMT http://www.aygfsteel.com/toby/archive/2010/10/08/333983.html http://www.aygfsteel.com/toby/comments/333983.html http://www.aygfsteel.com/toby/archive/2010/10/08/333983.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/333983.html http://www.aygfsteel.com/toby/services/trackbacks/333983.html 晚上Z学习了下axis1 ?axis2Q发C者的API相差很大Q不知道现在更流行的是哪个,晚上简单的入门后觉得,axis2q是比axis1开发v来容易上手的多,axis1单单对服务器发?wsdd文gq当麻烦。下面分别就axis1和axis2说下如何集成到自q目里: 一、集成axis1 1、从官网下蝲目http://ws.apache.org/axis/ Q最新的?.4 2、解压下载的axis压羃包,假设AXIS_HOME压后的根目录Qdemo己项目的名称 3、将AXIS_HOME/lib目录下的所有jar包都复制到自己项目的WEB-INF/lib? 4、将AXIS_HOME/webapps/axis/WEB-INF/web.xml中与axis相关的配|都复制_脓到自己项目的web.xml中去? 5、编写需要发布SOAP服务的javac,注意要发布的Ҏ需是public的。以下以Foo.javaZQ? 6、接下来是发布soap服务了,在axis1中有两种发布方式Q即时发布和定制发布Q下面分别介l两U发布方式: 6.1 x发布Q这h式非常简单,Foo.java的后~名改成jws,即java.jwsQ然后把该文件放在项目里可以在客L直接讉K到的目录下(如WEB-INF׃可以Q,比如直接攑֜目demo的根目录下,通过http://L?demo/Foo.jws讉KQ如果看到Click to see the WSDLp明发布成功了Q点击进d能看WSDL的描q文件了。接下来可以写客户端测试代码了Q? 试代码׃说明了,怿大家能看明白。即时发布方式非常简单、快速,但前提是必须有需要发布soap服务的JAVAcȝ源文Ӟ如果只有.class或者jar包,那显然就不适用了? 6.2 定制发布Q定制发布相对于x发布要发杂一些,需要手写wsdd文g来描qweb serviceQ但是在牺牲了简单、快速之后,带来的却是灵zL和适用性的大大提高? 首先在WEB-INF/目录下创建deploy.wsdd文gQ文件内容如下: set AXIS_HOME=D:\axis
set AXIS_LIB=%AXIS_HOME%\lib
set AXISCLASSPATH=%AXIS_LIB%\axis.jar;%AXIS_LIB%\commons-discovery.jar; %AXIS_LIB%\commons-logging.jar;%AXIS_LIB%\jaxrpc.jar;%AXIS_LIB%\saaj.jar; %AXIS_LIB%\log4j-1.2.8.jar;%AXIS_LIB%\xml-apis.jar;%AXIS_LIB%\xercesImpl.jar
java -cp %AXISCLASSPATH% org.apache.axis.client.AdminClient -lhttp://localhost:8080/demo/services/AdminService deploy.wsdd 以上的三个set命oQ设|变量值AXISCLASSPATH为axis相关jar包\径集Qjava命o是通过axis提供的工LAdminClient来发布deploy.wsdd所描述的工LQ执行上面的命o之后Q保持服务器是启动状态)Q会在同一目录下生成server-config.wsdd文gQ说明发布成功。可以用6.1x发布中的客户端测试代码来试刚发布的soap服务Q修改下path的值即可? 二、集成axis2 之前的准备工作和集成axis1相同Q就是axis2所带的jar包非怹多,挑选必ȝjar可以了? 仍然以FoocMؓ例,在项目的WEB-INF/目录下徏立名为pojo的目录,然后Foo.class 文g攑օpojo目录中,q样发布完成了Q可以通过在浏览器输入http://L?demo/services/listServices来查看刚才发布的服务。简单吧Q这是axis2带来的无需M配置Q同样适合.class文g的发布方式。下面就是在客户端进行测试:
]]>
再一ơwebservice发布服务步骤记录 http://www.aygfsteel.com/toby/archive/2010/09/30/333563.htmltobyxiong tobyxiong Thu, 30 Sep 2010 08:36:00 GMT http://www.aygfsteel.com/toby/archive/2010/09/30/333563.html http://www.aygfsteel.com/toby/comments/333563.html http://www.aygfsteel.com/toby/archive/2010/09/30/333563.html#Feedback 0 http://www.aygfsteel.com/toby/comments/commentRss/333563.html http://www.aygfsteel.com/toby/services/trackbacks/333563.html 1.下蝲axis.war包。下载地址
http://download.csdn.net/source/177442
2.war包放到tomcat的\webapps目录?br />3.启动tomcat后。在览器键?/font>
http://localhost:8080/axis2/
q行讉KQ会出现axis2的成功页?br />4.点击
Administration
q个链接Q进入登录页面。用户名Qadmin 。密码:axis2 5.新徏java文g
package
test.joeyta;
public
class
HelloWorldService
{
public
String echo(String value)
{
//
這個 service 只是入的文字 return 出去
System.out.println(
"
Service HelloWorldService:
"
+
value);
return
value; }
}
6.新徏service.xml文g
<
service
>
<
parameter
name
="ServiceClass"
locked
="false"
>
test.joeyta.HelloWorldService
</
parameter
>
<
operation
name
="echo"
>
<
messageReceiver
class
="org.apache.axis2.rpc.receivers.RPCMessageReceiver"
/>
</
operation
>
</
service
>
7.打包Q打包前目录l构 --build
--ws_server
--META-INF
--services.xml
--test
--joeyta
--HelloWorldService.class
在windows环境下,在console下,更换目录到build\ws_server
输入一下命令:
jar –cf ws_server.aar . Q?span style="FONT-SIZE: 9pt">注意最后一个点代表当前目录?/span> 8.发布 发布Q?br /> AXIS2的webservice的发布是q样的,首先你要先把AXIS2的war distribution发到C个servlet容器中,我这里用的是Tomcat. 发布的方法前面提CQ把axis2.war拯?TOMCAT-HOME%/webapps下?br /> 启动tomcat,然后输入Q?a href="http://localhost:8080/axis2/axis2-admin/">http://localhost:8080/axis2/axis2-admin/ 输入用户名admin 密码axis2p入了axis2 Web Admin Module,然后在页面左边的菜单的Tools下选择Upload Service,然后选择前面打好的interop.aar upload. q有U手动发布的方式,你发布axis2.war 到tomcat的时候,tomcat会自动展开生成一个axis2的目录在 %TOMCAT-HOME%/webapps下面Q进入到目录%TOMCAT-HOME%\webapps\axis2\WEB-INF\servicesQ把前面打好包的interop.aar拯到这? 9.试的话可以看axis2客户端生成代码这?/font>
]]>
վ֩ģ壺
|
|
ɽ |
|
|
|
|
|
ԫ |
|
Ͷ |
ˮ |
۶ |
|
|
|
|
|
ī |
㶫ʡ |
|
|
ʻ |
ǿ |
Ԫ |
ˮ |
ƽ |
ǰ |
|
|
Т |
|
ʡ |
|
|
ɽ |
|
ǭ |
|
|
ƽ˳ |