Author: palin
Date: 2007-05-03 11:43:45 -0400 (Thu, 03 May 2007)
New Revision: 2954
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/metadata/PolicyMetaExtension.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java
Log:
Some changes to MetaDataBuilder to consider policies attached to bindings and portTypes
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/metadata/PolicyMetaExtension.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/metadata/PolicyMetaExtension.java 2007-05-03
11:47:53 UTC (rev 2953)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/metadata/PolicyMetaExtension.java 2007-05-03
15:43:45 UTC (rev 2954)
@@ -1,14 +1,8 @@
package org.jboss.ws.extensions.policy.metadata;
-import java.util.List;
-
import org.jboss.ws.extensions.policy.Policy;
-import org.jboss.ws.extensions.policy.PolicyFactory;
import org.jboss.ws.metadata.umdm.MetaDataExtension;
-import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
-import org.jboss.ws.metadata.wsdl.WSDLExtensibilityElement;
-import org.w3c.dom.Element;
public class PolicyMetaExtension extends MetaDataExtension
{
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java 2007-05-03
11:47:53 UTC (rev 2953)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java 2007-05-03
15:43:45 UTC (rev 2954)
@@ -28,6 +28,7 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -71,6 +72,7 @@
import
org.jboss.ws.metadata.j2ee.UnifiedWebSecurityMetaData.UnifiedWebResourceCollection;
import org.jboss.ws.metadata.umdm.ClientEndpointMetaData;
import org.jboss.ws.metadata.umdm.EndpointMetaData;
+import org.jboss.ws.metadata.umdm.ExtensibleMetaData;
import org.jboss.ws.metadata.umdm.OperationMetaData;
import org.jboss.ws.metadata.umdm.ServerEndpointMetaData;
import org.jboss.ws.metadata.wsdl.WSDLBinding;
@@ -466,41 +468,79 @@
protected void processPolicyMetaDataExtension(EndpointMetaData epMetaData,
WSDLDefinitions wsdlDefinitions)
{
- //PolicyReferece at endpointLevel
- List<WSDLExtensibilityElement> policyReferenceList =
wsdlDefinitions.getService(epMetaData.getServiceMetaData().
- getServiceName().getLocalPart()).getEndpoint(epMetaData.getPortName()).
- getExtensibilityElements(Constants.WSDL_ELEMENT_POLICYREFERENCE);
- ServerEndpointMetaData sepMetaData = (ServerEndpointMetaData)epMetaData;
+ //Collect all policies defined in our wsdl definitions
+ PolicyFactory factory = PolicyFactory.newInstance();
+ Map<String,Policy> localPolicyElementsMap = new
HashMap<String,Policy>();
+ for (WSDLExtensibilityElement policyElement :
wsdlDefinitions.getExtensibilityElements(Constants.WSDL_ELEMENT_POLICY))
+ {
+ Policy policy = factory.createPolicy(policyElement.getElement());
+ localPolicyElementsMap.put(policy.getID(), policy);
+ }
- if (policyReferenceList != null && policyReferenceList.size() != 0
&& epMetaData instanceof ServerEndpointMetaData)
+ WSDLService wsdlService =
wsdlDefinitions.getService(epMetaData.getServiceMetaData().getServiceName().getLocalPart());
+ WSDLEndpoint wsdlEndpoint = wsdlService.getEndpoint(epMetaData.getPortName());
+ WSDLInterface wsdlInterface =
wsdlDefinitions.getInterface(epMetaData.getPortTypeName());
+ WSDLBinding wsdlBinding =
wsdlDefinitions.getBindingByInterfaceName(epMetaData.getPortTypeName());
+
+ //Port scope
+ List<WSDLExtensibilityElement> portPolicyRefList =
wsdlEndpoint.getExtensibilityElements(Constants.WSDL_ELEMENT_POLICYREFERENCE);
+ deployPolicies(portPolicyRefList, localPolicyElementsMap, epMetaData);
+
+ //Binding scope
+ List<WSDLExtensibilityElement> bindingPolicyRefList =
wsdlBinding.getExtensibilityElements(Constants.WSDL_ELEMENT_POLICYREFERENCE);
+ deployPolicies(bindingPolicyRefList, localPolicyElementsMap, epMetaData);
+
+ //PortType scope
+ List<WSDLExtensibilityElement> portTypePolicyRefList =
wsdlInterface.getExtensibilityElements(Constants.WSDL_PROPERTY_POLICYURIS);
+ deployPolicies(portTypePolicyRefList, localPolicyElementsMap, epMetaData);
+
+ }
+
+
+ private void deployPolicies(List<WSDLExtensibilityElement> policyReferences,
Map<String,Policy> localPolicies, ExtensibleMetaData extMetaData)
+ {
+ if (policyReferences != null && policyReferences.size() != 0 &&
extMetaData instanceof ServerEndpointMetaData)
{
- for (WSDLExtensibilityElement element : policyReferenceList)
+ PolicyFactory factory = PolicyFactory.newInstance();
+ for (WSDLExtensibilityElement element : policyReferences)
{
- for (WSDLExtensibilityElement policyElement :
wsdlDefinitions.getExtensibilityElements(element.getElement().getAttribute("URI").substring(1)))
+ boolean local = true;
+ String uri = element.getElement().getAttribute("URI");
+ //TODO!!!
+ //process uri
+ if (local)
{
- PolicyMetaExtension ext = new
PolicyMetaExtension(Constants.URI_WS_POLICY);
- Policy policy =
PolicyFactory.newInstance().createPolicy(policyElement.getElement());
- try
- {
- Policy deployedPolicy =
PolicyDeployer.getInstance().deployServerside(policy, sepMetaData);
- ext.setPolicy(deployedPolicy);
- sepMetaData.addExtension(ext);
- }
- catch (UnsupportedPolicy e)
- {
- if (log.isDebugEnabled())
- {
- log.debug("Policy Not supported:" +
policy.toXMLString(true));
- }
- }
-
+ Policy policy = localPolicies.get(uri.substring(1)); //get rid of
'#'
+ //clone the policy before asking for deployment
+ deployPolicy(factory.createPolicy(policy.toElement()),extMetaData);
}
-
+ else
+ {
+ //TODO!!! get the policy definition, create the policy and deploy it
+ }
}
-
}
}
+ private void deployPolicy(Policy policy, ExtensibleMetaData extMetaData)
+ {
+ PolicyMetaExtension ext = new PolicyMetaExtension(Constants.URI_WS_POLICY);
+ try
+ {
+ Policy deployedPolicy = PolicyDeployer.getInstance().deployServerside(policy,
extMetaData);
+ ext.setPolicy(deployedPolicy);
+ extMetaData.addExtension(ext);
+ }
+ catch (UnsupportedPolicy e)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Policy Not supported:" + policy.toXMLString(true));
+ }
+ }
+ }
+
+
protected void processEndpointMetaDataExtensions(EndpointMetaData epMetaData,
WSDLDefinitions wsdlDefinitions)
{
for (WSDLInterface wsdlInterface : wsdlDefinitions.getInterfaces())
Show replies by date