posts - 7, comments - 1, trackbacks - 0, articles - 0

          2006年9月1日

          1. mysql driver -> server\default\lib
          2. jdbc connection datasource server/default/deploy/mysql-xa-ds.xml
          <?xml version="1.0" encoding="UTF-8"?>
          <datasources>
          ?<xa-datasource>
          ??<jndi-name>MySqlXADS</jndi-name>
          ??<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
          ??<xa-datasource-property name="Url">jdbc:mysql://127.0.0.1:3306/temp</xa-datasource-property>
          ??<xa-datasource-property name="User">root</xa-datasource-property>
          ??<xa-datasource-property name="Password">....</xa-datasource-property>
          ??<user-name>root</user-name>
          ??<password>.....</password>
          ??<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
          ??<metadata>
          ???<type-mapping>mySQL</type-mapping>
          ??</metadata>
          ?</xa-datasource>
          </datasources>

          3. server/default/conf/standardjbosscmp-jdbc.xml
          <defaults>
          ????? <datasource>java:/MySqlXADS</datasource>
          ????? <datasource-mapping>mySQL</datasource-mapping>
          ....
          ....??
          </defaults>

          4. server/default/conf/jboss-service.xml
          <mbean code="org.jboss.tm.XidFactory"
          ????? name="jboss:service=XidFactory">
          ?//uncommented the line below...
          ????? <attribute name="Pad">true</attribute>
          ?? </mbean>

          posted @ 2006-09-01 08:55 Jedi 閱讀(1120) | 評(píng)論 (0)編輯 收藏

          2006年8月15日

          1. 某個(gè)service的參數(shù)有復(fù)雜對(duì)象時(shí),如果要用默認(rèn)的beanmapping,記得這個(gè)對(duì)象要有的默認(rèn)構(gòu)造器(空參數(shù)構(gòu)造器),不然Axis在處理的時(shí)候會(huì)所有的字段都是同一個(gè)值..至于原因我沒搞清楚-,-~~
          2. 不要用List,盡量用數(shù)組!
          ValueBean[]?getValues()?
          ????
          {?
          ????????ArrayList?result?
          =?new?ArrayList();?
          ????????
          return?(ValueBean[])?result.toArray();?
          ????}
          上面的代碼還是會(huì)出問題,要用iterator一個(gè)一個(gè)map過去
          public?class?ValueHelper?
          ????
          {?
          ????????
          public?static?ValueBean[]?toArray(List?values)?
          ????????
          {
          ????????????ValueBean[]?result?
          =?new?ValueBean[values.size()];?
          ????????????Iterator?i?
          =?values.iterator();?
          ????????????
          int?i?=?0;?
          ????????????
          while?(i.hasNext())?
          ????????????
          {?
          ????????????????ValueBean?value?
          =?(ValueBean)?i.next();?
          ????????????????result[i
          ++]?=?value;?
          ????????????}
          ?
          ????????????
          return?result;?
          ????????}
          ?
          ????}
          ?
          ????ValueBean[]?getValues()?
          {?
          ????????ArrayList?result?
          =?new?ArrayList();??
          ????????
          return?ValueHelper.toArray(result);?
          ????}
          3. 要生成符合ws-i的web service最好用document/literal
          <service name="MyWebRes" provider="java:RPC" style="document "use="literal">

          posted @ 2006-08-15 09:22 Jedi 閱讀(278) | 評(píng)論 (0)編輯 收藏

          http://www.fiddlertool.com/fiddler/?
          .net framework 1.1 needed

          for firefox need some added configurat

          menu->tools->preference/option->connection settings->bottom->

          C:\Documents and Settings\jedikings\My Documents\Fiddler\Scripts\BrowserPAC.js -> reload

          posted @ 2006-08-15 09:15 Jedi 閱讀(247) | 評(píng)論 (0)編輯 收藏

          2006年7月11日

          var ?proxy = ? null ;
          ? function??getTest()??//?test?by?the?way?amazon?uses
          {
          ????
          if?(!proxy)?{
          ????????
          var?listener?=?{?
          ????????
          //?gets?called?once?the?proxy?has?been?instantiated
          ????????????onLoad:?function?(aProxy)?
          ????????????
          {
          ????????????????proxy?
          =?aProxy;
          ????????????????proxy.setListener(listener);
          ????????????????requestTest();
          ????????????}
          ,
          ????????
          //?gets?called?if?an?error?occurs
          ????????????onError:?function?(aError)?
          ????????????
          {
          ????????????????alert(aError);
          ????????????}
          ,
          ????????
          //?callback?function?is?hardcoded?to?{methodname}Callback?in?1.4beta
          ????????????getInstanceByIDCallback?:?function?(aresult)?
          ????????????
          {
          ????????????????alert(
          "enter?callback");??????????????
          ????????????????
          //alert("a="+aresult.a+",?b="+aresult.b);
          ????????????}

          ????????}
          ;
          ????????createProxy(listener);
          ????}

          ????
          else?{
          ????????requestTest(
          );
          ????}

          }

          function?createProxy(aCreationListener)?
          {
          ????
          try?{
          ????????
          var?factory?=?new?WebServiceProxyFactory();
          ????????factory.createProxyAsync("...wsdl location...."
          ,?"binding name",?"",?true,?aCreationListener);
          ????}

          ????
          catch?(ex)?{
          ????????alert(
          "test?"+?ex);
          ????}

          }


          function??requestTest()?
          {
          ????
          if?(proxy)?{
          ????????netscape.security.PrivilegeManager.enablePrivilege(
          "UniversalBrowserRead");
          ????????
          ????????
          /*
          ????????//?if?complex?object?is?the?parameter
          ????????var?KeywordSearchRequest?=?new?Object();????????
          ????????KeywordSearchRequest.page="1";
          ????????KeywordSearchRequest.mode="books";
          ????????KeywordSearchRequest.tag="webservices-20";
          ????????KeywordSearchRequest.type="lite";
          ????????KeywordSearchRequest.devtag="D2Z2KU2NWTOHI";
          ????????KeywordSearchRequest.format="xml";
          ????????KeywordSearchRequest.version="1.0";
          ????????
          */

          ????????proxy.getInstanceByID(
          "id.....");
          ????????alert(
          "call?complete!");
          ????}

          ????
          else?{
          ????????alert(
          "Error:?Proxy?set?up?not?complete!");
          ????}

          }

          用起來還是很簡(jiǎn)單,唯一要注意的是用Axis生成Web Service的時(shí)候記得在global configuration里面改一下
          <parameter name="sendMultiRefs" value="false"/>

          ie下的話也有一個(gè)webservice.htc,沒仔細(xì)研究過..

          posted @ 2006-07-11 12:13 Jedi 閱讀(846) | 評(píng)論 (0)編輯 收藏

          2006年7月9日

          public ? class ?Singleton?{

          ????
          private ? volatile ? static ?Singleton?uniqueInstance;
          ????
          private ?Singleton(){
          ????????
          ????}
          ????
          ????
          public ? static ?Singleton?getInstance(){
          ????????
          if (uniqueInstance == null ){
          ????????????
          synchronized (Singleton. class ){
          ????????????????
          if (uniqueInstance == null ){
          ????????????????????uniqueInstance?
          = ? new ?Singleton();
          ????????????????}
          ????????????}
          ????????}????????
          ????????
          return ?uniqueInstance;?
          ????}

          }

          1. private constructor
          2. static getInstance
          3. syncronized..waste a lot of time
          4. double check..modified syncronize, so time-waste might occurs only when first time the instance construct

          posted @ 2006-07-09 12:42 Jedi 閱讀(303) | 評(píng)論 (0)編輯 收藏

          2006年6月24日

          http://www.newsmth.net/bbscon.php?bid=756&id=53934

          以我的機(jī)器為例
          我得jdk裝在了
          C:\Program Files\Java\jdk1.5.0_06
          安裝這個(gè)jdk的時(shí)候,它要求我安裝jre,我也選擇裝了,裝在了
          C:\Program Files\Java\jre1.5.0_06

          然后? C:\Program Files\Java\jdk1.5.0_06\ 目錄下有個(gè)jre目錄
          就是存在? C:\Program Files\Java\jdk1.5.0_06\jre? 這么一個(gè)jre

          C:\Program Files\Java\jre1.5.0_06? 我們叫它 jre a
          C:\Program Files\Java\jdk1.5.0_06\jre? 我們叫它 jre b

          平常所說的jre是指? 這里的jre a,它是為了讓你的機(jī)器可以運(yùn)行 java程序的
          只能運(yùn)行,不能開發(fā),因?yàn)闆]有javac
          這個(gè)jre可以單獨(dú)安裝,版本一樣的話都一樣(根據(jù)licene,好象目前不允許剪裁)

          jre b 是隨jdk的,不能不裝,因?yàn)? jdk>jre? jdk也需要jre啊
          就是裝jdk就會(huì)出現(xiàn)這個(gè)jre b

          一點(diǎn)高級(jí)的,jrea 和 jreb有什么不同

          jreb 是為jdk服務(wù)的,它有jrea的全部功能,同時(shí)為了jdk服務(wù),它的類庫,比方說rt.jar
          ,多一些調(diào)試信息,因?yàn)殚_發(fā)java程序,會(huì)調(diào)試啊,用jrea沒辦法調(diào)試,比方說不能斷點(diǎn)到
          ?基礎(chǔ)類庫里面
          看jrea和b的rt.jar 大小不一樣,jreb的大一些,帶有調(diào)試信息(主要是class里的
          LineNumberTable) ,所以運(yùn)行時(shí),jreb的速度或者載入速度難免慢一些,或者說,用jdk運(yùn)
          行java程序比jre運(yùn)行慢一些,雖然你感覺不到,至少class尺寸上不一樣

          ?

          posted @ 2006-06-24 03:26 Jedi 閱讀(324) | 評(píng)論 (1)編輯 收藏

          2006年6月13日

          Problem:???Started with a simple SimUDuck App..
          ???Joe's company?makes a duck pond simulation game, SimUDuck, The game can show a large variety of duck species swimming and making quacking sounds.

          Initial Design:
          diagram.JPG
          But now some new functionality should be added, for example: we need some of the ducks to FLY.

          First Design:
          ???We add a method fly() into the Duck class. It seems worked, but something went horribly wrong because not all ducks can fly. so....

          Second Design:?Using inheritance and polymorphism
          ???Always override the fly() mehtod in the subclass where needed.

          test.JPG
          ???

          ???Drawbacks:?Everytime a new duck is added, you will be forced to look at and possibly override fly() and quack(). so is there a cleaner way of having only some of the duck types fly or quack?

          Third Design: Using interface!
          ???test1.JPG
          Drawbacks: It completely destroy code reuse for those behaviors.

          1. Design Principles: Identify the aspects of your application that vary and separate them form what stays the same!
          ?????????????????????????????? which means Encapsulate the parts that vary!
          2. Design Principles: Program to an interface, not an implementation! (interface here means supertype! including interface
          ???????????????????????????????and abstract class!.. making use of the polymorphism functionality).
          3. Design?Principles:??Favor composition over interface!?

          Strategy Pattern: Using Composition!
          test2.JPG

          Code implement:
          FlyBehavior.java
          public?interface?FlyBehavior{
          ???
          public?void?fly();
          }

          FlyWithWings.java
          public?class?FlyWithWings?implements?FlyBehavior{
          ???
          public?void?fly(){
          ??????System.out.println(
          "I'm?flying!!");
          ???}

          }

          FlyNoWay.java
          public?class?FlyNoWay?implements?FlyBehavior{
          ???
          public?void?fly(){
          ??????System.out.println(
          "I?can't?fly");
          ???}

          }

          Duck.java
          public?abstract?class?Duck{
          ???FlyBehavior?flyBehavior;
          ???
          public?Duck(){??????
          ???}

          ???
          ???
          public?abstract?void?display();
          ???
          ???
          public?void?performFly(){
          ??????flyBehavior.fly();
          ???}

          ???
          ???
          public?void?swim(){
          ??????System.out.println(
          "All?ducks?float,?even?decoys!");
          ???}

          }

          MallardDuck.java
          public?class?MallardDuck{
          ???
          public?MallardDuck(){
          ??????flyBehavior
          =new?FlyWithWings();??????
          ???}

          ???
          ???
          public?void?display(){
          ??????System.out.println(
          "I'm?a?real?mallard?duck");
          ???}

          }

          The Definition?of Strategy Pattern:?The?Strategy Pattern defines a family of algorithms, encapsulates each one, and makes them intercahgeable. Strategy lets the algorithm vary indepanedtl from client?that use it
          ?
          Problems:
          1. It's weird to have a class that's jast a behavior: classes represent things both have state and methods. a flying behavior might have instance variables representing the attributes for the flying behavior.
          2.?Be care?of?Over-Design: implement your code first, then refractoring!

          posted @ 2006-06-13 12:42 Jedi 閱讀(1318) | 評(píng)論 (0)編輯 收藏

          主站蜘蛛池模板: 大足县| 张家界市| 海南省| 凤山市| 遂溪县| 雅安市| 潜江市| 正定县| 石首市| 邓州市| 扎鲁特旗| 青川县| 湟源县| 邢台县| 开封县| 遂宁市| 柳江县| 高要市| 赣榆县| 湖北省| 大庆市| 昌吉市| 广宁县| 江陵县| 九台市| 内江市| 瑞金市| 米林县| 宜川县| 临清市| 河北区| 金门县| 罗城| 巴彦县| 荆门市| 汉阴县| 沙田区| 砀山县| 宿州市| 兖州市| 从化市|