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.geronimo.system.plugin;
021:
022: import java.io.IOException;
023: import java.util.Map;
024:
025: import org.apache.geronimo.kernel.repository.ArtifactManager;
026: import org.apache.geronimo.kernel.repository.ListableRepository;
027: import org.apache.geronimo.system.configuration.LocalPluginAttributeStore;
028: import org.apache.geronimo.system.resolver.LocalAliasedArtifactResolver;
029: import org.apache.geronimo.system.serverinfo.ServerInfo;
030: import org.apache.geronimo.gbean.GBeanInfo;
031: import org.apache.geronimo.gbean.GBeanInfoBuilder;
032:
033: /**
034: * @version $Rev: 613462 $ $Date: 2008-01-19 13:46:39 -0800 (Sat, 19 Jan 2008) $
035: */
036: public class ReferenceServerInstanceData extends ServerInstanceData {
037:
038: private final LocalPluginAttributeStore attributeStore;
039: private final LocalAliasedArtifactResolver artifactResolver;
040:
041: public ReferenceServerInstanceData() {
042: attributeStore = null;
043: artifactResolver = null;
044: }
045:
046: public ReferenceServerInstanceData(
047: LocalPluginAttributeStore attributeStore,
048: LocalAliasedArtifactResolver artifactResolver) {
049: this .attributeStore = attributeStore;
050: this .artifactResolver = artifactResolver;
051: }
052:
053: @Override
054: public String getConfigFile() {
055: return attributeStore.getConfigFile();
056: }
057:
058: @Override
059: public String getConfigSubstitutionsFile() {
060: return attributeStore.getConfigSubstitutionsFile();
061: }
062:
063: @Override
064: public String getConfigSubstitutionsPrefix() {
065: return attributeStore.getConfigSubstitutionsPrefix();
066: }
067:
068: @Override
069: public String getArtifactAliasesFile() {
070: return artifactResolver.getArtifactAliasesFile();
071: }
072:
073: @Override
074: public ServerInstance getServerInstance(
075: ArtifactManager artifactManager,
076: ListableRepository targetRepo, ServerInfo serverInfo,
077: Map<String, ServerInstance> serverInstances, boolean live)
078: throws IOException {
079: if (live) {
080: return new ServerInstance(getName(), attributeStore,
081: artifactResolver);
082: } else {
083: return super .getServerInstance(artifactManager, targetRepo,
084: serverInfo, serverInstances, live);
085: }
086: }
087:
088: @Override
089: public String toString() {
090: StringBuffer buf = new StringBuffer();
091: buf.append("ReferenceServerInstanceData:\n");
092: buf.append(" Name: ").append(getName()).append("\n");
093: buf.append(" ConfigFile: ").append(getConfigFile()).append(
094: "\n");
095: buf.append(" ConfigSubstitutionsFile: ").append(
096: getConfigSubstitutionsFile()).append("\n");
097: buf.append(" ConfigSubstitutionsPrefix: ").append(
098: getConfigSubstitutionsPrefix()).append("\n");
099: buf.append(" ArtifactAliasesFile: ").append(
100: getArtifactAliasesFile()).append("\n");
101: return buf.toString();
102: }
103:
104: public static final GBeanInfo GBEAN_INFO;
105:
106: static {
107: GBeanInfoBuilder infoFactory = GBeanInfoBuilder
108: .createStatic(ReferenceServerInstanceData.class,
109: "ServerInstanceData");
110: infoFactory.addAttribute("name", String.class, true, true);
111: infoFactory.addReference("AttributeStore",
112: LocalPluginAttributeStore.class, "AttributeStore");
113: infoFactory.addReference("ArtifactResolver",
114: LocalAliasedArtifactResolver.class, "ArtifactResolver");
115:
116: infoFactory.setConstructor(new String[] { "AttributeStore",
117: "ArtifactResolver" });
118:
119: GBEAN_INFO = infoFactory.getBeanInfo();
120: }
121:
122: public static GBeanInfo getGBeanInfo() {
123: return GBEAN_INFO;
124: }
125: }
|