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:
020: package org.apache.axis2.description;
021:
022: import org.apache.axiom.om.OMElement;
023: import org.apache.axis2.AxisFault;
024: import org.apache.axis2.i18n.Messages;
025:
026: import java.util.ArrayList;
027:
028: /**
029: * This is to store deployment time data , described by
030: * <moduleConfig module="modulename">
031: * <parameter> ....</parameter>
032: * </moduleConfig>
033: * <p/>
034: * Right now this just keeps stores the set of parameters
035: */
036: public class ModuleConfiguration implements ParameterInclude {
037: private String moduleName;
038: private ParameterInclude parameterInclude;
039:
040: // to keep the pointer to its parent , only to access parameters
041: private ParameterInclude parent;
042:
043: public ModuleConfiguration(String moduleName,
044: ParameterInclude parent) {
045: this .moduleName = moduleName;
046: this .parent = parent;
047: parameterInclude = new ParameterIncludeImpl();
048: }
049:
050: public void addParameter(Parameter param) throws AxisFault {
051: if (isParameterLocked(param.getName())) {
052: throw new AxisFault(Messages.getMessage(
053: "paramterlockedbyparent", param.getName()));
054: } else {
055: parameterInclude.addParameter(param);
056: }
057: }
058:
059: public void removeParameter(Parameter param) throws AxisFault {
060: if (isParameterLocked(param.getName())) {
061: throw new AxisFault(Messages.getMessage(
062: "paramterlockedbyparent", param.getName()));
063: } else {
064: parameterInclude.removeParameter(param);
065: }
066: }
067:
068: public void deserializeParameters(OMElement parameterElement)
069: throws AxisFault {
070: this .parameterInclude.deserializeParameters(parameterElement);
071: }
072:
073: public String getModuleName() {
074: return moduleName;
075: }
076:
077: public Parameter getParameter(String name) {
078: return parameterInclude.getParameter(name);
079: }
080:
081: public ArrayList getParameters() {
082: return parameterInclude.getParameters();
083: }
084:
085: public boolean isParameterLocked(String parameterName) {
086:
087: // checking the locked value of parent
088: boolean loscked = false;
089:
090: if (parent != null) {
091: loscked = parent.isParameterLocked(parameterName);
092: }
093:
094: if (loscked) {
095: return true;
096: } else {
097: Parameter parameter = getParameter(parameterName);
098:
099: return (parameter != null) && parameter.isLocked();
100: }
101: }
102: }
|