Author: alessio.soldano(a)jboss.com
Date: 2013-06-14 09:46:58 -0400 (Fri, 14 Jun 2013)
New Revision: 17678
Added:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/extensions/policy/
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/extensions/policy/EndpointPolicyAttachments.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/extensions/policy/PolicyAttachment.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/extensions/policy/PolicyAttachmentStore.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/extensions/policy/PolicySetsAnnotationListener.java
stack/cxf/trunk/modules/client/src/main/resources/META-INF/policies/org.jboss.wsf.stack.cxf.extensions.policy.PolicyAttachmentStore
stack/cxf/trunk/modules/client/src/test/resources/META-INF/policies/org.jboss.wsf.stack.cxf.extensions.policy.PolicyAttachmentStore
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3648-b/policies/org.jboss.wsf.stack.cxf.extensions.policy.PolicyAttachmentStore
Removed:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/policy/
stack/cxf/trunk/modules/client/src/main/resources/META-INF/policies/org.jboss.wsf.stack.cxf.policy.PolicyAttachmentStore
stack/cxf/trunk/modules/client/src/test/resources/META-INF/policies/org.jboss.wsf.stack.cxf.policy.PolicyAttachmentStore
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3648-b/policies/org.jboss.wsf.stack.cxf.policy.PolicyAttachmentStore
Modified:
stack/cxf/trunk/modules/client/src/test/java/org/jboss/wsf/stack/cxf/policy/PolicySetsTest.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/EndpointFour.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/EndpointOneImpl.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/EndpointThree.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/EndpointTwo.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/AnnotatedServiceImpl.java
Log:
[JBWS-3648] Package refactoring + moving @PolicySets to jbossws-api
Added:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/extensions/policy/EndpointPolicyAttachments.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/extensions/policy/EndpointPolicyAttachments.java
(rev 0)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/extensions/policy/EndpointPolicyAttachments.java 2013-06-14
13:46:58 UTC (rev 17678)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.extensions.policy;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cxf.annotations.Policy.Placement;
+
+
+/**
+ * A class for collecting policy attachments for a given endpoint
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 03-Jun-2013
+ *
+ */
+public class EndpointPolicyAttachments
+{
+ private Map<Placement, List<PolicyAttachment>> attachmentMap;
+
+ private EndpointPolicyAttachments(Map<Placement, List<PolicyAttachment>>
attachmentMap) {
+ this.attachmentMap = attachmentMap;
+ }
+
+ public static EndpointPolicyAttachments newInstance(String[] sets,
PolicyAttachmentStore store) {
+ Map<Placement, List<PolicyAttachment>> map = new HashMap<Placement,
List<PolicyAttachment>>();
+ for (String set : sets) {
+ List<PolicyAttachment> attachments = store.get(set);
+ for (PolicyAttachment attachment: attachments) {
+ Placement p = attachment.getPlacement();
+ if (map.containsKey(p)) {
+ map.get(p).add(attachment);
+ } else {
+ List<PolicyAttachment> list = new
ArrayList<PolicyAttachment>(4);
+ list.add(attachment);
+ map.put(attachment.getPlacement(), list);
+ }
+ }
+ }
+ return new EndpointPolicyAttachments(map);
+ }
+
+ public List<PolicyAttachment> getPolicyAttachments(Placement placement)
+ {
+ List<PolicyAttachment> pal = attachmentMap.get(placement);
+ if (pal == null) {
+ return Collections.emptyList();
+ } else {
+ return pal;
+ }
+ }
+}
Added:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/extensions/policy/PolicyAttachment.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/extensions/policy/PolicyAttachment.java
(rev 0)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/extensions/policy/PolicyAttachment.java 2013-06-14
13:46:58 UTC (rev 17678)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.extensions.policy;
+
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.cxf.annotations.Policy.Placement;
+import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.staxutils.StaxUtils;
+import org.apache.cxf.ws.policy.PolicyConstants;
+import org.jboss.wsf.stack.cxf.Messages;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * A lazy-loaded Policy attachment reference
+ * with the placement point it is meant for.
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 03-Jun-2013
+ *
+ */
+public class PolicyAttachment
+{
+ private Placement placement;
+ private String uri;
+
+ public PolicyAttachment(Placement placement, String uri)
+ {
+ this.placement = placement;
+ this.uri = uri;
+ }
+
+ public Placement getPlacement()
+ {
+ return placement;
+ }
+
+ public Element read(String defName)
+ {
+ XMLStreamReader reader = null;
+ InputStream is = null;
+ try
+ {
+ is = new URL(uri).openStream();
+ reader = StaxUtils.createXMLStreamReader(is);
+ Document doc = StaxUtils.read(reader);
+ Element elem = doc.getDocumentElement();
+ String id = elem.getAttributeNS(PolicyConstants.WSU_NAMESPACE_URI,
PolicyConstants.WSU_ID_ATTR_NAME);
+ if (StringUtils.isEmpty(id))
+ {
+ Attr att = doc.createAttributeNS(PolicyConstants.WSU_NAMESPACE_URI,
"wsu:" + PolicyConstants.WSU_ID_ATTR_NAME);
+ att.setNodeValue(defName);
+ elem.setAttributeNodeNS(att);
+ }
+ return elem;
+ }
+ catch (Exception e)
+ {
+ throw Messages.MESSAGES.errorParsingPolicyAttachment(uri, e);
+ }
+ finally
+ {
+ StaxUtils.close(reader);
+ if (is != null) {
+ try {
+ is.close();
+ } catch (Exception e) {
+ //ignore
+ }
+ }
+ }
+ }
+}
Added:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/extensions/policy/PolicyAttachmentStore.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/extensions/policy/PolicyAttachmentStore.java
(rev 0)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/extensions/policy/PolicyAttachmentStore.java 2013-06-14
13:46:58 UTC (rev 17678)
@@ -0,0 +1,163 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.extensions.policy;
+
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cxf.annotations.Policy.Placement;
+import org.jboss.wsf.stack.cxf.client.ProviderImpl;
+
+
+/**
+ * The store containing pre-defined policy attachments
+ * grouped by set name; lazy loaded on first use.
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 03-Jun-2013
+ *
+ */
+public class PolicyAttachmentStore
+{
+ private static final String POLICY_ATTACHMENT_LOCATION =
"META-INF/policies/";
+ private final Map<String, List<PolicyAttachment>> attachments;
+ private static PolicyAttachmentStore defaultServerInstance;
+
+ /**
+ * Creates a PolicyAttachmentStore parsing policy sets located
+ * using the provided classloader.
+ *
+ * @param cl
+ */
+ public PolicyAttachmentStore(ClassLoader cl) {
+ Map<String, List<PolicyAttachment>> map = new HashMap<String,
List<PolicyAttachment>>();
+ parsePolicyAttachmentResources(cl, map);
+ attachments = map;
+ }
+
+ /**
+ * Get a singleton PolicyAttachmentStore getting policy sets using
+ * the classloader of JBossWS-CXF JAXWS Provider SPI impl.
+ *
+ * @return
+ */
+ public static synchronized PolicyAttachmentStore getDefaultInstance() {
+ if (defaultServerInstance == null) {
+ defaultServerInstance = new
PolicyAttachmentStore(ProviderImpl.class.getClassLoader());
+ }
+ return defaultServerInstance;
+ }
+
+ public void merge(PolicyAttachmentStore pas) {
+ this.attachments.putAll(pas.attachments);
+ }
+
+ public List<PolicyAttachment> get(String setName)
+ {
+ List<PolicyAttachment> l = attachments.get(setName);
+ if (l != null && !l.isEmpty()) {
+ return Collections.unmodifiableList(l);
+ } else {
+ return Collections.emptyList();
+ }
+ }
+
+ public boolean isEmpty() {
+ return attachments.isEmpty();
+ }
+
+ private static void parsePolicyAttachmentResources(ClassLoader cl, Map<String,
List<PolicyAttachment>> map) {
+ try {
+ Enumeration<URL> urls = getResources(cl, POLICY_ATTACHMENT_LOCATION +
PolicyAttachmentStore.class.getName());
+ if (urls != null) {
+ while (urls.hasMoreElements()) {
+ parsePolicyAttachmentStore(urls.nextElement(), map);
+ }
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static void parsePolicyAttachmentStore(URL url, Map<String,
List<PolicyAttachment>> map) throws IOException {
+ InputStream storeStream = url.openStream();
+ if (storeStream != null) {
+ String baseUrl = url.toString();
+ baseUrl = baseUrl.substring(0, baseUrl.length() -
PolicyAttachmentStore.class.getName().length());
+ BufferedReader br = new BufferedReader(new InputStreamReader(storeStream,
"UTF-8"));
+ try {
+ String set;
+ while ((set = br.readLine()) != null) {
+ for (Placement p : Placement.values()) {
+ final String newUrl = baseUrl + set + "-" + p +
".xml";
+ final URL policyAttachmentUrl = new URL(newUrl);
+ InputStream is = null;
+ try {
+ is = policyAttachmentUrl.openStream();
+ if (is != null) {
+ if (map.containsKey(set)) {
+ map.get(set).add(new PolicyAttachment(p, newUrl));
+ } else {
+ List<PolicyAttachment> list = new
ArrayList<PolicyAttachment>(4);
+ list.add(new PolicyAttachment(p, newUrl));
+ map.put(set, list);
+ }
+ }
+ } catch (FileNotFoundException fnfe) {
+ //ignore
+ } finally {
+ if (is != null)
+ is.close();
+ }
+ }
+ }
+ } finally {
+ br.close();
+ }
+ }
+ }
+
+ private static Enumeration<URL> getResources(final ClassLoader cl, final String
filename) throws Exception {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null) {
+ return cl.getResources(filename);
+ } else {
+ return AccessController.doPrivileged(new
PrivilegedExceptionAction<Enumeration<URL>>() {
+ public Enumeration<URL> run() throws Exception {
+ return cl.getResources(filename);
+ }
+ });
+ }
+ }
+}
Added:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/extensions/policy/PolicySetsAnnotationListener.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/extensions/policy/PolicySetsAnnotationListener.java
(rev 0)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/extensions/policy/PolicySetsAnnotationListener.java 2013-06-14
13:46:58 UTC (rev 17678)
@@ -0,0 +1,270 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.extensions.policy;
+
+import static org.jboss.wsf.stack.cxf.Loggers.ROOT_LOGGER;
+
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.wsdl.extensions.UnknownExtensibilityElement;
+
+import org.apache.cxf.annotations.Policy.Placement;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.service.factory.AbstractServiceFactoryBean;
+import org.apache.cxf.service.factory.FactoryBeanListener;
+import org.apache.cxf.service.model.AbstractPropertiesHolder;
+import org.apache.cxf.service.model.BindingFaultInfo;
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.DescriptionInfo;
+import org.apache.cxf.service.model.FaultInfo;
+import org.apache.cxf.service.model.InterfaceInfo;
+import org.apache.cxf.service.model.OperationInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.ws.policy.PolicyConstants;
+import org.apache.neethi.Constants;
+import org.jboss.ws.api.annotation.PolicySets;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * A FactoryBeanListener that adds policies according to a given map of
EndpointPolicyAttachment
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 03-Jun-2013
+ */
+public class PolicySetsAnnotationListener implements FactoryBeanListener
+{
+ private final Map<Class<?>, EndpointPolicyAttachments> epaMap = new
HashMap<Class<?>, EndpointPolicyAttachments>();
+ private PolicyAttachmentStore store;
+
+ public PolicySetsAnnotationListener() {
+ this.store = PolicyAttachmentStore.getDefaultInstance();
+ }
+
+ public PolicySetsAnnotationListener(ClassLoader cl) {
+ this.store = PolicyAttachmentStore.getDefaultInstance();
+ if (cl != null) {
+ PolicyAttachmentStore pas = new PolicyAttachmentStore(cl);
+ if (!pas.isEmpty()) {
+ pas.merge(this.store);
+ this.store = pas;
+ }
+ }
+ }
+
+ public PolicySetsAnnotationListener(PolicyAttachmentStore store) {
+ this.store = store;
+ }
+
+ protected EndpointPolicyAttachments getEndpointPolicyAttachment(Class<?> clazz)
{
+ if (epaMap.containsKey(clazz)) {
+ return epaMap.get(clazz);
+ } else {
+ final PolicySets ps = clazz.getAnnotation(PolicySets.class);
+ final EndpointPolicyAttachments epa = (ps != null) ?
EndpointPolicyAttachments.newInstance(ps.value(), store) : null;
+ epaMap.put(clazz, epa);
+ return epa;
+ }
+ }
+
+ public void handleEvent(Event ev, AbstractServiceFactoryBean factory, Object... args)
+ {
+ switch (ev)
+ {
+ case ENDPOINT_SELECTED : {
+ Class<?> cls = (Class<?>) args[2];
+ Class<?> implCls = (Class<?>) args[3];
+ Endpoint ep = (Endpoint) args[1];
+ addPolicies(factory, ep, cls, implCls);
+ break;
+ }
+ case BINDING_OPERATION_CREATED :
+ BindingOperationInfo boi = (BindingOperationInfo) args[1];
+ Method m = (Method) args[2];
+ addPolicies(factory, boi.getOperationInfo(), m);
+ break;
+ default :
+ //ignore
+ }
+ }
+
+ private void addPolicies(AbstractServiceFactoryBean factory, OperationInfo inf, Method
m)
+ {
+ if (m == null)
+ {
+ return;
+ }
+
+ final Class<?> cls = m.getDeclaringClass();
+ EndpointPolicyAttachments epa = getEndpointPolicyAttachment(cls);
+ if (epa != null)
+ {
+ final ServiceInfo service = inf.getInterface().getService();
+ for (PolicyAttachment pa :
epa.getPolicyAttachments(Placement.PORT_TYPE_OPERATION)) {
+ addPolicy(inf, service, pa, cls, inf.getName().getLocalPart() +
"PortTypeOpPolicy");
+ }
+ for (PolicyAttachment pa :
epa.getPolicyAttachments(Placement.PORT_TYPE_OPERATION_INPUT)) {
+ addPolicy(inf.getInput(), service, pa, cls, inf.getName().getLocalPart() +
"PortTypeOpInputPolicy");
+ }
+ for (PolicyAttachment pa :
epa.getPolicyAttachments(Placement.PORT_TYPE_OPERATION_OUTPUT)) {
+ addPolicy(inf.getOutput(), service, pa, cls, inf.getName().getLocalPart() +
"PortTypeOpOutputPolicy");
+ }
+ for (PolicyAttachment pa :
epa.getPolicyAttachments(Placement.PORT_TYPE_OPERATION_FAULT)) {
+ for (FaultInfo f : inf.getFaults())
+ {
+ addPolicy(f, service, pa, cls, f.getName().getLocalPart() +
"PortTypeOpFaultPolicy");
+ }
+ }
+ }
+ }
+
+ private void addPolicies(AbstractServiceFactoryBean factory, Endpoint ep,
Class<?> seiCls, Class<?> implCls)
+ {
+ EndpointPolicyAttachments epa = null;
+ Class<?> cls = seiCls;
+ if (ep.getEndpointInfo().getInterface() != null) {
+ epa = getEndpointPolicyAttachment(seiCls);
+ }
+ if (epa == null) {
+ cls = implCls;
+ epa = getEndpointPolicyAttachment(implCls);
+ }
+ if (epa != null) {
+ final BindingInfo binf = ep.getBinding().getBindingInfo();
+ final ServiceInfo si = ep.getService().getServiceInfos().get(0);
+ final InterfaceInfo inf = ep.getEndpointInfo().getInterface();
+
+ for (PolicyAttachment pa : epa.getPolicyAttachments(Placement.BINDING)) {
+ addPolicy(binf, si, pa, cls, binf.getName().getLocalPart() +
"BindingPolicy");
+ }
+ for (PolicyAttachment pa : epa.getPolicyAttachments(Placement.PORT_TYPE)) {
+ addPolicy(inf, si, pa, cls, inf.getName().getLocalPart() +
"PortTypePolicy");
+ }
+ for (PolicyAttachment pa : epa.getPolicyAttachments(Placement.SERVICE)) {
+ addPolicy(si, si, pa, cls, si.getName().getLocalPart() +
"ServicePolicy");
+ }
+ for (PolicyAttachment pa : epa.getPolicyAttachments(Placement.SERVICE_PORT)) {
+ addPolicy(ep.getEndpointInfo(), si, pa, cls,
ep.getEndpointInfo().getName().getLocalPart()
+ + "PortPolicy");
+ }
+
+ for (BindingOperationInfo binfo : binf.getOperations())
+ {
+ for (PolicyAttachment pa :
epa.getPolicyAttachments(Placement.BINDING_OPERATION)) {
+ addPolicy(binfo, si, pa, cls, binfo.getName().getLocalPart() +
"BindingOpPolicy");
+ }
+ for (PolicyAttachment pa :
epa.getPolicyAttachments(Placement.BINDING_OPERATION_INPUT)) {
+ addPolicy(binfo.getInput(), si, pa, cls, binfo.getName().getLocalPart()
+ + "BindingOpInputPolicy");
+ }
+ for (PolicyAttachment pa :
epa.getPolicyAttachments(Placement.BINDING_OPERATION_OUTPUT)) {
+ addPolicy(binfo.getOutput(), si, pa, cls, binfo.getName().getLocalPart()
+ + "BindingOpOutputPolicy");
+ }
+ for (PolicyAttachment pa :
epa.getPolicyAttachments(Placement.BINDING_OPERATION_FAULT)) {
+ for (BindingFaultInfo f : binfo.getFaults())
+ {
+ addPolicy(f, si, pa, cls, f.getFaultInfo().getName().getLocalPart()
+ + "BindingOpFaultPolicy");
+ }
+ }
+ }
+ }
+ }
+
+ private void addPolicy(AbstractPropertiesHolder place, ServiceInfo service,
PolicyAttachment pa, Class<?> cls, String defName)
+ {
+ Element el = addPolicy(service, pa, cls, defName);
+ UnknownExtensibilityElement uee = new UnknownExtensibilityElement();
+ uee.setElement(el);
+ uee.setRequired(true);
+ uee.setElementType(DOMUtils.getElementQName(el));
+ place.addExtensor(uee);
+ }
+
+ private Element addPolicy(ServiceInfo service, PolicyAttachment pa, Class<?>
cls, String defName)
+ {
+ Element element = pa.read(defName);
+ String refId = getPolicyId(element);
+ ROOT_LOGGER.addingPolicyAttachment(pa.getPlacement(), refId, cls);
+
+ if (service.getDescription() == null && cls != null)
+ {
+ service.setDescription(new DescriptionInfo());
+ URL u = cls.getResource("/");
+ if (u != null)
+ {
+ service.getDescription().setBaseURI(u.toString());
+ }
+ }
+
+ // if not already added to service add it, otherwise ignore
+ // and just create the policy reference.
+ if (!isExistsPolicy(service, refId))
+ {
+ UnknownExtensibilityElement uee = new UnknownExtensibilityElement();
+ uee.setElement(element);
+ uee.setRequired(true);
+ uee.setElementType(DOMUtils.getElementQName(element));
+ service.getDescription().addExtensor(uee);
+ }
+
+ refId = "#" + refId;
+
+ Document doc = DOMUtils.createDocument();
+ Element el = doc.createElementNS(element.getNamespaceURI(), "wsp:" +
Constants.ELEM_POLICY_REF);
+ Attr att = doc.createAttributeNS(null, "URI");
+ att.setValue(refId);
+ el.setAttributeNodeNS(att);
+ return el;
+ }
+
+ private String getPolicyId(Element element)
+ {
+ return element.getAttributeNS(PolicyConstants.WSU_NAMESPACE_URI,
PolicyConstants.WSU_ID_ATTR_NAME);
+ }
+
+ private boolean isExistsPolicy(ServiceInfo service, String uri)
+ {
+ Object exts[] = service.getDescription().getExtensors().get();
+ exts = exts == null ? new Object[0] : exts;
+ for (Object o : exts)
+ {
+ if (o instanceof UnknownExtensibilityElement)
+ {
+ UnknownExtensibilityElement uee = (UnknownExtensibilityElement) o;
+ String uri2 = getPolicyId(uee.getElement());
+ if (uri.equals(uri2))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
Added:
stack/cxf/trunk/modules/client/src/main/resources/META-INF/policies/org.jboss.wsf.stack.cxf.extensions.policy.PolicyAttachmentStore
===================================================================
---
stack/cxf/trunk/modules/client/src/main/resources/META-INF/policies/org.jboss.wsf.stack.cxf.extensions.policy.PolicyAttachmentStore
(rev 0)
+++
stack/cxf/trunk/modules/client/src/main/resources/META-INF/policies/org.jboss.wsf.stack.cxf.extensions.policy.PolicyAttachmentStore 2013-06-14
13:46:58 UTC (rev 17678)
@@ -0,0 +1,8 @@
+AsymmetricBinding_X509v1_TripleDesRsa15_EncryptBeforeSigning_ProtectTokens
+AsymmetricBinding_X509v1_GCM192OAEP_ProtectTokens
+WS-SP-EX221_WSS10_Mutual_Auth_X509_Sign_Encrypt
+WS-SP-EX222_WSS10_Mutual_Auth_X509_Sign_Encrypt
+WS-SP-EX223_WSS11_Anonymous_X509_Sign_Encrypt
+WS-SP-EX224_WSS11_Mutual_Auth_X509_Sign_Encrypt
+WS-RM_Policy_spec_example
+WS-Addressing
\ No newline at end of file
Deleted:
stack/cxf/trunk/modules/client/src/main/resources/META-INF/policies/org.jboss.wsf.stack.cxf.policy.PolicyAttachmentStore
===================================================================
---
stack/cxf/trunk/modules/client/src/main/resources/META-INF/policies/org.jboss.wsf.stack.cxf.policy.PolicyAttachmentStore 2013-06-14
13:44:20 UTC (rev 17677)
+++
stack/cxf/trunk/modules/client/src/main/resources/META-INF/policies/org.jboss.wsf.stack.cxf.policy.PolicyAttachmentStore 2013-06-14
13:46:58 UTC (rev 17678)
@@ -1,8 +0,0 @@
-AsymmetricBinding_X509v1_TripleDesRsa15_EncryptBeforeSigning_ProtectTokens
-AsymmetricBinding_X509v1_GCM192OAEP_ProtectTokens
-WS-SP-EX221_WSS10_Mutual_Auth_X509_Sign_Encrypt
-WS-SP-EX222_WSS10_Mutual_Auth_X509_Sign_Encrypt
-WS-SP-EX223_WSS11_Anonymous_X509_Sign_Encrypt
-WS-SP-EX224_WSS11_Mutual_Auth_X509_Sign_Encrypt
-WS-RM_Policy_spec_example
-WS-Addressing
\ No newline at end of file
Modified:
stack/cxf/trunk/modules/client/src/test/java/org/jboss/wsf/stack/cxf/policy/PolicySetsTest.java
===================================================================
---
stack/cxf/trunk/modules/client/src/test/java/org/jboss/wsf/stack/cxf/policy/PolicySetsTest.java 2013-06-14
13:44:20 UTC (rev 17677)
+++
stack/cxf/trunk/modules/client/src/test/java/org/jboss/wsf/stack/cxf/policy/PolicySetsTest.java 2013-06-14
13:46:58 UTC (rev 17678)
@@ -26,6 +26,9 @@
import junit.framework.TestCase;
import org.apache.cxf.annotations.Policy.Placement;
+import org.jboss.wsf.stack.cxf.extensions.policy.EndpointPolicyAttachments;
+import org.jboss.wsf.stack.cxf.extensions.policy.PolicyAttachment;
+import org.jboss.wsf.stack.cxf.extensions.policy.PolicyAttachmentStore;
import org.junit.Test;
import org.w3c.dom.Element;
Added:
stack/cxf/trunk/modules/client/src/test/resources/META-INF/policies/org.jboss.wsf.stack.cxf.extensions.policy.PolicyAttachmentStore
===================================================================
---
stack/cxf/trunk/modules/client/src/test/resources/META-INF/policies/org.jboss.wsf.stack.cxf.extensions.policy.PolicyAttachmentStore
(rev 0)
+++
stack/cxf/trunk/modules/client/src/test/resources/META-INF/policies/org.jboss.wsf.stack.cxf.extensions.policy.PolicyAttachmentStore 2013-06-14
13:46:58 UTC (rev 17678)
@@ -0,0 +1 @@
+WS-SP-EX224
\ No newline at end of file
Deleted:
stack/cxf/trunk/modules/client/src/test/resources/META-INF/policies/org.jboss.wsf.stack.cxf.policy.PolicyAttachmentStore
===================================================================
---
stack/cxf/trunk/modules/client/src/test/resources/META-INF/policies/org.jboss.wsf.stack.cxf.policy.PolicyAttachmentStore 2013-06-14
13:44:20 UTC (rev 17677)
+++
stack/cxf/trunk/modules/client/src/test/resources/META-INF/policies/org.jboss.wsf.stack.cxf.policy.PolicyAttachmentStore 2013-06-14
13:46:58 UTC (rev 17678)
@@ -1 +0,0 @@
-WS-SP-EX224
\ No newline at end of file
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2013-06-14
13:44:20 UTC (rev 17677)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2013-06-14
13:46:58 UTC (rev 17678)
@@ -53,11 +53,11 @@
import org.jboss.wsf.spi.metadata.webservices.JBossWebservicesMetaData;
import org.jboss.wsf.stack.cxf.client.Constants;
import org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher;
+import org.jboss.wsf.stack.cxf.extensions.policy.PolicySetsAnnotationListener;
import org.jboss.wsf.stack.cxf.interceptor.EnableDecoupledFaultInterceptor;
import org.jboss.wsf.stack.cxf.interceptor.EndpointAssociationInterceptor;
import org.jboss.wsf.stack.cxf.interceptor.NsCtxSelectorStoreInterceptor;
import org.jboss.wsf.stack.cxf.management.InstrumentationManagerExtImpl;
-import org.jboss.wsf.stack.cxf.policy.PolicySetsAnnotationListener;
/**
* A wrapper of the Bus for performing most of the configurations required on it by
JBossWS
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/EndpointFour.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/EndpointFour.java 2013-06-14
13:44:20 UTC (rev 17677)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/EndpointFour.java 2013-06-14
13:46:58 UTC (rev 17678)
@@ -24,7 +24,7 @@
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
-import org.jboss.wsf.stack.cxf.policy.PolicySets;
+import org.jboss.ws.api.annotation.PolicySets;
@WebService(name = "EndpointFour", targetNamespace =
"http://org.jboss.ws.jaxws.cxf/jbws3648")
@SOAPBinding(style = SOAPBinding.Style.RPC)
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/EndpointOneImpl.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/EndpointOneImpl.java 2013-06-14
13:44:20 UTC (rev 17677)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/EndpointOneImpl.java 2013-06-14
13:46:58 UTC (rev 17678)
@@ -26,7 +26,7 @@
import javax.jws.soap.SOAPBinding;
import org.jboss.logging.Logger;
-import org.jboss.wsf.stack.cxf.policy.PolicySets;
+import org.jboss.ws.api.annotation.PolicySets;
@WebService(name = "EndpointOne", targetNamespace =
"http://org.jboss.ws.jaxws.cxf/jbws3648", serviceName = "ServiceOne")
@SOAPBinding(style = SOAPBinding.Style.RPC)
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/EndpointThree.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/EndpointThree.java 2013-06-14
13:44:20 UTC (rev 17677)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/EndpointThree.java 2013-06-14
13:46:58 UTC (rev 17678)
@@ -24,8 +24,9 @@
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
-import org.jboss.wsf.stack.cxf.policy.PolicySets;
+import org.jboss.ws.api.annotation.PolicySets;
+
@WebService(name = "EndpointThree", targetNamespace =
"http://org.jboss.ws.jaxws.cxf/jbws3648")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@PolicySets({"AsymmetricBinding_X509v1_TripleDesRsa15_EncryptBeforeSigning_ProtectTokens",
"WS-Addressing"})
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/EndpointTwo.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/EndpointTwo.java 2013-06-14
13:44:20 UTC (rev 17677)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/EndpointTwo.java 2013-06-14
13:46:58 UTC (rev 17678)
@@ -24,7 +24,7 @@
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
-import org.jboss.wsf.stack.cxf.policy.PolicySets;
+import org.jboss.ws.api.annotation.PolicySets;
@WebService(name = "EndpointTwo", targetNamespace =
"http://org.jboss.ws.jaxws.cxf/jbws3648")
@SOAPBinding(style = SOAPBinding.Style.RPC)
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/AnnotatedServiceImpl.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/AnnotatedServiceImpl.java 2013-06-14
13:44:20 UTC (rev 17677)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/AnnotatedServiceImpl.java 2013-06-14
13:46:58 UTC (rev 17678)
@@ -25,7 +25,7 @@
import org.apache.cxf.annotations.EndpointProperties;
import org.apache.cxf.annotations.EndpointProperty;
-import org.jboss.wsf.stack.cxf.policy.PolicySets;
+import org.jboss.ws.api.annotation.PolicySets;
@WebService(
portName = "AnnotatedSecurityServicePort",
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3648-b/policies/org.jboss.wsf.stack.cxf.extensions.policy.PolicyAttachmentStore
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3648-b/policies/org.jboss.wsf.stack.cxf.extensions.policy.PolicyAttachmentStore
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3648-b/policies/org.jboss.wsf.stack.cxf.extensions.policy.PolicyAttachmentStore 2013-06-14
13:46:58 UTC (rev 17678)
@@ -0,0 +1 @@
+My-WSSE-conf
\ No newline at end of file
Deleted:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3648-b/policies/org.jboss.wsf.stack.cxf.policy.PolicyAttachmentStore
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3648-b/policies/org.jboss.wsf.stack.cxf.policy.PolicyAttachmentStore 2013-06-14
13:44:20 UTC (rev 17677)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3648-b/policies/org.jboss.wsf.stack.cxf.policy.PolicyAttachmentStore 2013-06-14
13:46:58 UTC (rev 17678)
@@ -1 +0,0 @@
-My-WSSE-conf
\ No newline at end of file