[wsas-java-dev] svn commit r1895 - in trunk/wsas/java/modules:
admin/src/org/wso2/wsas/admin/service
admin/src/org/wso2/wsas/admin/service/util
clustering/src/org/wso2/wsas/clustering
clustering/src/org/wso2/wsas/clustering/commands
core/src/org/wso2/wsas/transport
core/src/org/wso2/wsas/transport/util core/src/org/wso2/wsas/util
svn at wso2.org
svn at wso2.org
Wed Apr 18 23:14:31 PDT 2007
Author: azeez
Date: Wed Apr 18 23:13:38 2007
New Revision: 1895
Added:
trunk/wsas/java/modules/core/src/org/wso2/wsas/util/PolicyUtil.java
- copied, changed from r1866, trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/util/PolicyUtil.java
Removed:
trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/util/PolicyUtil.java
Modified:
trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/GlobalAdmin.java
trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/ModuleAdmin.java
trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/OperationAdmin.java
trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/ServiceAdmin.java
trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/ServiceGroupAdmin.java
trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/util/CreateArchive.java
trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/ConfigurationCommand.java
trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/WSASConfigManagerListener.java
trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/commands/AbstractConfigurationCommand.java
trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/commands/ApplyServicePolicyCommand.java
trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/commands/LoadServiceGroupsCommand.java
trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/commands/ReloadConfigurationCommand.java
trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/commands/UnloadServiceGroupsCommand.java
trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/WSASServlet.java
trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/HttpGetRequestProcessor.java
trunk/wsas/java/modules/core/src/org/wso2/wsas/util/RequestBlockingHandler.java
trunk/wsas/java/modules/core/src/org/wso2/wsas/util/TracePersisterImpl.java
Log:
1. Improving the clustering code
2. Improving the ?wsdl & ?wsdl2 handling code.
Modified: trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/GlobalAdmin.java
==============================================================================
--- trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/GlobalAdmin.java (original)
+++ trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/GlobalAdmin.java Wed Apr 18 23:13:38 2007
@@ -34,11 +34,10 @@
import org.apache.commons.logging.LogFactory;
import org.wso2.wsas.ServerConstants;
import org.wso2.wsas.admin.service.util.AdminDatabaseAuthenticator;
-import org.wso2.wsas.admin.service.util.PolicyUtil;
+import org.wso2.wsas.util.PolicyUtil;
import org.wso2.wsas.persistence.PersistenceManager;
import org.wso2.wsas.persistence.exception.ServiceUserNotFoundException;
import org.wso2.wsas.persistence.dataobject.ServiceUserDO;
-import org.wso2.wsas.util.HibernateConfigFactory;
import org.wso2.wsas.util.ParameterUtil;
import javax.activation.DataHandler;
@@ -49,7 +48,6 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.Calendar;
-import java.util.Map;
import java.text.SimpleDateFormat;
Modified: trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/ModuleAdmin.java
==============================================================================
--- trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/ModuleAdmin.java (original)
+++ trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/ModuleAdmin.java Wed Apr 18 23:13:38 2007
@@ -19,7 +19,7 @@
import org.wso2.wsas.security.RahasUtil;
import org.wso2.wsas.security.ServerCrypto;
import org.wso2.wsas.admin.service.util.ModuleMetaData;
-import org.wso2.wsas.admin.service.util.PolicyUtil;
+import org.wso2.wsas.util.PolicyUtil;
import org.wso2.wsas.persistence.PersistenceManager;
import org.wso2.wsas.persistence.dataobject.*;
import org.wso2.wsas.persistence.exception.DuplicateEntityException;
Modified: trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/OperationAdmin.java
==============================================================================
--- trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/OperationAdmin.java (original)
+++ trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/OperationAdmin.java Wed Apr 18 23:13:38 2007
@@ -24,13 +24,12 @@
import org.apache.log4j.Logger;
import org.apache.neethi.Policy;
import org.wso2.wsas.admin.service.util.OperationMetaData;
-import org.wso2.wsas.admin.service.util.PolicyUtil;
+import org.wso2.wsas.util.PolicyUtil;
import org.wso2.wsas.persistence.PersistenceManager;
import org.wso2.wsas.persistence.dataobject.OperationDO;
import org.wso2.wsas.persistence.dataobject.OperationParameterDO;
import org.wso2.wsas.persistence.dataobject.ServiceIdentifierDO;
import org.wso2.wsas.persistence.exception.DuplicateEntityException;
-import org.wso2.wsas.util.HibernateConfigFactory;
import org.wso2.wsas.util.ParameterUtil;
import javax.xml.namespace.QName;
Modified: trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/ServiceAdmin.java
==============================================================================
--- trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/ServiceAdmin.java (original)
+++ trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/ServiceAdmin.java Wed Apr 18 23:13:38 2007
@@ -42,6 +42,7 @@
import org.wso2.wsas.persistence.exception.ServicePolicyNotFoundException;
import org.wso2.wsas.transport.util.TransportSummary;
import org.wso2.wsas.util.ParameterUtil;
+import org.wso2.wsas.util.PolicyUtil;
import org.wso2.wsas.ServerConstants;
import javax.xml.namespace.QName;
@@ -769,7 +770,6 @@
throw new AxisFault("Invalid service name " + serviceId);
}
- Policy servicePolicy;
if (!policyElement.getLocalName().equals(org.apache.neethi.Constants.ELEM_POLICY)) {
policyElement = policyElement.getFirstElement();
}
@@ -785,9 +785,7 @@
String idAttrVal = attribute.getAttributeValue();
PolicyInclude policyInclude = axisService.getPolicyInclude();
- servicePolicy =
- PolicyUtil.getPolicyFromOMElement(policyElement);
-
+ Policy servicePolicy = PolicyUtil.getPolicyFromOMElement(policyElement);
ServicePolicyDO servicePolicyDO = new ServicePolicyDO();
servicePolicyDO.setUuid(idAttrVal);
Modified: trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/ServiceGroupAdmin.java
==============================================================================
--- trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/ServiceGroupAdmin.java (original)
+++ trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/ServiceGroupAdmin.java Wed Apr 18 23:13:38 2007
@@ -15,16 +15,14 @@
*/
package org.wso2.wsas.admin.service;
-import org.wso2.wsas.admin.service.util.PolicyUtil;
+import org.wso2.wsas.util.PolicyUtil;
import org.wso2.wsas.admin.service.util.ServiceGroupMetaData;
import org.wso2.wsas.util.ParameterUtil;
-import org.wso2.wsas.util.HibernateConfigFactory;
import org.wso2.wsas.util.AdminServicesFilter;
import org.wso2.wsas.persistence.PersistenceManager;
import org.wso2.wsas.persistence.exception.DuplicateEntityException;
import org.wso2.wsas.persistence.dataobject.ServiceGroupDO;
import org.wso2.wsas.persistence.dataobject.ServiceGroupParameterDO;
-import org.wso2.wsas.ServerConstants;
import org.apache.axiom.om.OMElement;
Modified: trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/util/CreateArchive.java
==============================================================================
--- trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/util/CreateArchive.java (original)
+++ trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/util/CreateArchive.java Wed Apr 18 23:13:38 2007
@@ -17,7 +17,6 @@
import org.apache.axiom.om.*;
import org.apache.axis2.AxisFault;
-import org.apache.axis2.dataretrieval.DRConstants;
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.deployment.DeploymentConstants;
@@ -31,6 +30,7 @@
import org.wso2.utils.ArchiveManipulator;
import org.wso2.utils.WSO2Constants;
import org.wso2.wsas.ServerConstants;
+import org.wso2.wsas.util.PolicyUtil;
import javax.xml.stream.XMLStreamException;
import javax.xml.namespace.QName;
Modified: trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/ConfigurationCommand.java
==============================================================================
--- trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/ConfigurationCommand.java (original)
+++ trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/ConfigurationCommand.java Wed Apr 18 23:13:38 2007
@@ -16,16 +16,38 @@
package org.wso2.wsas.clustering;
import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.cluster.configuration.ConfigurationEvent;
/**
- *
+ * This class represents the 2-phase commit protocol, where an event is processed,
+ * the system is prepared to switch to a new configuration based on the processed event,
+ * and finally commits the new configuration (i.e. the system switches to the new configuration).
+ * As can be seen, this is a 3-step process.
*/
public interface ConfigurationCommand {
- public void prepare();
+ /**
+ * Process the <code>event</event>. The implementer of this interface will
+ * need to cache the outcome of this processing.
+ *
+ * @param event
+ * @param configContext
+ * @throws Exception
+ */
+ public void process(ConfigurationEvent event,
+ ConfigurationContext configContext) throws Exception;
- public void commit() throws Exception;
+ /**
+ * Prepare to switch to the new configuration
+ *
+ * @param configContext
+ */
+ public void prepare(ConfigurationContext configContext);
- public void setConfiguration(Object configuration);
-
- public void setConfigurationContext(ConfigurationContext configContext);
+ /**
+ * Commit the new configuration. i.e. switch the system to the new configuration
+ *
+ * @param configContext
+ * @throws Exception
+ */
+ public void commit(ConfigurationContext configContext) throws Exception;
}
Modified: trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/WSASConfigManagerListener.java
==============================================================================
--- trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/WSASConfigManagerListener.java (original)
+++ trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/WSASConfigManagerListener.java Wed Apr 18 23:13:38 2007
@@ -18,19 +18,15 @@
import org.apache.axis2.cluster.configuration.ConfigurationEvent;
import org.apache.axis2.cluster.configuration.ConfigurationManagerListener;
import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.description.AxisServiceGroup;
import org.apache.axis2.description.Parameter;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.wso2.utils.ServerConfiguration;
import org.wso2.wsas.ServerConstants;
import org.wso2.wsas.clustering.commands.ConfigurationCommandFactory;
-import org.wso2.wsas.deployment.ServerConfigurator;
-import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
@@ -76,88 +72,15 @@
public void serviceGroupsLoaded(ConfigurationEvent configurationEvent) {
-
- // Set isProcessing to true so that, even if a prepare or commit is received
- // before this method is completed, the system will wait, until the reload is complete
- isProcessing = true;
-
- String[] sgNames = configurationEvent.getServiceGroupNames();
- log.info("Going to load service groups...");
-
- AxisConfiguration axisConfig = configurationContext.getAxisConfiguration();
- boolean isOperationSuccessful = true;
- List axisServiceGroups = new ArrayList();
- for (int i = 0; i < sgNames.length; i++) {
- String sgName = sgNames[i];
- log.info("Going to load service groups - " + sgName + " ...");
- AxisServiceGroup serviceGroup = axisConfig.getServiceGroup(sgName);
- if (serviceGroup == null) { // New service group
-// DeploymentEngine.buildServiceGroup();
- // TODO:
- } else { // Existing service group
- //TODO
- }
- axisServiceGroups.add(serviceGroup);
- }
-
- if (isOperationSuccessful) {
- ConfigurationCommand cmd = getConfigurationCommand(configurationEvent);
- cmd.setConfiguration(axisServiceGroups);
- pendingCommits.add(cmd);
- }
-
- // We've finished processing this request, so reset the isProcessing flag to false
- isProcessing = false;
+ processEvent(configurationEvent);
}
public void serviceGroupsUnloaded(ConfigurationEvent configurationEvent) {
-
- // Set isProcessing to true so that, even if a prepare or commit is received
- // before this method is completed, the system will wait, until the reload is complete
- isProcessing = true;
- String[] sgNames = configurationEvent.getServiceGroupNames();
- log.info("Going to unload service groups...");
-
-
- AxisConfiguration axisConfig = configurationContext.getAxisConfiguration();
- boolean isOperationSuccessful = true;
- List axisServiceGroups = new ArrayList();
- for (int i = 0; i < sgNames.length; i++) {
- String sgName = sgNames[i];
- AxisServiceGroup serviceGroup = axisConfig.getServiceGroup(sgName);
-
- if (serviceGroup == null) {
- isOperationSuccessful = false;
- String msg = "Service group " + sgName + " does not exist";
- log.info(msg);
- notifyFailure(new Exception(msg));
- break;
- } else {
- log.info("Going to unload service group " + sgName);
- axisServiceGroups.add(serviceGroup);
- }
- }
- if (isOperationSuccessful) {
- ConfigurationCommand cmd = getConfigurationCommand(configurationEvent);
- cmd.setConfiguration(axisServiceGroups);
- pendingCommits.add(cmd);
- }
-
- // We've finished processing this request, so reset the isProcessing flag to false
- isProcessing = false;
+ processEvent(configurationEvent);
}
public void policyApplied(ConfigurationEvent configurationEvent) {
-
- // Set isProcessing to true so that, even if a prepare or commit is received
- // before this method is completed, the system will wait, until the reload is complete
- isProcessing = true;
-
- log.info("Applying policy to service ...");
- //TODO: impl
-
- // We've finished processing this request, so reset the isProcessing flag to false
- isProcessing = false;
+ processEvent(configurationEvent);
}
/**
@@ -166,34 +89,20 @@
* @param configurationEvent
*/
public void configurationReloaded(ConfigurationEvent configurationEvent) {
+ processEvent(configurationEvent);
+ }
+
+ private void processEvent(ConfigurationEvent configurationEvent) {
// Set isProcessing to true so that, even if a prepare or commit is received
- // before this reload is completed, the system will wait, until the reload is complete
+ // before this method is completed, the system will wait, until the reload is complete
isProcessing = true;
-
- log.info("Loading new configuration...");
- ServerConfiguration config = ServerConfiguration.getInstance();
- String repoLocation =
- config.getFirstProperty(ServerConfiguration.AXIS2_CONFIG_REPO_LOCATION);
+ ConfigurationCommand cmd = getConfigurationCommand(configurationEvent);
try {
- ServerConfigurator.getInstance().init(repoLocation,
- System.getProperty(ServerConstants.WEB_RESOURCE_LOCATION));
- ConfigurationContext newConfigurationContext =
- ConfigurationContextFactory
- .createConfigurationContext(ServerConfigurator.getInstance());
- ConfigurationCommand cmd = getConfigurationCommand(configurationEvent);
- cmd.setConfiguration(newConfigurationContext);
+ cmd.process(configurationEvent, configurationContext);
pendingCommits.add(cmd);
- log.info("New configuration successfully loaded and cached. " +
- "Waiting for prepare request...");
-
} catch (Throwable e) {
- try {
- notifyFailure(e);
- } catch (Exception e1) {
- log.error(e1);
- }
- log.error("Could not reload new configuration", e);
+ notifyFailure(e);
}
// We've finished processing this request, so reset the isProcessing flag to false
@@ -221,7 +130,7 @@
log.info("Preparing to commit...");
prepareReceivedTime = System.currentTimeMillis();
for (Iterator iter = pendingCommits.iterator(); iter.hasNext();) {
- ((ConfigurationCommand) iter.next()).prepare();
+ ((ConfigurationCommand) iter.next()).prepare(configurationContext);
}
isPreparing = false;
}
@@ -300,7 +209,7 @@
for (Iterator iter = pendingCommits.iterator(); iter.hasNext();) {
ConfigurationCommand cmd = (ConfigurationCommand) iter.next();
try {
- cmd.commit();
+ cmd.commit(configurationContext);
} catch (Exception e) {
notifyFailure(new Exception("Could not commit " + cmd));
}
@@ -343,10 +252,8 @@
}
private ConfigurationCommand getConfigurationCommand(ConfigurationEvent configurationEvent) {
- ConfigurationCommand cmd = ConfigurationCommandFactory.
+ return ConfigurationCommandFactory.
getConfigurationCommand(configurationEvent.getConfigurationType());
- cmd.setConfigurationContext(configurationContext);
- return cmd;
}
private void notifyFailure(Throwable e) {
@@ -367,5 +274,4 @@
log.error(e2);
}
}
-
}
Modified: trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/commands/AbstractConfigurationCommand.java
==============================================================================
--- trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/commands/AbstractConfigurationCommand.java (original)
+++ trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/commands/AbstractConfigurationCommand.java Wed Apr 18 23:13:38 2007
@@ -19,7 +19,9 @@
import org.wso2.wsas.ServerConstants;
import org.apache.axis2.description.AxisServiceGroup;
import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.AxisService;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.cluster.configuration.ConfigurationEvent;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -29,17 +31,7 @@
*/
public abstract class AbstractConfigurationCommand implements ConfigurationCommand {
protected static Log log = LogFactory.getLog(AbstractConfigurationCommand.class);
- protected Object configuration;
- protected ConfigurationContext configContext;
-
- public void setConfiguration(Object configuration) {
- this.configuration = configuration;
- }
-
- public void setConfigurationContext(ConfigurationContext configContext) {
- this.configContext = configContext;
- }
-
+
protected void addBlockAllRequestsParameter(AxisServiceGroup serviceGroup) {
if (serviceGroup == null) {
return;
@@ -52,4 +44,31 @@
log.error("Cannot add parameter to AxisServiceGroup", axisFault);
}
}
+
+ protected void addBlockAllRequestsParameter(AxisService service) {
+ if (service == null) {
+ return;
+ }
+ Parameter param = new Parameter(ServerConstants.BLOCK_ALL_REQUESTS,
+ Boolean.TRUE);
+ try {
+ service.addParameter(param);
+ } catch (AxisFault axisFault) {
+ log.error("Cannot add parameter to AxisService", axisFault);
+ }
+ }
+
+ protected void removeBlockAllRequestsParameter(AxisService service) {
+ if (service == null) {
+ return;
+ }
+ try {
+ Parameter param = service.getParameter(ServerConstants.BLOCK_ALL_REQUESTS);
+ if (param != null) {
+ service.removeParameter(param);
+ }
+ } catch (AxisFault axisFault) {
+ log.error("Cannot add parameter to AxisService", axisFault);
+ }
+ }
}
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 Wed Apr 18 23:13:38 2007
@@ -15,23 +15,95 @@
*/
package org.wso2.wsas.clustering.commands;
-import org.apache.axis2.description.AxisServiceGroup;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axis2.cluster.configuration.ConfigurationEvent;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.PolicyInclude;
+import org.apache.neethi.Policy;
+import org.wso2.wsas.util.PolicyUtil;
+
+import java.io.ByteArrayInputStream;
/**
*
*/
public class ApplyServicePolicyCommand extends AbstractConfigurationCommand {
- public void prepare() {
- addBlockAllRequestsParameter((AxisServiceGroup) configuration); //TODO: this may be AxisService
+ private ServicePolicy servicePolicy;
+
+ public void process(ConfigurationEvent event,
+ ConfigurationContext confiCtx) throws Exception {
+ log.info("Applying policy to service ...");
+ this.servicePolicy = null;
+ String serviceName = event.getServiceName();
+
+ // Build the Policy
+ String policyString = event.getPolicy();
+ ByteArrayInputStream bais = new ByteArrayInputStream(policyString.getBytes());
+ OMElement policyElement;
+ AxisService axisService =
+ confiCtx.getAxisConfiguration().getService(serviceName);
+ if (axisService == null) {
+ String msg = "Service " + serviceName + " does not exist";
+ log.info(msg);
+ throw new Exception(msg);
+ }
+ policyElement = new StAXOMBuilder(bais).getDocumentElement();
+ policyElement.build();
+ Policy policy = PolicyUtil.getPolicyFromOMElement(policyElement);
+ this.servicePolicy = new ServicePolicy(axisService, policy);
+ }
+
+ public void prepare(ConfigurationContext configContext) {
+ addBlockAllRequestsParameter(this.servicePolicy.getAxisService());
}
- public void commit() throws Exception {
- //TODO: Method implementation
+ public void commit(ConfigurationContext configContext) throws Exception {
+ 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);
+ }
+ } 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
+ policyInclude.addPolicyElement(PolicyInclude.AXIS_SERVICE_POLICY,
+ newPolicy);
+ }
+ removeBlockAllRequestsParameter(axisService);
}
public String toString() {
- return "APPLY_SERVICE_POLICY";
+ return "APPLY_SERVICE_POLICY_EVENT";
+ }
+
+ private class ServicePolicy {
+ private AxisService axisService;
+ private Policy policy;
+
+ public ServicePolicy(AxisService axisService, Policy policy) {
+ this.axisService = axisService;
+ this.policy = policy;
+ }
+
+ public AxisService getAxisService() {
+ return axisService;
+ }
+
+ public Policy getPolicy() {
+ return policy;
+ }
}
}
Modified: trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/commands/LoadServiceGroupsCommand.java
==============================================================================
--- trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/commands/LoadServiceGroupsCommand.java (original)
+++ trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/commands/LoadServiceGroupsCommand.java Wed Apr 18 23:13:38 2007
@@ -15,26 +15,54 @@
*/
package org.wso2.wsas.clustering.commands;
+import org.apache.axis2.cluster.configuration.ConfigurationEvent;
+import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.description.AxisServiceGroup;
+import org.apache.axis2.engine.AxisConfiguration;
-import java.util.List;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
/**
*
*/
public class LoadServiceGroupsCommand extends AbstractConfigurationCommand {
+ private List axisServiceGroups;
+
+ public void process(ConfigurationEvent event,
+ ConfigurationContext confiCtx) throws Exception {
+ log.info("Going to load service groups...");
+ String[] sgNames = event.getServiceGroupNames();
+ if(axisServiceGroups != null){
+ axisServiceGroups.clear();
+ }
+ AxisConfiguration axisConfig = confiCtx.getAxisConfiguration();
+ List axisServiceGroups = new ArrayList();
+ for (int i = 0; i < sgNames.length; i++) {
+ String sgName = sgNames[i];
+ log.info("Going to load service groups - " + sgName + " ...");
+ AxisServiceGroup serviceGroup = axisConfig.getServiceGroup(sgName);
+ if (serviceGroup == null) { // New service group
+// DeploymentEngine.buildServiceGroup();
+ // TODO:
+ } else { // Existing service group
+ //TODO
+ }
+ axisServiceGroups.add(serviceGroup);
+ }
+ this.axisServiceGroups = axisServiceGroups;
+ }
- public void prepare() {
- List axisServiceGroups = (List) configuration;
- for (Iterator iterator = axisServiceGroups.iterator();
+ public void prepare(ConfigurationContext configContext) {
+ for (Iterator iterator = this.axisServiceGroups.iterator();
iterator.hasNext();) {
AxisServiceGroup axisSG = (AxisServiceGroup) iterator.next();
addBlockAllRequestsParameter(axisSG);
}
}
- public void commit() throws Exception {
+ public void commit(ConfigurationContext configContext) throws Exception {
//TODO: Method implementation
}
Modified: trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/commands/ReloadConfigurationCommand.java
==============================================================================
--- trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/commands/ReloadConfigurationCommand.java (original)
+++ trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/commands/ReloadConfigurationCommand.java Wed Apr 18 23:13:38 2007
@@ -15,27 +15,47 @@
*/
package org.wso2.wsas.clustering.commands;
+import org.apache.axis2.cluster.configuration.ConfigurationEvent;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.wso2.utils.ServerConfiguration;
import org.wso2.wsas.ServerConstants;
+import org.wso2.wsas.deployment.ServerConfigurator;
import org.wso2.wsas.util.Controllable;
-import org.apache.axis2.context.ConfigurationContext;
/**
*
*/
public class ReloadConfigurationCommand extends AbstractConfigurationCommand {
- public void commit() throws Exception {
+
+ private ConfigurationContext newConfigContext;
+
+ public void process(ConfigurationEvent event,
+ ConfigurationContext configCtx) throws Exception {
+ log.info("Loading new configuration...");
+ ServerConfiguration config = ServerConfiguration.getInstance();
+ String repoLocation =
+ config.getFirstProperty(ServerConfiguration.AXIS2_CONFIG_REPO_LOCATION);
+ ServerConfigurator.getInstance().init(repoLocation,
+ System.getProperty(ServerConstants.WEB_RESOURCE_LOCATION));
+ this.newConfigContext =
+ ConfigurationContextFactory.
+ createConfigurationContext(ServerConfigurator.getInstance());
+ log.info("New configuration successfully loaded and cached. " +
+ "Waiting for prepare request...");
+ }
+
+ public void prepare(ConfigurationContext configCtx) {
+ configCtx.setProperty(ServerConstants.BLOCK_ALL_REQUESTS,
+ Boolean.TRUE);
+ }
+
+ public void commit(ConfigurationContext configContext) throws Exception {
Controllable controllable =
(Controllable) configContext.
getProperty(ServerConstants.WSO2WSAS_INSTANCE);
configContext.getServiceGroupContexts().clear();
- ConfigurationContext newConfigCtx = (ConfigurationContext) configuration;
- controllable.setConfigurationContext(newConfigCtx);
- configContext = newConfigCtx;
- }
-
- public void prepare() {
- ((ConfigurationContext) configuration).setProperty(ServerConstants.BLOCK_ALL_REQUESTS,
- Boolean.TRUE);
+ controllable.setConfigurationContext(this.newConfigContext);
}
public String toString() {
Modified: trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/commands/UnloadServiceGroupsCommand.java
==============================================================================
--- trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/commands/UnloadServiceGroupsCommand.java (original)
+++ trunk/wsas/java/modules/clustering/src/org/wso2/wsas/clustering/commands/UnloadServiceGroupsCommand.java Wed Apr 18 23:13:38 2007
@@ -15,36 +15,65 @@
*/
package org.wso2.wsas.clustering.commands;
+import org.apache.axis2.cluster.configuration.ConfigurationEvent;
+import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.description.AxisServiceGroup;
+import org.apache.axis2.engine.AxisConfiguration;
-import java.util.List;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
/**
*
*/
public class UnloadServiceGroupsCommand extends AbstractConfigurationCommand {
- public void prepare() {
- List axisServiceGroups = (List) configuration;
- for (Iterator iterator = axisServiceGroups.iterator();
+ private List axisServiceGroups;
+
+ public void process(ConfigurationEvent event,
+ ConfigurationContext confiCtx) throws Exception {
+ log.info("Going to unload service groups...");
+
+ if(axisServiceGroups != null){
+ axisServiceGroups.clear();
+ }
+ String[] sgNames = event.getServiceGroupNames();
+ AxisConfiguration axisConfig = confiCtx.getAxisConfiguration();
+ List axisServiceGroups = new ArrayList();
+ for (int i = 0; i < sgNames.length; i++) {
+ String sgName = sgNames[i];
+ AxisServiceGroup serviceGroup = axisConfig.getServiceGroup(sgName);
+ if (serviceGroup == null) {
+ String msg = "Service group " + sgName + " does not exist";
+ log.info(msg);
+ throw new Exception(msg);
+ } else {
+ log.info("Going to unload service group " + sgName);
+ axisServiceGroups.add(serviceGroup);
+ }
+ }
+ this.axisServiceGroups = axisServiceGroups;
+ }
+
+ public void prepare(ConfigurationContext configContext) {
+ for (Iterator iterator = this.axisServiceGroups.iterator();
iterator.hasNext();) {
AxisServiceGroup axisSG = (AxisServiceGroup) iterator.next();
addBlockAllRequestsParameter(axisSG);
}
}
- public void commit() throws Exception {
- List serviceGroups = (List) configuration;
- for (Iterator sgIter = serviceGroups.iterator(); sgIter.hasNext();) {
+ public void commit(ConfigurationContext configContext) throws Exception {
+ for (Iterator sgIter = this.axisServiceGroups.iterator(); sgIter.hasNext();) {
AxisServiceGroup serviceGroup = (AxisServiceGroup) sgIter.next();
- configContext.getAxisConfiguration().
- removeServiceGroup(serviceGroup.getServiceGroupName());
+ configContext.getAxisConfiguration().
+ removeServiceGroup(serviceGroup.getServiceGroupName());
}
}
public String toString() {
- return "LOAD_SERVICE_GROUPS_EVENT";
+ return "UNLOAD_SERVICE_GROUPS_EVENT";
}
}
Modified: trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/WSASServlet.java
==============================================================================
--- trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/WSASServlet.java (original)
+++ trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/WSASServlet.java Wed Apr 18 23:13:38 2007
@@ -74,15 +74,15 @@
if (queryString.toLowerCase().indexOf("info") == 0) {
HttpGetRequestProcessor.processInfo(configContext, requestURI, response);
} else if (queryString.toLowerCase().indexOf("xsd") == 0) {
- HttpGetRequestProcessor
- .processXsd(configContext, requestURI, response, request);
+ HttpGetRequestProcessor.processXsd(configContext, requestURI,
+ response, request);
} else if (queryString.toLowerCase().indexOf("policy") == 0) {
- HttpGetRequestProcessor
- .processPolicy(configContext, requestURI, response, request);
+ HttpGetRequestProcessor.processPolicy(configContext, requestURI,
+ response, request);
} else if (queryString.toLowerCase().indexOf("wsdl2") == 0) {
- HttpGetRequestProcessor.printWSDL(configContext, request, response, 1);
+ HttpGetRequestProcessor.printWSDL20(configContext, request, response);
} else if (queryString.toLowerCase().indexOf("wsdl") == 0) {
- HttpGetRequestProcessor.printWSDL(configContext, request, response, 0);
+ HttpGetRequestProcessor.printWSDL11(configContext, request, response);
} else if (queryString.toLowerCase().indexOf("cert") == 0) {
HttpGetRequestProcessor.processCert(configContext, response, request);
} else {
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 Wed Apr 18 23:13:38 2007
@@ -104,28 +104,53 @@
}
+ public static void printWSDL11(final ConfigurationContext configurationContext,
+ final HttpServletRequest request,
+ final HttpServletResponse response) throws IOException {
+ WSDLPrinter wsdlPrinter = new WSDLPrinter() {
+ public void printWSDL(AxisService axisService) throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ axisService.printWSDL(baos,
+ NetworkUtils.getLocalHostname(),
+ getServiceContextPath(configurationContext));
+ writeDocument(baos,
+ response.getOutputStream(),
+ "annotated-wsdl.xsl",
+ configurationContext.getContextRoot());
+ }
+ };
+ printWSDL(configurationContext, request, response, wsdlPrinter);
+ }
+
+ public static void printWSDL20(final ConfigurationContext configurationContext,
+ final HttpServletRequest request,
+ final HttpServletResponse response) throws IOException {
+ WSDLPrinter wsdlPrinter = new WSDLPrinter() {
+ public void printWSDL(AxisService axisService) throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ axisService.printWSDL2(baos,
+ NetworkUtils.getLocalHostname(),
+ getServiceContextPath(configurationContext));
+ writeDocument(baos,
+ response.getOutputStream(),
+ "annotated-wsdl2.xsl",
+ configurationContext.getContextRoot());
+ }
+ };
+ printWSDL(configurationContext, request, response, wsdlPrinter);
+ }
+
/**
- * wsdlType = 0, wsdl1.1; wsdlType = 1 ; wsdl2.0
- *
* @param request
* @param response
- * @param wsdlType
+ * @param wsdlPrinter
*/
- public static void printWSDL(ConfigurationContext configurationContext,
- HttpServletRequest request, HttpServletResponse response,
- int wsdlType) throws IOException {
+ private static void printWSDL(ConfigurationContext configurationContext,
+ HttpServletRequest request,
+ HttpServletResponse response,
+ WSDLPrinter wsdlPrinter) throws IOException {
String requestURI = request.getRequestURI();
String serviceName = requestURI.substring(requestURI.lastIndexOf("/") + 1);
- String requestURL = request.getRequestURL().toString();
- int ipindex = requestURL.indexOf("//");
- String ip = null;
- if (ipindex >= 0) {
- ip = requestURL.substring(ipindex + 2, requestURL.length());
- int separatorIndex = ip.indexOf(":");
- if (separatorIndex > 0) {
- ip = ip.substring(0, separatorIndex);
- }
- }
AxisService axisService =
configurationContext.getAxisConfiguration().getServiceForActivation(serviceName);
@@ -138,29 +163,8 @@
" is inactive. Cannot display WSDL document.</h4>").getBytes());
outputStream.flush();
}
-
response.setContentType("text/xml");
- // Filter out the 'root' from serviceContextPath
- String serviceContextPath = getServiceContextPath(configurationContext);
- String contextRoot = request.getContextPath();
-
-
- int index = serviceContextPath.lastIndexOf("/");
- String servicePath = serviceContextPath.substring(index + 1,
- serviceContextPath.length());
- if (wsdlType == 0) {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- axisService.printWSDL(baos, ip, servicePath);
- writeDocument(baos, outputStream, "annotated-wsdl.xsl", contextRoot);
- } else if (wsdlType == 1) {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- axisService.printWSDL2(baos, ip, servicePath);
- writeDocument(baos, outputStream, "annotated-wsdl2.xsl", contextRoot);
- } else {
- response.setContentType("text/html");
- outputStream.write("<h4>WSDL for service not found</h4>".getBytes());
- outputStream.flush();
- }
+ wsdlPrinter.printWSDL(axisService);
} else {
response.setContentType("text/html");
outputStream.write(("<h4>Service " + serviceName +
@@ -392,28 +396,27 @@
writeDocument(baos, outputStream, "annotated-xsd.xsl", contextRoot);
}
- private static void writeDocument(ByteArrayOutputStream byteArryaOutStream,
+ private static void writeDocument(ByteArrayOutputStream byteArrayOutStream,
OutputStream out,
String annotatedXsl,
String contextRoot) {
XMLStreamWriter writer;
try {
+ ByteArrayInputStream bais =
+ new ByteArrayInputStream(byteArrayOutStream.toByteArray());
XMLStreamReader reader =
- XMLInputFactory.newInstance().
- createXMLStreamReader(new ByteArrayInputStream(byteArryaOutStream.
- toByteArray()));
+ XMLInputFactory.newInstance().createXMLStreamReader(bais);
StAXOMBuilder builder = new StAXOMBuilder(reader);
- OMElement schemaDocument = builder.getDocumentElement();
-
+ OMElement docElem = builder.getDocumentElement();
writer = XMLOutputFactory.newInstance().createXMLStreamWriter(out);
if (annotatedXsl != null) {
writer.writeProcessingInstruction("xml-stylesheet",
" type=\"text/xsl\" href=\"" +
- contextRoot +
+ (contextRoot.equals("/") ? "" : contextRoot) +
"/styles/" +
annotatedXsl + "\"");
}
- schemaDocument.serialize(writer);
+ docElem.serialize(writer);
writer.flush();
} catch (XMLStreamException e) {
log.error(e);
@@ -483,4 +486,8 @@
}
return serviceContextPath;
}
+
+ private interface WSDLPrinter {
+ void printWSDL(AxisService axisService) throws IOException;
+ }
}
Copied: trunk/wsas/java/modules/core/src/org/wso2/wsas/util/PolicyUtil.java (from r1866, trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/util/PolicyUtil.java)
==============================================================================
--- trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/util/PolicyUtil.java (original)
+++ trunk/wsas/java/modules/core/src/org/wso2/wsas/util/PolicyUtil.java Wed Apr 18 23:13:38 2007
@@ -13,37 +13,43 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.wso2.wsas.admin.service.util;
+package org.wso2.wsas.util;
import org.apache.axiom.om.*;
import org.apache.axiom.om.impl.llom.factory.OMXMLBuilderFactory;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.neethi.Policy;
import org.apache.neethi.PolicyEngine;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.XMLStreamReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
public class PolicyUtil {
- private static final String emptyPolicy = "<wsp:Policy xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\" />";
+ private static final String EMPTY_POLICY =
+ "<wsp:Policy xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\" />";
public static OMElement getPolicyAsOMElement(Policy policy) {
-
+
try {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(baos);
-
- policy.serialize(writer);
- writer.flush();
-
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- return OMXMLBuilderFactory.createStAXOMBuilder(OMAbstractFactory.getOMFactory(), XMLInputFactory.newInstance().createXMLStreamReader(bais)).getDocumentElement();
-
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(baos);
+ policy.serialize(writer);
+ writer.flush();
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ XMLStreamReader xmlStreamReader =
+ XMLInputFactory.newInstance().createXMLStreamReader(bais);
+ StAXOMBuilder staxOMBuilder =
+ OMXMLBuilderFactory.createStAXOMBuilder(OMAbstractFactory.getOMFactory(),
+ xmlStreamReader);
+ return staxOMBuilder.getDocumentElement();
+
} catch (Exception ex) {
- throw new RuntimeException("can't convert the policy to an OMElement" , ex);
+ throw new RuntimeException("can't convert the policy to an OMElement", ex);
}
}
@@ -52,9 +58,9 @@
}
public static OMElement getEmptyPolicyAsOMElement() {
- ByteArrayInputStream bais = new ByteArrayInputStream(emptyPolicy.getBytes());
+ ByteArrayInputStream bais = new ByteArrayInputStream(EMPTY_POLICY.getBytes());
Policy policy = PolicyEngine.getPolicy(bais);
-
+
return getPolicyAsOMElement(policy);
}
Modified: trunk/wsas/java/modules/core/src/org/wso2/wsas/util/RequestBlockingHandler.java
==============================================================================
--- trunk/wsas/java/modules/core/src/org/wso2/wsas/util/RequestBlockingHandler.java (original)
+++ trunk/wsas/java/modules/core/src/org/wso2/wsas/util/RequestBlockingHandler.java Wed Apr 18 23:13:38 2007
@@ -30,10 +30,14 @@
public class RequestBlockingHandler extends AbstractHandler {
public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
+
+ // Handle blocking at gobal level
ConfigurationContext cfgCtx = msgContext.getConfigurationContext();
Boolean isBlockingAllRequests =
(Boolean) cfgCtx.getProperty(ServerConstants.BLOCK_ALL_REQUESTS);
AxisServiceGroup serviceGroup = msgContext.getAxisServiceGroup();
+
+ // Handle blocking at service group level
Boolean isBlockingServiceGroupRequests = Boolean.FALSE;
if (serviceGroup != null) {
Parameter blockingParam =
@@ -43,6 +47,17 @@
}
}
+ // Handle blocking at service level
+ AxisService service = msgContext.getAxisService();
+ Boolean isBlockingServiceRequests = Boolean.FALSE;
+ if (service != null) {
+ Parameter blockingParam =
+ service.getParameter(ServerConstants.BLOCK_ALL_REQUESTS);
+ if (blockingParam != null) {
+ isBlockingServiceRequests = (Boolean) blockingParam.getValue();
+ }
+ }
+
if (isBlockingAllRequests != null && isBlockingAllRequests.booleanValue()) {
// Allow only NodeManager service commit requests to pass through. Block all others
@@ -57,7 +72,10 @@
}
}
} else if (isBlockingServiceGroupRequests.booleanValue()) {
- throw new AxisFault("This service is being initialized or unloaded. " +
+ throw new AxisFault("This service group is being initialized or unloaded. " +
+ "Please try again in a few seconds.");
+ } else if (isBlockingServiceRequests.booleanValue()) {
+ throw new AxisFault("This service is being initialized. " +
"Please try again in a few seconds.");
}
return InvocationResponse.CONTINUE;
Modified: trunk/wsas/java/modules/core/src/org/wso2/wsas/util/TracePersisterImpl.java
==============================================================================
--- trunk/wsas/java/modules/core/src/org/wso2/wsas/util/TracePersisterImpl.java (original)
+++ trunk/wsas/java/modules/core/src/org/wso2/wsas/util/TracePersisterImpl.java Wed Apr 18 23:13:38 2007
@@ -45,7 +45,7 @@
private static Log log = LogFactory.getLog(TracePersisterImpl.class);
private MessageContext msgContext;
- private static final Log TRACE_MESSAGES = LogFactory.getLog("trace.messages");
+ private static final Log TRACE_LOGGER = LogFactory.getLog("trace.messages");
private PersistenceManager pm = new PersistenceManager();
@@ -72,8 +72,8 @@
}
msgDO.setXml(xml);
- if (TRACE_MESSAGES.isTraceEnabled()) {
- TRACE_MESSAGES.trace(xml);
+ if (TRACE_LOGGER.isTraceEnabled()) {
+ TRACE_LOGGER.trace(xml);
}
long msgSequence = getMessageSequence(serviceName + "." + operationName,
@@ -88,6 +88,9 @@
public void saveTraceStatus(String onOff) {
pm.updateConfigurationProperty(TracerConstants.TRACING_STATUS, onOff);
+ /*if(onOff.equalsIgnoreCase("on")){
+ TRACE_LOGGER.set
+ }*/
}
public String[] getMessages(String serviceId,
More information about the Wsas-java-dev
mailing list