You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sa...@apache.org on 2006/09/20 17:28:21 UTC
svn commit: r448235 - in /webservices/axis2/trunk/java/modules:
kernel/src/org/apache/axis2/description/
kernel/src/org/apache/axis2/modules/ kernel/test/org/apache/axis2/ samples/
samples/src/userguide/loggingmodule/ savan/src/org/apache/savan/module/...
Author: sanka
Date: Wed Sep 20 08:28:20 2006
New Revision: 448235
URL: http://svn.apache.org/viewvc?view=rev&rev=448235
Log:
Added two new methods to the Module interface. We discussed this sometime
back and no one opposed it.
see: http://marc.theaimsgroup.com/?l=axis-dev&m=115080063628582&w=2
Modified:
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/modules/Module.java
webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/InavalidModuleImpl.java
webservices/axis2/trunk/java/modules/samples/project.xml
webservices/axis2/trunk/java/modules/samples/src/userguide/loggingmodule/LoggingModule.java
webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/module/SavanModule.java
webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/Rampart.java
webservices/axis2/trunk/java/modules/soapmonitor/project.xml
webservices/axis2/trunk/java/modules/soapmonitor/src/org/apache/axis2/handlers/soapmonitor/SOAPMonitorModule.java
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java?view=diff&rev=448235&r1=448234&r2=448235
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java Wed Sep 20 08:28:20 2006
@@ -1,35 +1,38 @@
/*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.axis2.description;
-import org.apache.axiom.om.OMElement;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.i18n.Messages;
-import org.apache.neethi.Policy;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import javax.xml.namespace.QName;
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.modules.Module;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.Policy;
+
public abstract class AxisDescription implements ParameterInclude,
DescriptionConstants {
@@ -40,8 +43,10 @@
private PolicyInclude policyInclude = null;
private HashMap children;
-
-
+
+ // creating a logger instance
+ private Log log = LogFactory.getLog(this.getClass());
+
public AxisDescription() {
parameterInclude = new ParameterIncludeImpl();
children = new HashMap();
@@ -54,7 +59,8 @@
}
if (isParameterLocked(param.getName())) {
- throw new AxisFault(Messages.getMessage("paramterlockedbyparent", param.getName()));
+ throw new AxisFault(Messages.getMessage("paramterlockedbyparent",
+ param.getName()));
}
parameterInclude.addParameter(param);
@@ -94,7 +100,6 @@
&& getParameter(parameterName).isLocked();
}
-
public void setParent(AxisDescription parent) {
this.parent = parent;
}
@@ -133,137 +138,131 @@
public void removeChild(Object key) {
children.remove(key);
}
-
/**
* This method sets the policy as the default of this AxisDescription
* instance. Further more this method does the followings.
- *
- * (1) Engage whatever modules necessary to execute new the effective
- * policy of this AxisDescription instance.
- * (2) Disengage whatever modules that are not necessary to excute the
- * new effective policy of this AxisDescription instance.
- * (3) Check whether each module can execute the new effective policy
- * of this AxisDescription instance.
- * (4) If not throw an AxisFault to notify the user.
- * (5) Else notify each module about the new effective policy.
- *
- * @param policy the new policy of this AxisDescription instance. The
- * effective policy is the merge of this argument with effective
- * policy of parent of this AxisDescription.
- * @throws AxisFault if any module is unable to execute the effective policy
- * of this AxisDescription instance sucessfully or no module to
- * execute some portion (one or more PrimtiveAssertions ) of that
- * effective policy.
+ *
+ * (1) Engage whatever modules necessary to execute new the effective policy
+ * of this AxisDescription instance. (2) Disengage whatever modules that are
+ * not necessary to excute the new effective policy of this AxisDescription
+ * instance. (3) Check whether each module can execute the new effective
+ * policy of this AxisDescription instance. (4) If not throw an AxisFault to
+ * notify the user. (5) Else notify each module about the new effective
+ * policy.
+ *
+ * @param policy
+ * the new policy of this AxisDescription instance. The effective
+ * policy is the merge of this argument with effective policy of
+ * parent of this AxisDescription.
+ * @throws AxisFault
+ * if any module is unable to execute the effective policy of
+ * this AxisDescription instance sucessfully or no module to
+ * execute some portion (one or more PrimtiveAssertions ) of
+ * that effective policy.
*/
public void applyPolicy(Policy policy) throws AxisFault {
AxisConfiguration configuration = getAxisConfiguration();
-// this.policyInclude.setPolicy(policy);
-//
-// Policy effPolicy = this.policyInclude.getEffectivePolicy();
-// ExactlyOne exactlyOne = (ExactlyOne) effPolicy.getTerms().get(0);
-//
-// ArrayList list = new ArrayList();
-//
-// for (Iterator iterator = exactlyOne.getTerms().iterator(); iterator.hasNext();) {
-// All all = (All) iterator.next();
-// if (!checkAllternative(all.getTerms(), configuration)) {
-// list.add(all);
-// }
-// }
-//
-// exactlyOne.getTerms().removeAll(list);
-//
-// if (exactlyOne.isEmpty()) {
-// throw new AxisFault("can't find any Alternative with known Policy assertions");
-// }
-//
-// Map modules = configuration.getModules();
-//
-// for (Iterator iterator = modules.values().iterator(); iterator.hasNext();) {
-// AxisModule module = (AxisModule) iterator.next();
-// // TODO needs to implement this method
-//// module.validate(effPolicy);
-// }
-//
-// if (exactlyOne.isEmpty()) {
-// throw new AxisFault("can't find any compaitible Alternative");
-// }
-//
-// // pick an arbitary Alternative
-// All target = (All) exactlyOne.getTerms().get(0);
-// exactlyOne.getTerms().removeAll(exactlyOne.getTerms());
-// exactlyOne.addTerm(target);
-//
-// List requiredModules = getModulesForAlternative(target.getTerms(), configuration);
-//
-// for (Iterator iterator = requiredModules.iterator(); iterator.hasNext();) {
-// AxisModule module = (AxisModule) iterator.next();
-// if (! isEngaged(module.getName())) {
-// engageModule(module, configuration);
-// } else {
-// // TODO needs to implement this method
-//// module.applyPolicy(effPolicy, this);
-// }
-// }
-
- }
-
- private List getModulesForAlternative(List primitiveTerms, AxisConfiguration configuration) {
+ // sets AxisDescription policy
+ this.policyInclude.setPolicy(policy);
-// ArrayList namespaceURIs = new ArrayList();
-// ArrayList modulesList = new ArrayList();
-//
-// PrimitiveAssertion primitive;
-// String namespaceURI;
-//
-// for (Iterator iterator = primitiveTerms.iterator(); iterator.hasNext();) {
-// primitive = (PrimitiveAssertion) iterator.next();
-// namespaceURI = primitive.getName().getNamespaceURI();
-//
-// if (! namespaceURIs.contains(namespaceURI)) {
-// namespaceURIs.add(namespaceURI);
-// }
-// }
-//
-// for (Iterator iterator = namespaceURIs.iterator(); iterator.hasNext();) {
-// modulesList.addAll(configuration.getModulesForPolicyNamesapce((String) iterator.next()));
-// }
-//
-// return modulesList;
- throw new UnsupportedOperationException("TODO");
+ /*
+ * now we should take the effective one .. it is necessary since
+ * AxisDescription.applyPolicy(..) doesn't override policies at the
+ * Upper levels.
+ */
+ Policy effPolicy = this.policyInclude.getEffectivePolicy();
+
+ /*
+ * for the moment we consider policies with only one alternative. If the
+ * policy contains multiple alternatives only the first alternative will
+ * be considered.
+ */
+ Iterator iterator = effPolicy.getAlternatives();
+ if (! iterator.hasNext()) {
+ throw new AxisFault("Policy doesn't contain any policy alternatives");
+ }
+
+ List assertionList = (List) iterator.next();
+
+ Assertion assertion;
+ String namespaceURI;
+
+ List moduleList;
+
+ List namespaceList = new ArrayList();
+ List modulesToEngage = new ArrayList();
+
+ for (Iterator assertions = assertionList.iterator(); assertions.hasNext();) {
+ assertion = (Assertion) assertions.next();
+ namespaceURI = assertion.getName().getNamespaceURI();
+
+ moduleList = configuration.getModulesForPolicyNamesapce(namespaceURI);
+
+ if (moduleList == null) {
+ log.debug("can't find any module to process " + assertion.getName() + " type assertions");
+ continue;
+ }
+
+ if (canSupportAssertion(assertion, moduleList)) {
+ throw new AxisFault("atleast one module can't support " + assertion.getName());
+ }
+
+ if (namespaceList.contains(namespaceURI)) {
+ namespaceList.add(namespaceURI);
+ modulesToEngage.addAll(moduleList);
+ }
+ }
+
+ engageModulesToAxisDescription(modulesToEngage, this);
}
- private boolean checkAllternative(List terms, AxisConfiguration configuration) {
-//
-// PrimitiveAssertion assertion;
-//
-// for (Iterator iterator = terms.iterator(); iterator.hasNext();) {
-// assertion = (PrimitiveAssertion) iterator.next();
-//
-// String namespace = assertion.getName().getNamespaceURI();
-// List modulesList = configuration.getModulesForPolicyNamesapce(namespace);
-// if (modulesList != null) {
+ private boolean canSupportAssertion(Assertion assertion, List moduleList) {
+
+ Module module;
+
+ for (Iterator iterator = moduleList.iterator(); iterator.hasNext();) {
+ module = (Module) iterator.next();
+ /*
+ * FIXME .. need to add this method to the Module Interface ..
+ */
+//
+// if (! module.canSupportAssertion(assertion)) {
+// log.debug(((AxisModule) module).getName() + " says it can't support " + assertion.getName());
// return false;
// }
-//
-// }
-// return true;
- throw new UnsupportedOperationException("TODO");
+ }
+
+ return true;
}
-
- public AxisConfiguration getAxisConfiguration() {
+ private void engageModulesToAxisDescription(List moduleList, AxisDescription description) throws AxisFault {
+ AxisModule axisModule;
+
+ for (Iterator iterator = moduleList.iterator(); iterator.hasNext(); ) {
+ axisModule = (AxisModule) iterator.next();
+
+ if (! description.isEngaged(axisModule.getName())) {
+ // engages the module to AxisDescription
+ description.engageModule(axisModule, getAxisConfiguration());
+ // notifies the module about the engagement
+ axisModule.getModule().engageNotify(description);
+ }
+ }
+ }
+
+ public AxisConfiguration getAxisConfiguration() {
+
if (this instanceof AxisConfiguration) {
return (AxisConfiguration) this;
}
-
+
if (getParent() != null) {
return getParent().getAxisConfiguration();
}
-
+
return null;
}
@@ -271,12 +270,12 @@
/**
* Engagaging a module to diferrent level
- *
+ *
* @param axisModule
* @param axisConfig
*/
public abstract void engageModule(AxisModule axisModule,
- AxisConfiguration axisConfig) throws AxisFault;
-
+ AxisConfiguration axisConfig) throws AxisFault;
+
public abstract boolean isEngaged(QName axisModule);
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/modules/Module.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/modules/Module.java?view=diff&rev=448235&r1=448234&r2=448235
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/modules/Module.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/modules/Module.java Wed Sep 20 08:28:20 2006
@@ -22,6 +22,8 @@
import org.apache.axis2.description.AxisDescription;
import org.apache.axis2.description.AxisModule;
import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.Policy;
/**
* Every module provides an implementation of this class. Modules are in one of
@@ -51,6 +53,25 @@
*/
void engageNotify(AxisDescription axisDescription) throws AxisFault;
+ /**
+ * Evalute whether it can support the specified assertion and returns true if the assertion can
+ * be supported.
+ *
+ * @param assertion the assertion that the module must decide whether it can support or not.
+ * @return true if the specified assertion can be supported by the module
+ */
+ public boolean canSupportAssertion(Assertion assertion);
+
+ /**
+ * Evaluates specified policy for the specified AxisDescription. It computes the configuration that
+ * is appropriate to support the policy and stores it the appropriate description.
+ *
+ * @param policy the policy that is applicable for the specified AxisDescription
+ * @throws AxisFault if anything goes wrong.
+ */
+ public void applyPolicy(Policy policy, AxisDescription axisDescription) throws AxisFault;
+
+
// shutdown the module
public void shutdown(ConfigurationContext configurationContext) throws AxisFault;
}
Modified: webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/InavalidModuleImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/InavalidModuleImpl.java?view=diff&rev=448235&r1=448234&r2=448235
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/InavalidModuleImpl.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/InavalidModuleImpl.java Wed Sep 20 08:28:20 2006
@@ -4,6 +4,8 @@
import org.apache.axis2.description.AxisDescription;
import org.apache.axis2.description.AxisModule;
import org.apache.axis2.modules.Module;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.Policy;
/*
* Copyright 2004,2005 The Apache Software Foundation.
*
@@ -32,4 +34,13 @@
// shutdown the module
public void shutdown(ConfigurationContext configurationContext) throws AxisFault {
}
+
+ public void applyPolicy(Policy policy, AxisDescription axisDescription) throws AxisFault {
+ }
+
+ public boolean canSupportAssertion(Assertion assertion) {
+ return true;
+ }
+
+
}
Modified: webservices/axis2/trunk/java/modules/samples/project.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/project.xml?view=diff&rev=448235&r1=448234&r2=448235
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/project.xml (original)
+++ webservices/axis2/trunk/java/modules/samples/project.xml Wed Sep 20 08:28:20 2006
@@ -41,7 +41,14 @@
<artifactId>axiom-impl</artifactId>
<version>${axiom.version}</version>
</dependency>
-
+ <dependency>
+ <groupId>ws-commons</groupId>
+ <artifactId>neethi</artifactId>
+ <version>${neethi.version}</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ </dependency>
<dependency>
<groupId>axis2</groupId>
<artifactId>axis2-addressing</artifactId>
Modified: webservices/axis2/trunk/java/modules/samples/src/userguide/loggingmodule/LoggingModule.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/src/userguide/loggingmodule/LoggingModule.java?view=diff&rev=448235&r1=448234&r2=448235
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/userguide/loggingmodule/LoggingModule.java (original)
+++ webservices/axis2/trunk/java/modules/samples/src/userguide/loggingmodule/LoggingModule.java Wed Sep 20 08:28:20 2006
@@ -22,6 +22,8 @@
import org.apache.axis2.description.AxisDescription;
import org.apache.axis2.description.AxisModule;
import org.apache.axis2.modules.Module;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.Policy;
public class LoggingModule implements Module {
@@ -39,5 +41,12 @@
public String[] getPolicyNamespaces() {
return null;
+ }
+
+ public void applyPolicy(Policy policy, AxisDescription axisDescription) throws AxisFault {
+ }
+
+ public boolean canSupportAssertion(Assertion assertion) {
+ return true;
}
}
Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/module/SavanModule.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/module/SavanModule.java?view=diff&rev=448235&r1=448234&r2=448235
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/module/SavanModule.java (original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/module/SavanModule.java Wed Sep 20 08:28:20 2006
@@ -26,6 +26,8 @@
import org.apache.axis2.modules.Module;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.Policy;
import org.apache.savan.SavanConstants;
import org.apache.savan.SavanException;
import org.apache.savan.configuration.ConfigurationManager;
@@ -64,5 +66,16 @@
public void shutdown(ConfigurationContext configurationContext) throws AxisFault {
}
+
+ public void applyPolicy(Policy policy, AxisDescription axisDescription) throws AxisFault {
+ // TODO
+ }
+
+ public boolean canSupportAssertion(Assertion assertion) {
+ // TODO
+ return true;
+ }
+
+
}
Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/Rampart.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/Rampart.java?view=diff&rev=448235&r1=448234&r2=448235
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/Rampart.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/Rampart.java Wed Sep 20 08:28:20 2006
@@ -23,6 +23,10 @@
import org.apache.axis2.modules.Module;
import org.apache.axis2.modules.ModulePolicyExtension;
import org.apache.axis2.modules.PolicyExtension;
+
+import org.apache.neethi.Assertion;
+import org.apache.neethi.Policy;
+
import org.apache.ws.security.policy1.extension.WSSCodegenPolicyExtension;
public class Rampart implements Module, ModulePolicyExtension {
@@ -37,10 +41,19 @@
}
public void shutdown(ConfigurationContext configurationContext) throws AxisFault {
- // Do nothing
+ // at the moment, nothing needs to be done ..
}
public PolicyExtension getPolicyExtension() {
return new WSSCodegenPolicyExtension();
+ }
+
+ public void applyPolicy(Policy policy, AxisDescription axisDescription) throws AxisFault {
+ // TODO
+ }
+
+ public boolean canSupportAssertion(Assertion assertion) {
+ // TODO
+ return true;
}
}
Modified: webservices/axis2/trunk/java/modules/soapmonitor/project.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/soapmonitor/project.xml?view=diff&rev=448235&r1=448234&r2=448235
==============================================================================
--- webservices/axis2/trunk/java/modules/soapmonitor/project.xml (original)
+++ webservices/axis2/trunk/java/modules/soapmonitor/project.xml Wed Sep 20 08:28:20 2006
@@ -38,6 +38,14 @@
<version>${axiom.version}</version>
</dependency>
<dependency>
+ <groupId>ws-commons</groupId>
+ <artifactId>neethi</artifactId>
+ <version>${neethi.version}</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ </dependency>
+ <dependency>
<groupId>axis2</groupId>
<artifactId>axis2-kernel</artifactId>
<version>${pom.currentVersion}</version>
Modified: webservices/axis2/trunk/java/modules/soapmonitor/src/org/apache/axis2/handlers/soapmonitor/SOAPMonitorModule.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/soapmonitor/src/org/apache/axis2/handlers/soapmonitor/SOAPMonitorModule.java?view=diff&rev=448235&r1=448234&r2=448235
==============================================================================
--- webservices/axis2/trunk/java/modules/soapmonitor/src/org/apache/axis2/handlers/soapmonitor/SOAPMonitorModule.java (original)
+++ webservices/axis2/trunk/java/modules/soapmonitor/src/org/apache/axis2/handlers/soapmonitor/SOAPMonitorModule.java Wed Sep 20 08:28:20 2006
@@ -23,6 +23,8 @@
import org.apache.axis2.description.AxisModule;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.modules.Module;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.Policy;
public class SOAPMonitorModule implements Module {
@@ -41,4 +43,13 @@
public String[] getPolicyNamespaces() {
return null;
}
+
+ public void applyPolicy(Policy policy, AxisDescription axisDescription) throws AxisFault {
+ }
+
+ public boolean canSupportAssertion(Assertion assertion) {
+ return true;
+ }
+
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org