jabsorb筆記_幾個(gè)小例子第1/2頁
更新時(shí)間:2008年10月11日 18:50:14 作者:
研究了一下 jabsorb,寫了幾個(gè)簡單的例子,希望能夠幫助菜鳥快速入門。
研究了一下 jabsorb,寫了幾個(gè)簡單的例子,希望能夠幫助菜鳥快速入門。
首先引用jabsorb-1.2.2.jar,slf4j-api-1.4.2.jar,slf4j-jdk14-1.4.2.jar,jsonrpc.js
類文件:
package com.test;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class TestJabsorb {
public String getMessage(String s) {
return "你好: " + s;
}
public String getMessage() {
return "無參數(shù)";
}
public String getMessage(List al) {
String res="list參數(shù):";
for(Iterator it = al.iterator();it.hasNext();){
Object next = it.next();
res+=next+",";
}
return res;
}
public String getMessage(String[] array) {
String res="數(shù)組參數(shù):";
for(int i=0;i<array.length;i++){
res+=array[i]+",";
}
return res;
}
public String getMessage(Map map) {
String res="map參數(shù):";
Set entrySet = map.entrySet();
for(Iterator it = entrySet.iterator();it.hasNext();){
Object next = it.next();
res+=next+",";
}
return res;
}
public String getMessage(Test2 t2) {
String res="Test2(bean)參數(shù):";
res+=t2.p1+",";
res+=t2.p2+",";
return res;
}
public String getMessage(Test3 t2) {
String res="Test3(bean)參數(shù):";
res+=t2.p1+",";
res+=t2.p2+",";
return res;
}
public Test2 getMessage2() {
Test2 res=new Test2();
res.p1="11";
res.p2="22";
return res;
}
public Test3 getMessage3() {
Test3 res=new Test3();
res.p1="11";
res.p2="22";
return res;
}
public List getList()
{
List list = new LinkedList();
list.add("中國");
list.add(1234);
return list;
}
public Map getMap()
{
Map map = new HashMap();
map.put("bird", "鳥");
map.put("human", "人類");
return map;
}
}
package com.test;
public class Test2{
public String p1;
public String p2;
public String getP1() {
return p1;
}
public void setP1(String p1) {
this.p1 = p1;
}
public String getP2() {
return p2;
}
public void setP2(String p2) {
this.p2 = p2;
}
}
首先引用jabsorb-1.2.2.jar,slf4j-api-1.4.2.jar,slf4j-jdk14-1.4.2.jar,jsonrpc.js
類文件:
package com.test;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class TestJabsorb {
public String getMessage(String s) {
return "你好: " + s;
}
public String getMessage() {
return "無參數(shù)";
}
public String getMessage(List al) {
String res="list參數(shù):";
for(Iterator it = al.iterator();it.hasNext();){
Object next = it.next();
res+=next+",";
}
return res;
}
public String getMessage(String[] array) {
String res="數(shù)組參數(shù):";
for(int i=0;i<array.length;i++){
res+=array[i]+",";
}
return res;
}
public String getMessage(Map map) {
String res="map參數(shù):";
Set entrySet = map.entrySet();
for(Iterator it = entrySet.iterator();it.hasNext();){
Object next = it.next();
res+=next+",";
}
return res;
}
public String getMessage(Test2 t2) {
String res="Test2(bean)參數(shù):";
res+=t2.p1+",";
res+=t2.p2+",";
return res;
}
public String getMessage(Test3 t2) {
String res="Test3(bean)參數(shù):";
res+=t2.p1+",";
res+=t2.p2+",";
return res;
}
public Test2 getMessage2() {
Test2 res=new Test2();
res.p1="11";
res.p2="22";
return res;
}
public Test3 getMessage3() {
Test3 res=new Test3();
res.p1="11";
res.p2="22";
return res;
}
public List getList()
{
List list = new LinkedList();
list.add("中國");
list.add(1234);
return list;
}
public Map getMap()
{
Map map = new HashMap();
map.put("bird", "鳥");
map.put("human", "人類");
return map;
}
}
package com.test;
public class Test2{
public String p1;
public String p2;
public String getP1() {
return p1;
}
public void setP1(String p1) {
this.p1 = p1;
}
public String getP2() {
return p2;
}
public void setP2(String p2) {
this.p2 = p2;
}
}
相關(guān)文章
JavaScript面向?qū)ο蟪绦蛟O(shè)計(jì)三 原型模式(上)
在javaScript面向?qū)ο笤O(shè)計(jì)一和Javascript面向?qū)ο笤O(shè)計(jì)二中分別介紹了工廠模式和構(gòu)造函數(shù)模式,以及他們格式的優(yōu)缺點(diǎn),今天繼續(xù)講解原型模式2011-12-12JavaScript的單例模式 (singleton in Javascript)
JavaScript的單例模式 (singleton in Javascript)2010-06-06javascript new一個(gè)對象的實(shí)質(zhì)
javascript 中,new一個(gè)對象的實(shí)質(zhì)是什么?即,當(dāng)我們構(gòu)建一個(gè)類的實(shí)例的時(shí)候,真正做了些什么?2010-01-01實(shí)現(xiàn)JavaScript中繼承的三種方式
在JavaScript中,繼承可以通過三種手法實(shí)現(xiàn)原型鏈繼承 使用apply、call方法 對象實(shí)例間的繼承。2009-10-10Javascript面向?qū)ο髷U(kuò)展庫代碼分享
最近一直在用js做項(xiàng)目,遇到了許多需要應(yīng)用面向?qū)ο髞碓O(shè)計(jì)的功能,由于js對OOP的原生支持還不是很完善,所以就寫了一個(gè)面向?qū)ο蟮臄U(kuò)展庫用做底層支持,現(xiàn)在把它單獨(dú)整理出來,完善了一些功能,在這里分享一下2012-03-03