Author: palin
Date: 2007-05-16 15:58:28 -0400 (Wed, 16 May 2007)
New Revision: 3112
Added:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/metadata/PolicyMetaDataBuilder.java
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/PolicyDeployer.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/domainAssertion/NopAssertionDeployer.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSClientMetaDataBuilder.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSMetaDataBuilder.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSServerMetaDataBuilder.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java
Log:
Partial commit: still refactoring policy metadata generation
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/PolicyDeployer.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/PolicyDeployer.java 2007-05-16
19:47:00 UTC (rev 3111)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/PolicyDeployer.java 2007-05-16
19:58:28 UTC (rev 3112)
@@ -33,6 +33,7 @@
import org.apache.ws.policy.XorCompositeAssertion;
import org.jboss.logging.Logger;
import org.jboss.ws.extensions.policy.deployer.domainAssertion.AssertionDeployer;
+import org.jboss.ws.extensions.policy.deployer.domainAssertion.NopAssertionDeployer;
import
org.jboss.ws.extensions.policy.deployer.domainAssertion.WSSecurityAssertionDeployer;
import org.jboss.ws.extensions.policy.deployer.exceptions.UnsupportedAlternative;
import org.jboss.ws.extensions.policy.deployer.exceptions.UnsupportedAssertion;
@@ -69,19 +70,19 @@
}
//for test
- public static PolicyDeployer newInstance(Map<String,Class> specialDomainMap)
+ public static PolicyDeployer newInstance(Map<String,Class> customDomainMap)
{
PolicyDeployer instance = new PolicyDeployer();
- instance.domainDeployerMap = specialDomainMap;
+ instance.domainDeployerMap = customDomainMap;
return instance;
}
-// for tools
+ //for tools
public static PolicyDeployer newInstanceForTools()
{
PolicyDeployer instance = new PolicyDeployer();
-
instance.domainDeployerMap.put("http://www.jboss.com/ws-security/sch...;
+
instance.domainDeployerMap.put("http://www.jboss.com/ws-security/sch...;,
NopAssertionDeployer.class);
return instance;
}
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/domainAssertion/NopAssertionDeployer.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/domainAssertion/NopAssertionDeployer.java 2007-05-16
19:47:00 UTC (rev 3111)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/domainAssertion/NopAssertionDeployer.java 2007-05-16
19:58:28 UTC (rev 3112)
@@ -1,3 +1,24 @@
+/*
+ * 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.deployer.domainAssertion;
import org.apache.ws.policy.PrimitiveAssertion;
@@ -4,19 +25,30 @@
import org.jboss.ws.extensions.policy.deployer.exceptions.UnsupportedAssertion;
import org.jboss.ws.metadata.umdm.ExtensibleMetaData;
+/**
+ * This assertion deployer actually does nothing when asked to
+ * deploy a policy assertion. It is used as a placeholder by
+ * PolicyDeployer in case no modification to umdm or anything
+ * else is actually required (for example when running the
+ * wsprovide tool).
+ *
+ * @author Stefano Maestri <mailto:stefano.maestri@javalinux.it>
+ * @author Alessio Soldano <mailto:alessio.soldano@javalinux.it>
+ *
+ * @since 16-May-2007
+ *
+ */
public class NopAssertionDeployer implements AssertionDeployer
{
public void deployClientSide(PrimitiveAssertion assertion, ExtensibleMetaData
extMetaData) throws UnsupportedAssertion
{
- // TODO Auto-generated method stub
-
+ //nop
}
public void deployServerSide(PrimitiveAssertion assertion, ExtensibleMetaData
extMetaData) throws UnsupportedAssertion
{
- // TODO Auto-generated method stub
-
+ //nop
}
}
Added:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/metadata/PolicyMetaDataBuilder.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/metadata/PolicyMetaDataBuilder.java
(rev 0)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/metadata/PolicyMetaDataBuilder.java 2007-05-16
19:58:28 UTC (rev 3112)
@@ -0,0 +1,299 @@
+/*
+ * 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.metadata;
+
+import java.io.InputStream;
+import java.util.List;
+
+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;
+import org.jboss.ws.core.server.UnifiedDeploymentInfo;
+import org.jboss.ws.extensions.policy.PolicyScopeLevel;
+import org.jboss.ws.extensions.policy.annotation.PolicyAttachment;
+import org.jboss.ws.extensions.policy.deployer.PolicyDeployer;
+import org.jboss.ws.extensions.policy.deployer.exceptions.UnsupportedPolicy;
+import org.jboss.ws.metadata.umdm.EndpointMetaData;
+import org.jboss.ws.metadata.umdm.ExtensibleMetaData;
+import org.jboss.ws.metadata.umdm.ServerEndpointMetaData;
+import org.jboss.ws.metadata.wsdl.WSDLBinding;
+import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
+import org.jboss.ws.metadata.wsdl.WSDLEndpoint;
+import org.jboss.ws.metadata.wsdl.WSDLExtensibilityElement;
+import org.jboss.ws.metadata.wsdl.WSDLInterface;
+import org.jboss.ws.metadata.wsdl.WSDLService;
+
+/**
+ * @author Alessio Soldano, <mailto:alessio.soldano@javalinux.it>
+ *
+ * since 16-May-2007
+ */
+public class PolicyMetaDataBuilder
+{
+ private static final Logger log = Logger.getLogger(PolicyMetaDataBuilder.class);
+ private boolean serverSide = true;
+ private boolean toolMode = false;
+
+ public PolicyMetaDataBuilder()
+ {
+
+ }
+
+ /**
+ * Creates a new PolicyMetaDataBuilder for server side policy processing.
+ *
+ * @param toolMode True if running wsprovide (no policy deployments)
+ * @return
+ */
+ public static PolicyMetaDataBuilder getServerSidePolicyMetaDataBuilder(boolean
toolMode) {
+ PolicyMetaDataBuilder builder = new PolicyMetaDataBuilder();
+ builder.setServerSide(true);
+ builder.setToolMode(toolMode);
+ return builder;
+ }
+
+ /**
+ * Creates a new PolicyMetaDataBuilder for client side policy processing.
+ *
+ * @return
+ */
+ public static PolicyMetaDataBuilder getClientSidePolicyMetaDataBuilder() {
+ PolicyMetaDataBuilder builder = new PolicyMetaDataBuilder();
+ builder.setServerSide(false);
+ return builder;
+ }
+
+ public void processPolicyAnnotations(EndpointMetaData epMetaData, Class<?>
sepClass, UnifiedDeploymentInfo udi)
+ {
+ for (org.jboss.ws.extensions.policy.annotation.Policy policy :
sepClass.getAnnotation(PolicyAttachment.class).value())
+ {
+ InputStream is = null;
+ try
+ {
+ DOMPolicyReader reader = (DOMPolicyReader)
PolicyFactory.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
+ is = udi.getMetaDataFileURL(policy.policyFileLocation()).openStream();
+ Policy unnormalizedPolicy = reader.readPolicy(is);
+ Policy normPolicy = (Policy)unnormalizedPolicy.normalize();
+ log.info("Deploying Annotated Policy =
"+policy.policyFileLocation());
+ PolicyScopeLevel scope = policy.scope();
+ if (PolicyScopeLevel.WSDL_PORT.equals(scope) ||
PolicyScopeLevel.WSDL_PORT_TYPE.equals(scope) ||
+ PolicyScopeLevel.WSDL_BINDING.equals(scope))
+ {
+ deployPolicy(normPolicy, scope, epMetaData);
+ }
+ else
+ {
+ throw new WSException("Policy scope "+scope+" not supported
yet!");
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ } finally
+ {
+ try
+ {
+ is.close();
+ } catch (Exception e) {}
+ }
+ }
+ }
+
+ public void processPolicyExtensions(EndpointMetaData epMetaData, WSDLDefinitions
wsdlDefinitions)
+ {
+ //Collect all policies defined in our wsdl definitions
+ 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());
+ localPolicyRegistry.register(policy.getPolicyURI(), policy);
+ }
+ //Port scope
+ WSDLService wsdlService =
wsdlDefinitions.getService(epMetaData.getServiceMetaData().getServiceName());
+ if (wsdlService != null)
+ {
+ WSDLEndpoint wsdlEndpoint = wsdlService.getEndpoint(epMetaData.getPortName());
+ if (wsdlEndpoint != null)
+ {
+ List<WSDLExtensibilityElement> portPolicyRefList =
wsdlEndpoint.getExtensibilityElements(Constants.WSDL_ELEMENT_POLICYREFERENCE);
+ processPolicies(portPolicyRefList, PolicyScopeLevel.WSDL_PORT,
localPolicyRegistry, epMetaData);
+ }
+ else
+ {
+ log.warn("Cannot get port
'"+epMetaData.getPortName()+"' from the given wsdl definitions! Eventual
policies attached to this port won't be considered.");
+ }
+ }
+ else
+ {
+ log.warn("Cannot get service
'"+epMetaData.getServiceMetaData().getServiceName()+"' from the given
wsdl definitions! Eventual policies attached to this service won't be
considered.");
+ }
+
+ //Binding scope
+ WSDLBinding wsdlBinding =
wsdlDefinitions.getBindingByInterfaceName(epMetaData.getPortTypeName());
+ if (wsdlBinding != null)
+ {
+ List<WSDLExtensibilityElement> bindingPolicyRefList =
wsdlBinding.getExtensibilityElements(Constants.WSDL_ELEMENT_POLICYREFERENCE);
+ processPolicies(bindingPolicyRefList, PolicyScopeLevel.WSDL_BINDING,
localPolicyRegistry, epMetaData);
+ }
+ else
+ {
+ log.warn("Cannot get binding for portType
'"+epMetaData.getPortTypeName()+"' from the given wsdl definitions!
Eventual policies attached to this binding won't be considered.");
+ }
+
+ //PortType scope
+ WSDLInterface wsdlInterface =
wsdlDefinitions.getInterface(epMetaData.getPortTypeName());
+ if (wsdlInterface != null)
+ {
+ List<WSDLExtensibilityElement> portTypePolicyRefList =
wsdlInterface.getExtensibilityElements(Constants.WSDL_PROPERTY_POLICYURIS);
+ processPolicies(portTypePolicyRefList, PolicyScopeLevel.WSDL_PORT_TYPE,
localPolicyRegistry, epMetaData);
+ }
+ else
+ {
+ log.warn("Cannot get portType
'"+epMetaData.getPortTypeName()+"' from the given wsdl definitions!
Eventual policies attached to this portType won't be considered.");
+ }
+ }
+
+ private void processPolicies(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)
+ {
+ 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);
+ }
+ }
+ }
+
+ /**
+ * Implementors should add PolicyMetaDataExt to the provided ExtensibleMetaData
according
+ * to the specified policy and policy scope.
+ *
+ * @param policy
+ * @param scope
+ * @param extMetaData
+ */
+ protected void deployPolicy(Policy policy, PolicyScopeLevel scope, ExtensibleMetaData
extMetaData)
+ {
+ PolicyDeployer deployer;
+ if (toolMode)
+ {
+ deployer = PolicyDeployer.newInstanceForTools();
+ }
+ else
+ {
+ deployer = PolicyDeployer.getInstance();
+ }
+ if (serverSide)
+ {
+ deployPolicyServerSide(policy, scope, extMetaData, deployer);
+ }
+ else
+ {
+ deployPolicyClientSide(policy, scope, extMetaData, deployer);
+ }
+ }
+
+
+ protected void deployPolicyServerSide(Policy policy, PolicyScopeLevel scope,
ExtensibleMetaData extMetaData, PolicyDeployer deployer)
+ {
+ PolicyMetaExtension ext =
(PolicyMetaExtension)extMetaData.getExtension(Constants.URI_WS_POLICY);
+ if (ext == null)
+ {
+ ext = new PolicyMetaExtension(Constants.URI_WS_POLICY);
+ extMetaData.addExtension(ext);
+ }
+ try
+ {
+ Policy deployedPolicy = deployer.deployServerside(policy, extMetaData);
+ ext.addPolicy(scope,deployedPolicy);
+ }
+ catch (UnsupportedPolicy e)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Policy Not supported:" + policy.getPolicyURI());
+ }
+ }
+ }
+
+
+ protected void deployPolicyClientSide(Policy policy, PolicyScopeLevel scope,
ExtensibleMetaData extMetaData, PolicyDeployer deployer)
+ {
+ PolicyMetaExtension ext =
(PolicyMetaExtension)extMetaData.getExtension(Constants.URI_WS_POLICY);
+ if (ext == null)
+ {
+ ext = new PolicyMetaExtension(Constants.URI_WS_POLICY);
+ extMetaData.addExtension(ext);
+ }
+ try
+ {
+ deployer.deployClientSide(policy, extMetaData);
+ ext.addPolicy(scope, policy);
+ }
+ catch (UnsupportedPolicy e)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Policy Not supported:" + policy.getPolicyURI());
+ }
+ WSException.rethrow("Policy not supported! " + policy.getPolicyURI(),
e);
+ }
+ }
+
+ public boolean isServerSide()
+ {
+ return serverSide;
+ }
+
+ public void setServerSide(boolean serverSide)
+ {
+ this.serverSide = serverSide;
+ }
+
+ public boolean isToolMode()
+ {
+ return toolMode;
+ }
+
+ public void setToolMode(boolean toolMode)
+ {
+ this.toolMode = toolMode;
+ }
+}
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSClientMetaDataBuilder.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSClientMetaDataBuilder.java 2007-05-16
19:47:00 UTC (rev 3111)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSClientMetaDataBuilder.java 2007-05-16
19:58:28 UTC (rev 3112)
@@ -39,6 +39,7 @@
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.PolicyMetaDataBuilder;
import org.jboss.ws.extensions.policy.metadata.PolicyMetaExtension;
import org.jboss.ws.integration.ResourceLoaderAdapter;
import org.jboss.ws.integration.UnifiedVirtualFile;
@@ -93,7 +94,9 @@
// Setup policies for each endpoint
for (EndpointMetaData epMetaData : serviceMetaData.getEndpoints())
{
- processPolicyMetaDataExtension(epMetaData, wsdlDefinitions);
+ PolicyMetaDataBuilder policyBuilder =
PolicyMetaDataBuilder.getClientSidePolicyMetaDataBuilder();
+ policyBuilder.processPolicyExtensions(epMetaData, wsdlDefinitions);
+ //processPolicyMetaDataExtension(epMetaData, wsdlDefinitions);
}
// Read the WSDL and initialize the schema model
@@ -307,25 +310,25 @@
}
- protected void deployPolicy(Policy policy, PolicyScopeLevel scope, ExtensibleMetaData
extMetaData)
- {
- PolicyMetaExtension ext =
(PolicyMetaExtension)extMetaData.getExtension(Constants.URI_WS_POLICY);
- if (ext == null)
- {
- ext = new PolicyMetaExtension(Constants.URI_WS_POLICY);
- extMetaData.addExtension(ext);
- }
- try
- {
- PolicyDeployer.getInstance().deployClientSide(policy, extMetaData);
- ext.addPolicy(scope, policy);
- }
- catch (UnsupportedPolicy e)
- {
- if (log.isDebugEnabled())
- {
- log.debug("Policy Not supported:" + policy.getPolicyURI());
- }
- }
- }
+// protected void deployPolicy(Policy policy, PolicyScopeLevel scope,
ExtensibleMetaData extMetaData)
+// {
+// PolicyMetaExtension ext =
(PolicyMetaExtension)extMetaData.getExtension(Constants.URI_WS_POLICY);
+// if (ext == null)
+// {
+// ext = new PolicyMetaExtension(Constants.URI_WS_POLICY);
+// extMetaData.addExtension(ext);
+// }
+// try
+// {
+// PolicyDeployer.getInstance().deployClientSide(policy, extMetaData);
+// ext.addPolicy(scope, policy);
+// }
+// catch (UnsupportedPolicy e)
+// {
+// if (log.isDebugEnabled())
+// {
+// log.debug("Policy Not supported:" + policy.getPolicyURI());
+// }
+// }
+// }
}
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSMetaDataBuilder.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSMetaDataBuilder.java 2007-05-16
19:47:00 UTC (rev 3111)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSMetaDataBuilder.java 2007-05-16
19:58:28 UTC (rev 3112)
@@ -974,128 +974,128 @@
}
- protected void processPolicyAnnotation(EndpointMetaData epMetaData, Class<?>
sepClass, UnifiedDeploymentInfo udi)
- {
- for (org.jboss.ws.extensions.policy.annotation.Policy policy :
sepClass.getAnnotation(PolicyAttachment.class).value())
- {
- InputStream is = null;
- try
- {
- DOMPolicyReader reader = (DOMPolicyReader)
PolicyFactory.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
- is = udi.getMetaDataFileURL(policy.policyFileLocation()).openStream();
- Policy unnormalizedPolicy = reader.readPolicy(is);
- Policy normPolicy = (Policy)unnormalizedPolicy.normalize();
- log.info("Deploying Annotated Policy =
"+policy.policyFileLocation());
- PolicyScopeLevel scope = policy.scope();
- if (PolicyScopeLevel.WSDL_PORT.equals(scope) ||
PolicyScopeLevel.WSDL_PORT_TYPE.equals(scope) ||
- PolicyScopeLevel.WSDL_BINDING.equals(scope))
- {
- deployPolicy(normPolicy, scope, epMetaData);
- }
- else
- {
- throw new WSException("Policy scope "+scope+" not supported
yet!");
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- } finally
- {
- try
- {
- is.close();
- } catch (Exception e) {}
- }
- }
- }
+// protected void processPolicyAnnotation(EndpointMetaData epMetaData, Class<?>
sepClass, UnifiedDeploymentInfo udi)
+// {
+// for (org.jboss.ws.extensions.policy.annotation.Policy policy :
sepClass.getAnnotation(PolicyAttachment.class).value())
+// {
+// InputStream is = null;
+// try
+// {
+// DOMPolicyReader reader = (DOMPolicyReader)
PolicyFactory.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
+// is = udi.getMetaDataFileURL(policy.policyFileLocation()).openStream();
+// Policy unnormalizedPolicy = reader.readPolicy(is);
+// Policy normPolicy = (Policy)unnormalizedPolicy.normalize();
+// log.info("Deploying Annotated Policy =
"+policy.policyFileLocation());
+// PolicyScopeLevel scope = policy.scope();
+// if (PolicyScopeLevel.WSDL_PORT.equals(scope) ||
PolicyScopeLevel.WSDL_PORT_TYPE.equals(scope) ||
+// PolicyScopeLevel.WSDL_BINDING.equals(scope))
+// {
+// deployPolicy(normPolicy, scope, epMetaData);
+// }
+// else
+// {
+// throw new WSException("Policy scope "+scope+" not
supported yet!");
+// }
+// }
+// catch (Exception e)
+// {
+// e.printStackTrace();
+// } finally
+// {
+// try
+// {
+// is.close();
+// } catch (Exception e) {}
+// }
+// }
+// }
+//
+// protected void processPolicyMetaDataExtension(EndpointMetaData epMetaData,
WSDLDefinitions wsdlDefinitions)
+// {
+// //Collect all policies defined in our wsdl definitions
+// 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());
+// localPolicyRegistry.register(policy.getPolicyURI(), policy);
+// }
+// //Port scope
+// WSDLService wsdlService =
wsdlDefinitions.getService(epMetaData.getServiceMetaData().getServiceName());
+// if (wsdlService != null)
+// {
+// WSDLEndpoint wsdlEndpoint =
wsdlService.getEndpoint(epMetaData.getPortName());
+// if (wsdlEndpoint != null)
+// {
+// List<WSDLExtensibilityElement> portPolicyRefList =
wsdlEndpoint.getExtensibilityElements(Constants.WSDL_ELEMENT_POLICYREFERENCE);
+// deployPolicies(portPolicyRefList, PolicyScopeLevel.WSDL_PORT,
localPolicyRegistry, epMetaData);
+// }
+// else
+// {
+// log.warn("Cannot get port
'"+epMetaData.getPortName()+"' from the given wsdl definitions! Eventual
policies attached to this port won't be considered.");
+// }
+// }
+// else
+// {
+// log.warn("Cannot get service
'"+epMetaData.getServiceMetaData().getServiceName()+"' from the given
wsdl definitions! Eventual policies attached to this service won't be
considered.");
+// }
+//
+// //Binding scope
+// WSDLBinding wsdlBinding =
wsdlDefinitions.getBindingByInterfaceName(epMetaData.getPortTypeName());
+// if (wsdlBinding != null)
+// {
+// List<WSDLExtensibilityElement> bindingPolicyRefList =
wsdlBinding.getExtensibilityElements(Constants.WSDL_ELEMENT_POLICYREFERENCE);
+// deployPolicies(bindingPolicyRefList, PolicyScopeLevel.WSDL_BINDING,
localPolicyRegistry, epMetaData);
+// }
+// else
+// {
+// log.warn("Cannot get binding for portType
'"+epMetaData.getPortTypeName()+"' from the given wsdl definitions!
Eventual policies attached to this binding won't be considered.");
+// }
+//
+// //PortType scope
+// WSDLInterface wsdlInterface =
wsdlDefinitions.getInterface(epMetaData.getPortTypeName());
+// if (wsdlInterface != null)
+// {
+// List<WSDLExtensibilityElement> portTypePolicyRefList =
wsdlInterface.getExtensibilityElements(Constants.WSDL_PROPERTY_POLICYURIS);
+// deployPolicies(portTypePolicyRefList, PolicyScopeLevel.WSDL_PORT_TYPE,
localPolicyRegistry, epMetaData);
+// }
+// else
+// {
+// log.warn("Cannot get portType
'"+epMetaData.getPortTypeName()+"' from the given wsdl definitions!
Eventual policies attached to this portType won't be considered.");
+// }
+// }
+//
+// 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)
+// {
+// 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);
+// }
+// }
+// }
+//
+// /**
+// * Implementors should add PolicyMetaDataExt to the provided ExtensibleMetaData
according
+// * to the specified policy and policy scope.
+// *
+// * @param policy
+// * @param scope
+// * @param extMetaData
+// */
+// protected abstract void deployPolicy(Policy policy, PolicyScopeLevel scope,
ExtensibleMetaData extMetaData);
- protected void processPolicyMetaDataExtension(EndpointMetaData epMetaData,
WSDLDefinitions wsdlDefinitions)
- {
- //Collect all policies defined in our wsdl definitions
- 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());
- localPolicyRegistry.register(policy.getPolicyURI(), policy);
- }
- //Port scope
- WSDLService wsdlService =
wsdlDefinitions.getService(epMetaData.getServiceMetaData().getServiceName());
- if (wsdlService != null)
- {
- WSDLEndpoint wsdlEndpoint = wsdlService.getEndpoint(epMetaData.getPortName());
- if (wsdlEndpoint != null)
- {
- List<WSDLExtensibilityElement> portPolicyRefList =
wsdlEndpoint.getExtensibilityElements(Constants.WSDL_ELEMENT_POLICYREFERENCE);
- deployPolicies(portPolicyRefList, PolicyScopeLevel.WSDL_PORT,
localPolicyRegistry, epMetaData);
- }
- else
- {
- log.warn("Cannot get port
'"+epMetaData.getPortName()+"' from the given wsdl definitions! Eventual
policies attached to this port won't be considered.");
- }
- }
- else
- {
- log.warn("Cannot get service
'"+epMetaData.getServiceMetaData().getServiceName()+"' from the given
wsdl definitions! Eventual policies attached to this service won't be
considered.");
- }
-
- //Binding scope
- WSDLBinding wsdlBinding =
wsdlDefinitions.getBindingByInterfaceName(epMetaData.getPortTypeName());
- if (wsdlBinding != null)
- {
- List<WSDLExtensibilityElement> bindingPolicyRefList =
wsdlBinding.getExtensibilityElements(Constants.WSDL_ELEMENT_POLICYREFERENCE);
- deployPolicies(bindingPolicyRefList, PolicyScopeLevel.WSDL_BINDING,
localPolicyRegistry, epMetaData);
- }
- else
- {
- log.warn("Cannot get binding for portType
'"+epMetaData.getPortTypeName()+"' from the given wsdl definitions!
Eventual policies attached to this binding won't be considered.");
- }
-
- //PortType scope
- WSDLInterface wsdlInterface =
wsdlDefinitions.getInterface(epMetaData.getPortTypeName());
- if (wsdlInterface != null)
- {
- List<WSDLExtensibilityElement> portTypePolicyRefList =
wsdlInterface.getExtensibilityElements(Constants.WSDL_PROPERTY_POLICYURIS);
- deployPolicies(portTypePolicyRefList, PolicyScopeLevel.WSDL_PORT_TYPE,
localPolicyRegistry, epMetaData);
- }
- else
- {
- log.warn("Cannot get portType
'"+epMetaData.getPortTypeName()+"' from the given wsdl definitions!
Eventual policies attached to this portType won't be considered.");
- }
- }
-
- 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)
- {
- 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);
- }
- }
- }
-
- /**
- * Implementors should add PolicyMetaDataExt to the provided ExtensibleMetaData
according
- * to the specified policy and policy scope.
- *
- * @param policy
- * @param scope
- * @param extMetaData
- */
- protected abstract void deployPolicy(Policy policy, PolicyScopeLevel scope,
ExtensibleMetaData extMetaData);
-
}
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSServerMetaDataBuilder.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSServerMetaDataBuilder.java 2007-05-16
19:47:00 UTC (rev 3111)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSServerMetaDataBuilder.java 2007-05-16
19:58:28 UTC (rev 3112)
@@ -161,25 +161,25 @@
}
}
- protected void deployPolicy(Policy policy, PolicyScopeLevel scope, ExtensibleMetaData
extMetaData)
- {
- PolicyMetaExtension ext =
(PolicyMetaExtension)extMetaData.getExtension(Constants.URI_WS_POLICY);
- if (ext == null)
- {
- ext = new PolicyMetaExtension(Constants.URI_WS_POLICY);
- extMetaData.addExtension(ext);
- }
- try
- {
- Policy deployedPolicy = PolicyDeployer.getInstance().deployServerside(policy,
extMetaData);
- ext.addPolicy(scope,deployedPolicy);
- }
- catch (UnsupportedPolicy e)
- {
- if (log.isDebugEnabled())
- {
- log.debug("Policy Not supported:" + policy.getPolicyURI());
- }
- }
- }
+// protected void deployPolicy(Policy policy, PolicyScopeLevel scope,
ExtensibleMetaData extMetaData)
+// {
+// PolicyMetaExtension ext =
(PolicyMetaExtension)extMetaData.getExtension(Constants.URI_WS_POLICY);
+// if (ext == null)
+// {
+// ext = new PolicyMetaExtension(Constants.URI_WS_POLICY);
+// extMetaData.addExtension(ext);
+// }
+// try
+// {
+// Policy deployedPolicy = PolicyDeployer.getInstance().deployServerside(policy,
extMetaData);
+// ext.addPolicy(scope,deployedPolicy);
+// }
+// catch (UnsupportedPolicy e)
+// {
+// if (log.isDebugEnabled())
+// {
+// log.debug("Policy Not supported:" + policy.getPolicyURI());
+// }
+// }
+// }
}
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java 2007-05-16
19:47:00 UTC (rev 3111)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java 2007-05-16
19:58:28 UTC (rev 3112)
@@ -38,6 +38,7 @@
import org.jboss.ws.core.server.UnifiedDeploymentInfo;
import org.jboss.ws.core.utils.IOUtils;
import org.jboss.ws.extensions.policy.annotation.PolicyAttachment;
+import org.jboss.ws.extensions.policy.metadata.PolicyMetaDataBuilder;
import org.jboss.ws.metadata.builder.MetaDataBuilder;
import org.jboss.ws.metadata.umdm.*;
import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
@@ -139,6 +140,13 @@
if (toolMode)
return sepMetaData;
+ //Process an optional @PolicyAttachment annotation
+ if (sepClass.isAnnotationPresent(PolicyAttachment.class))
+ {
+ PolicyMetaDataBuilder policyBuilder =
PolicyMetaDataBuilder.getServerSidePolicyMetaDataBuilder(toolMode);
+ policyBuilder.processPolicyAnnotations(sepMetaData, sepClass, udi);
+ }
+
// Sanity check: read the generated WSDL and initialize the schema model
// Note, this should no longer be needed, look into removing it
WSDLDefinitions wsdlDefinitions = serviceMetaData.getWsdlDefinitions();
@@ -160,10 +168,6 @@
else if (seiClass.isAnnotationPresent(HandlerChain.class))
processHandlerChain(sepMetaData, seiClass);
- //Process an optional @PolicyAttachment annotation
- if (sepClass.isAnnotationPresent(PolicyAttachment.class))
- processPolicyAnnotation(sepMetaData, sepClass, udi);
-
// process webservices.xml contributions
processWSDDContribution(sepMetaData);
@@ -344,16 +348,16 @@
if (policyLocation==null || policyLocation.length()==0)
throw new WSException("Missing wsdlFragmentLocation for @Policy on
" + sepClass.getName());
result.policyLocation = udi.getMetaDataFileURL(policyLocation);
-// if (result.policyLocation==null) {
-// try
-// {
-// result.policyLocation = new File(policyLocation).toURL();
-// }
-// catch (Exception e)
-// {
-// e.printStackTrace();
-// }
-// }
+ if (result.policyLocation==null) {
+ try
+ {
+ result.policyLocation = new File(policyLocation).toURL();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
System.out.println("Policy Location:
###"+result.policyLocation+"###");
}
@@ -362,6 +366,7 @@
private void processOrGenerateWSDL(Class wsClass, ServiceMetaData serviceMetaData, URL
wsdlLocation, EndpointMetaData epMetaData, URL policyLocation)
{
+ PolicyMetaDataBuilder policyBuilder =
PolicyMetaDataBuilder.getServerSidePolicyMetaDataBuilder(toolMode);
try
{
WSDLGenerator generator = new JAXBWSDLGenerator(jaxbCtx);
@@ -371,12 +376,12 @@
//we can no longer use the user provided wsdl without parsing it right now,
since we
//need to look for policies and eventually choose the supported policy
alternatives
WSDLDefinitions wsdlDefinitions = factory.parse(wsdlLocation);
- processPolicyMetaDataExtension(epMetaData, wsdlDefinitions);
+ policyBuilder.processPolicyExtensions(epMetaData, wsdlDefinitions);
if (policyLocation != null)
{
//process wsdl fragment with additional policies
WSDLDefinitions policyDefinitions = factory.parse(policyLocation);
- processPolicyMetaDataExtension(epMetaData, policyDefinitions);
+ policyBuilder.processPolicyExtensions(epMetaData, policyDefinitions);
}
//now we have the UMDM containing policy data; anyway we can't write a
new wsdl file with
//the supported alternatives and so on, since we need to publish the file the
user provided
@@ -394,7 +399,7 @@
else
{
WSDLDefinitions policyDefinitions = factory.parse(policyLocation);
- processPolicyMetaDataExtension(epMetaData, policyDefinitions);
+ policyBuilder.processPolicyExtensions(epMetaData, policyDefinitions);
//generate the wsdl4j model again for the actual UMDM containing policy
data
WSDLDefinitions actualWsdlDefinitions =
generator.generate(serviceMetaData);
writeWsdl(serviceMetaData,actualWsdlDefinitions,epMetaData);