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

          2006年6月13日

          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 閱讀(1125) | 評論 (0)編輯 收藏

          1. 某個service的參數(shù)有復(fù)雜對象時,如果要用默認(rèn)的beanmapping,記得這個對象要有的默認(rèn)構(gòu)造器(空參數(shù)構(gòu)造器),不然Axis在處理的時候會所有的字段都是同一個值..至于原因我沒搞清楚-,-~~
          2. 不要用List,盡量用數(shù)組!
          ValueBean[]?getValues()?
          ????
          {?
          ????????ArrayList?result?
          =?new?ArrayList();?
          ????????
          return?(ValueBean[])?result.toArray();?
          ????}
          上面的代碼還是會出問題,要用iterator一個一個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 閱讀(284) | 評論 (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 閱讀(253) | 評論 (0)編輯 收藏

          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!");
          ????}

          }

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

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

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

          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 閱讀(307) | 評論 (0)編輯 收藏

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

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

          然后? C:\Program Files\Java\jdk1.5.0_06\ 目錄下有個jre目錄
          就是存在? C:\Program Files\Java\jdk1.5.0_06\jre? 這么一個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ā),因為沒有javac
          這個jre可以單獨安裝,版本一樣的話都一樣(根據(jù)licene,好象目前不允許剪裁)

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

          一點高級的,jrea 和 jreb有什么不同

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

          ?

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

          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 閱讀(1326) | 評論 (0)編輯 收藏

          主站蜘蛛池模板: 临澧县| 汾西县| 神池县| 昆明市| 台东县| 蒙自县| 沅江市| 安康市| 清原| 卓尼县| 开鲁县| 苏州市| 郁南县| 中山市| 彩票| 辽源市| 喀喇沁旗| 丰镇市| 清涧县| 平南县| 福州市| 黎城县| 华阴市| 渭南市| 宝应县| 察雅县| 门头沟区| 基隆市| 宜城市| 玉树县| 永泰县| 阳江市| 墨玉县| 仙游县| 宜章县| 平武县| 武清区| 黎川县| 呈贡县| 富蕴县| 甘南县|