Author: maeste
Date: 2007-05-01 11:45:11 -0400 (Tue, 01 May 2007)
New Revision: 2950
Added:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/AssertionDeployer.java
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/exceptions/
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/exceptions/UnsupportedAlternative.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/exceptions/UnsupportedAssertion.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/exceptions/UnsupportedPolicy.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/metadata/
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/metadata/PolicyMetaExtension.java
Modified:
branches/JBWS-856/jbossws-core/.classpath
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/PolicyAssertion.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/PolicyFactory.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java
Log:
First implementation of PolicyDeployer
Modified: branches/JBWS-856/jbossws-core/.classpath
===================================================================
--- branches/JBWS-856/jbossws-core/.classpath 2007-04-30 20:08:38 UTC (rev 2949)
+++ branches/JBWS-856/jbossws-core/.classpath 2007-05-01 15:45:11 UTC (rev 2950)
@@ -33,5 +33,6 @@
<classpathentry kind="lib"
path="/build/thirdparty/getopt.jar"/>
<classpathentry kind="lib"
path="/build/thirdparty/jboss-common-core.jar"
sourcepath="/build/thirdparty/jboss-common-core-sources.jar"/>
<classpathentry combineaccessrules="false" kind="src"
path="/jbossws-api"/>
+ <classpathentry kind="lib"
path="/build/thirdparty/policy.jar"/>
<classpathentry kind="output" path="output-eclipse"/>
</classpath>
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/PolicyAssertion.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/PolicyAssertion.java 2007-04-30
20:08:38 UTC (rev 2949)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/PolicyAssertion.java 2007-05-01
15:45:11 UTC (rev 2950)
@@ -52,11 +52,13 @@
public class PolicyAssertion
{
private Element assertionElement;
+ private String nameSpace;
PolicyAssertion(Element element)
{
Document doc = DOMUtils.getOwnerDocument();
this.assertionElement = (Element)doc.adoptNode(element);
+ this.nameSpace = assertionElement.getNamespaceURI();
}
public Element getElement()
@@ -73,4 +75,10 @@
{
return toXMLString(true);
}
+
+ public String getNameSpace()
+ {
+ return nameSpace;
+ }
+
}
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/PolicyFactory.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/PolicyFactory.java 2007-04-30
20:08:38 UTC (rev 2949)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/PolicyFactory.java 2007-05-01
15:45:11 UTC (rev 2950)
@@ -23,17 +23,23 @@
// $Id$
+import java.io.File;
import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.Iterator;
import javax.xml.namespace.QName;
+import org.apache.xml.utils.DOMBuilder;
import org.jboss.ws.WSException;
import org.jboss.ws.core.utils.DOMUtils;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
+
+
/**
* A factory for Policy construction
*
@@ -113,4 +119,7 @@
return policy;
}
+
+
+
}
Added:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/AssertionDeployer.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/AssertionDeployer.java
(rev 0)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/AssertionDeployer.java 2007-05-01
15:45:11 UTC (rev 2950)
@@ -0,0 +1,10 @@
+package org.jboss.ws.extensions.policy.deployer;
+
+import org.jboss.ws.extensions.policy.PolicyAssertion;
+import org.jboss.ws.extensions.policy.deployer.exceptions.UnsupportedAssertion;
+import org.jboss.ws.metadata.umdm.ExtensibleMetaData;
+
+public interface AssertionDeployer
+{
+ public void deploy(PolicyAssertion assertion, ExtensibleMetaData extMetaData) throws
UnsupportedAssertion;
+}
Added:
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
(rev 0)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/PolicyDeployer.java 2007-05-01
15:45:11 UTC (rev 2950)
@@ -0,0 +1,144 @@
+/*
+ * 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;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.ws.extensions.policy.Policy;
+import org.jboss.ws.extensions.policy.PolicyAlternative;
+import org.jboss.ws.extensions.policy.PolicyAssertion;
+import org.jboss.ws.extensions.policy.PolicyFactory;
+import org.jboss.ws.extensions.policy.deployer.exceptions.UnsupportedAlternative;
+import org.jboss.ws.extensions.policy.deployer.exceptions.UnsupportedAssertion;
+import org.jboss.ws.extensions.policy.deployer.exceptions.UnsupportedPolicy;
+import org.jboss.ws.metadata.umdm.ExtensibleMetaData;
+
+
+
+/**
+ * @author Stefano Maestri <mailto:stefano.maestri@javalinux.it>
+ *
+ * since 27/04/2007
+ */
+public class PolicyDeployer
+{
+
+ private static PolicyDeployer me;
+ private Map<String, Class> domainDeployerMap = new HashMap<String,
Class>();
+
+
+ static {
+ me = new PolicyDeployer();
+ me.domainDeployerMap.put("",Object.class);
+ }
+
+ //hide constructor
+ PolicyDeployer()
+ {
+ }
+
+ public static PolicyDeployer getInstance()
+ {
+ return me;
+ }
+
+ //for test
+ public static PolicyDeployer newInstance(Map<String,Class> specialDomainMap)
+ {
+ PolicyDeployer instance = new PolicyDeployer();
+ instance.domainDeployerMap = specialDomainMap;
+ return instance;
+
+ }
+
+
+ public Policy deployServerside(Policy policy, ExtensibleMetaData extMetaData) throws
UnsupportedPolicy
+ {
+ Policy returnedPolicy =
PolicyFactory.newInstance().createPolicy(policy.toElement());
+ returnedPolicy.getPolicyAlternatives().clear();
+ for (PolicyAlternative alternative : policy.getPolicyAlternatives())
+ {
+ try
+ {
+ deployAlternativeServerSide(alternative,extMetaData);
+ returnedPolicy.addPolicyAlternative(alternative);
+ }
+ catch (UnsupportedAlternative e)
+ {
+ //policy is unsupported only if it have all alternative unsupported
+ }
+
+ }
+ if (returnedPolicy.getPolicyAlternatives().size() == 0)
+ {
+ throw new UnsupportedPolicy();
+ }
+ return returnedPolicy;
+ }
+
+ public void deployClientSide(Policy policy)
+ {
+
+ }
+
+ private void deployAlternativeServerSide(PolicyAlternative alternative,
ExtensibleMetaData extMetaData) throws UnsupportedAlternative
+ {
+ for (PolicyAssertion assertion : alternative.getPolicyAssertions())
+ {
+ try
+ {
+ deployAssertionServerSide(assertion,extMetaData);
+ }
+ catch (UnsupportedAssertion e)
+ {
+ //If there is al least one unsupported assertion the alternative isn't
supported
+ throw new UnsupportedAlternative();
+ }
+ }
+ }
+
+ private void deployAssertionServerSide(PolicyAssertion assertion, ExtensibleMetaData
extMetaData) throws UnsupportedAssertion
+ {
+ AssertionDeployer deployer = getDomainDeployerInstance(assertion.getNameSpace());
+ deployer.deploy(assertion,extMetaData);
+ }
+
+
+ /**
+ *
+ * @param namespace
+ * @return the correct AssertionDeployer instance, or null if namespace not supported
+ */
+ private AssertionDeployer getDomainDeployerInstance(String namespace) throws
UnsupportedAssertion
+ {
+ try {
+ if (! domainDeployerMap.containsKey(namespace) )
+ {
+ throw new UnsupportedAssertion();
+ }
+ return (AssertionDeployer) (domainDeployerMap.get(namespace)).newInstance();
+ } catch (Exception e) {
+ throw new UnsupportedAssertion();
+ }
+ }
+}
Added:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/exceptions/UnsupportedAlternative.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/exceptions/UnsupportedAlternative.java
(rev 0)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/exceptions/UnsupportedAlternative.java 2007-05-01
15:45:11 UTC (rev 2950)
@@ -0,0 +1,32 @@
+/*
+ * 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.exceptions;
+
+/**
+ * @author Stefano Maestri <mailto:stefano.maestri@javalinux.it>
+ *
+ * since 27/04/2007
+ */
+public class UnsupportedAlternative extends Exception
+{
+
+}
Added:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/exceptions/UnsupportedAssertion.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/exceptions/UnsupportedAssertion.java
(rev 0)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/exceptions/UnsupportedAssertion.java 2007-05-01
15:45:11 UTC (rev 2950)
@@ -0,0 +1,32 @@
+/*
+ * 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.exceptions;
+
+/**
+ * @author Stefano Maestri <mailto:stefano.maestri@javalinux.it>
+ *
+ * since 27/04/2007
+ */
+public class UnsupportedAssertion extends Exception
+{
+
+}
Added:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/exceptions/UnsupportedPolicy.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/exceptions/UnsupportedPolicy.java
(rev 0)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/deployer/exceptions/UnsupportedPolicy.java 2007-05-01
15:45:11 UTC (rev 2950)
@@ -0,0 +1,32 @@
+/*
+ * 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.exceptions;
+
+/**
+ * @author Stefano Maestri <mailto:stefano.maestri@javalinux.it>
+ *
+ * since 27/04/2007
+ */
+public class UnsupportedPolicy extends Exception
+{
+
+}
Added:
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
(rev 0)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/extensions/policy/metadata/PolicyMetaExtension.java 2007-05-01
15:45:11 UTC (rev 2950)
@@ -0,0 +1,37 @@
+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
+{
+
+ Policy policy;
+
+
+ public PolicyMetaExtension(String extensionNameSpace)
+ {
+ super(extensionNameSpace);
+ }
+
+
+ public Policy getPolicy()
+ {
+ return policy;
+ }
+
+ public void setPolicy(Policy policy)
+ {
+ this.policy = policy;
+ }
+
+
+
+}
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-04-30
20:08:38 UTC (rev 2949)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java 2007-05-01
15:45:11 UTC (rev 2950)
@@ -57,6 +57,11 @@
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.Policy;
+import org.jboss.ws.extensions.policy.PolicyFactory;
+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;
import org.jboss.ws.metadata.j2ee.UnifiedApplicationMetaData;
import org.jboss.ws.metadata.j2ee.UnifiedBeanMetaData;
import org.jboss.ws.metadata.j2ee.UnifiedEjbPortComponentMetaData;
@@ -72,6 +77,7 @@
import org.jboss.ws.metadata.wsdl.WSDLBindingOperation;
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.WSDLInterfaceOperation;
import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperationOutput;
@@ -458,6 +464,43 @@
}
}
+ 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;
+
+ if (policyReferenceList != null && policyReferenceList.size() != 0
&& epMetaData instanceof ServerEndpointMetaData)
+ {
+ for (WSDLExtensibilityElement element : policyReferenceList)
+ {
+ for (WSDLExtensibilityElement policyElement :
wsdlDefinitions.getExtensibilityElements(element.getElement().getAttribute("URI")))
+ {
+ 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));
+ }
+ }
+
+ }
+
+ }
+
+ }
+ }
+
protected void processEndpointMetaDataExtensions(EndpointMetaData epMetaData,
WSDLDefinitions wsdlDefinitions)
{
for (WSDLInterface wsdlInterface : wsdlDefinitions.getInterfaces())
@@ -495,6 +538,7 @@
sepMetaData.addExtension(ext);
sepMetaData.setManagedEndpointBean(EventingEndpoint.class.getName());
}
+
}
}