<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-295  評論-26  文章-1  trackbacks-0
     

    ----------厚厚發表于 2006年06月27日

    網絡上很多關于JAVA對Oracle中BLOB、CLOB類型字段的操作說明,有的不夠全面,有的不夠準確,甚至有的簡直就是胡說八道。最近的項目正巧用到了這方面的知識,在這里做個總結。
    環境:
    Database: Oracle 9i
    App Server: BEA Weblogic 8.14
    表結構:
    CREATE TABLE TESTBLOB (ID Int, NAME Varchar2(20), BLOBATTR Blob)
    CREATE TABLE TESTBLOB (ID Int, NAME Varchar2(20), CLOBATTR Clob)
    JAVA可以通過JDBC,也可以通過JNDI訪問并操作數據庫,這兩種方式的具體操作存在著一些差異,由于通過App Server的數據庫連接池JNDI獲得的數據庫連接提供的java.sql.Blob和java.sql.Clob實現類與JDBC方式提供的不同,因此在入庫操作的時候需要分別對待;出庫操作沒有這種差異,因此不用單獨對待。

    一、BLOB操作
    1、入庫
    (1)JDBC方式
    //通過JDBC獲得數據庫連接
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:testdb", "test", "test");
    con.setAutoCommit(false);
    Statement st = con.createStatement();
    //插入一個空對象empty_blob()
    st.executeUpdate("insert into TESTBLOB (ID, NAME, BLOBATTR) values (1, "thename", empty_blob())");
    //鎖定數據行進行更新,注意“for update”語句
    ResultSet rs = st.executeQuery("select BLOBATTR from TESTBLOB where ID=1 for update");
    if (rs.next())
    {
    //得到java.sql.Blob對象后強制轉換為oracle.sql.BLOB
    oracle.sql.BLOB blob = (oracle.sql.BLOB) rs.getBlob("BLOBATTR");
    OutputStream outStream = blob.getBinaryOutputStream();
    //data是傳入的byte數組,定義:byte[] data
    outStream.write(data, 0, data.length);
    }
    outStream.flush();
    outStream.close();
    con.commit();
    con.close();
    (2)JNDI方式
    //通過JNDI獲得數據庫連接
    Context context = new InitialContext();
    ds = (DataSource) context.lookup("ORA_JNDI");
    Connection con = ds.getConnection();
    con.setAutoCommit(false);
    Statement st = con.createStatement();
    //插入一個空對象empty_blob()
    st.executeUpdate("insert into TESTBLOB (ID, NAME, BLOBATTR) values (1, "thename", empty_blob())");
    //鎖定數據行進行更新,注意“for update”語句
    ResultSet rs = st.executeQuery("select BLOBATTR from TESTBLOB where ID=1 for update");
    if (rs.next())
    {
    //得到java.sql.Blob對象后強制轉換為weblogic.jdbc.vendor.oracle.OracleThinBlob(不同的App Server對應的可能會不同)
    weblogic.jdbc.vendor.oracle.OracleThinBlob blob = (weblogic.jdbc.vendor.oracle.OracleThinBlob) rs.getBlob("BLOBATTR");
    OutputStream outStream = blob.getBinaryOutputStream();
    //data是傳入的byte數組,定義:byte[] data
    outStream.write(data, 0, data.length);
    }
    outStream.flush();
    outStream.close();
    con.commit();
    con.close();
    2、出庫
    //獲得數據庫連接
    Connection con = ConnectionFactory.getConnection();
    con.setAutoCommit(false);
    Statement st = con.createStatement();
    //不需要“for update”
    ResultSet rs = st.executeQuery("select BLOBATTR from TESTBLOB where ID=1");
    if (rs.next())
    {
    java.sql.Blob blob = rs.getBlob("BLOBATTR");
    InputStream inStream = blob.getBinaryStream();
    //data是讀出并需要返回的數據,類型是byte[]
    data = new byte[input.available()];
    inStream.read(data);
    inStream.close();
    }
    inStream.close();
    con.commit();
    con.close();
    二、CLOB操作
    1、入庫
    (1)JDBC方式
    //通過JDBC獲得數據庫連接
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:testdb", "test", "test");
    con.setAutoCommit(false);
    Statement st = con.createStatement();
    //插入一個空對象empty_clob()
    st.executeUpdate("insert into TESTCLOB (ID, NAME, CLOBATTR) values (1, "thename", empty_clob())");
    //鎖定數據行進行更新,注意“for update”語句
    ResultSet rs = st.executeQuery("select CLOBATTR from TESTCLOB where ID=1 for update");
    if (rs.next())
    {
    //得到java.sql.Clob對象后強制轉換為oracle.sql.CLOB
    oracle.sql.CLOB clob = (oracle.sql.CLOB) rs.getClob("CLOBATTR");
    Writer outStream = clob.getCharacterOutputStream();
    //data是傳入的字符串,定義:String data
    char[] c = data.toCharArray();
    outStream.write(c, 0, c.length);
    }
    outStream.flush();
    outStream.close();
    con.commit();
    con.close();
    (2)JNDI方式
    //通過JNDI獲得數據庫連接
    Context context = new InitialContext();
    ds = (DataSource) context.lookup("ORA_JNDI");
    Connection con = ds.getConnection();
    con.setAutoCommit(false);
    Statement st = con.createStatement();
    //插入一個空對象empty_clob()
    st.executeUpdate("insert into TESTCLOB (ID, NAME, CLOBATTR) values (1, "thename", empty_clob())");
    //鎖定數據行進行更新,注意“for update”語句
    ResultSet rs = st.executeQuery("select CLOBATTR from TESTCLOB where ID=1 for update");
    if (rs.next())
    {
    //得到java.sql.Clob對象后強制轉換為weblogic.jdbc.vendor.oracle.OracleThinClob(不同的App Server對應的可能會不同)
    weblogic.jdbc.vendor.oracle.OracleThinClob clob = (weblogic.jdbc.vendor.oracle.OracleThinClob) rs.getClob("CLOBATTR");
    Writer outStream = clob.getCharacterOutputStream();
    //data是傳入的字符串,定義:String data
    char[] c = data.toCharArray();
    outStream.write(c, 0, c.length);
    }
    outStream.flush();
    outStream.close();
    con.commit();
    con.close();
    2、出庫
    //獲得數據庫連接
    Connection con = ConnectionFactory.getConnection();
    con.setAutoCommit(false);
    Statement st = con.createStatement();
    //不需要“for update”
    ResultSet rs = st.executeQuery("select CLOBATTR from TESTCLOB where ID=1");
    if (rs.next())
    {
    java.sql.Clob clob = rs.getClob("CLOBATTR");
    Reader inStream = clob.getCharacterStream();
    char[] c = new char[(int) clob.length()];
    inStream.read(c);
    //data是讀出并需要返回的數據,類型是String
    data = new String(c);
    inStream.close();
    }
    inStream.close();
    con.commit();
    con.close();
    需要注意的地方:
    1、java.sql.Blob、oracle.sql.BLOB、weblogic.jdbc.vendor.oracle.OracleThinBlob幾種類型的區別
    2、java.sql.Clob、oracle.sql.CLOB、weblogic.jdbc.vendor.oracle.OracleThinClob幾種類型的區別

    Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=839235


    posted @ 2007-07-24 16:43 華夢行 閱讀(672) | 評論 (0)編輯 收藏

    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <html>
    ??? <script language="javascript">


    //test function with post method
    function RequestByPost(value)
    {
    var data;
    data = '<?xml version="1.0" encoding="utf-8"?>';
    data = data + '<soapenv:Envelope xmlns:xsi=";
    data = data + '<soapenv:Body>';
    data = data + '<ns1:getUser xmlns:ns1="
    http://ss/">';
    data = data + '<Name>'+"ffff"+'</Name>';
    data = data + '</ns1:getUser>';
    data = data + '</soapenv:Body>';
    data = data + '</soapenv:Envelope>';

    var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    var URL="http://localhost:8080/myPj/SayHelloTo?wsdl";
    xmlhttp.Open("POST",URL, false);
    xmlhttp.SetRequestHeader ("Content-Type","text/xml; charset=UTF-8");
    xmlhttp.SetRequestHeader ("SOAPAction","http://ss/SayHelloTo");
    alert(data);
    xmlhttp.Send(data);
    alert( xmlhttp.responseText);
    document.getElementById('mm').value=xmlhttp.responseText;
    }

    ??? </script>
    ??? <title>
    ??????? Call webservice with javascript and xmlhttp.
    ??? </title>
    ??? <body>
    ???????
    ??????? <div id="mm">
    ??????? <input type="button" value="CallWebserviceByGet" onClick="RequestByGet(null)">
    ??????? <input type="button" value="CallWebserviceByPost" onClick="RequestByPost('Zach')">
    ??????? <input id="mm" type="text"/>
    ??? </body>
    </html>

    ?

    posted @ 2007-07-17 16:18 華夢行 閱讀(161) | 評論 (0)編輯 收藏
    res://msxml.dll/defaultss.xsl
    posted @ 2007-07-13 08:24 華夢行 閱讀(106) | 評論 (0)編輯 收藏
    Result:
    hello null
    <?xml version="1.0" ?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://ss/"><soapenv:Body><ns1:sayHelloResponse><return>hello null</return></ns1:sayHelloResponse></soapenv:Body></soapenv:Envelope>
    posted @ 2007-07-06 13:10 華夢行 閱讀(105) | 評論 (0)編輯 收藏

    nodeType 屬性

    KingCMS官方網站 Microsoft 2006-1-31 21:18:32
    作 用
    辨識節點的DOM 型態。  
    基本語法
    numNodeType = xmlDocNode.nodeType ;
     
    說 明

    此屬性只讀且傳回一個數值。

    有效的數值符合以下的型別:
    1-ELEMENT
    2-ATTRIBUTE
    3-TEXT
    4-CDATA
    5-ENTITY REFERENCE
    6-ENTITY
    7-PI (processing instruction)
    8-COMMENT
    9-DOCUMENT
    10-DOCUMENT TYPE
    11-DOCUMENT FRAGMENT
    12-NOTATION
     
     
    范 例
    numNodeType = xmlDoc.documentElement.nodeType;
    alert(numNodeType);
    posted @ 2007-07-06 12:58 華夢行 閱讀(131) | 評論 (0)編輯 收藏
    type:表示所有的數據類型
    Message: 指明被調用的函數的參數
    Port:??? 指明服務的具體內容,包括輸入輸出
    Binding:? 服務所綁定的協議

    addTwo Method invocation



    Method parameter(s)

    TypeValue
    int55
    int676

    Method returned

    int : "731"

    SOAP Request


    <?xml version="1.0" encoding="UTF-8"?>
    <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
        <S:Header/>
        <S:Body>
            <ns2:addTwo xmlns:ns2="http://my/">
                <mm>55</mm>
                <gg>676</gg>
            </ns2:addTwo>
        </S:Body>
    </S:Envelope>
    

    SOAP Response


    <?xml version="1.0" encoding="UTF-8"?>
    <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
        <S:Body>
            <ns2:addTwoResponse xmlns:ns2="http://my/">
                <return>731</return>
            </ns2:addTwoResponse>
        </S:Body>
    </S:Envelope>
    


    <?xml version="1.0" encoding="UTF-8"?><!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.2-hudson-112-M1. --><!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.2-hudson-112-M1. --><definitions xmlns:wsu="http://my/" xmlns:xsd="http://my/" name="firstService">
    <types>
    <xsd:schema>
    <xsd:import namespace="http://my/" schemaLocation="http://localhost:8080/ssServ/firstService?xsd=1"></xsd:import>
    </xsd:schema>
    </types>
    <message name="usrLogin">
    <part name="parameters" element="tns:usrLogin"></part>
    </message>
    <message name="usrLoginResponse">
    <part name="parameters" element="tns:usrLoginResponse"></part>
    </message>
    <message name="addTwo">
    <part name="parameters" element="tns:addTwo"></part>
    </message>
    <message name="addTwoResponse">
    <part name="parameters" element="tns:addTwoResponse"></part>
    </message>
    <message name="userLogin">
    <part name="parameters" element="tns:userLogin"></part>
    </message>
    <message name="userLoginResponse">
    <part name="parameters" element="tns:userLoginResponse"></part>
    </message>
    <portType name="first">
    <operation name="usrLogin">
    <input message="tns:usrLogin"></input>
    <output message="tns:usrLoginResponse"></output>
    </operation>
    <operation name="addTwo">
    <input message="tns:addTwo"></input>
    <output message="tns:addTwoResponse"></output>
    </operation>
    <operation name="userLogin">
    <input message="tns:userLogin"></input>
    <output message="tns:userLoginResponse"></output>
    </operation>
    </portType>
    <binding name="firstPortBinding" type="tns:first">
    <soap:binding transport="<operation name="usrLogin">
    <soap:operation soapAction=""></soap:operation>
    <input>
    <soap:body use="literal"></soap:body>
    </input>
    <output>
    <soap:body use="literal"></soap:body>
    </output>
    </operation>
    <operation name="addTwo">
    <soap:operation soapAction=""></soap:operation>
    <input>
    <soap:body use="literal"></soap:body>
    </input>
    <output>
    <soap:body use="literal"></soap:body>
    </output>
    </operation>
    <operation name="userLogin">
    <soap:operation soapAction=""></soap:operation>
    <input>
    <soap:body use="literal"></soap:body>
    </input>
    <output>
    <soap:body use="literal"></soap:body>
    </output>
    </operation>
    </binding>
    <service name="firstService">
    <port name="firstPort" binding="tns:firstPortBinding">
    <soap:address location="
    http://localhost:8080/ssServ/firstService"></soap:address>
    </port>
    </service>
    </definitions>

    從本質上說:客戶端發一個請求即SOAP 請求頭,到指定的web service地址wsdl,然后經過webservice的處理之后,返回一個 SOAP 相應, 然后再在客戶端解析他們
    posted @ 2007-07-05 18:27 華夢行 閱讀(171) | 評論 (0)編輯 收藏

    程序員每天該做的事
    1、總結自己一天任務的完成情況

    最好的方式是寫工作日志,把自己今天完成了什么事情,遇見了什么問題都記錄下來,日后翻看好處多多

    2、考慮自己明天應該做的主要工作

    把明天要做的事情列出來,并按照優先級排列,第二天應該把自己效率最高的時間分配給最重要的工作

    3、考慮自己一天工作中失誤的地方,并想出避免下一次再犯的方法

    出錯不要緊,最重要的是不要重復犯相同的錯誤,那是愚蠢

    4、考慮自己一天工作完成的質量和效率能否還能提高

    一天只提高1%,365天你的效率就能提高多少倍你知道嗎? (1+0.01)^365 = 37 倍

    posted @ 2007-07-05 11:33 華夢行 閱讀(129) | 評論 (0)編輯 收藏

    function hel(){
    ?alert("good");
    }?

    Event.observe(document, 'mousedown', hel.bindAsEventListener());


    ? Browser: {
    ??? IE:???? !!(window.attachEvent && !window.opera),?//判斷是不是IE? 轉換為boolean
    ??? Opera:? !!window.opera,
    ??? WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
    ??? Gecko:? navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1
    ? },

    posted @ 2007-07-03 11:13 華夢行 閱讀(152) | 評論 (0)編輯 收藏

    AnnotationProcessor ???? Annotation 處理的接口,實現類是DefaltAnnotationProcessor?:

    protected static?void lookupFieldResource (javax.naming.Context?context, java.lang.Object?instance, java.lang.reflect.Field?field, java.lang.String?name)
    ??????????Inject resources in specified field.
    protected static?void lookupMethodResource (javax.naming.Context?context, java.lang.Object?instance, java.lang.reflect.Method?method, java.lang.String?name)
    ??????????Inject resources in specified method.
    ?void postConstruct (java.lang.Object?instance)
    ??????????Call postConstruct method on the specified instance.
    ?void preDestroy (java.lang.Object?instance)
    ??????????Call preDestroy method on the specified instance.
    ?void processAnnotations (java.lang.Object?instance)
    ??????????Inject resources in specified instance


    public class DefaultAnnotationProcessor implements AnnotationProcessor {
    ???
    ??? protected javax.naming.Context context = null;
    ???
    ??? public DefaultAnnotationProcessor(javax.naming.Context context) {
    ??????? this.context = context;
    ??? }


    ??? /**
    ???? * Call postConstruct method on the specified instance.
    ???? */
    ??? public void postConstruct(Object instance)
    ??????? throws IllegalAccessException, InvocationTargetException {
    ???????
    ??????? Method[] methods = instance.getClass().getDeclaredMethods();
    ??????? Method postConstruct = null;
    ??????? for (int i = 0; i < methods.length; i++) {
    ??????????? if (methods[i].isAnnotationPresent(PostConstruct.class)) {
    ??????????????? if ((postConstruct != null)
    ??????????????????????? || (methods[i].getParameterTypes().length != 0)
    ??????????????????????? || (Modifier.isStatic(methods[i].getModifiers()))
    ??????????????????????? || (methods[i].getExceptionTypes().length > 0)
    ??????????????????????? || (!methods[i].getReturnType().getName().equals("void"))) {
    ??????????????????? throw new IllegalArgumentException("Invalid PostConstruct annotation");
    ??????????????? }
    ??????????????? postConstruct = methods[i];
    ??????????? }
    ??????? }

    ??????? // At the end the postconstruct annotated
    ??????? // method is invoked
    ??????? if (postConstruct != null) {
    ??????????? boolean accessibility = postConstruct.isAccessible();
    ??????????? postConstruct.setAccessible(true);
    ??????????? postConstruct.invoke(instance);
    ??????????? postConstruct.setAccessible(accessibility);
    ??????? }
    ???????
    ??? }
    ???
    ???
    ??? /**
    ???? * Call preDestroy method on the specified instance.
    ???? */
    ??? public void preDestroy(Object instance)
    ??????? throws IllegalAccessException, InvocationTargetException {
    ???????
    ??????? Method[] methods = instance.getClass().getDeclaredMethods();
    ??????? Method preDestroy = null;
    ??????? for (int i = 0; i < methods.length; i++) {
    ??????????? if (methods[i].isAnnotationPresent(PreDestroy.class)) {
    ??????????????? if ((preDestroy != null)
    ??????????????????????? || (methods[i].getParameterTypes().length != 0)
    ??????????????????????? || (Modifier.isStatic(methods[i].getModifiers()))
    ??????????????????????? || (methods[i].getExceptionTypes().length > 0)
    ??????????????????????? || (!methods[i].getReturnType().getName().equals("void"))) {
    ??????????????????? throw new IllegalArgumentException("Invalid PreDestroy annotation");
    ??????????????? }
    ??????????????? preDestroy = methods[i];
    ??????????? }
    ??????? }

    ??????? // At the end the postconstruct annotated
    ??????? // method is invoked
    ??????? if (preDestroy != null) {
    ??????????? boolean accessibility = preDestroy.isAccessible();
    ??????????? preDestroy.setAccessible(true);
    ??????????? preDestroy.invoke(instance);
    ??????????? preDestroy.setAccessible(accessibility);
    ??????? }
    ???????
    ??? }
    ???
    ???
    ??? /**
    ???? * Inject resources in specified instance.
    ???? */
    ??? public void processAnnotations(Object instance)
    ??????? throws IllegalAccessException, InvocationTargetException, NamingException {
    ???????
    ??????? if (context == null) {
    ??????????? // No resource injection
    ??????????? return;
    ??????? }
    ???????
    ??????? // Initialize fields annotations
    ??????? Field[] fields = instance.getClass().getDeclaredFields();
    ??????? for (int i = 0; i < fields.length; i++) {
    ??????????? if (fields[i].isAnnotationPresent(Resource.class)) {
    ??????????????? Resource annotation = (Resource) fields[i].getAnnotation(Resource.class);
    ??????????????? lookupFieldResource(context, instance, fields[i], annotation.name());
    ??????????? }
    ??????????? if (fields[i].isAnnotationPresent(EJB.class)) {
    ??????????????? EJB annotation = (EJB) fields[i].getAnnotation(EJB.class);
    ??????????????? lookupFieldResource(context, instance, fields[i], annotation.name());
    ??????????? }
    ??????????? if (fields[i].isAnnotationPresent(WebServiceRef.class)) {
    ??????????????? WebServiceRef annotation =
    ??????????????????? (WebServiceRef) fields[i].getAnnotation(WebServiceRef.class);
    ??????????????? lookupFieldResource(context, instance, fields[i], annotation.name());
    ??????????? }
    ??????????? if (fields[i].isAnnotationPresent(PersistenceContext.class)) {
    ??????????????? PersistenceContext annotation =
    ??????????????????? (PersistenceContext) fields[i].getAnnotation(PersistenceContext.class);
    ??????????????? lookupFieldResource(context, instance, fields[i], annotation.name());
    ??????????? }
    ??????????? if (fields[i].isAnnotationPresent(PersistenceUnit.class)) {
    ??????????????? PersistenceUnit annotation =
    ??????????????????? (PersistenceUnit) fields[i].getAnnotation(PersistenceUnit.class);
    ??????????????? lookupFieldResource(context, instance, fields[i], annotation.name());
    ??????????? }
    ??????? }
    ???????
    ??????? // Initialize methods annotations
    ??????? Method[] methods = instance.getClass().getDeclaredMethods();
    ??????? for (int i = 0; i < methods.length; i++) {
    ??????????? if (methods[i].isAnnotationPresent(Resource.class)) {
    ??????????????? Resource annotation = (Resource) methods[i].getAnnotation(Resource.class);
    ??????????????? lookupMethodResource(context, instance, methods[i], annotation.name());
    ??????????? }
    ??????????? if (methods[i].isAnnotationPresent(EJB.class)) {
    ??????????????? EJB annotation = (EJB) methods[i].getAnnotation(EJB.class);
    ??????????????? lookupMethodResource(context, instance, methods[i], annotation.name());
    ??????????? }
    ??????????? if (methods[i].isAnnotationPresent(WebServiceRef.class)) {
    ??????????????? WebServiceRef annotation =
    ??????????????????? (WebServiceRef) methods[i].getAnnotation(WebServiceRef.class);
    ??????????????? lookupMethodResource(context, instance, methods[i], annotation.name());
    ??????????? }
    ??????????? if (methods[i].isAnnotationPresent(PersistenceContext.class)) {
    ??????????????? PersistenceContext annotation =
    ??????????????????? (PersistenceContext) methods[i].getAnnotation(PersistenceContext.class);
    ??????????????? lookupMethodResource(context, instance, methods[i], annotation.name());
    ??????????? }
    ??????????? if (methods[i].isAnnotationPresent(PersistenceUnit.class)) {
    ??????????????? PersistenceUnit annotation =
    ??????????????????? (PersistenceUnit) methods[i].getAnnotation(PersistenceUnit.class);
    ??????????????? lookupMethodResource(context, instance, methods[i], annotation.name());
    ??????????? }
    ??????? }

    ??? }
    ???
    ???
    ??? /**
    ???? * Inject resources in specified field.
    ???? */
    ??? protected static void lookupFieldResource(javax.naming.Context context,
    ??????????? Object instance, Field field, String name)
    ??????? throws NamingException, IllegalAccessException {
    ???
    ??????? Object lookedupResource = null;
    ??????? boolean accessibility = false;
    ???????
    ??????? if ((name != null) &&
    ??????????????? (name.length() > 0)) {
    ??????????? lookedupResource = context.lookup(name);
    ??????? } else {
    ??????????? lookedupResource = context.lookup(instance.getClass().getName() + "/" + field.getName());
    ??????? }
    ???????
    ??????? accessibility = field.isAccessible();
    ??????? field.setAccessible(true);
    ??????? field.set(instance, lookedupResource);
    ??????? field.setAccessible(accessibility);
    ??? }


    ??? /**
    ???? * Inject resources in specified method.
    ???? */
    ??? protected static void lookupMethodResource(javax.naming.Context context,
    ??????????? Object instance, Method method, String name)
    ??????? throws NamingException, IllegalAccessException, InvocationTargetException {
    ???????
    ??????? if (!method.getName().startsWith("set")
    ??????????????? || method.getParameterTypes().length != 1
    ??????????????? || !method.getReturnType().getName().equals("void")) {
    ??????????? throw new IllegalArgumentException("Invalid method resource injection annotation");
    ??????? }
    ???????
    ??????? Object lookedupResource = null;
    ??????? boolean accessibility = false;
    ???????
    ??????? if ((name != null) &&
    ??????????????? (name.length() > 0)) {
    ??????????? lookedupResource = context.lookup(name);
    ??????? } else {
    ??????????? lookedupResource =
    ??????????????? context.lookup(instance.getClass().getName() + "/" + method.getName().substring(3));
    ??????? }
    ???????
    ??????? accessibility = method.isAccessible();
    ??????? method.setAccessible(true);
    ??????? method.invoke(instance, lookedupResource);
    ??????? method.setAccessible(accessibility);
    ??? }
    ???

    }

    posted @ 2007-06-28 15:26 華夢行 閱讀(666) | 評論 (0)編輯 收藏
    http://webfx.eae.net/
    posted @ 2007-06-28 12:54 華夢行 閱讀(121) | 評論 (0)編輯 收藏

    ? import java.lang.reflect.*;
    public class RunTest {
    ??? public static void main(String[] args) throws Exception {
    ???????
    ??????? int passed = 0, failed = 0;
    ??????? for (Method m : Class.forName("Foo").getMethods()) {
    ??????????? if (m.isAnnotationPresent(Test.class)) {
    ??????????????? try {
    ??????????????????? m.invoke(null);
    ???????????????????
    ??????????????????? passed++;
    ??????????????? } catch (Throwable ex) {
    ??????????????????? System.out.printf("Test %s failed: %s %n", m, ex.getCause());
    ??????????????????? failed++;
    ??????????????? }
    ??????????? }
    ??????? }
    ??????? System.out.printf("Passed: %d, Failed %d%n", passed, failed);
    ??? }
    }

    public class Foo {
    ??? @Test public static void m1() {
    ??? System.out.println("m1 SUcsessful");
    ??? }
    ??? public static void m2() { }
    ??? @Test public static void m3() {
    ??????? System.out.println("m3 Fails");
    ??????? throw new RuntimeException("Boom");
    ??? }
    ??? public static void m4() { }
    ??? @Test public static void m5() { }
    ??? public static void m6() { }
    ??? @Test public static void m7() {
    ??????? throw new RuntimeException("Crash");??????? }
    ???
    ??? public static void m8() { }
    }


    import java.lang.annotation.*;
    /*
    ?* Test.java
    ?*
    ?* Created on 2007年6月28日, 上午8:52
    ?*
    ?* To change this template, choose Tools | Template Manager
    ?* and open the template in the editor.
    ?*/

    /**
    ?*
    ?* @author ljl
    ?*/
    @Documented
    @Retention(RetentionPolicy.RUNTIME)
    @Target(ElementType.METHOD)
    public @interface Test {
    ???
    ???
    ???
    }

    posted @ 2007-06-28 09:24 華夢行 閱讀(303) | 評論 (0)編輯 收藏

    /** The original page id sent from the server */
    dwr.engine._origScriptSessionId = "${scriptSessionId}";

    /** The session cookie name */
    dwr.engine._sessionCookieName = "${sessionCookieName}"; // JSESSIONID

    以上這段代碼取自? dwr?源碼包中?engine.js
    這里的${scriptSessionId}?? 與? ${sessionCookieName} 是從哪里或得的,又是怎么獲得的呢。
    有怎么會用? ${}? ,${}?是什么意思呢?請各位大俠不吝賜教!

    posted @ 2007-06-21 21:28 華夢行 閱讀(1847) | 評論 (2)編輯 收藏
    僅列出標題
    共15頁: First 上一頁 7 8 9 10 11 12 13 14 15 
    主站蜘蛛池模板: 亚洲AV无码一区二区三区牲色| 全亚洲最新黄色特级网站 | 亚洲av无码一区二区三区天堂| 7723日本高清完整版免费| 亚洲男人的天堂在线播放| 97在线视频免费公开视频| 亚洲一区日韩高清中文字幕亚洲 | 一个人看的www免费在线视频| 亚洲国产专区一区| 国产高清对白在线观看免费91| 亚洲性在线看高清h片| 久久国产乱子伦精品免费午夜| 国产亚洲精品激情都市| 182tv免费视频在线观看| 亚洲av福利无码无一区二区 | 好紧我太爽了视频免费国产 | 亚洲乱妇老熟女爽到高潮的片| 午夜高清免费在线观看| 亚洲第一第二第三第四第五第六| 国产大片91精品免费观看男同| 黄色免费网址在线观看| 亚洲日韩av无码| 91精品国产免费久久国语麻豆| 亚洲av片不卡无码久久| 大学生a级毛片免费观看| 免费看一级高潮毛片| 亚洲国产一二三精品无码| 最近免费中文字幕大全免费| 亚洲综合精品成人| 亚洲人午夜射精精品日韩| 久草视频在线免费看| 精品丝袜国产自在线拍亚洲| 亚洲国产成人久久精品99| 日本在线看片免费| 中国亚洲呦女专区| 在线精品亚洲一区二区三区| 99久9在线|免费| 国产亚洲午夜精品| 亚洲视频中文字幕| 免费一级黄色毛片| 在线看无码的免费网站|