??xml version="1.0" encoding="utf-8" standalone="yes"?>久久久噜噜噜久久久,亚洲精品视频在线播放,亚洲成人观看http://www.aygfsteel.com/EvanLiu/休息Q休?/description>zh-cnThu, 08 May 2025 04:38:37 GMTThu, 08 May 2025 04:38:37 GMT60WebSphere下LinkageError解决办法http://www.aygfsteel.com/EvanLiu/archive/2009/03/14/259752.htmlEvanLiuEvanLiuSat, 14 Mar 2009 12:26:00 GMThttp://www.aygfsteel.com/EvanLiu/archive/2009/03/14/259752.htmlhttp://www.aygfsteel.com/EvanLiu/comments/259752.htmlhttp://www.aygfsteel.com/EvanLiu/archive/2009/03/14/259752.html#Feedback1http://www.aygfsteel.com/EvanLiu/comments/commentRss/259752.htmlhttp://www.aygfsteel.com/EvanLiu/services/trackbacks/259752.html环境QWebSphere 6.l
JRE: WebSphere 6.1 JRE
目需求:(x)用SUN JDK6自带的JAX-WS创徏Web Service?其中Server端的Web Service接口已发布,我这边的目直接Ҏ(gu)Ҏ(gu)提供的WSDL创徏Client?br /> 到的问题:(x)
当调用javax.xml.ws.Service的构造方?Service(URL url, QName qName)的时候,报错如下Q?br />
[3/14/09 14:51:53:750 CST] 0000002c SystemErr     R Caused by: java.lang.Throwable: java.lang.LinkageError: You are loading old SAAJ from jar:file:/C:/Program%20Files/IBM/SDP70/runtimes/base_v61/lib/j2ee.jar!/javax/xml/soap/MessageFactory.class
 at com.sun.xml.ws.api.SOAPVersion.<init>(SOAPVersion.java:184)
 at com.sun.xml.ws.api.SOAPVersion.<clinit>(SOAPVersion.java:83)
 at java.lang.J9VMInternals.initializeImpl(Native Method)
 at java.lang.J9VMInternals.initialize(J9VMInternals.java:177)
 at com.sun.xml.ws.api.BindingID.<clinit>(BindingID.java:318)
 ...(以下省略300?
Caused by: java.lang.Throwable: java.lang.NoSuchMethodError: javax/xml/soap/MessageFactory.newInstance(Ljava/lang/String;)Ljavax/xml/soap/MessageFactory;
 at com.sun.xml.ws.api.SOAPVersion.<init>(SOAPVersion.java:178)
 ... 21 more


也就是说Q程序先去读取了WebSphere 6.1的j2ee.jar包里的相关类Q而没去读取我们真正要用的两个SAAJ jar包:(x)saaj-api.jar和saaj-impl.jar. l果出错了?br />
IBM上找到的原因?qing)解军_法:(x)

如何在WebSphere中解决jar包冲H?/a>

 

主要是把Classloader mode从默认的Parent_FirstҎ(gu)Parent_LastQ让E序先读自己的class文g以及(qing)jar包?br /> 我就照样画葫芦设|了。顺便说一下,兌׃n库到应用E序Q我无论如何都做不成功。关闭Application,q入ApplicationQ关联共享库Q关联好了,保存成功Q退到外面,再进去,׃n库又没关联上。设|Classloader mode的时候也遇到了这L(fng)问题Q但最l还是迫使其让我保存了。共享库׃理Q反正无所谓,只要加蝲序变了成?br /> 但事实上Q我的担心成Z事实Q程序启动失败,虽然h了,但只跑了一部分代码,后面的服务都没v来。想想也是,E序那么大,用到的jar包那么多Q改了Classloader modeQ一切全都ؕ套了...

之后Q查看Console-->TroubleShooting-->Class Loader ViewQ发现系l最开始加载的是WebSphere下的ext目录下的jar?/p>

?/h1>

所以就投机取yQ把我要用的两个saaj包放Cext目录下,重启Q程序运行成?br /> 当然Q这不是一个好的解军_法,阿三那里能不能通得q还是个问题





EvanLiu 2009-03-14 20:26 发表评论
]]>ThreadLocal学习(fn)http://www.aygfsteel.com/EvanLiu/archive/2009/02/18/255272.htmlEvanLiuEvanLiuWed, 18 Feb 2009 08:28:00 GMThttp://www.aygfsteel.com/EvanLiu/archive/2009/02/18/255272.htmlhttp://www.aygfsteel.com/EvanLiu/comments/255272.htmlhttp://www.aygfsteel.com/EvanLiu/archive/2009/02/18/255272.html#Feedback1http://www.aygfsteel.com/EvanLiu/comments/commentRss/255272.htmlhttp://www.aygfsteel.com/EvanLiu/services/trackbacks/255272.html阅读全文

EvanLiu 2009-02-18 16:28 发表评论
]]>
java.util.ConcurrentModificationExceptionhttp://www.aygfsteel.com/EvanLiu/archive/2008/08/31/224453.htmlEvanLiuEvanLiuSun, 31 Aug 2008 11:44:00 GMThttp://www.aygfsteel.com/EvanLiu/archive/2008/08/31/224453.htmlhttp://www.aygfsteel.com/EvanLiu/comments/224453.htmlhttp://www.aygfsteel.com/EvanLiu/archive/2008/08/31/224453.html#Feedback3http://www.aygfsteel.com/EvanLiu/comments/commentRss/224453.htmlhttp://www.aygfsteel.com/EvanLiu/services/trackbacks/224453.html List list = ...;
for(Iterator iter = list.iterator(); iter.hasNext();) {
    Object obj = iter.next();
    ...
    if(***) {
        list.remove(obj);
    }
}
在执行了removeҎ(gu)之后Q再L行@环,iter.next()的时候,报java.util.ConcurrentModificationException(当然Q如果remove的是最后一条,׃?x)再L行next()操作?

