001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 package org.apache.geronimo.deployment.plugin;
019
020 import javax.enterprise.deploy.spi.TargetModuleID;
021 import javax.enterprise.deploy.spi.Target;
022 import javax.enterprise.deploy.shared.ModuleType;
023 import java.io.Serializable;
024
025 /**
026 *
027 *
028 * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
029 */
030 public class TargetModuleIDImpl implements TargetModuleID, Serializable {
031 private String webURL;
032 private ModuleType type;
033 private final Target target;
034 private final String moduleID;
035 private final TargetModuleID parentTargetModuleID;
036 private final TargetModuleID[] childTargetModuleID;
037
038 public TargetModuleIDImpl(Target target, String moduleID) {
039 this.target = target;
040 this.moduleID = moduleID;
041 parentTargetModuleID = null;
042 childTargetModuleID = null;
043 }
044
045 public TargetModuleIDImpl(Target target, String moduleID, String[] childIDs) {
046 this.target = target;
047 this.moduleID = moduleID;
048 parentTargetModuleID = null;
049 if(childIDs == null || childIDs.length == 0) {
050 childTargetModuleID = null;
051 } else {
052 childTargetModuleID = new TargetModuleID[childIDs.length];
053 for (int i = 0; i < childIDs.length; i++) {
054 String childID = childIDs[i];
055 childTargetModuleID[i] = new TargetModuleIDImpl(target, childID, this);
056 }
057 }
058 }
059
060 private TargetModuleIDImpl(Target target, String moduleID, TargetModuleID parent) {
061 this.target = target;
062 this.moduleID = moduleID;
063 this.parentTargetModuleID = parent;
064 childTargetModuleID = null;
065 }
066
067 public Target getTarget() {
068 return target;
069 }
070
071 public String getModuleID() {
072 return moduleID;
073 }
074
075 public TargetModuleID getParentTargetModuleID() {
076 return parentTargetModuleID;
077 }
078
079 public TargetModuleID[] getChildTargetModuleID() {
080 return childTargetModuleID;
081 }
082
083 public String getWebURL() {
084 return webURL;
085 }
086
087 public void setWebURL(String webURL) {
088 this.webURL = webURL;
089 }
090
091 public ModuleType getType() {
092 return type;
093 }
094
095 public void setType(ModuleType type) {
096 this.type = type;
097 }
098
099 public String toString() {
100 return "[" + target + ", " + moduleID + "]";
101 }
102
103 public boolean equals(Object o) {
104 if (this == o) return true;
105 if (!(o instanceof TargetModuleIDImpl)) return false;
106
107 final TargetModuleIDImpl targetModuleID = (TargetModuleIDImpl) o;
108
109 if (!moduleID.equals(targetModuleID.moduleID)) return false;
110 if (!target.equals(targetModuleID.target)) return false;
111
112 return true;
113 }
114
115 public int hashCode() {
116 int result;
117 result = target.hashCode();
118 result = 29 * result + moduleID.hashCode();
119 return result;
120 }
121 }