|
Apache CXF example source code file (WSActionAnnotator.java)
The Apache CXF WSActionAnnotator.java source code/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.annotator; import java.util.ArrayList; import java.util.List; import javax.xml.namespace.QName; import javax.xml.ws.Action; import javax.xml.ws.FaultAction; import org.apache.cxf.common.util.StringUtils; import org.apache.cxf.service.model.AbstractMessageContainer; import org.apache.cxf.service.model.FaultInfo; import org.apache.cxf.service.model.MessageInfo; import org.apache.cxf.service.model.OperationInfo; import org.apache.cxf.tools.common.model.Annotator; import org.apache.cxf.tools.common.model.JAnnotation; import org.apache.cxf.tools.common.model.JAnnotationElement; import org.apache.cxf.tools.common.model.JavaAnnotatable; import org.apache.cxf.tools.common.model.JavaException; import org.apache.cxf.tools.common.model.JavaInterface; import org.apache.cxf.tools.common.model.JavaMethod; public final class WSActionAnnotator implements Annotator { private static final QName WSAW_ACTION_QNAME = new QName("http://www.w3.org/2006/05/addressing/wsdl", "Action"); private static final QName WSAM_ACTION_QNAME = new QName("http://www.w3.org/2007/05/addressing/metadata", "Action"); private static final QName WSAW_OLD_ACTION_QNAME = new QName("http://www.w3.org/2005/02/addressing/wsdl", "Action"); private OperationInfo operation; public WSActionAnnotator(final OperationInfo op) { this.operation = op; } private String getAction(AbstractMessageContainer mi) { QName action = (QName)mi.getExtensionAttribute(WSAW_ACTION_QNAME); if (action == null) { action = (QName)mi.getExtensionAttribute(WSAM_ACTION_QNAME); } if (action == null) { action = (QName)mi.getExtensionAttribute(WSAW_OLD_ACTION_QNAME); } if (action != null) { String s = action.getLocalPart(); if (!StringUtils.isEmpty(s)) { return s; } } return null; } public void annotate(JavaAnnotatable ja) { JavaMethod method; if (ja instanceof JavaMethod) { method = (JavaMethod) ja; } else { throw new RuntimeException("Action can only annotate JavaMethod"); } boolean required = false; JavaInterface intf = method.getInterface(); MessageInfo inputMessage = operation.getInput(); MessageInfo outputMessage = operation.getOutput(); JAnnotation actionAnnotation = new JAnnotation(Action.class); if (inputMessage.getExtensionAttributes() != null) { String inputAction = getAction(inputMessage); if (inputAction != null) { actionAnnotation.addElement(new JAnnotationElement("input", inputAction)); required = true; } } if (outputMessage != null && outputMessage.getExtensionAttributes() != null) { String outputAction = getAction(outputMessage); if (outputAction != null) { actionAnnotation.addElement(new JAnnotationElement("output", outputAction)); required = true; } } if (operation.hasFaults()) { List<JAnnotation> faultAnnotations = new ArrayList Other Apache CXF examples (source code examples)Here is a short list of links related to this Apache CXF WSActionAnnotator.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.