下面来看一下源?br /> public interface Iterator<E> {
    boolean hasNext();
    E next();
    void remove();
}

public interface Collection<E> extends Iterable<E> {
    ...
    Iterator<E> iterator();
    boolean add(E o);
    boolean remove(Object o);
    ...
}

q里有两个removeҎ(gu)

接下来来看看AbstractList
public abstract class AbstractList<E> extends AbstractCollection<E> implements List<E> { 
//AbstractCollection和List都承了Collection
    protected transient int modCount = 0;
    private class Itr implements Iterator<E> {  //内部cItr
        int cursor = 0;
        int lastRet = -1;
        int expectedModCount = modCount;

        public boolean hasNext() {
            return cursor != size();
        }

        public E next() {
            checkForComodification();  //特别注意q个Ҏ(gu)
            try {
                E next = get(cursor);
                lastRet = cursor++;
                return next;
            } catch(IndexOutOfBoundsException e) {
                checkForComodification();
                throw new NoSuchElementException();
            }
        }

        public void remove() {
            if (lastRet == -1)
                throw new IllegalStateException();
            checkForComodification();

            try {
                AbstractList.this.remove(lastRet);  //执行remove对象的操?br />                 if (lastRet < cursor)
                    cursor--;
                lastRet = -1;
                expectedModCount = modCount;  //重新讄了expectedModCount的|避免了ConcurrentModificationException的?br />             } catch(IndexOutOfBoundsException e) {
                throw new ConcurrentModificationException();
            }
        }

        final void checkForComodification() {
            if (modCount != expectedModCount)  //当expectedModCount和modCount不相{时Q就抛出ConcurrentModificationException
                throw new ConcurrentModificationException();
        }
    }   
}


remove(Object o)在ArrayList中实现如下:(x)
public boolean remove(Object o) {
    if (o == null) {
            for (int index = 0; index < size; index++)
        if (elementData[index] == null) {
            fastRemove(index);
            return true;
        }
    } else {
        for (int index = 0; index < size; index++)
            if (o.equals(elementData[index])) {
                fastRemove(index);
                return true;
            }
    }
    return false;
}
private void fastRemove(int index) {
    modCount++;  //只增加了modCount
    ....
}

所以,产生ConcurrentModificationException的原因就是:(x)
执行remove(Object o)Ҏ(gu)之后QmodCount和expectedModCount不相{了。然后当代码执行到next()Ҏ(gu)Ӟ判断了checkForComodification()Q发C个数g{,抛Z该Exception?br /> 要避免这个ExceptionQ就应该使用remove()Ҏ(gu)?/strong>

q里我们׃看add(Object o)Ҏ(gu)了,也是同样的原因,但没有对应的add()Ҏ(gu)。一般嘛Q就另徏一个List?br />

下面是网上的其他解释Q更能从本质上解释原因:(x)
Iterator 是工作在一个独立的U程中,q且拥有一?mutex 锁?Iterator 被创Z后会(x)建立一个指向原来对象的单链索引表,当原来的对象数量发生变化Ӟq个索引表的内容不会(x)同步改变Q所以当索引指针往后移动的时候就找不到要q代的对象,所以按?fail-fast 原则 Iterator ?x)马上抛?java.util.ConcurrentModificationException 异常?br /> 所?Iterator 在工作的时候是不允许被q代的对象被改变的。但你可以?Iterator 本n的方?remove() 来删除对象, Iterator.remove() Ҏ(gu)?x)在删除当前q代对象的同时维护烦(ch)引的一致性?br />
http://gceclub.sun.com.cn/yuanchuang/week-14/iterator.html



EvanLiu 2008-08-31 19:44 发表评论
]]>
物化视图(Materialized View)基础http://www.aygfsteel.com/EvanLiu/archive/2008/08/09/218295.htmlEvanLiuEvanLiuSat, 09 Aug 2008 07:53:00 GMThttp://www.aygfsteel.com/EvanLiu/archive/2008/08/09/218295.htmlhttp://www.aygfsteel.com/EvanLiu/comments/218295.htmlhttp://www.aygfsteel.com/EvanLiu/archive/2008/08/09/218295.html#Feedback0http://www.aygfsteel.com/EvanLiu/comments/commentRss/218295.htmlhttp://www.aygfsteel.com/EvanLiu/services/trackbacks/218295.html数据的的本地副本Q或者用来生成基于数据表求和的汇总表。物化视囑֭储基于远E表的数据,也可以称为快照?br /> 所以物化视囑֒视图的最大区别是Q物化视囑֜本地保存数据Q而视囑֏是一些SQL语句而已。视囄好处是简化用过E,物化视图的好处提高性能Q当然也可以化用过E。提高查询速度的代价就是放弃一定的数据实时性?br /> 物化视图可以查询表,视图和其它的物化视图?br />
创徏物化视图Q应先在对于的基表上创徏存储的日志空_(d)(x)
create materialized view log on tablex
tablespace mytestspace           -- 日志I间
with rowid;

