Author: palin
Date: 2007-05-04 04:39:46 -0400 (Fri, 04 May 2007)
New Revision: 2957
Added:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/PolicyScopeLevel.java
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:
Partial commit: some changes to MetaDataBuilder to deal with policy references using the
apache library and to save policy scope in the umdm
Added:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/PolicyScopeLevel.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/PolicyScopeLevel.java
(rev 0)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/PolicyScopeLevel.java 2007-05-04
08:39:46 UTC (rev 2957)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.ws.extensions.policy;
+
+
+/**
+ * When attaching a Policy to a WSDL element, a Policy Scope is implied for that
attachment.
+ * PolicyScopeLevel enumerates all kind of element a Policy can be attached to in wsdl
1.1.
+ *
+ * @author Alessio Soldano, <alessio.soldano(a)javalinux.it>
+ * @since 3-May-2007
+ */
+public enum PolicyScopeLevel
+{
+ WSDL_SERVICE, //wsdl:service
+ WSDL_PORT, //wsdl:port
+ WSDL_PORT_TYPE, //wsdl:portType
+ WSDL_BINDING, //wsdl:binding
+ BINDING_OPERATION, //wsdl:binding/wsdl:operation
+ PORT_TYPE_OPERATION, //wsdl:portType/wsdl:operation
+ BINDING_OPERATION_INPUT, //wsdl:binding/wsdl:operation/wsdl:input
+ PORT_TYPE_OPERATION_INPUT, //wsdl:portType/wsdl:operation/wsdl:input
+ MESSAGE //wsdl:message
+}
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
22:43:23 UTC (rev 2956)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/metadata/PolicyMetaExtension.java 2007-05-04
08:39:46 UTC (rev 2957)
@@ -2,12 +2,14 @@
import org.apache.ws.policy.Policy;
+import org.jboss.ws.extensions.policy.PolicyScopeLevel;
import org.jboss.ws.metadata.umdm.MetaDataExtension;
public class PolicyMetaExtension extends MetaDataExtension
{
- Policy policy;
+ private Policy policy;
+ private PolicyScopeLevel scope;
public PolicyMetaExtension(String extensionNameSpace)
@@ -25,7 +27,17 @@
{
this.policy = policy;
}
-
-
+
+ public PolicyScopeLevel getScope()
+ {
+ return scope;
+ }
+
+
+ public void setScope(PolicyScopeLevel scope)
+ {
+ this.scope = scope;
+ }
+
}
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
22:43:23 UTC (rev 2956)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java 2007-05-04
08:39:46 UTC (rev 2957)
@@ -45,8 +45,10 @@
import javax.xml.ws.addressing.AddressingProperties;
import org.apache.ws.policy.Policy;
+import org.apache.ws.policy.PolicyReference;
import org.apache.ws.policy.util.DOMPolicyReader;
import org.apache.ws.policy.util.PolicyFactory;
+import org.apache.ws.policy.util.PolicyRegistry;
import org.jboss.logging.Logger;
import org.jboss.ws.Constants;
import org.jboss.ws.WSException;
@@ -61,6 +63,7 @@
import org.jboss.ws.extensions.eventing.EventingUtils;
import org.jboss.ws.extensions.eventing.deployment.EventingEndpoint;
import org.jboss.ws.extensions.eventing.metadata.EventingEpMetaExt;
+import org.jboss.ws.extensions.policy.PolicyScopeLevel;
import org.jboss.ws.extensions.policy.deployer.PolicyDeployer;
import org.jboss.ws.extensions.policy.deployer.exceptions.UnsupportedPolicy;
import org.jboss.ws.extensions.policy.metadata.PolicyMetaExtension;
@@ -470,12 +473,12 @@
protected void processPolicyMetaDataExtension(EndpointMetaData epMetaData,
WSDLDefinitions wsdlDefinitions)
{
//Collect all policies defined in our wsdl definitions
- DOMPolicyReader reader = (DOMPolicyReader)
PolicyFactory.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
- Map<String,Policy> localPolicyElementsMap = new
HashMap<String,Policy>();
+ DOMPolicyReader reader = (DOMPolicyReader)
PolicyFactory.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
+ PolicyRegistry localPolicyRegistry = new PolicyRegistry();
for (WSDLExtensibilityElement policyElement :
wsdlDefinitions.getExtensibilityElements(Constants.WSDL_ELEMENT_POLICY))
{
Policy policy = reader.readPolicy(policyElement.getElement());
- localPolicyElementsMap.put(policy.getId(), policy);
+ localPolicyRegistry.register(policy.getPolicyURI(), policy);
}
WSDLService wsdlService =
wsdlDefinitions.getService(epMetaData.getServiceMetaData().getServiceName().getLocalPart());
@@ -485,51 +488,50 @@
//Port scope
List<WSDLExtensibilityElement> portPolicyRefList =
wsdlEndpoint.getExtensibilityElements(Constants.WSDL_ELEMENT_POLICYREFERENCE);
- deployPolicies(portPolicyRefList, localPolicyElementsMap, epMetaData);
+ deployPolicies(portPolicyRefList, PolicyScopeLevel.WSDL_PORT, localPolicyRegistry,
epMetaData);
//Binding scope
List<WSDLExtensibilityElement> bindingPolicyRefList =
wsdlBinding.getExtensibilityElements(Constants.WSDL_ELEMENT_POLICYREFERENCE);
- deployPolicies(bindingPolicyRefList, localPolicyElementsMap, epMetaData);
+ deployPolicies(bindingPolicyRefList, PolicyScopeLevel.WSDL_BINDING,
localPolicyRegistry, epMetaData);
//PortType scope
List<WSDLExtensibilityElement> portTypePolicyRefList =
wsdlInterface.getExtensibilityElements(Constants.WSDL_PROPERTY_POLICYURIS);
- deployPolicies(portTypePolicyRefList, localPolicyElementsMap, epMetaData);
+ deployPolicies(portTypePolicyRefList, PolicyScopeLevel.WSDL_PORT_TYPE,
localPolicyRegistry, epMetaData);
}
- private void deployPolicies(List<WSDLExtensibilityElement> policyReferences,
Map<String,Policy> localPolicies, ExtensibleMetaData extMetaData)
+ private void deployPolicies(List<WSDLExtensibilityElement> policyReferences,
PolicyScopeLevel scope, PolicyRegistry localPolicies, ExtensibleMetaData extMetaData)
{
if (policyReferences != null && policyReferences.size() != 0 &&
extMetaData instanceof ServerEndpointMetaData)
{
DOMPolicyReader reader = (DOMPolicyReader)
PolicyFactory.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
for (WSDLExtensibilityElement element : policyReferences)
{
-// boolean local = true;
-// String uri = element.getElement().getAttribute("URI");
-// //TODO!!!
-// //process uri
-// if (local)
-// {
-// Policy policy = localPolicies.get(uri.substring(1)); //get rid of
'#'
-// //clone the policy before asking for deployment
- deployPolicy((Policy)
reader.readPolicyReference(element.getElement()).normalize(),extMetaData);
-// }
-// else
-// {
-// //TODO!!! get the policy definition, create the policy and deploy it
-// }
+ PolicyReference policyRef =
reader.readPolicyReference(element.getElement());
+ Policy normPolicy;
+ try
+ {
+ normPolicy = (Policy)policyRef.normalize(localPolicies);
+ }
+ catch (RuntimeException e)
+ {
+ //TODO!!! not a local policy: get the policy definition and create the
policy
+ normPolicy = null;
+ }
+ deployPolicy(normPolicy, scope, extMetaData);
}
}
}
- private void deployPolicy(Policy policy, ExtensibleMetaData extMetaData)
+ private void deployPolicy(Policy policy, PolicyScopeLevel scope, ExtensibleMetaData
extMetaData)
{
PolicyMetaExtension ext = new PolicyMetaExtension(Constants.URI_WS_POLICY);
try
{
Policy deployedPolicy = PolicyDeployer.getInstance().deployServerside(policy,
extMetaData);
ext.setPolicy(deployedPolicy);
+ ext.setScope(scope);
extMetaData.addExtension(ext);
}
catch (UnsupportedPolicy e)