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 阅读(1101) | 评论 (0)编辑 收藏

2006年8月15日

1. 某个service的参数有复杂对象时,如果要用默认的beanmapping,记得这个对象要有的默认构造器(空参数构造器),不然Axis在处理的时候会所有的字段都是同一个值..至于原因我没搞清楚-,-~~
2. 不要用List,尽量用数组!
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 阅读(258) | 评论 (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 阅读(231) | 评论 (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!");
    }

}

用起来还是很简单,唯一要注意的是用Axis生成Web Service的时候记得在global configuration里面改一下
<parameter name="sendMultiRefs" value="false"/>

ie下的话也有一个webservice.htc,没仔细研究过..

posted @ 2006-07-11 12:13 Jedi 阅读(823) | 评论 (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 阅读(284) | 评论 (0)编辑 收藏

2006年6月24日

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

以我的机器为例
我得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,它是为了让你的机器可以运行 java程序的
只能运行,不能开发,因为没有javac
这个jre可以单独安装,版本一样的话都一样(根据licene,好象目前不允许剪裁)

jre b 是随jdk的,不能不装,因为  jdk>jre  jdk也需要jre啊
就是装jdk就会出现这个jre b

一点高级的,jrea 和 jreb有什么不同

jreb 是为jdk服务的,它有jrea的全部功能,同时为了jdk服务,它的类库,比方说rt.jar
,多一些调试信息,因为开发java程序,会调试啊,用jrea没办法调试,比方说不能断点到
 基础类库里面
看jrea和b的rt.jar 大小不一样,jreb的大一些,带有调试信息(主要是class里的
LineNumberTable) ,所以运行时,jreb的速度或者载入速度难免慢一些,或者说,用jdk运
行java程序比jre运行慢一些,虽然你感觉不到,至少class尺寸上不一样

 

posted @ 2006-06-24 03:26 Jedi 阅读(307) | 评论 (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 阅读(1298) | 评论 (0)编辑 收藏