然后再创建物化视图:(x)
create materialized vew myfirstmv
on prebuild tabley                   -- 物化视囑־立在一个已l存在的表上Q也可不加这?br /> tablespace mytestspace
build deffered                         -- buld clause子句Qdeffered表示创徏时不生成数据Q默认ؓ(f)build immediate
refresh fast                             -- refresh 子句。fast表示只刷Cơ刷C后所作的修改。相对ؓ(f)complete。默认ؓ(f)force
           on commit                   -- 对基表的DML操作提交的同时进行刷新。默认ؓ(f)on demand
           start with to_date('2008-08-08 20:00:00', 'yyyy-mm-dd hh24:mi:ss')             --W一ơ刷新时?br />            next TRUNC(SYSDATE+1)+18/24          --h旉间隔。每两天h一ơ,旉Z??br /> as
        select x1, x2, x3 from tablex

          
删除Ӟ删除物化视图和物化视图日志无序要求Q不q先删除日志Q会(x)使删除物化视囄速度加快很多?br /> 如果物化视图日志存在的话Q物化视囑֜删除的时候,需要将物化视图日志中所有当前物化视N要刷新的记录删除掉。这意味着一个DDL的语句中包含着DML的部分?br />
以上都没l过实际操作Q以后有旉再说


http://xznsoft.javaeye.com/blog/124000



EvanLiu 2008-08-09 15:53 发表评论
]]>
JMS单不完全实现http://www.aygfsteel.com/EvanLiu/archive/2008/08/03/219721.htmlEvanLiuEvanLiuSun, 03 Aug 2008 10:04:00 GMThttp://www.aygfsteel.com/EvanLiu/archive/2008/08/03/219721.htmlhttp://www.aygfsteel.com/EvanLiu/comments/219721.htmlhttp://www.aygfsteel.com/EvanLiu/archive/2008/08/03/219721.html#Feedback0http://www.aygfsteel.com/EvanLiu/comments/commentRss/219721.htmlhttp://www.aygfsteel.com/EvanLiu/services/trackbacks/219721.html
主要的几个对象:(x)ConnectionFactory、Connection、Destination、Session、MessageProducer、MessageConsumer
其相互关pd下图Q?br />
1.PTP:
单回?个对象:(x)QueueConnectionFactory、QuequeConnection、Queue、QueueSession、QueueSender、QueueReceiver、QueueBrowser
    1) Sender
    try {
        //具体怎么得到׃写了Q各个系l肯定都不一P但终I是通过jdni来获?br />         Context jndiContext = new InitialContext();
        QueueConnectionFactory factory = jndiContext.lookup("**Factory");
        Queue queue = jndiContext.lookup("**Queue");
        QueueConnection connection = factory.createQueueConnection();
        boolean transaction = true;
        QueueSession session = connection.createQueueSession(transaction , Session.AUTO_ACKNOWLEDGE);
        Message objMessage = session.createObjectMessage();  //或session.createTextMessage("...");
        objMessage.setObject((Serializable)obj); //obj传输的对?br />         QueueSender sender = session.createSender(queue);
        publisher.setTimeToLive(timeout); //long timeout = ...
        connection.start();
        sender.send(objMessage);
        //or
        /**
        sender = session.createSender(null);
        sender.send(queue, message);
        */
        //如果不用了,收拑ֹ净
        publisher.close();
        session.close();
        connection.close();
    } catch (JMSException e) {
        //TODO
    } finally {
        publisher = null;
        session = null;
        connection = null;
    }

    2) Receiver/Browser
        a.d接收Qsynchronously
        try {
            QueueReceiver receiver = session.createReceiver(queue);
            receiver.receiveNoWait();
            /**
            QueueBrowser browser = session.createBrowser(queue); //QueueBrowser只会(x)取消息,但不?x)取走消?br />             Enumeration elements = browser.getEnumeration();
            while(elements.hasMoreElements) {
                Message message = elements.nextElement();
                ...
            }
            */
        } catch (JMSException e) {
            ...
        }

        b.消息侦听Q也是最主要的应用,asynchronously
        try {
            MessageListener myListener = new MyListener();
            QueueReceiver receiver = session.createReceiver(queue);
            receiver.setMessageListener(myListener);
            connection.start();
        } catch (JMSException e) {
            ...    
        }

        public class MyListener impelments MessageListner {
            public void onMessage(Message message) {
                if(message instanceof TextMessage) {
                    ...
                } else if (message instanceof ObjectMessage) {
                    ...
                } else {
                    ...
                }    
            }
        }


2.Pub/Sub:
单回?个对象:(x)TopicConnectionFactory、TopicConnection、Topic、TopicSession、TopicPublisher、TopicSubscriber
    1) Publisher
    try {
        //具体怎么得到׃写了Q各个系l肯定都不一P但终I是通过jdni来获?br />         Context jndiContext = new InitialContext();
        TopicConnectionFactory factory = jndiContext.lookup("**Factory");
        Topic topic = jndiContext.lookup("**Topic");
        TopicConnection connection = factory.createTopicConnection();
        TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);  //false表示不用事?br />         Message objMessage = session.createObjectMessage();
        objMessage.setObject((Serializable)obj); //obj传输的对?br />         TopicPublisher publisher = session.createPublisher(topic);
        publisher.setTimeToLive(100000);
        connection.start();
        publisher.publish(message);
        //or
        /**
        publisher = session.createPublisher(null);
        publiser.publish(topic, message);
        */
        publisher.close();
        session.close();
        connection.close();
    } catch (JMSException e) {
        //TODO
    }


    2) Subscriber
        a.d接收Q比如上面发送完后,接收回应消息Q相当于同步接收?br />         try {
            TopicSubscriber subscriber = session.createSubScriber(topic);
            message = subscriber.receiver(timeout); //long timeout = ...
            subscriber.close();
        } catch (JMSException e) {
            ...    
        }


        b.消息侦听Qasynchronously
        try {
            ...
            TopicSubscriber subscriber = session.createSubScriber(topic);
            MessageListener listener = new MyListener();
            subscriber.setMessageListener(listener); //关键在于q个listener
            connection.start();
        } catch (JMSException e) {
            ...
        }

        MyListener实现同上




