KickJava   Java API By Example, From Geeks To Geeks.

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


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

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