01: package org.objectweb.celtix.systest.ws.addressing.jms;
02:
03: import java.net.URL;
04: import java.util.List;
05: import java.util.logging.Level;
06: import java.util.logging.Logger;
07:
08: import javax.xml.ws.Endpoint;
09: import javax.xml.ws.handler.Handler;
10:
11: import org.objectweb.celtix.systest.common.TestServerBase;
12: import org.objectweb.celtix.systest.ws.addressing.HeaderVerifier;
13: import org.objectweb.celtix.systest.ws.addressing.MAPVerifier;
14: import org.objectweb.celtix.systest.ws.addressing.VerificationCache;
15:
16: public class Server extends TestServerBase implements VerificationCache {
17:
18: private String verified;
19:
20: protected void run() {
21: GreeterImpl implementor = new GreeterImpl();
22: implementor.verificationCache = this ;
23: String address = "jms:ConnectionFactory#dynamicQueues/test.jmstransport.addressing.queue";
24: URL url = getClass().getResource("client.xml");
25: assertNotNull("cannot find test resource", url);
26: String configFileName = url.toString();
27: if (configFileName != null) {
28: System.setProperty("celtix.config.file", configFileName);
29: }
30:
31: Endpoint endpoint = Endpoint.publish(address, implementor);
32: List<Handler> handlerChain = endpoint.getBinding()
33: .getHandlerChain();
34: for (Object 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[] args) {
44: try {
45: Server s = new Server();
46: s.start();
47: } catch (Exception ex) {
48: ex.printStackTrace();
49: System.exit(-1);
50: } finally {
51: System.out.println("done!");
52: }
53: }
54:
55: public void put(String verification) {
56: if (verification != null) {
57: verified = verified == null ? verification : verified
58: + "; " + verification;
59: }
60: }
61:
62: /**
63: * Used to facilitate assertions on server-side behaviour.
64: *
65: * @param log logger to use for diagnostics if assertions fail
66: * @return true if assertions hold
67: */
68: protected boolean verify(Logger log) {
69: if (verified != null) {
70: log.log(Level.WARNING,
71: "MAP/Header verification failed: {0}", verified);
72: }
73: return verified == null;
74: }
75: }
|