EvanLiu 2008-08-03 18:04 发表评论
]]>
JMS基本概念Q{Q?/title><link>http://www.aygfsteel.com/EvanLiu/archive/2008/08/03/213934.html</link><dc:creator>EvanLiu</dc:creator><author>EvanLiu</author><pubDate>Sun, 03 Aug 2008 09:51:00 GMT</pubDate><guid>http://www.aygfsteel.com/EvanLiu/archive/2008/08/03/213934.html</guid><wfw:comment>http://www.aygfsteel.com/EvanLiu/comments/213934.html</wfw:comment><comments>http://www.aygfsteel.com/EvanLiu/archive/2008/08/03/213934.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/EvanLiu/comments/commentRss/213934.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/EvanLiu/services/trackbacks/213934.html</trackback:ping><description><![CDATA[<h3><span style="color: #3064ff;">1.JMS概述</span></h3> JAVA 消息服务(JMS)定义了Java 中访问消息中间g的接口。JMS只是接口Qƈ没有l予实现Q实现JMS接口的消息中间gUCؓ(f)JMS Provider<br /> <br /> 消息中间件提供企业数据的异步传输Q通过消息中间Ӟ一些原本互相孤立的业务lg可以l合成一个可靠的、灵zȝpȝ。也可以模拟实现同步传输Q但其实质仍然是异步的?br /> <br /> <p>JMS 支持两种消息cdPTP QPoint-to-PointQ和Pub/SubQPublish-SubscribeQ,分别UCQPTP Domain 和Pub/Sub Domain?br /> PTP的主要特Ҏ(gu)Q?br /> 1Q一条消息只有一个用?br /> 2Q不存在旉限制<br /> Pub/Sub主要特点有:(x)<br /> 1Q一条消息可以有多个使用?br /> 2Q存在时间限制。订阅者可以用持久方式来订阅消息Q但是也?x)过期或者取消订?br /> </p> <p>q两U接口都l承l一的JMS Parent 接口QJMS 主要接口如下所C:(x)</p> <div> <table border="1"> <colgroup><col><col><col></colgroup> <tbody> <tr> <td><strong>JMS Parent </strong></td> <td><strong>PTPDomain</strong></td> <td><strong>Pub/Sub Domain </strong></td> </tr> <tr> <td>ConnectionFactory</td> <td>QueueConnectionFactory</td> <td>TopicConnectionFactory</td> </tr> <tr> <td>Connection</td> <td>QueueConnection</td> <td>TopicConnection</td> </tr> <tr> <td>Destination</td> <td>Queue</td> <td>Topic</td> </tr> <tr> <td>Session</td> <td>QueueSession</td> <td>TopicSession</td> </tr> <tr> <td>MessageProducer</td> <td>QueueSender</td> <td>TopicPublisher</td> </tr> <tr> <td>MessageConsumer</td> <td>QueueReceiver,QueueBrowser</td> <td>TopicSubscriber</td> </tr> </tbody> </table> </div> <p>以下是对q些接口的简单描qͼ(x)</p> <p>ConnectionFactory Q连接工厂,JMS 用它创徏q接</p> <p>Connection QJMS 客户端到JMS Provider 的连?/p> <p>Destination Q消息的目的?/p> <p>SessionQ?一个发送或接收消息的线E?/p> <p>MessageProducerQ?由Session 对象创徏的用来发送消息的对象</p> <p>MessageConsumerQ?由Session 对象创徏的用来接收消息的对象</p> <p><br /> </p> <h3><span style="color: #3064ff;">2.JMS消息模型</span></h3> <p>JMS 消息׃下几部分l成Q消息头Q属性,消息体?/p> <p><span><strong>消息?Header) </strong></span>-消息头包含消息的识别信息和\׃息,消息头包含一些标准的属性如QJMSDestination,JMSMessageID{?/p> <div> <table border="1"> <colgroup><col><col></colgroup> <tbody> <tr> <td><strong>消息?/strong></td> <td><strong>p讄</strong></td> </tr> <tr> <td>JMSDestination</td> <td>send ?publish Ҏ(gu)</td> </tr> <tr> <td>JMSDeliveryMode</td> <td>send ?publish Ҏ(gu)</td> </tr> <tr> <td>JMSExpiration</td> <td>send ?publish Ҏ(gu)</td> </tr> <tr> <td>JMSPriority</td> <td>send ?publish Ҏ(gu)</td> </tr> <tr> <td>JMSMessageID</td> <td>send ?publish Ҏ(gu)</td> </tr> <tr> <td>JMSTimestamp</td> <td>send ?publish Ҏ(gu)</td> </tr> <tr> <td>JMSCorrelationID</td> <td>客户</td> </tr> <tr> <td>JMSReplyTo</td> <td>客户</td> </tr> <tr> <td>JMSType</td> <td>客户</td> </tr> <tr> <td>JMSRedelivered</td> <td>JMS Provider</td> </tr> </tbody> </table> </div> <p><strong>属?Properties)</strong> -除了消息头中定义好的标准属性外QJMS提供一U机制增加新属性到消息头中Q这U新属性包含以下几U:(x)</p> <div> <ol type="1"> <li> <p>应用需要用到的属?</p> </li> <li> <p>消息头中原有的一些可选属?</p> </li> <li> <p>JMS Provider 需要用到的属性?/p> </li> </ol> </div> <p>标准的JMS 消息头包含以下属性:(x)</p> <p>JMSDestination --消息发送的目的地?/p> <p>JMSDeliveryMode --传递模式, 有两U模式:(x)PERSISTENT和NON_PERSISTENTQPERSISTENT表示该消息一定要被送到目的圎ͼ否则?x)导致应用错误? NON_PERSISTENT表示偶然丢失该消息是被允许的Q这两种模式使开发者可以在消息传递的可靠性和吞吐量之间找到^衡点?/p> <p>JMSMessageID 唯一识别每个消息的标识,由JMS Provider 产生?/p> <p>JMSTimestamp 一个消息被提交lJMS Provider 到消息被发出的时间?/p> <p>JMSCorrelationID 用来q接到另外一个消息,典型的应用是在回复消息中q接到原消息?/p> <p>JMSReplyTo 提供本消息回复消息的目的地址?/p> <p>JMSRedelivered如果一个客L(fng)收到一个设|了JMSRedelivered属性的消息Q则表示可能该客L(fng)曄在早些时候收到过该消息,但ƈ没有{收(acknowledged)?/p> <p>JMSType 消息cd的识别符?/p> <p>JMSExpiration 消息q期旉Q等于QueueSender 的sendҎ(gu)中的timeToLive值或TopicPublisher 的publish Ҏ(gu)中的timeToLive值加上发送时ȝGMT旉倹{如果timeToLive值等于零Q则JMSExpiration被设为零Q表C消息怸q期。如果发送后Q在消息q期旉之后消息q没有被发送到目的圎ͼ则该消息被清除?/p> <p>JMSPriority 消息优先U,?-9 十个U别Q?-4 是普通消息,5-9 是加急消息。JMS 不要求JMS Provider严格按照q十个优先发送消息,但必M证加急消息要先于普通消息到达?/p> <p><strong>消息?Body)</strong> - JMS API定义?U消息体格式Q也叫消息类型,你可以用不同Ş式发送接收数据ƈ可以兼容现有的消息格式,下面描述q?U类型:(x)</p> <div> <table border="1"> <colgroup><col><col></colgroup> <tbody> <tr> <td><strong>消息cd</strong></td> <td><strong>消息?/strong></td> </tr> <tr> <td>TextMessage</td> <td>java.lang.String对象Q如xml文g内容</td> </tr> <tr> <td>MapMessage</td> <td>?值对的集合,名是String对象Q值类型可以是JavaM基本cd</td> </tr> <tr> <td>BytesMessage</td> <td>字节?/td> </tr> <tr> <td>StreamMessage</td> <td>Java中的输入输出?/td> </tr> <tr> <td>ObjectMessage</td> <td>Java中的可序列化对象</td> </tr> <tr> <td>Message</td> <td>没有消息体,只有消息头和属?/td> </tr> </tbody> </table> </div> <p>Message是以?cȝ基础。最常用的是ObjectMessage和TextMessage<br /> </p> <h3><span style="color: #3064ff;">3.消息的同步异步接?/span></h3> <p><strong>消息的同步接?/strong></p> <p>同步接收是指客户端主动去接收消息QJMS 客户端可以采用MessageConsumer的receiveҎ(gu)L收下一个消息?/p> <p><strong>消息的异步接?/strong></p> <p>异步接收是指当消息到达时Q主动通知客户端。JMS客户端可以通过注册一个实现MessageListener接口的对象到MessageConsumerQ这P每当消息到达ӞJMS Provider ?x)调用MessageListener中的onMessage Ҏ(gu)?/p> <h3><span style="color: #3064ff;">4.PTP模型</span></h3> <p>PTP(Point-to-Point)模型是基于队列的Q发送方发消息到队列Q接收方从队列接收消息,队列的存在得消息的异步传输成ؓ(f)可能。和邮gpȝ中的邮箱一P队列可以包含各种消息QJMS Provider 提供工具理队列的创建、删除。JMS PTP模型定义了客L(fng)如何向队列发送消息,从队列接收消息,览队列中的消息?/p> <p>下面描述JMS PTP 模型中的主要概念和对象:(x)</p> <div> <table border="1"> <colgroup><col><col></colgroup> <tbody> <tr> <td><strong>名称</strong></td> <td><strong>描述</strong></td> </tr> <tr> <td>Queue</td> <td>由JMS Provider 理Q队列由队列名识别,客户端可以通过JNDI接口用队列名得到一个队列对象?/td> </tr> <tr> <td>TemporaryQueue</td> <td>由QueueConnection 创徏Q而且只能由创建它的QueueConnection 使用?/td> </tr> <tr> <td>QueueConnectionFactory</td> <td>客户端用QueueConnectionFactory 创徏QueueConnection 对象?/td> </tr> <tr> <td>QueueConnection</td> <td>一个到JMS PTP provider 的连接,客户端可以用QueueConnection创徏QueueSession来发送和接收消息?/td> </tr> <tr> <td>QueueSession</td> <td>? 供一些方法创建QueueReceiver、QueueSender、QueueBrowser和TemporaryQueue。如果在 QueueSession关闭Ӟ有一些消息已l被收到Q但q没有被{收(acknowledged)Q那么,当接收者下ơ连接到相同的队列时Q这些消? q会(x)被再ơ接收?/td> </tr> <tr> <td>QueueReceiver</td> <td>客户端用QueueReceiver接收队列中的消息Q如果用户在QueueReceiver中设定了消息选择条gQ那么不W合条g的消息会(x)留在队列中,不会(x)被接收到?/td> </tr> <tr> <td>QueueSender</td> <td>客户端用QueueSender 发送消息到队列?/td> </tr> <tr> <td>QueueBrowser</td> <td>客户端可以QueueBrowser 览队列中的消息Q但不会(x)收走消息?/td> </tr> <tr> <td>QueueRequestor</td> <td>JMS 提供QueueRequestorcȝ化消息的收发q程。QueueRequestor的构造函数有两个参数QQueueSession和queueQQueueRequestor 通过创徏一个(f)旉列来完成最l的收发消息h?/td> </tr> <tr> <td>可靠?Reliability)</td> <td>队列可以长久C存消息直到接收者收到消息。接收者不需要因为担心消息会(x)丢失而时d队列保持Ȁzȝq接状态,充分体现了异步传输模式的优势?/td> </tr> </tbody> </table> </div> <br /> <h3><span style="color: #3064ff;">4.Pub/Sub模型</span></h3> <p>JMS Pub/Sub 模型定义了如何向一个内容节点发布和订阅消息Q这些节点被UC主题(topic)?/p> <p>主题可以被认为是消息的传输中介,发布?publisher)发布消息C题,订阅?subscribe)从主题订阅消息。主题得消息订阅者和消息发布者保持互相独立,不需要接触即可保证消息的传送?/p> <p>下面描述JMS Pub/Sub 模型中的主要概念和对象:(x)</p> <div> <table border="1"> <colgroup><col><col></colgroup> <tbody> <tr> <td><strong>名称 </strong></td> <td><strong>描述</strong></td> </tr> <tr> <td>订阅(subscription)</td> <td>消息订阅分ؓ(f)非持久订?non-durable subscription)和持久订?durablesubscrip-tion)Q非持久订阅只有当客L(fng)处于Ȁzȝ态,也就是和JMS Provider保持q接状态才能收到发送到某个主题的消息,而当客户端处于离U状态,q个旉D发C题的消息会(x)丢失Q永q不?x)收到。持久订阅时Q客L(fng)向JMS注册一个识别自pn份的IDQ当q个客户端处于离U时QJMS Provider ?x)?f)q个ID 保存所有发送到主题的消息,当客户再ơ连接到JMS ProviderӞ?x)根据自qID得到所有当自己处于ȝ时发送到主题的消息?/td> </tr> <tr> <td>Topic</td> <td>主题由JMS Provider 理Q主题由主题名识别,客户端可以通过JNDI接口用主题名得到一个主题对象。JMS没有l出主题的组l和层次l构的定义,由JMS Provider 自己定义?/td> </tr> <tr> <td>TemporaryTopic</td> <td>临时主题由TopicConnection创徏Q而且只能由创建它的TopicConnection使用。(f)时主题不能提供持久订阅功能?/td> </tr> <tr> <td>TopicConnectionFactory</td> <td>客户端用TopicConnectionFactory 创徏TopicConnection 对象?/td> </tr> <tr> <td>TopicConnection</td> <td>TopicConnection 是一个到JMS Pub/Sub provider的连接,客户端可以用TopicConnection创徏TopicSession来发布和订阅消息?/td> </tr> <tr> <td>TopicSession</td> <td>TopicSession提供一些方法创建TopicPublisher、TopicSubscriber、TemporaryTopic。它q提供unsubscribeҎ(gu)取消消息的持久订阅?/td> </tr> <tr> <td>TopicPublisher</td> <td>客户端用TopicPublisher 发布消息C题?/td> </tr> <tr> <td>TopicSubscriber</td> <td>客户端用TopicSubscriber接收发布C题上的消息。可以在TopicSubscriber中设|消息过滤功能,q样Q不W合要求的消息不?x)被接收?/td> </tr> <tr> <td>Durable TopicSubscriber</td> <td>如果一个客L(fng)需要持久订阅消息,可以使用Durable TopicSubscriberQTopSession提供一个方法createDurableSubscriber创徏Durable TopicSubscriber 对象?/td> </tr> <tr> <td>恢复和重新派?Recovery and Redelivery)</td> <td>非持久订阅状态下Q不能恢复或重新zN一个未{收的消息。只有持久订阅才能恢复或重新zN一个未{收的消息?/td> </tr> <tr> <td>TopicRequestor</td> <td>JMS 提供TopicRequestorcȝ化消息的收发q程。TopicRequestor的构造函数有两个参数QTopicSession和topic。TopicRequestor 通过创徏一个(f)时主题来完成最l的发布和接收消息请求?/td> </tr> <tr> <td>可靠?Reliability)</td> <td>当所有的消息必须被接Ӟ则用持久订阅模式。当丢失消息能够被容忍,则用非持久订阅模</td> </tr> </tbody> </table> </div> <p><br /> </p> <br /> <br /> <br /> <script type="text/JavaScript"> alimama_pid="mm_10891533_910884_1874773"; alimama_titlecolor="0000FF"; alimama_descolor ="000000"; alimama_bgcolor="FFFFFF"; alimama_bordercolor="E6E6E6"; alimama_linkcolor="008000"; alimama_bottomcolor="FFFFFF"; alimama_anglesize="0"; alimama_bgpic="0"; alimama_icon="0"; alimama_sizecode="15"; alimama_width=950; alimama_height=90; alimama_type=2; </script> <script src="http://a.alimama.cn/inf.js" type=text/javascript> </script> <img src ="http://www.aygfsteel.com/EvanLiu/aggbug/213934.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/EvanLiu/" target="_blank">EvanLiu</a> 2008-08-03 17:51 <a href="http://www.aygfsteel.com/EvanLiu/archive/2008/08/03/213934.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JAAS学习(fn)http://www.aygfsteel.com/EvanLiu/archive/2008/08/02/212749.htmlEvanLiuEvanLiuSat, 02 Aug 2008 05:52:00 GMThttp://www.aygfsteel.com/EvanLiu/archive/2008/08/02/212749.htmlhttp://www.aygfsteel.com/EvanLiu/comments/212749.htmlhttp://www.aygfsteel.com/EvanLiu/archive/2008/08/02/212749.html#Feedback0http://www.aygfsteel.com/EvanLiu/comments/commentRss/212749.htmlhttp://www.aygfsteel.com/EvanLiu/services/trackbacks/212749.html 目前行的Acegi中也提供了JAAS
JAAS的几个核心类和接口:(x)
  1.Subject: 实际被认证的人或者服?br />   2.Principal (interface): Subject的唯一标识。一个Subject含有一个或多个PricipalQ比如一个h有n份证、护照等Pricipal
  3.LoginContext
  4.LoginModule (interface)
  5.CallbackHandler (interface)
q有两个配置文gQ?#215;××.confQ或configQ??×××..policy
JAAS首先使用一个LoginContextcL查找配置文g中的内容Q这些内容可以用来对LoginModulesq行初始化。所? LoginContext没有指定的初始化参数都会(x)包含在配|文件中。LoginContext向LoginModule传递一个CallbackHandler对象和一个SubjectQ如果LoginModuleq需要其他认证信息,它就?x)用CallbackHandler回调适当的应用程序,从而获得这些信息?br />
在应用程序中Q一般这样用LoginContext:
    try {
        LoginContext loginContext = new LoginContext("Sample", callbackHandler );  //"Sample"定义在相关的conf文g? callbackHandler见下?br />         loginContext.login();  //如果认证p|Q则抛出异常
    } catch (LoginException e) {
        //do sth.
    }

