Author: alessio.soldano(a)jboss.com
Date: 2013-06-13 06:38:02 -0400 (Thu, 13 Jun 2013)
New Revision: 17667
Modified:
stack/cxf/branches/JBWS-3648/modules/client/src/main/java/org/jboss/wsf/stack/cxf/policy/PolicyAttachment.java
stack/cxf/branches/JBWS-3648/modules/client/src/main/java/org/jboss/wsf/stack/cxf/policy/PolicyAttachmentStore.java
stack/cxf/branches/JBWS-3648/modules/client/src/main/java/org/jboss/wsf/stack/cxf/policy/PolicySetsAnnotationListener.java
Log:
Some cleanup
Modified:
stack/cxf/branches/JBWS-3648/modules/client/src/main/java/org/jboss/wsf/stack/cxf/policy/PolicyAttachment.java
===================================================================
---
stack/cxf/branches/JBWS-3648/modules/client/src/main/java/org/jboss/wsf/stack/cxf/policy/PolicyAttachment.java 2013-06-08
10:24:31 UTC (rev 17666)
+++
stack/cxf/branches/JBWS-3648/modules/client/src/main/java/org/jboss/wsf/stack/cxf/policy/PolicyAttachment.java 2013-06-13
10:38:02 UTC (rev 17667)
@@ -24,19 +24,16 @@
import java.io.InputStream;
import java.net.URL;
-import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import org.apache.cxf.annotations.Policy.Placement;
import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.resource.ExtendedURIResolver;
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;
-import org.xml.sax.InputSource;
/**
* A lazy-loaded Policy attachment reference
@@ -61,40 +58,6 @@
{
return placement;
}
-
-// public Element read(String defName)
-// {
-// String id = uri;
-// ExtendedURIResolver resolver = new ExtendedURIResolver();
-// InputSource src = resolver.resolve(id, "classpath:");
-// if (null == src)
-// {
-// return null;
-// }
-// XMLStreamReader reader = null;
-// try
-// {
-// reader = StaxUtils.createXMLStreamReader(src);
-// Document doc = StaxUtils.read(reader);
-// Element elem = doc.getDocumentElement();
-// 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 (XMLStreamException e)
-// {
-// throw new RuntimeException(e);
-// }
-// finally
-// {
-// StaxUtils.close(reader);
-// }
-// }
public Element read(String defName)
{
Modified:
stack/cxf/branches/JBWS-3648/modules/client/src/main/java/org/jboss/wsf/stack/cxf/policy/PolicyAttachmentStore.java
===================================================================
---
stack/cxf/branches/JBWS-3648/modules/client/src/main/java/org/jboss/wsf/stack/cxf/policy/PolicyAttachmentStore.java 2013-06-08
10:24:31 UTC (rev 17666)
+++
stack/cxf/branches/JBWS-3648/modules/client/src/main/java/org/jboss/wsf/stack/cxf/policy/PolicyAttachmentStore.java 2013-06-13
10:38:02 UTC (rev 17667)
@@ -55,11 +55,23 @@
private ClassLoader cl;
private static PolicyAttachmentStore defaultServerInstance;
+ /**
+ * Creates a PolicyAttachmentStore parsing policy sets located
+ * using the provided classloader.
+ *
+ * @param cl
+ */
public PolicyAttachmentStore(ClassLoader cl) {
this.cl = cl;
}
- public static synchronized PolicyAttachmentStore getDefaultServerInstance() {
+ /**
+ * 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());
}
Modified:
stack/cxf/branches/JBWS-3648/modules/client/src/main/java/org/jboss/wsf/stack/cxf/policy/PolicySetsAnnotationListener.java
===================================================================
---
stack/cxf/branches/JBWS-3648/modules/client/src/main/java/org/jboss/wsf/stack/cxf/policy/PolicySetsAnnotationListener.java 2013-06-08
10:24:31 UTC (rev 17666)
+++
stack/cxf/branches/JBWS-3648/modules/client/src/main/java/org/jboss/wsf/stack/cxf/policy/PolicySetsAnnotationListener.java 2013-06-13
10:38:02 UTC (rev 17667)
@@ -46,7 +46,6 @@
import org.apache.cxf.service.model.ServiceInfo;
import org.apache.cxf.ws.policy.PolicyConstants;
import org.apache.neethi.Constants;
-import org.jboss.logging.Logger;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -59,12 +58,11 @@
*/
public class PolicySetsAnnotationListener implements FactoryBeanListener
{
- private final Map<Class<?>, EndpointPolicyAttachments> epaMap = new
HashMap<Class<?>, EndpointPolicyAttachments>(); //usare la SEI come class
- private static final Logger LOG =
Logger.getLogger(PolicySetsAnnotationListener.class);
+ private final Map<Class<?>, EndpointPolicyAttachments> epaMap = new
HashMap<Class<?>, EndpointPolicyAttachments>();
private PolicyAttachmentStore store;
public PolicySetsAnnotationListener() {
- this.store = PolicyAttachmentStore.getDefaultServerInstance();
+ this.store = PolicyAttachmentStore.getDefaultInstance();
}
public PolicySetsAnnotationListener(PolicyAttachmentStore store) {
@@ -84,44 +82,20 @@
public void handleEvent(Event ev, AbstractServiceFactoryBean factory, Object... args)
{
-// Logger.getLogger(this.getClass()).info("**** EVENT: " + ev + "#
Args: ");
-// for (Object o : args) {
-// Logger.getLogger(this.getClass()).info(o);
-// }
switch (ev)
{
-// case INTERFACE_CREATED : {
-// InterfaceInfo ii = (InterfaceInfo) args[0];
-// Class<?> cls = (Class<?>) args[1];
-// addPolicies(factory, ii, cls);
-// break;
-// }
-
case ENDPOINT_SELECTED : {
Class<?> cls = (Class<?>) args[2];
Class<?> implCls = (Class<?>) args[3];
Endpoint ep = (Endpoint) args[1];
-// if (ep.getEndpointInfo().getInterface() != null)
-// {
-// addPolicies(factory, ep, cls);
-// }
addPolicies(factory, ep, cls, implCls);
break;
}
-
-// case INTERFACE_OPERATION_BOUND : { //TODO possibly remove either this block or
next one
-// OperationInfo inf = (OperationInfo) args[0];
-// Method m = (Method) args[1];
-// addPolicies(factory, inf, m);
-// break;
-// }
-
case BINDING_OPERATION_CREATED :
BindingOperationInfo boi = (BindingOperationInfo) args[1];
Method m = (Method) args[2];
addPolicies(factory, boi.getOperationInfo(), m);
break;
-
default :
//ignore
}
@@ -211,47 +185,19 @@
}
}
-// private void addPolicies(AbstractServiceFactoryBean factory, InterfaceInfo ii,
Class<?> cls)
-// {
-// if (cls == null)
-// {
-// return;
-// }
-// EndpointPolicyAttachment epa = epaMap.get(cls);
-// if (epa != null)
-// {
-// for (PolicyAttachment pa : epa.getPolicyAttachment(Placement.PORT_TYPE)) {
-// addPolicy(ii, ii.getService(), pa, cls, ii.getName().getLocalPart() +
"PortTypePolicy");
-// }
-// for (PolicyAttachment pa : epa.getPolicyAttachment(Placement.SERVICE)) {
-// addPolicy(ii, ii.getService(), pa, cls, ii.getName().getLocalPart() +
"PortTypePolicy");
-// }
-// }
-// }
-
private void addPolicy(AbstractPropertiesHolder place, ServiceInfo service,
PolicyAttachment pa, Class<?> cls, String defName)
{
- LOG.info("***** " + place + ", " + pa.getPlacement() + ",
" + service + ", " + cls + ", " + defName);
Element el = addPolicy(service, pa, cls, defName);
-// if (el != null)
-// {
- UnknownExtensibilityElement uee = new UnknownExtensibilityElement();
- uee.setElement(el);
- uee.setRequired(true);
- uee.setElementType(DOMUtils.getElementQName(el));
- place.addExtensor(uee);
-// }
+ 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);
-// if (element == null)
-// {
-// return null;
-// }
-
- // might have been updated on load policy
String refId = getPolicyId(element);
ROOT_LOGGER.addingPolicyAttachment(pa.getPlacement(), refId, cls);