KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > celtix > systest > ws > addressing > jms > Server


1 package org.objectweb.celtix.systest.ws.addressing.jms;
2
3
4 import java.net.URL JavaDoc;
5 import java.util.List JavaDoc;
6 import java.util.logging.Level JavaDoc;
7 import java.util.logging.Logger JavaDoc;
8
9 import javax.xml.ws.Endpoint;
10 import javax.xml.ws.handler.Handler;
11
12 import org.objectweb.celtix.systest.common.TestServerBase;
13 import org.objectweb.celtix.systest.ws.addressing.HeaderVerifier;
14 import org.objectweb.celtix.systest.ws.addressing.MAPVerifier;
15 import org.objectweb.celtix.systest.ws.addressing.VerificationCache;
16
17 public class Server extends TestServerBase implements VerificationCache {
18     
19     private String JavaDoc verified;
20  
21     protected void run() {
22         GreeterImpl implementor = new GreeterImpl();
23         implementor.verificationCache = this;
24         String JavaDoc address = "jms:ConnectionFactory#dynamicQueues/test.jmstransport.addressing.queue";
25         URL JavaDoc url = getClass().getResource("client.xml");
26         assertNotNull("cannot find test resource", url);
27         String JavaDoc configFileName = url.toString();
28         if (configFileName != null) {
29             System.setProperty("celtix.config.file", configFileName);
30         }
31         
32         Endpoint endpoint = Endpoint.publish(address, implementor);
33         List JavaDoc<Handler> handlerChain = endpoint.getBinding().getHandlerChain();
34         for (Object JavaDoc h : handlerChain) {
35             if (h instanceof MAPVerifier) {
36                 ((MAPVerifier)h).setVerificationCache(this);
37             } else if (h instanceof HeaderVerifier) {
38                 ((HeaderVerifier)h).setVerificationCache(this);
39             }
40         }
41     }
42     
43     public static void main(String JavaDoc[] args) {
44         try {
45             Server s = new Server();
46             s.start();
47         } catch (Exception JavaDoc ex) {
48             ex.printStackTrace();
49             System.exit(-1);
50         } finally {
51             System.out.println("done!");
52         }
53     }
54
55     public void put(String JavaDoc verification) {
56         if (verification != null) {
57             verified = verified == null
58                        ? verification
59                 : verified + "; " + verification;
60         }
61     }
62
63     /**
64      * Used to facilitate assertions on server-side behaviour.
65      *
66      * @param log logger to use for diagnostics if assertions fail
67      * @return true if assertions hold
68      */

69     protected boolean verify(Logger JavaDoc log) {
70         if (verified != null) {
71             log.log(Level.WARNING,
72                     "MAP/Header verification failed: {0}",
73                     verified);
74         }
75         return verified == null;
76     }
77 }
78
Popular Tags