我们要用JAASQ就需要实Cq接口,以及(qing)配置好文?br /> 上面的代码,只是在应用时Q这样写够了。当?dng)在这之前Q还需要设|callbackHandlerQ?br />     SampleCallbackHandler callbackHandler = new SampleCallbackHandler();
    // 讄用户名、密码等需要验证的信息到callbackHandler里。具体怎么设,看自qSampleCallbackHandler怎么设计?br />      ......

举例Q?br />     public class SampleCallbackHandler implements CallbackHandler {
        protected String username;
        protected String password;

        public void handle(Callback[] callbacks)
            throws UnsupportedCallbackException {    //q个Ҏ(gu)是必d现的,用来讄username和password到对应的Callback变量?br />                for (int index = 0; index < callbacks.length; index++) {
                   
if (callbacks[index] instanceof NameCallback) {
                    NameCallback ncb 
= (NameCallback) callbacks[index];
                    ncb.setName(username);
              } else
if (callbacks[index] instanceof PasswordCallback) {
                    PasswordCallback pcb 
= (PasswordCallback) callbacks[index];
                    pcb.setPassword(password.toCharArray());
              } else if() {  //如果q有其他需要验证的信息
                       ...
              }
        }
       
        //其他Ҏ(gu)Q诸如设|username和password
    }

    然后来说前面?Sample"。这里的"Sample"对应一个Sample.conf文gQ这个文件的具体位置可以自己讄。conf文g中配|了对应的LoginModulec,可以是一个或多个Q用来做不同的验证?br />     public class SampleLoginModule implements LoginModule {
        ....
    }
