[wsas-java-dev] svn commit r1912 - in trunk/wsas/java/modules:
clustering clustering/src/org/wso2/wsas/clustering
clustering/src/org/wso2/wsas/clustering/commands
core/src/org/wso2/wsas/transport/util samples/NodeManagement
samples/conf
svn at wso2.org
svn at wso2.org
Thu Apr 19 21:38:48 PDT 2007
Author: azeez
Date: Thu Apr 19 21:38:10 2007
New Revision: 1912
Added:
trunk/wsas/java/modules/samples/NodeManagement/applyservicepolicy
trunk/wsas/java/modules/samples/NodeManagement/policy.xml
Modified:
trunk/wsas/java/modules/clustering/clustering-codegen.xml
trunk/wsas/java/modules/clustering/nodemanager.wsdl
trunk/wsas/java/modules/clustering/pom.xml
trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/NodeManager.java
trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/NodeManagerClient.java
trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/commands/ApplyServicePolicyCommand.java
trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/HttpGetRequestProcessor.java
trunk/wsas/java/modules/samples/conf/wsas-samples-codegen.xml
Log:
1. Updates to applyPolicy functionality in Config Management
2. Included a sample for applyPolicy
3. Moving generated clustering sources to target/clustering
Modified: trunk/wsas/java/modules/clustering/clustering-codegen.xml
==============================================================================
--- trunk/wsas/java/modules/clustering/clustering-codegen.xml (original)
+++ trunk/wsas/java/modules/clustering/clustering-codegen.xml Thu Apr 19 21:38:10 2007
@@ -4,7 +4,7 @@
<!-- NodeManager Stub -->
<set>
<uri>./nodemanager.wsdl</uri>
- <o>./generated/src</o>
+ <o>./target/generated/src</o>
<p>org.wso2.wsas.clustering</p>
<d>adb</d>
<sn>WSO2WSASNodeManager</sn>
Modified: trunk/wsas/java/modules/clustering/nodemanager.wsdl
==============================================================================
--- trunk/wsas/java/modules/clustering/nodemanager.wsdl (original)
+++ trunk/wsas/java/modules/clustering/nodemanager.wsdl Thu Apr 19 21:38:10 2007
@@ -1,4 +1,3 @@
-<?xml-stylesheet type="text/xsl" href="/styles/annotated-wsdl.xsl"?>
<wsdl:definitions xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:ns0="http://org.apache.axis2/xsd"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
@@ -22,7 +21,7 @@
<xs:complexType>
<xs:sequence>
<xs:element name="serviceName" nillable="true" type="xs:string"/>
- <xs:element name="policyId" nillable="true" type="xs:string"/>
+ <xs:element name="policy" nillable="true" type="xs:anyType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@@ -49,28 +48,6 @@
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="loadServiceGroupFault">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="loadServiceGroupFault" type="xs:anyType"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="loadServiceGroup">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="serviceGroupName" nillable="true" type="xs:string"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
- <xs:element name="loadServiceGroupResponse">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="return" nillable="true" type="xs:boolean"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
<xs:element name="loadServiceGroupsFault">
<xs:complexType>
<xs:sequence>
@@ -81,12 +58,12 @@
<xs:element name="loadServiceGroups">
<xs:complexType>
<xs:sequence>
-
<xs:element maxOccurs="unbounded" name="serviceGroupNames" nillable="true"
type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
+
<xs:element name="loadServiceGroupsResponse">
<xs:complexType>
<xs:sequence>
@@ -100,11 +77,11 @@
<xs:element name="prepareFault" type="xs:anyType"/>
</xs:sequence>
</xs:complexType>
-
</xs:element>
<xs:element name="prepareResponse">
<xs:complexType>
<xs:sequence>
+
<xs:element name="return" nillable="true" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
@@ -118,33 +95,11 @@
</xs:element>
<xs:element name="reloadConfigurationResponse">
<xs:complexType>
-
<xs:sequence>
<xs:element name="return" nillable="true" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
- </xs:element>
- <xs:element name="unloadServiceGroupFault">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="unloadServiceGroupFault" type="xs:anyType"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="unloadServiceGroup">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="serviceGroupName" nillable="true" type="xs:string"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="unloadServiceGroupResponse">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="return" nillable="true" type="xs:boolean"/>
- </xs:sequence>
- </xs:complexType>
</xs:element>
<xs:element name="unloadServiceGroupsFault">
<xs:complexType>
@@ -154,7 +109,6 @@
</xs:complexType>
</xs:element>
<xs:element name="unloadServiceGroups">
-
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="serviceGroupNames" nillable="true"
@@ -164,6 +118,7 @@
</xs:element>
<xs:element name="unloadServiceGroupsResponse">
<xs:complexType>
+
<xs:sequence>
<xs:element name="return" nillable="true" type="xs:boolean"/>
</xs:sequence>
@@ -196,15 +151,6 @@
<wsdl:message name="loadServiceGroupsFault">
<wsdl:part name="part1" element="ns0:loadServiceGroupsFault"/>
</wsdl:message>
- <wsdl:message name="loadServiceGroupMessage">
- <wsdl:part name="part1" element="ns0:loadServiceGroup"/>
- </wsdl:message>
- <wsdl:message name="loadServiceGroupResponse">
- <wsdl:part name="part1" element="ns0:loadServiceGroupResponse"/>
- </wsdl:message>
- <wsdl:message name="loadServiceGroupFault">
- <wsdl:part name="part1" element="ns0:loadServiceGroupFault"/>
- </wsdl:message>
<wsdl:message name="reloadConfigurationMessage"/>
<wsdl:message name="reloadConfigurationResponse">
<wsdl:part name="part1" element="ns0:reloadConfigurationResponse"/>
@@ -219,15 +165,6 @@
<wsdl:message name="commitFault">
<wsdl:part name="part1" element="ns0:commitFault"/>
</wsdl:message>
- <wsdl:message name="unloadServiceGroupMessage">
- <wsdl:part name="part1" element="ns0:unloadServiceGroup"/>
- </wsdl:message>
- <wsdl:message name="unloadServiceGroupResponse">
- <wsdl:part name="part1" element="ns0:unloadServiceGroupResponse"/>
- </wsdl:message>
- <wsdl:message name="unloadServiceGroupFault">
- <wsdl:part name="part1" element="ns0:unloadServiceGroupFault"/>
- </wsdl:message>
<wsdl:message name="unloadServiceGroupsMessage">
<wsdl:part name="part1" element="ns0:unloadServiceGroups"/>
</wsdl:message>
@@ -256,12 +193,6 @@
<wsdl:output message="ns0:loadServiceGroupsResponse"/>
<wsdl:fault message="ns0:loadServiceGroupsFault" name="loadServiceGroupsFault"/>
</wsdl:operation>
- <wsdl:operation name="loadServiceGroup">
- <wsdl:input xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
- message="ns0:loadServiceGroupMessage" wsaw:Action="urn:loadServiceGroup"/>
- <wsdl:output message="ns0:loadServiceGroupResponse"/>
- <wsdl:fault message="ns0:loadServiceGroupFault" name="loadServiceGroupFault"/>
- </wsdl:operation>
<wsdl:operation name="reloadConfiguration">
<wsdl:input xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
message="ns0:reloadConfigurationMessage"
@@ -275,13 +206,6 @@
<wsdl:output message="ns0:commitResponse"/>
<wsdl:fault message="ns0:commitFault" name="commitFault"/>
</wsdl:operation>
- <wsdl:operation name="unloadServiceGroup">
- <wsdl:input xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
- message="ns0:unloadServiceGroupMessage"
- wsaw:Action="urn:unloadServiceGroup"/>
- <wsdl:output message="ns0:unloadServiceGroupResponse"/>
- <wsdl:fault message="ns0:unloadServiceGroupFault" name="unloadServiceGroupFault"/>
- </wsdl:operation>
<wsdl:operation name="unloadServiceGroups">
<wsdl:input xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
message="ns0:unloadServiceGroupsMessage"
@@ -328,18 +252,6 @@
<soap12:fault use="literal" name="loadServiceGroupsFault"/>
</wsdl:fault>
</wsdl:operation>
- <wsdl:operation name="loadServiceGroup">
- <soap:operation soapAction="urn:loadServiceGroup" style="document"/>
- <wsdl:input>
- <soap:body use="literal"/>
- </wsdl:input>
- <wsdl:output>
- <soap:body use="literal"/>
- </wsdl:output>
- <wsdl:fault name="loadServiceGroupFault">
- <soap12:fault use="literal" name="loadServiceGroupFault"/>
- </wsdl:fault>
- </wsdl:operation>
<wsdl:operation name="reloadConfiguration">
<soap:operation soapAction="urn:reloadConfiguration" style="document"/>
<wsdl:input>
@@ -364,18 +276,6 @@
<soap12:fault use="literal" name="commitFault"/>
</wsdl:fault>
</wsdl:operation>
- <wsdl:operation name="unloadServiceGroup">
- <soap:operation soapAction="urn:unloadServiceGroup" style="document"/>
- <wsdl:input>
- <soap:body use="literal"/>
- </wsdl:input>
- <wsdl:output>
- <soap:body use="literal"/>
- </wsdl:output>
- <wsdl:fault name="unloadServiceGroupFault">
- <soap12:fault use="literal" name="unloadServiceGroupFault"/>
- </wsdl:fault>
- </wsdl:operation>
<wsdl:operation name="unloadServiceGroups">
<soap:operation soapAction="urn:unloadServiceGroups" style="document"/>
<wsdl:input>
@@ -427,18 +327,6 @@
<soap12:fault use="literal" name="loadServiceGroupsFault"/>
</wsdl:fault>
</wsdl:operation>
- <wsdl:operation name="loadServiceGroup">
- <soap12:operation soapAction="urn:loadServiceGroup" style="document"/>
- <wsdl:input>
- <soap12:body use="literal"/>
- </wsdl:input>
- <wsdl:output>
- <soap12:body use="literal"/>
- </wsdl:output>
- <wsdl:fault name="loadServiceGroupFault">
- <soap12:fault use="literal" name="loadServiceGroupFault"/>
- </wsdl:fault>
- </wsdl:operation>
<wsdl:operation name="reloadConfiguration">
<soap12:operation soapAction="urn:reloadConfiguration" style="document"/>
<wsdl:input>
@@ -463,18 +351,6 @@
<soap12:fault use="literal" name="commitFault"/>
</wsdl:fault>
</wsdl:operation>
- <wsdl:operation name="unloadServiceGroup">
- <soap12:operation soapAction="urn:unloadServiceGroup" style="document"/>
- <wsdl:input>
- <soap12:body use="literal"/>
- </wsdl:input>
- <wsdl:output>
- <soap12:body use="literal"/>
- </wsdl:output>
- <wsdl:fault name="unloadServiceGroupFault">
- <soap12:fault use="literal" name="unloadServiceGroupFault"/>
- </wsdl:fault>
- </wsdl:operation>
<wsdl:operation name="unloadServiceGroups">
<soap12:operation soapAction="urn:unloadServiceGroups" style="document"/>
<wsdl:input>
@@ -517,15 +393,6 @@
<mime:content type="text/xml"/>
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="loadServiceGroup">
- <http:operation location="loadServiceGroup"/>
- <wsdl:input>
- <mime:content type="text/xml"/>
- </wsdl:input>
- <wsdl:output>
- <mime:content type="text/xml"/>
- </wsdl:output>
- </wsdl:operation>
<wsdl:operation name="reloadConfiguration">
<http:operation location="reloadConfiguration"/>
<wsdl:input>
@@ -544,15 +411,6 @@
<mime:content type="text/xml"/>
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="unloadServiceGroup">
- <http:operation location="unloadServiceGroup"/>
- <wsdl:input>
- <mime:content type="text/xml"/>
- </wsdl:input>
- <wsdl:output>
- <mime:content type="text/xml"/>
- </wsdl:output>
- </wsdl:operation>
<wsdl:operation name="unloadServiceGroups">
<http:operation location="unloadServiceGroups"/>
<wsdl:input>
Modified: trunk/wsas/java/modules/clustering/pom.xml
==============================================================================
--- trunk/wsas/java/modules/clustering/pom.xml (original)
+++ trunk/wsas/java/modules/clustering/pom.xml Thu Apr 19 21:38:10 2007
@@ -49,7 +49,7 @@
</goals>
<configuration>
<sources>
- <source>${basedir}/generated/src</source>
+ <source>${basedir}/target/generated/src</source>
</sources>
</configuration>
</execution>
Modified: trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/NodeManager.java
==============================================================================
--- trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/NodeManager.java (original)
+++ trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/NodeManager.java Thu Apr 19 21:38:10 2007
@@ -25,6 +25,7 @@
import org.apache.axis2.description.Parameter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.axiom.om.OMElement;
/**
*
@@ -58,28 +59,25 @@
return isOperationSuccessful();
}
- public boolean applyPolicy(String serviceName, String policy) throws AxisFault {
+ public boolean applyPolicy(String serviceName, OMElement policy) throws AxisFault {
init();
ConfigurationManager configMan = getConfigurationManager();
if (configMan == null) {
throw new AxisFault(CONFIG_MANAGER_NULL);
}
- configMan.applyPolicy(serviceName, policy);
+ System.err.println("###### Policy=" + policy.toString());
+ configMan.applyPolicy(serviceName, policy.toString());
return isOperationSuccessful();
}
public boolean reloadConfiguration() throws AxisFault {
init();
ConfigurationManager configMan = getConfigurationManager();
- if (configMan != null) {
- configMan.reloadConfiguration();
- if (!isOperationSuccessful()) {
- return false;
- }
- } else {
+ if (configMan == null) {
throw new AxisFault(CONFIG_MANAGER_NULL);
}
- return true;
+ configMan.reloadConfiguration();
+ return isOperationSuccessful();
}
public boolean prepare() throws AxisFault {
@@ -89,10 +87,10 @@
public boolean commit() throws AxisFault {
init();
ConfigurationManager configMan = getConfigurationManager();
- if (configMan != null) {
- return isCommitSuccessful(configMan);
+ if (configMan == null) {
+ throw new AxisFault(CONFIG_MANAGER_NULL);
}
- return true;
+ return isCommitSuccessful(configMan);
}
private ConfigurationManager getConfigurationManager() {
Modified: trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/NodeManagerClient.java
==============================================================================
--- trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/NodeManagerClient.java (original)
+++ trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/NodeManagerClient.java Thu Apr 19 21:38:10 2007
@@ -16,10 +16,12 @@
package org.wso2.wsas.clustering;
import org.apache.axis2.AxisFault;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import java.util.StringTokenizer;
import java.util.List;
import java.util.ArrayList;
+import java.io.FileInputStream;
/**
*
@@ -51,9 +53,14 @@
return resp.get_return();
}
- private boolean applyServicePolicy() throws Exception {
- // TODO
- return false;
+ private boolean applyServicePolicy(String serviceName, String policyFile) throws Exception {
+ WSO2WSASNodeManagerStub.ApplyPolicy req =
+ new WSO2WSASNodeManagerStub.ApplyPolicy();
+ req.setServiceName(serviceName);
+ StAXOMBuilder builder = new StAXOMBuilder(new FileInputStream(policyFile));
+ req.setPolicy(builder.getDocumentElement());
+ WSO2WSASNodeManagerStub.ApplyPolicyResponse resp = stub.applyPolicy(req);
+ return resp.get_return();
}
private boolean commit() throws Exception {
@@ -83,7 +90,9 @@
String[] serviceGroups = getServiceGroups(getParam("--service-groups", args));
isOperationSuccessful = client.unloadServiceGroups(serviceGroups);
} else if (operation.equals("applypolicy")) {
- isOperationSuccessful = client.applyServicePolicy();
+ String serviceName = getParam("--service", args);
+ String policyFile = getParam("--policy-file", args);
+ isOperationSuccessful = client.applyServicePolicy(serviceName, policyFile);
} else if (operation.equals("commit")) {
isOperationSuccessful = client.commit();
} else {
Modified: trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/commands/ApplyServicePolicyCommand.java
==============================================================================
--- trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/commands/ApplyServicePolicyCommand.java (original)
+++ trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/commands/ApplyServicePolicyCommand.java Thu Apr 19 21:38:10 2007
@@ -22,9 +22,11 @@
import org.apache.axis2.description.AxisService;
import org.apache.axis2.description.PolicyInclude;
import org.apache.neethi.Policy;
+import org.apache.neethi.util.PolicyComparator;
import org.wso2.wsas.util.PolicyUtil;
import java.io.ByteArrayInputStream;
+import java.util.Iterator;
/**
*
@@ -64,22 +66,28 @@
AxisService axisService = this.servicePolicy.getAxisService();
Policy newPolicy = this.servicePolicy.getPolicy();
- String policyId = newPolicy.getId();
PolicyInclude policyInclude = axisService.getPolicyInclude();
- if (policyId != null) { // Can the policy be identified by its ID?
- Policy originalPolicy = policyInclude.getPolicy(policyId);
- if (originalPolicy != null) { // An already existing policy?
- policyInclude.updatePolicy(newPolicy);
- } else { // A new policy
- policyInclude.addPolicyElement(PolicyInclude.AXIS_SERVICE_POLICY,
- newPolicy);
+
+ // Handle existing policy updates
+ boolean isPolicyFound = false;
+ for(Iterator iter = policyInclude.getPolicyElements().iterator();
+ iter.hasNext();){
+ Object obj = iter.next();
+ if(obj instanceof Policy){
+ Policy policy = (Policy) obj;
+ if(PolicyComparator.compare(policy, newPolicy)){
+ newPolicy.setId(policy.getId());
+ policyInclude.updatePolicy(newPolicy);
+ isPolicyFound = true;
+ break;
+ }
}
- } else {
+ }
- //TODO: Do we need to set some policy ID in this case?
- // TODO: This may be very critical, since there is no way of uniquely identifying this policy
+ // Handle new policy additions
+ if(!isPolicyFound){
policyInclude.addPolicyElement(PolicyInclude.AXIS_SERVICE_POLICY,
- newPolicy);
+ newPolicy);
}
removeBlockAllRequestsParameter(axisService);
}
Modified: trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/HttpGetRequestProcessor.java
==============================================================================
--- trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/HttpGetRequestProcessor.java (original)
+++ trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/HttpGetRequestProcessor.java Thu Apr 19 21:38:10 2007
@@ -61,8 +61,8 @@
private static PersistenceManager pm = new PersistenceManager();
public static void processCert(ConfigurationContext configurationContext,
- HttpServletResponse response, HttpServletRequest request)
- throws IOException {
+ HttpServletResponse response,
+ HttpServletRequest request) throws IOException {
String requestURI = request.getRequestURI();
String serviceName = requestURI.substring(requestURI.lastIndexOf("/") + 1);
Added: trunk/wsas/java/modules/samples/NodeManagement/applyservicepolicy
==============================================================================
--- (empty file)
+++ trunk/wsas/java/modules/samples/NodeManagement/applyservicepolicy Thu Apr 19 21:38:10 2007
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+EPR=http://10.100.1.118:9762/services/WSO2WSASNodeManager
+
+./admin.sh --epr $EPR --operation applypolicy --service version --policy-file policy.xml
+if [ "$?" = "0" ]; then
+ ./admin.sh --epr $EPR --operation commit
+ echo Successfully committed.
+else
+ echo Applying service policy failed
+fi
\ No newline at end of file
Added: trunk/wsas/java/modules/samples/NodeManagement/policy.xml
==============================================================================
--- (empty file)
+++ trunk/wsas/java/modules/samples/NodeManagement/policy.xml Thu Apr 19 21:38:10 2007
@@ -0,0 +1,9 @@
+<wsp:Policy Name="urn:version"
+ Id="urn:version"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <intf:ServicePolicyTestAssertion1 marker="2" xmlns:intf="http://test.policy.org/wsas"/>
+ </wsp:All>
+ </wsp:ExactlyOne>
+</wsp:Policy>
\ No newline at end of file
Modified: trunk/wsas/java/modules/samples/conf/wsas-samples-codegen.xml
==============================================================================
--- trunk/wsas/java/modules/samples/conf/wsas-samples-codegen.xml (original)
+++ trunk/wsas/java/modules/samples/conf/wsas-samples-codegen.xml Thu Apr 19 21:38:10 2007
@@ -1,6 +1,5 @@
<config>
-
<!-- CommodityQuote Sample-->
<set>
<uri>./CommodityQuote/wsdl/CommodityQuote.wsdl</uri>
@@ -121,7 +120,7 @@
<d>adb</d>
<ns2p>http://wso2.org/repos/wso2/people/jonathan/flickr.wsdl=org.wso2.www.types.flickr.client</ns2p>
<u/>
- <wv>2</wv>
+ <wv>2</wv>
</set>
</config>
More information about the Wsas-java-dev
mailing list