001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019: package org.apache.axis2.clustering.context.commands;
020:
021: import org.apache.axis2.AxisFault;
022: import org.apache.axis2.Constants;
023: import org.apache.axis2.clustering.ClusteringFault;
024: import org.apache.axis2.context.ConfigurationContext;
025: import org.apache.axis2.context.ServiceContext;
026: import org.apache.axis2.context.ServiceGroupContext;
027: import org.apache.axis2.description.AxisService;
028: import org.apache.axis2.description.AxisServiceGroup;
029: import org.apache.commons.logging.Log;
030: import org.apache.commons.logging.LogFactory;
031:
032: /**
033: *
034: */
035: public class UpdateServiceContextCommand extends UpdateContextCommand {
036:
037: private static final Log log = LogFactory
038: .getLog(UpdateServiceContextCommand.class);
039:
040: protected String serviceGroupName;
041: protected String serviceGroupContextId;
042: protected String serviceName;
043:
044: public void setServiceGroupName(String serviceGroupName) {
045: this .serviceGroupName = serviceGroupName;
046: }
047:
048: public void setServiceName(String serviceName) {
049: this .serviceName = serviceName;
050: }
051:
052: public void setServiceGroupContextId(String serviceGroupContextId) {
053: this .serviceGroupContextId = serviceGroupContextId;
054: }
055:
056: public void execute(ConfigurationContext configurationContext)
057: throws ClusteringFault {
058: log.debug("Updating service context properties...");
059: ServiceGroupContext sgCtx = configurationContext
060: .getServiceGroupContext(serviceGroupContextId);
061: if (sgCtx != null) {
062: try {
063: AxisService axisService = configurationContext
064: .getAxisConfiguration().getService(serviceName);
065: ServiceContext serviceContext = sgCtx
066: .getServiceContext(axisService);
067: propertyUpdater.updateProperties(serviceContext);
068: } catch (AxisFault e) {
069: throw new ClusteringFault(e);
070: }
071: } else {
072: sgCtx = configurationContext
073: .getServiceGroupContext(serviceGroupContextId);
074: AxisService axisService;
075: try {
076: axisService = configurationContext
077: .getAxisConfiguration().getService(serviceName);
078: } catch (AxisFault axisFault) {
079: throw new ClusteringFault(axisFault);
080: }
081: String scope = axisService.getScope();
082: if (sgCtx == null) {
083: AxisServiceGroup serviceGroup = configurationContext
084: .getAxisConfiguration().getServiceGroup(
085: serviceGroupName);
086: if (serviceGroup == null) {
087: return;
088: }
089: sgCtx = new ServiceGroupContext(configurationContext,
090: serviceGroup);
091: sgCtx.setId(serviceGroupContextId);
092: if (scope.equals(Constants.SCOPE_APPLICATION)) {
093: configurationContext
094: .addServiceGroupContextIntoApplicationScopeTable(sgCtx);
095: } else if (scope.equals(Constants.SCOPE_SOAP_SESSION)) {
096: configurationContext
097: .addServiceGroupContextIntoSoapSessionTable(sgCtx);
098: }
099: }
100: try {
101: ServiceContext serviceContext = sgCtx
102: .getServiceContext(axisService);
103: propertyUpdater.updateProperties(serviceContext);
104: } catch (AxisFault axisFault) {
105: throw new ClusteringFault(axisFault);
106: }
107: }
108: }
109:
110: public String toString() {
111: return "UpdateServiceContextCommand(" + uniqueId + ")";
112: }
113: }
|