LoginModule?个方法需要实玎ͼ单点写个Ҏ(gu)名得了:(x)
public void initialize(Subject subject, CallbackHandler callbackHandler, Map arg2, Map arg3);
public boolean login() throws LoginException;
public boolean commit() throws LoginException;
public boolean abort() throws LoginException;
public boolean logout() throws LoginException;
业务逻辑主要在login()中实玎ͼ步骤包括了从callbackHandler中读取用户名密码Q然后该从数据库验证׃数据库验证,该从配置文g验证׃配置文g验证Q该从其他系l中验证׃其他pȝ中验?..

Pricipal的实现就不写了,下面链接中的例子写得很详l。我的只是给自己理一个大概步骤,以后回顾h也方?br /> 不过Subject和Pricipal应该有更重要的用处,比如在Authorization中,把pricipal和要可以执行的相x作对应v来。这个还没看下去Q接触的代码中也没用到。放C后补?br />
更多内容Q可直接查看sun的JDK文档http://java.sun.com/javase/6/docs/technotes/guides/security/jaas/JAASRefGuide.html
实例Q?a href="http://www.aygfsteel.com/fastunit/archive/2008/01/28/178204.html">http://www.aygfsteel.com/fastunit/archive/2008/01/28/178204.html






EvanLiu 2008-08-02 13:52 发表评论
]]>
struts validate之ApplicationResources.properties内容dqhttp://www.aygfsteel.com/EvanLiu/archive/2008/06/16/208276.htmlEvanLiuEvanLiuMon, 16 Jun 2008 04:42:00 GMThttp://www.aygfsteel.com/EvanLiu/archive/2008/06/16/208276.htmlhttp://www.aygfsteel.com/EvanLiu/comments/208276.htmlhttp://www.aygfsteel.com/EvanLiu/archive/2008/06/16/208276.html#Feedback0http://www.aygfsteel.com/EvanLiu/comments/commentRss/208276.htmlhttp://www.aygfsteel.com/EvanLiu/services/trackbacks/208276.html ~码qo(h)器设|成UTF-8~码
配置都正,在jdk\bin目录下,用native2ascii ApplicationResources.properties ApplicationResources2.properties
l果JSP面昄提示信息Ӟ提示信息成了q?br />
解决办法Qnative2ascii -encoding UTF-8 ApplicationResources.properties ApplicationResources2.properties

