001 /** 002 * 003 * Copyright 2004 Protique Ltd 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 * 017 **/ 018 package org.codehaus.activesoap.policy.addressing; 019 020 import org.codehaus.activesoap.HandlerRegistry; 021 import org.codehaus.activesoap.handler.Policy; 022 import org.codehaus.activesoap.handler.stax.AnyElementMarshaler; 023 import org.codehaus.activesoap.policy.addressing.handler.AttributedURIHandler; 024 import org.codehaus.activesoap.policy.addressing.handler.EndpointReferenceTypeHandler; 025 import org.codehaus.activesoap.policy.addressing.handler.RelationshipHandler; 026 027 import javax.xml.namespace.QName; 028 029 /** 030 * Represents an ActiveSOAP policy to maintain a WS-Addressing context via the 031 * {@link AddressingContext} class 032 * 033 * @version $Revision: 1.4 $ 034 */ 035 public class AddressingPolicy implements Policy { 036 public static final String DEFAULT_NAMESPACE = "http://schemas.xmlsoap.org/ws/2003/03/addressing"; 037 038 private AnyElementMarshaler anyContentMarshaler; 039 040 public AddressingPolicy(AnyElementMarshaler anyContentMarshaler) { 041 this.anyContentMarshaler = anyContentMarshaler; 042 } 043 044 public void addPolicy(HandlerRegistry registry) { 045 registry.addHandler(AddressingContext.MessageID_QNAME, new AttributedURIHandler() { 046 protected void setValue(AddressingContext context, AttributedURI value) { 047 context.setMessageID(value); 048 } 049 }); 050 registry.addHandler(AddressingContext.RelatesTo_QNAME, new RelationshipHandler() { 051 protected void setValue(AddressingContext context, Relationship value) { 052 context.setRelatesTo(value); 053 } 054 }); 055 registry.addHandler(AddressingContext.To_QNAME, new AttributedURIHandler() { 056 protected void setValue(AddressingContext context, AttributedURI value) { 057 context.setTo(value); 058 } 059 }); 060 registry.addHandler(AddressingContext.Action_QNAME, new AttributedURIHandler() { 061 protected void setValue(AddressingContext context, AttributedURI value) { 062 context.setAction(value); 063 } 064 }); 065 registry.addHandler(AddressingContext.From_QNAME, new EndpointReferenceTypeHandler(anyContentMarshaler) { 066 protected void setValue(AddressingContext context, EndpointReferenceType value) { 067 context.setFrom(value); 068 } 069 }); 070 registry.addHandler(AddressingContext.ReplyTo_QNAME, new EndpointReferenceTypeHandler(anyContentMarshaler) { 071 protected void setValue(AddressingContext context, EndpointReferenceType value) { 072 context.setReplyTo(value); 073 } 074 }); 075 registry.addHandler(AddressingContext.FaultTo_QNAME, new EndpointReferenceTypeHandler(anyContentMarshaler) { 076 protected void setValue(AddressingContext context, EndpointReferenceType value) { 077 context.setFaultTo(value); 078 } 079 }); 080 registry.addHandler(AddressingContext.Recipient_QNAME, new EndpointReferenceTypeHandler(anyContentMarshaler) { 081 protected void setValue(AddressingContext context, EndpointReferenceType value) { 082 context.setRecipient(value); 083 } 084 }); 085 } 086 087 public void removePolicy(HandlerRegistry registry) { 088 } 089 }