感谢http://kenshinlk.javaeye.com/blog/59080



EvanLiu 2008-06-16 12:42 发表评论
]]>
struts validate之ValidatorActionFormhttp://www.aygfsteel.com/EvanLiu/archive/2008/06/15/207964.htmlEvanLiuEvanLiuSat, 14 Jun 2008 16:58:00 GMThttp://www.aygfsteel.com/EvanLiu/archive/2008/06/15/207964.htmlhttp://www.aygfsteel.com/EvanLiu/comments/207964.htmlhttp://www.aygfsteel.com/EvanLiu/archive/2008/06/15/207964.html#Feedback0http://www.aygfsteel.com/EvanLiu/comments/commentRss/207964.htmlhttp://www.aygfsteel.com/EvanLiu/services/trackbacks/207964.html
代码如下Q?br /> public class UserForm extends ValidatorActionForm {
    private Integer id;
    private String name;
    private String password;
    private String confirmpwd;
    private String email;
    private Integer sex;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    ...
}
Actioncȝq?br /> validation.xml:
<formset>
        <form name="/register/register">
            <field property="name" depends="required">
                <arg0 key="user.name"/> 
            </field>
            <field property="confirmpwd" depends="required">
                <arg0 key="user.confirmpwd"/>
            </field>
        </form>
    ...

ApplicationContext.properties:
user.name = {0}\u6d93\u5d88\u5158\u6d93\u8679\u2516
    ...

~译后,ApplicationContext.properties能在WEB-INF\classes下找刎ͼ且struts-config.xml里也已添?br />
JSP面Q?br />     ...
<html:form action="/register/register" method="post" enctype="multipart/form-data">            
    <input type="hidden" name="method" value="register" />   
    <div class="reg03">
        <html:text property="name" styleId="name" style="width:245px" />
        <font color="red"><html:errors property="name"/></font>        
    </div>
    ...

l果Q验证v作用Q但是提CZ息打C出来?nbsp;
HELPQ!Q?br />
已解?br /> 需要修改validation.xml和ApplicationContext.properties
validation.xml:
    ...
<field property="name" depends="required">
    <msg name="required" key="user.required"/>
    <arg0 key="user.name"/>
    ...

ApplicationContext.properties Q未转码前)(j)
    ...
user.name=姓名
user.required={0}不能为空
    ...






EvanLiu 2008-06-15 00:58 发表评论
]]>
foxmail下邮件CSS׃的问?/title><link>http://www.aygfsteel.com/EvanLiu/archive/2008/05/13/200189.html</link><dc:creator>EvanLiu</dc:creator><author>EvanLiu</author><pubDate>Tue, 13 May 2008 05:32:00 GMT</pubDate><guid>http://www.aygfsteel.com/EvanLiu/archive/2008/05/13/200189.html</guid><wfw:comment>http://www.aygfsteel.com/EvanLiu/comments/200189.html</wfw:comment><comments>http://www.aygfsteel.com/EvanLiu/archive/2008/05/13/200189.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/EvanLiu/comments/commentRss/200189.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/EvanLiu/services/trackbacks/200189.html</trackback:ping><description><![CDATA[今天做一个邮件程序,试Ӟ发现用foxmail攉件时QCSS׃。后来看源码Q发?lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">q段声明在显C的时候被qo(h)掉了。在<!DOCTYPE 前加了字W,然后?x)蟩q字W,?lt;!DOCTYPE qo(h)。后?span style="color: red;">写了两行<!DOCTYPE 声明</span>QCSS正怺。应该是foxmail的规则是只过滤第一行声明?br /> <br /> 另外Q用outlook2007攉件的时候,当图片是写在css里的时候,不能下蝲囄。在“工具-信Q中心-自动下蝲”那里取消了禁止自动下载功能,仍然不能昄。目前仍未解?br /> <br /> <br /> <script type="text/JavaScript"> alimama_pid="mm_10891533_910884_1874773"; alimama_titlecolor="0000FF"; alimama_descolor ="000000"; alimama_bgcolor="FFFFFF"; alimama_bordercolor="E6E6E6"; alimama_linkcolor="008000"; alimama_bottomcolor="FFFFFF"; alimama_anglesize="0"; alimama_bgpic="0"; alimama_icon="0"; alimama_sizecode="15"; alimama_width=950; alimama_height=90; alimama_type=2; </script> <script src="http://a.alimama.cn/inf.js" type=text/javascript> </script> <img src ="http://www.aygfsteel.com/EvanLiu/aggbug/200189.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/EvanLiu/" target="_blank">EvanLiu</a> 2008-05-13 13:32 <a href="http://www.aygfsteel.com/EvanLiu/archive/2008/05/13/200189.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> վ֩ģ壺 <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">̩</a>| <a href="http://" target="_blank">ƽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ĵ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">˫</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">¡</a>| <a href="http://" target="_blank">÷ӿ</a>| <a href="http://" target="_blank">Զ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ҵ</a>| <a href="http://" target="_blank">«Ϫ</a>| <a href="http://" target="_blank">躣</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ԭ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">˱</a>| <a href="http://" target="_blank">̨</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ʶ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ԣ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ľ</a>| <a href="http://" target="_blank">ľ</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>