You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by gd...@apache.org on 2007/02/17 09:01:31 UTC
svn commit: r508724 [3/3] - in /geronimo/server/trunk:
applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/util/
assemblies/geronimo-boilerplate-minimal/
assemblies/geronimo-boilerplate-minimal/src/main/resources/va...
Added: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/CopyArtifactTypeHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/CopyArtifactTypeHandler.java?view=auto&rev=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/CopyArtifactTypeHandler.java (added)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/CopyArtifactTypeHandler.java Sat Feb 17 00:01:26 2007
@@ -0,0 +1,89 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.kernel.repository;
+
+import java.io.InputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.BufferedOutputStream;
+import java.io.FileOutputStream;
+import java.io.BufferedInputStream;
+
+import org.apache.geronimo.kernel.repository.ArtifactTypeHandler;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.FileWriteMonitor;
+
+/**
+ * @version $Rev: 476049 $ $Date: 2006-11-17 15:35:17 +1100 (Fri, 17 Nov 2006) $
+ */
+public class CopyArtifactTypeHandler implements ArtifactTypeHandler {
+ private final static int TRANSFER_NOTIFICATION_SIZE = 10240; // announce every this many bytes
+ private final static int TRANSFER_BUF_SIZE = 10240; // try this many bytes at a time
+
+ public void install(InputStream source, int size, Artifact artifact, FileWriteMonitor monitor, File target) throws IOException {
+ // assure that the target directory exists
+ File parent = target.getParentFile();
+ if (!parent.exists() && !parent.mkdirs()) {
+ throw new RuntimeException("Unable to create directory " + parent.getAbsolutePath());
+ }
+
+ // copy it
+ if (monitor != null) {
+ monitor.writeStarted(artifact.toString(), size);
+ }
+ int total = 0;
+ BufferedOutputStream out = null;
+ BufferedInputStream in = null;
+ try {
+ int threshold = TRANSFER_NOTIFICATION_SIZE;
+ out = new BufferedOutputStream(new FileOutputStream(target));
+ in = new BufferedInputStream(source);
+ byte[] buf = new byte[TRANSFER_BUF_SIZE];
+ int count;
+ while ((count = in.read(buf)) > -1) {
+ out.write(buf, 0, count);
+ if (monitor != null) {
+ total += count;
+ if (total > threshold) {
+ threshold += TRANSFER_NOTIFICATION_SIZE;
+ monitor.writeProgress(total);
+ }
+ }
+ }
+ out.close(); // also flushes the stream
+ out = null;
+ in.close();
+ in = null;
+ } finally {
+ if (out != null) {
+ try {
+ out.close();
+ } catch (IOException ignored) {
+ }
+ }
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException ignored) {
+ }
+ }
+ if (monitor != null) {
+ monitor.writeComplete(total);
+ }
+ }
+ }
+}
Added: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/Maven1Repository.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/Maven1Repository.java?view=auto&rev=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/Maven1Repository.java (added)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/Maven1Repository.java Sat Feb 17 00:01:26 2007
@@ -0,0 +1,150 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.kernel.repository;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @version $Rev: 476049 $ $Date: 2006-11-17 15:35:17 +1100 (Fri, 17 Nov 2006) $
+ */
+public class Maven1Repository extends AbstractRepository implements WritableListableRepository {
+
+ public Maven1Repository(File rootFile) {
+ super(rootFile);
+ }
+
+ public File getLocation(Artifact artifact) {
+ File path = new File(rootFile, artifact.getGroupId());
+ path = new File(path, artifact.getType() + "s");
+ String ext = artifact.getType();
+ if(ext.equals("ejb")) {
+ ext = "jar";
+ }
+ path = new File(path, artifact.getArtifactId() + "-" + artifact.getVersion() + "." + ext);
+
+ return path;
+ }
+
+ public SortedSet list(Artifact query) {
+ SortedSet artifacts = new TreeSet();
+ if(query.getGroupId() != null && query.getArtifactId() != null && query.getType() != null) {
+
+ File path = new File(rootFile, query.getGroupId());
+ path = new File(path, query.getType() + "s");
+
+ File[] files = path.listFiles();
+ if (files != null) {
+ for (int i = 0; i < files.length; i++) {
+ File file = files[i];
+ String fileName = file.getName();
+ if (fileName.startsWith(query.getArtifactId() + "-") && fileName.endsWith("." + query.getType())) {
+ String version = fileName.substring(query.getArtifactId().length() + 1);
+ version = version.substring(0, version.length() - 1 - query.getType().length());
+ if(query.getVersion() != null && !query.getVersion().toString().equals(version)) {
+ continue;
+ }
+ artifacts.add(new Artifact(query.getGroupId(), query.getArtifactId(), version, query.getType()));
+ }
+ }
+ }
+ } else {
+ // todo: not very efficient
+ SortedSet set = list();
+ String targetGroup = query.getGroupId();
+ String targetArtifact = query.getArtifactId();
+ Version targetVersion = query.getVersion();
+ String targetType = query.getType();
+ for (Iterator it = set.iterator(); it.hasNext();) {
+ Artifact candidate = (Artifact) it.next();
+ if(targetGroup != null && !targetGroup.equals(candidate.getGroupId())) {
+ continue;
+ }
+ if(targetArtifact != null && !targetArtifact.equals(candidate.getArtifactId())) {
+ continue;
+ }
+ if(targetType != null && !targetType.equals(candidate.getType())) {
+ continue;
+ }
+ if(targetVersion != null && !targetVersion.equals(candidate.getVersion())) {
+ continue;
+ }
+ artifacts.add(candidate);
+ }
+ }
+ return artifacts;
+ }
+
+ //thanks to Brett Porter for this regex lifted from a maven1-2 porting tool
+ private static final Pattern MAVEN_1_PATTERN = Pattern.compile("(.+)/(.+)s/(.+)-([0-9].+)\\.([^0-9]+)");
+
+ public SortedSet list() {
+ SortedSet artifacts = new TreeSet();
+ String[] names = getFiles(rootFile, "");
+ Matcher matcher = MAVEN_1_PATTERN.matcher("");
+ for (int i = 0; i < names.length; i++) {
+ matcher.reset(names[i]);
+ if (matcher.matches()) {
+ String groupId = matcher.group(1);
+ String artifactId = matcher.group(3);
+ String version = matcher.group(4);
+ String type = matcher.group(2);
+ if(groupId.indexOf('/') > -1 || artifactId.indexOf('/') > -1 || type.indexOf('/') > -1 ||
+ version.indexOf('/') > -1) {
+ log.warn("could not resolve URI for malformed repository entry: " + names[i] +
+ " - the filename should look like: <groupId>/<type>s/<artifactId>-<version>.<type> "+
+ "Perhaps you put in a file without a version number in the name?");
+ } else {
+ artifacts.add(new Artifact(groupId, artifactId, version, type));
+ }
+ } else {
+ log.warn("could not resolve URI for malformed repository entry: " + names[i] +
+ " - the filename should look like: <groupId>/<type>s/<artifactId>-<version>.<type> "+
+ "Perhaps you put in a file without a version number in the name?");
+ }
+
+ }
+ return artifacts;
+ }
+
+ public String[] getFiles(File base, String prefix) {
+ if (!base.canRead() || !base.isDirectory()) {
+ throw new IllegalArgumentException(base.getAbsolutePath());
+ }
+ List list = new ArrayList();
+ File[] hits = base.listFiles();
+ for (int i = 0; i < hits.length; i++) {
+ File hit = hits[i];
+ if (hit.canRead()) {
+ if (hit.isDirectory()) {
+ list.addAll(Arrays.asList(getFiles(hit, prefix.equals("") ? hit.getName() : prefix + "/" + hit.getName())));
+ } else {
+ list.add(prefix.equals("") ? hit.getName() : prefix + "/" + hit.getName());
+ }
+ }
+ }
+ return (String[]) list.toArray(new String[list.size()]);
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/Maven2Repository.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/Maven2Repository.java?view=auto&rev=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/Maven2Repository.java (added)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/Maven2Repository.java Sat Feb 17 00:01:26 2007
@@ -0,0 +1,190 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.kernel.repository;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+/**
+ * @version $Rev: 476049 $ $Date: 2006-11-17 15:35:17 +1100 (Fri, 17 Nov 2006) $
+ */
+public class Maven2Repository extends AbstractRepository implements WritableListableRepository {
+
+ public Maven2Repository(File rootFile) {
+ super(rootFile);
+ }
+
+ public File getLocation(Artifact artifact) {
+ if(!artifact.isResolved()) {
+ throw new IllegalArgumentException("Artifact "+artifact+" is not fully resolved");
+ }
+ File path = new File(rootFile, artifact.getGroupId().replace('.', File.separatorChar));
+ path = new File(path, artifact.getArtifactId());
+ path = new File(path, artifact.getVersion().toString());
+ path = new File(path, artifact.getArtifactId() + "-" + artifact.getVersion() + "." + artifact.getType());
+
+ return path;
+ }
+
+ public SortedSet list() {
+ return listInternal(null, null, null);
+ }
+
+ public SortedSet list(Artifact query) {
+ if(query.getGroupId() != null) { // todo: see if more logic can be shared with the other case
+ File path = new File(rootFile, query.getGroupId().replace('.', File.separatorChar));
+ path = new File(path, query.getArtifactId());
+ if(!path.canRead() || !path.isDirectory()) {
+ return new TreeSet();
+ }
+
+ SortedSet artifacts = new TreeSet();
+
+ File[] versionDirs = path.listFiles();
+ for (int i = 0; i < versionDirs.length; i++) {
+ File versionDir = versionDirs[i];
+ if (versionDir.canRead() && versionDir.isDirectory()) {
+ String version = versionDir.getName();
+ if(query.getVersion() != null && !query.getVersion().toString().equals(version)) {
+ continue;
+ }
+ // Assumes that artifactId is set
+ final String filePrefix = query.getArtifactId() + "-" + version + ".";
+ File[] list = versionDir.listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return name.startsWith(filePrefix);
+ }
+ });
+ for (int j = 0; j < list.length; j++) {
+ File file = list[j];
+ String end = file.getName().substring(filePrefix.length());
+ if(query.getType() != null && !query.getType().equals(end)) {
+ continue;
+ }
+ if(end.indexOf('.') < 0) {
+ artifacts.add(new Artifact(query.getGroupId(), query.getArtifactId(), version, end));
+ }
+ }
+ }
+ }
+ return artifacts;
+ } else {
+ return listInternal(query.getArtifactId(), query.getType(), query.getVersion() == null ? null : query.getVersion().toString());
+ }
+ }
+
+ private SortedSet listInternal(String artifactMatch, String typeMatch, String versionMatch) {
+ SortedSet artifacts = new TreeSet();
+ File[] groupIds = rootFile.listFiles();
+ for (int i = 0; i < groupIds.length; i++) {
+ File groupId = groupIds[i];
+ if (groupId.canRead() && groupId.isDirectory()) {
+ File[] versionDirs = groupId.listFiles();
+ for (int j = 0; j < versionDirs.length; j++) {
+ File versionDir = versionDirs[j];
+ if (versionDir.canRead() && versionDir.isDirectory()) {
+ artifacts.addAll(getArtifacts(null, versionDir, artifactMatch, typeMatch, versionMatch));
+ }
+ }
+ }
+ }
+ return artifacts;
+ }
+
+ private List getArtifacts(String groupId, File versionDir, String artifactMatch, String typeMatch, String versionMatch) {
+ // org/apache/xbean/xbean-classpath/2.2-SNAPSHOT/xbean-classpath-2.2-SNAPSHOT.jar
+ List artifacts = new ArrayList();
+ String artifactId = versionDir.getParentFile().getName();
+
+ File[] files = versionDir.listFiles();
+ for (int i = 0; i < files.length; i++) {
+ File file = files[i];
+ if (file.canRead()) {
+ if (file.isDirectory()) {
+ File test = new File(file, "META-INF");
+ if(test.exists() && test.isDirectory() && test.canRead() && groupId != null) {
+ String version = versionDir.getName();
+ String fileHeader = artifactId + "-" + version + ".";
+
+ String fileName = file.getName();
+ if (fileName.startsWith(fileHeader)) {
+ // type is everything after the file header
+ String type = fileName.substring(fileHeader.length());
+
+ if (!type.endsWith(".sha1") && !type.endsWith(".md5")) {
+ if(artifactMatch != null && !artifactMatch.equals(artifactId)) {
+ continue;
+ }
+ if(typeMatch != null && !typeMatch.equals(type)) {
+ continue;
+ }
+ if(versionMatch != null && !versionMatch.equals(version)) {
+ continue;
+ }
+ artifacts.add(new Artifact(groupId,
+ artifactId,
+ version,
+ type));
+ }
+ }
+ } else { // this is just part of the path to the artifact
+ String nextGroupId;
+ if (groupId == null) {
+ nextGroupId = artifactId;
+ } else {
+ nextGroupId = groupId + "." + artifactId;
+ }
+
+ artifacts.addAll(getArtifacts(nextGroupId, file, artifactMatch, typeMatch, versionMatch));
+ }
+ } else if (groupId != null) {
+ String version = versionDir.getName();
+ String fileHeader = artifactId + "-" + version + ".";
+
+ String fileName = file.getName();
+ if (fileName.startsWith(fileHeader)) {
+ // type is everything after the file header
+ String type = fileName.substring(fileHeader.length());
+
+ if (!type.endsWith(".sha1") && !type.endsWith(".md5")) {
+ if(artifactMatch != null && !artifactMatch.equals(artifactId)) {
+ continue;
+ }
+ if(typeMatch != null && !typeMatch.equals(type)) {
+ continue;
+ }
+ if(versionMatch != null && !versionMatch.equals(version)) {
+ continue;
+ }
+ artifacts.add(new Artifact(groupId,
+ artifactId,
+ version,
+ type
+ ));
+ }
+ }
+ }
+ }
+ }
+ return artifacts;
+ }
+
+}
Added: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/UnpackArtifactTypeHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/UnpackArtifactTypeHandler.java?view=auto&rev=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/UnpackArtifactTypeHandler.java (added)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/UnpackArtifactTypeHandler.java Sat Feb 17 00:01:26 2007
@@ -0,0 +1,96 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.kernel.repository;
+
+import java.io.InputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipEntry;
+
+import org.apache.geronimo.kernel.repository.ArtifactTypeHandler;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.FileWriteMonitor;
+import org.apache.geronimo.kernel.config.IOUtil;
+
+/**
+ * @version $Rev: 476049 $ $Date: 2006-11-17 15:35:17 +1100 (Fri, 17 Nov 2006) $
+ */
+public class UnpackArtifactTypeHandler implements ArtifactTypeHandler {
+ private final static int TRANSFER_NOTIFICATION_SIZE = 10240; // announce every this many bytes
+ private final static int TRANSFER_BUF_SIZE = 10240; // try this many bytes at a time
+
+ public void install(InputStream source, int size, Artifact artifact, FileWriteMonitor monitor, File target) throws IOException {
+ // assure that the target directory exists
+ File parent = target.getParentFile();
+ if (!parent.exists() && !parent.mkdirs()) {
+ throw new RuntimeException("Unable to create directory " + parent.getAbsolutePath());
+ }
+
+ // copy it
+ if (monitor != null) {
+ monitor.writeStarted(artifact.toString(), size);
+ }
+
+ int total = 0;
+ ZipInputStream in = new ZipInputStream(source);
+ try {
+
+ int threshold = UnpackArtifactTypeHandler.TRANSFER_NOTIFICATION_SIZE;
+ byte[] buffer = new byte[TRANSFER_BUF_SIZE];
+
+ for (ZipEntry entry = in.getNextEntry(); entry != null; entry = in.getNextEntry()) {
+ File file = new File(target, entry.getName());
+ if (entry.isDirectory()) {
+ file.mkdirs();
+ } else {
+ if (!entry.getName().equals("META-INF/startup-jar")) {
+ file.getParentFile().mkdirs();
+ OutputStream out = new FileOutputStream(file);
+ try {
+ int count;
+ while ((count = in.read(buffer)) > 0) {
+ out.write(buffer, 0, count);
+ if (monitor != null) {
+ total += count;
+ if (total > threshold) {
+ threshold += UnpackArtifactTypeHandler.TRANSFER_NOTIFICATION_SIZE;
+ monitor.writeProgress(total);
+ }
+ }
+ }
+ } finally {
+ IOUtil.flush(out);
+ out.close();
+ }
+ in.closeEntry();
+ }
+ }
+ }
+ } catch (IOException e) {
+ IOUtil.recursiveDelete(target);
+ throw e;
+ } finally {
+ in.close();
+ if (monitor != null) {
+ monitor.writeComplete(total);
+ }
+ }
+ }
+}
Copied: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/MainBootstrapper.java (from r503370, geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/MainBootstrapper.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/MainBootstrapper.java?view=diff&rev=508724&p1=geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/MainBootstrapper.java&r1=503370&p2=geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/MainBootstrapper.java&r2=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/MainBootstrapper.java (original)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/MainBootstrapper.java Sat Feb 17 00:01:26 2007
@@ -74,11 +74,11 @@
}
}
- protected void shutdown() {
+ public void shutdown() {
kernel.shutdown();
}
- protected void bootKernel() throws Exception {
+ public void bootKernel() throws Exception {
kernel = KernelFactory.newInstance().createKernel("MainBootstrapper");
kernel.boot();
@@ -89,10 +89,10 @@
});
}
- protected void loadBootConfiguration(ClassLoader classLoader) throws Exception {
+ public void loadBootConfiguration(ClassLoader classLoader) throws Exception {
InputStream in = classLoader.getResourceAsStream("META-INF/config.ser");
try {
- ConfigurationUtil.loadBootstrapConfiguration(kernel, in, classLoader);
+ ConfigurationUtil.loadBootstrapConfiguration(kernel, in, classLoader, true);
} finally {
if (in != null) {
try {
@@ -104,7 +104,7 @@
}
}
- protected void loadPersistentConfigurations() throws Exception {
+ public void loadPersistentConfigurations() throws Exception {
List<Artifact> configs = new ArrayList<Artifact>();
AbstractNameQuery query = new AbstractNameQuery(PersistentConfigurationList.class.getName());
@@ -125,8 +125,12 @@
}
}
- protected Main getMain() throws Exception {
+ public Main getMain() throws Exception {
return (Main) kernel.getGBean(Main.class);
+ }
+
+ public Kernel getKernel() {
+ return kernel;
}
}
Added: geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/repository/AbstractRepositoryTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/repository/AbstractRepositoryTest.java?view=auto&rev=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/repository/AbstractRepositoryTest.java (added)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/repository/AbstractRepositoryTest.java Sat Feb 17 00:01:26 2007
@@ -0,0 +1,171 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.kernel.repository;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.Properties;
+import java.util.SortedSet;
+
+import junit.framework.TestCase;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.ListableRepository;
+import org.apache.geronimo.kernel.repository.Version;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @version $Rev: 476049 $ $Date: 2006-11-17 15:35:17 +1100 (Fri, 17 Nov 2006) $
+ */
+public class AbstractRepositoryTest extends TestCase {
+ private static final Log log = LogFactory.getLog(AbstractRepositoryTest.class);
+
+ protected ListableRepository repository;
+ protected File rootRepoDir;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ // Don't want .svn dirs messing up my count!
+ deleteSVN(rootRepoDir);
+ }
+
+ private void deleteSVN(File dir) {
+ if(!dir.isDirectory() || !dir.canRead()) {
+ throw new IllegalStateException("Invalid dir "+dir.getAbsolutePath());
+ }
+ File[] children = dir.listFiles();
+ for (int i = 0; i < children.length; i++) {
+ File child = children[i];
+ if(child.isDirectory()) {
+ if(child.getName().equals(".svn")) {
+ recursiveDelete(child);
+ } else {
+ deleteSVN(child);
+ }
+ }
+ }
+ }
+
+ private void recursiveDelete(File dir) {
+ if(!dir.isDirectory() || !dir.canRead()) {
+ throw new IllegalStateException("Invalid dir "+dir.getAbsolutePath());
+ }
+ File[] children = dir.listFiles();
+ for (int i = 0; i < children.length; i++) {
+ File child = children[i];
+ if(child.isDirectory()) {
+ recursiveDelete(child);
+ } else {
+ if(!child.delete()) {
+ throw new IllegalStateException("Cannot delete "+child.getAbsolutePath());
+ }
+ }
+ }
+ if(!dir.delete()) {
+ throw new IllegalStateException("Cannot delete "+dir.getAbsolutePath());
+ }
+ }
+
+ public void testListAll() {
+ SortedSet artifacts = repository.list();
+ log.debug("Matched artifacts: "+artifacts);
+
+ assertTrue(artifacts.contains(new Artifact("org.foo", "test", "2.0.1", "properties")));
+ assertFalse(artifacts.contains(new Artifact("Unknown", "artifact", "2.0.1", "properties")));
+ assertEquals(4, artifacts.size());
+ }
+
+ public void testListSpecifyArtifact() {
+ SortedSet artifacts = repository.list(new Artifact(null, "test", (Version)null, null));
+
+ assertTrue(artifacts.contains(new Artifact("org.bar", "test", "1.5", "properties")));
+ assertTrue(artifacts.contains(new Artifact("org.bar", "test", "1.3", "properties")));
+ assertTrue(artifacts.contains(new Artifact("org.foo", "test", "2.0.1", "properties")));
+ assertEquals(3, artifacts.size());
+ }
+
+ public void testListSpecifyArtifactGroup() {
+ SortedSet artifacts = repository.list(new Artifact("org.bar", "test", (Version)null, null));
+
+ assertTrue(artifacts.contains(new Artifact("org.bar", "test", "1.5", "properties")));
+ assertTrue(artifacts.contains(new Artifact("org.bar", "test", "1.3", "properties")));
+ assertEquals(2, artifacts.size());
+ }
+
+ public void testListSpecifyArtifactType() {
+ SortedSet artifacts = repository.list(new Artifact(null, "test", (Version)null, "properties"));
+
+ assertTrue(artifacts.contains(new Artifact("org.bar", "test", "1.5", "properties")));
+ assertTrue(artifacts.contains(new Artifact("org.bar", "test", "1.3", "properties")));
+ assertTrue(artifacts.contains(new Artifact("org.foo", "test", "2.0.1", "properties")));
+ assertEquals(3, artifacts.size());
+ }
+
+ public void testListSpecifyArtifactVersion() {
+ SortedSet artifacts = repository.list(new Artifact(null, "test", "1.5", null));
+
+ assertTrue(artifacts.contains(new Artifact("org.bar", "test", "1.5", "properties")));
+ assertEquals(1, artifacts.size());
+ }
+
+ public void testListSpecifyArtifactGroupType() {
+ SortedSet artifacts = repository.list(new Artifact("org.bar", "test", (Version)null, "properties"));
+
+ assertTrue(artifacts.contains(new Artifact("org.bar", "test", "1.5", "properties")));
+ assertTrue(artifacts.contains(new Artifact("org.bar", "test", "1.3", "properties")));
+ assertEquals(2, artifacts.size());
+ }
+
+ public void testListSpecifyArtifactGroupVersion() {
+ SortedSet artifacts = repository.list(new Artifact("org.bar", "test", "1.5", null));
+
+ assertTrue(artifacts.contains(new Artifact("org.bar", "test", "1.5", "properties")));
+ assertEquals(1, artifacts.size());
+ }
+
+ public void testListSpecifyArtifactVersionType() {
+ SortedSet artifacts = repository.list(new Artifact(null, "test", "1.5", "properties"));
+
+ assertTrue(artifacts.contains(new Artifact("org.bar", "test", "1.5", "properties")));
+ assertEquals(1, artifacts.size());
+ }
+
+ public void testListSpecifyAll() {
+ SortedSet artifacts = repository.list(new Artifact("org.bar", "test", "1.5", "properties"));
+
+ assertTrue(artifacts.contains(new Artifact("org.bar", "test", "1.5", "properties")));
+ assertEquals(1, artifacts.size());
+ }
+
+ public void testLocation() throws Exception {
+ Artifact artifact = new Artifact("org.foo", "test", "2.0.1", "properties");
+ assertTrue(repository.contains(artifact));
+
+ File location = repository.getLocation(artifact);
+ assertTrue(location.exists());
+ assertTrue(location.isFile());
+ assertTrue(location.canRead());
+
+ Properties properties = new Properties();
+ properties.load(new FileInputStream(location));
+ assertEquals(artifact.getGroupId(), properties.get("groupId"));
+ assertEquals(artifact.getArtifactId(), properties.get("artifactId"));
+ assertEquals(artifact.getVersion().toString(), properties.get("version"));
+ assertEquals(artifact.getType(), properties.get("type"));
+ }
+}
Added: geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/repository/Maven1RepositoryTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/repository/Maven1RepositoryTest.java?view=auto&rev=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/repository/Maven1RepositoryTest.java (added)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/repository/Maven1RepositoryTest.java Sat Feb 17 00:01:26 2007
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.kernel.repository;
+
+import java.io.File;
+
+/**
+ * @version $Rev: 476049 $ $Date: 2006-11-17 15:35:17 +1100 (Fri, 17 Nov 2006) $
+ */
+public class Maven1RepositoryTest extends AbstractRepositoryTest {
+ private File basedir = new File(System.getProperty("basedir"));
+
+ protected void setUp() throws Exception {
+ rootRepoDir = new File(basedir, "target/m1");
+ repository = new Maven1Repository(rootRepoDir);
+ super.setUp();
+ }
+}
Added: geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/repository/Maven2RepositoryTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/repository/Maven2RepositoryTest.java?view=auto&rev=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/repository/Maven2RepositoryTest.java (added)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/repository/Maven2RepositoryTest.java Sat Feb 17 00:01:26 2007
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.kernel.repository;
+
+import java.io.File;
+
+/**
+ * @version $Rev: 476049 $ $Date: 2006-11-17 15:35:17 +1100 (Fri, 17 Nov 2006) $
+ */
+public class Maven2RepositoryTest extends AbstractRepositoryTest {
+ private File basedir = new File(System.getProperty("basedir"));
+
+ protected void setUp() throws Exception {
+ rootRepoDir = new File(basedir, "target/m2");
+ repository = new Maven2Repository(rootRepoDir);
+ super.setUp();
+ }
+}
Added: geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m1/junk/propertiess/junk-1.5.properties
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m1/junk/propertiess/junk-1.5.properties?view=auto&rev=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m1/junk/propertiess/junk-1.5.properties (added)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m1/junk/propertiess/junk-1.5.properties Sat Feb 17 00:01:26 2007
@@ -0,0 +1,16 @@
+##
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
Added: geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m1/org.bar/propertiess/test-1.3.properties
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m1/org.bar/propertiess/test-1.3.properties?view=auto&rev=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m1/org.bar/propertiess/test-1.3.properties (added)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m1/org.bar/propertiess/test-1.3.properties Sat Feb 17 00:01:26 2007
@@ -0,0 +1,21 @@
+#=====================================================================
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#=====================================================================
+
+groupId=org.bar
+artifactId=test
+version=1.3
+type=properties
Added: geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m1/org.bar/propertiess/test-1.5.properties
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m1/org.bar/propertiess/test-1.5.properties?view=auto&rev=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m1/org.bar/propertiess/test-1.5.properties (added)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m1/org.bar/propertiess/test-1.5.properties Sat Feb 17 00:01:26 2007
@@ -0,0 +1,21 @@
+#=====================================================================
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#=====================================================================
+
+groupId=org.bar
+artifactId=test
+version=1.5
+type=properties
Added: geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m1/org.foo/propertiess/test-2.0.1.properties
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m1/org.foo/propertiess/test-2.0.1.properties?view=auto&rev=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m1/org.foo/propertiess/test-2.0.1.properties (added)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m1/org.foo/propertiess/test-2.0.1.properties Sat Feb 17 00:01:26 2007
@@ -0,0 +1,21 @@
+#=====================================================================
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#=====================================================================
+
+groupId=org.foo
+artifactId=test
+version=2.0.1
+type=properties
Added: geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m2/junk/junk/1.5/junk-1.5.properties
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m2/junk/junk/1.5/junk-1.5.properties?view=auto&rev=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m2/junk/junk/1.5/junk-1.5.properties (added)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m2/junk/junk/1.5/junk-1.5.properties Sat Feb 17 00:01:26 2007
@@ -0,0 +1,16 @@
+##
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
Added: geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m2/org/bar/test/1.3/test-1.3.properties
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m2/org/bar/test/1.3/test-1.3.properties?view=auto&rev=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m2/org/bar/test/1.3/test-1.3.properties (added)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m2/org/bar/test/1.3/test-1.3.properties Sat Feb 17 00:01:26 2007
@@ -0,0 +1,21 @@
+#=====================================================================
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#=====================================================================
+
+groupId=org.bar
+artifactId=test
+version=1.3
+type=properties
Added: geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m2/org/bar/test/1.5/test-1.5.properties
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m2/org/bar/test/1.5/test-1.5.properties?view=auto&rev=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m2/org/bar/test/1.5/test-1.5.properties (added)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m2/org/bar/test/1.5/test-1.5.properties Sat Feb 17 00:01:26 2007
@@ -0,0 +1,21 @@
+#=====================================================================
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#=====================================================================
+
+groupId=org.bar
+artifactId=test
+version=1.5
+type=properties
Added: geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m2/org/foo/test/2.0.1/test-2.0.1.properties
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m2/org/foo/test/2.0.1/test-2.0.1.properties?view=auto&rev=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m2/org/foo/test/2.0.1/test-2.0.1.properties (added)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/test/repo/m2/org/foo/test/2.0.1/test-2.0.1.properties Sat Feb 17 00:01:26 2007
@@ -0,0 +1,21 @@
+#=====================================================================
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#=====================================================================
+
+groupId=org.foo
+artifactId=test
+version=2.0.1
+type=properties
Modified: geronimo/server/trunk/modules/geronimo-system/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-system/pom.xml?view=diff&rev=508724&r1=508723&r2=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-system/pom.xml (original)
+++ geronimo/server/trunk/modules/geronimo-system/pom.xml Sat Feb 17 00:01:26 2007
@@ -100,30 +100,6 @@
</tasks>
</configuration>
</execution>
-
- <execution>
- <id>test-resources</id>
- <phase>generate-test-resources</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <tasks>
- <delete dir="${project.build.directory}/tmp"/>
- <mkdir dir="${project.build.directory}/tmp"/>
-
- <mkdir dir="${project.build.directory}/m1"/>
- <copy todir="${project.build.directory}/m1">
- <fileset dir="${basedir}/src/test/repo/m1"/>
- </copy>
-
- <mkdir dir="${project.build.directory}/m2"/>
- <copy todir="${project.build.directory}/m2">
- <fileset dir="${basedir}/src/test/repo/m2"/>
- </copy>
- </tasks>
- </configuration>
- </execution>
</executions>
<dependencies>
Modified: geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/repository/AbstractRepository.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/repository/AbstractRepository.java?view=diff&rev=508724&r1=508723&r2=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/repository/AbstractRepository.java (original)
+++ geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/repository/AbstractRepository.java Sat Feb 17 00:01:26 2007
@@ -17,229 +17,24 @@
package org.apache.geronimo.system.repository;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Enumeration;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipException;
-import java.util.zip.ZipFile;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.kernel.repository.ArtifactTypeHandler;
-import org.apache.geronimo.kernel.repository.FileWriteMonitor;
-import org.apache.geronimo.kernel.repository.WriteableRepository;
-import org.apache.geronimo.kernel.util.XmlUtil;
import org.apache.geronimo.system.serverinfo.ServerInfo;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
/**
* @version $Rev$ $Date$
*/
-public abstract class AbstractRepository implements WriteableRepository {
+public abstract class AbstractRepository extends org.apache.geronimo.kernel.repository.AbstractRepository {
protected static final Log log = LogFactory.getLog(AbstractRepository.class);
- private final static ArtifactTypeHandler DEFAULT_TYPE_HANDLER = new CopyArtifactTypeHandler();
- protected final File rootFile;
- private final Map typeHandlers = new HashMap();
public AbstractRepository(URI root, ServerInfo serverInfo, boolean resolveToServer) {
- this(resolveRoot(root, serverInfo, resolveToServer));
+ super(new ServerInfoRootResolver(serverInfo, resolveToServer).resolve(root));
}
-
+
public AbstractRepository(File rootFile) {
- if (rootFile == null) throw new NullPointerException("root is null");
-
- if (!rootFile.exists() || !rootFile.isDirectory() || !rootFile.canRead()) {
- throw new IllegalStateException("Maven2Repository must have a root that's a valid readable directory (not " + rootFile.getAbsolutePath() + ")");
- }
-
- this.rootFile = rootFile;
- log.debug("Repository root is " + rootFile.getAbsolutePath());
-
- typeHandlers.put("car", new UnpackArtifactTypeHandler());
- }
-
- private static File resolveRoot(URI root, ServerInfo serverInfo, boolean resolveToServer) {
- if (root == null) throw new NullPointerException("root is null");
-
- if (!root.toString().endsWith("/")) {
- try {
- root = new URI(root.toString() + "/");
- } catch (URISyntaxException e) {
- throw new RuntimeException("Invalid repository root (does not end with / ) and can't add myself", e);
- }
- }
-
- URI resolvedUri;
- if (serverInfo != null) {
- resolvedUri = resolveToServer ? serverInfo.resolveServer(root) : serverInfo.resolve(root);
- } else {
- resolvedUri = root;
- }
-
- if (!resolvedUri.getScheme().equals("file")) {
- throw new IllegalStateException("FileSystemRepository must have a root that's a local directory (not " + resolvedUri + ")");
- }
-
- File rootFile = new File(resolvedUri);
- return rootFile;
- }
-
- public boolean contains(Artifact artifact) {
- // Note: getLocation(artifact) does an artifact.isResolved() check - no need to do it here.
- File location = getLocation(artifact);
- return location.canRead() && (location.isFile() || new File(location, "META-INF").isDirectory());
+ super(rootFile);
}
- private static final String NAMESPACE = "http://geronimo.apache.org/xml/ns/deployment-1.2";
- public LinkedHashSet getDependencies(Artifact artifact) {
- if(!artifact.isResolved()) {
- throw new IllegalArgumentException("Artifact "+artifact+" is not fully resolved");
- }
- LinkedHashSet dependencies = new LinkedHashSet();
- URL url;
- try {
- File location = getLocation(artifact);
- url = location.toURL();
- } catch (MalformedURLException e) {
- throw (IllegalStateException)new IllegalStateException("Unable to get URL for dependency " + artifact).initCause(e);
- }
- ClassLoader depCL = new URLClassLoader(new URL[]{url}, new ClassLoader() {
- @Override
- public URL getResource(String name) {
- return null;
- }
- });
- InputStream is = depCL.getResourceAsStream("META-INF/geronimo-dependency.xml");
- try {
- if (is != null) {
- InputSource in = new InputSource(is);
- DocumentBuilderFactory dfactory = XmlUtil.newDocumentBuilderFactory();
- dfactory.setNamespaceAware(true);
- try {
- Document doc = dfactory.newDocumentBuilder().parse(in);
- Element root = doc.getDocumentElement();
- NodeList configs = root.getElementsByTagNameNS(NAMESPACE, "dependency");
- for (int i = 0; i < configs.getLength(); i++) {
- Element dependencyElement = (Element) configs.item(i);
- String groupId = getString(dependencyElement, "groupId");
- String artifactId = getString(dependencyElement, "artifactId");
- String version = getString(dependencyElement, "version");
- String type = getString(dependencyElement, "type");
- if (type == null) {
- type = "jar";
- }
- dependencies.add(new Artifact(groupId, artifactId, version, type));
- }
- } catch (IOException e) {
- throw (IllegalStateException)new IllegalStateException("Unable to parse geronimo-dependency.xml file in " + url).initCause(e);
- } catch (ParserConfigurationException e) {
- throw (IllegalStateException)new IllegalStateException("Unable to parse geronimo-dependency.xml file in " + url).initCause(e);
- } catch (SAXException e) {
- throw (IllegalStateException)new IllegalStateException("Unable to parse geronimo-dependency.xml file in " + url).initCause(e);
- }
- }
- } finally {
- if (is != null) {
- try {
- is.close();
- } catch (IOException ignore) {
- // ignore
- }
- }
- }
- return dependencies;
- }
-
- private String getString(Element dependencyElement, String childName) {
- NodeList children = dependencyElement.getElementsByTagNameNS(NAMESPACE, childName);
- if (children == null || children.getLength() == 0) {
- return null;
- }
- String value = "";
- NodeList text = children.item(0).getChildNodes();
- for (int t = 0; t < text.getLength(); t++) {
- Node n = text.item(t);
- if (n.getNodeType() == Node.TEXT_NODE) {
- value += n.getNodeValue();
- }
- }
- return value.trim();
- }
-
- public void setTypeHandler(String type, ArtifactTypeHandler handler) {
- typeHandlers.put(type, handler);
- }
-
- public void copyToRepository(File source, Artifact destination, FileWriteMonitor monitor) throws IOException {
- if(!destination.isResolved()) {
- throw new IllegalArgumentException("Artifact "+destination+" is not fully resolved");
- }
- if (!source.exists() || !source.canRead() || source.isDirectory()) {
- throw new IllegalArgumentException("Cannot read source file at " + source.getAbsolutePath());
- }
- int size = 0;
- try {
- ZipFile zip = new ZipFile(source);
- for (Enumeration entries=zip.entries(); entries.hasMoreElements();) {
- ZipEntry entry = (ZipEntry)entries.nextElement();
- size += entry.getSize();
- }
- } catch (ZipException ze) {
- size = (int)source.length();
- }
- FileInputStream is = new FileInputStream(source);
- try {
- copyToRepository(is, size, destination, monitor);
- } finally {
- try {
- is.close();
- } catch (IOException ignored) {
- // ignored
- }
- }
- }
-
- public void copyToRepository(InputStream source, int size, Artifact destination, FileWriteMonitor monitor) throws IOException {
- if(!destination.isResolved()) {
- throw new IllegalArgumentException("Artifact "+destination+" is not fully resolved");
- }
- // is this a writable repository
- if (!rootFile.canWrite()) {
- throw new IllegalStateException("This repository is not writable: " + rootFile.getAbsolutePath() + ")");
- }
-
- // where are we going to install the file
- File location = getLocation(destination);
-
- // assure that there isn't already a file installed at the specified location
- if (location.exists()) {
- throw new IllegalArgumentException("Destination " + location.getAbsolutePath() + " already exists!");
- }
-
- ArtifactTypeHandler typeHandler = (ArtifactTypeHandler) typeHandlers.get(destination.getType());
- if (typeHandler == null) typeHandler = DEFAULT_TYPE_HANDLER;
- typeHandler.install(source, size, destination, monitor, location);
-
- if (destination.getType().equalsIgnoreCase("car")) {
- log.debug("Installed module configuration; id=" + destination + "; location=" + location);
- }
- }
}
Modified: geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/repository/Maven1Repository.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/repository/Maven1Repository.java?view=diff&rev=508724&r1=508723&r2=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/repository/Maven1Repository.java (original)
+++ geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/repository/Maven1Repository.java Sat Feb 17 00:01:26 2007
@@ -18,161 +18,33 @@
import java.io.File;
import java.net.URI;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import java.util.Iterator;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.kernel.repository.WritableListableRepository;
-import org.apache.geronimo.kernel.repository.Version;
import org.apache.geronimo.system.serverinfo.ServerInfo;
/**
* @version $Rev$ $Date$
*/
-public class Maven1Repository extends AbstractRepository implements WritableListableRepository {
+public class Maven1Repository extends org.apache.geronimo.kernel.repository.Maven1Repository {
+
public Maven1Repository(URI root, ServerInfo serverInfo, boolean resolveToServer) {
- super(root, serverInfo, resolveToServer);
+ super(new ServerInfoRootResolver(serverInfo, resolveToServer).resolve(root));
}
public Maven1Repository(File rootFile) {
super(rootFile);
}
- public File getLocation(Artifact artifact) {
- File path = new File(rootFile, artifact.getGroupId());
- path = new File(path, artifact.getType() + "s");
- String ext = artifact.getType();
- if(ext.equals("ejb")) {
- ext = "jar";
- }
- path = new File(path, artifact.getArtifactId() + "-" + artifact.getVersion() + "." + ext);
-
- return path;
- }
-
- public SortedSet list(Artifact query) {
- SortedSet artifacts = new TreeSet();
- if(query.getGroupId() != null && query.getArtifactId() != null && query.getType() != null) {
-
- File path = new File(rootFile, query.getGroupId());
- path = new File(path, query.getType() + "s");
-
- File[] files = path.listFiles();
- if (files != null) {
- for (int i = 0; i < files.length; i++) {
- File file = files[i];
- String fileName = file.getName();
- if (fileName.startsWith(query.getArtifactId() + "-") && fileName.endsWith("." + query.getType())) {
- String version = fileName.substring(query.getArtifactId().length() + 1);
- version = version.substring(0, version.length() - 1 - query.getType().length());
- if(query.getVersion() != null && !query.getVersion().toString().equals(version)) {
- continue;
- }
- artifacts.add(new Artifact(query.getGroupId(), query.getArtifactId(), version, query.getType()));
- }
- }
- }
- } else {
- // todo: not very efficient
- SortedSet set = list();
- String targetGroup = query.getGroupId();
- String targetArtifact = query.getArtifactId();
- Version targetVersion = query.getVersion();
- String targetType = query.getType();
- for (Iterator it = set.iterator(); it.hasNext();) {
- Artifact candidate = (Artifact) it.next();
- if(targetGroup != null && !targetGroup.equals(candidate.getGroupId())) {
- continue;
- }
- if(targetArtifact != null && !targetArtifact.equals(candidate.getArtifactId())) {
- continue;
- }
- if(targetType != null && !targetType.equals(candidate.getType())) {
- continue;
- }
- if(targetVersion != null && !targetVersion.equals(candidate.getVersion())) {
- continue;
- }
- artifacts.add(candidate);
- }
- }
- return artifacts;
- }
-
- //thanks to Brett Porter for this regex lifted from a maven1-2 porting tool
- private static final Pattern MAVEN_1_PATTERN = Pattern.compile("(.+)/(.+)s/(.+)-([0-9].+)\\.([^0-9]+)");
-
- public SortedSet list() {
- SortedSet artifacts = new TreeSet();
- String[] names = getFiles(rootFile, "");
- Matcher matcher = MAVEN_1_PATTERN.matcher("");
- for (int i = 0; i < names.length; i++) {
- matcher.reset(names[i]);
- if (matcher.matches()) {
- String groupId = matcher.group(1);
- String artifactId = matcher.group(3);
- String version = matcher.group(4);
- String type = matcher.group(2);
- if(groupId.indexOf('/') > -1 || artifactId.indexOf('/') > -1 || type.indexOf('/') > -1 ||
- version.indexOf('/') > -1) {
- log.warn("could not resolve URI for malformed repository entry: " + names[i] +
- " - the filename should look like: <groupId>/<type>s/<artifactId>-<version>.<type> "+
- "Perhaps you put in a file without a version number in the name?");
- } else {
- artifacts.add(new Artifact(groupId, artifactId, version, type));
- }
- } else {
- log.warn("could not resolve URI for malformed repository entry: " + names[i] +
- " - the filename should look like: <groupId>/<type>s/<artifactId>-<version>.<type> "+
- "Perhaps you put in a file without a version number in the name?");
- }
-
- }
- return artifacts;
- }
-
- public String[] getFiles(File base, String prefix) {
- if (!base.canRead() || !base.isDirectory()) {
- throw new IllegalArgumentException(base.getAbsolutePath());
- }
- List list = new ArrayList();
- File[] hits = base.listFiles();
- for (int i = 0; i < hits.length; i++) {
- File hit = hits[i];
- if (hit.canRead()) {
- if (hit.isDirectory()) {
- list.addAll(Arrays.asList(getFiles(hit, prefix.equals("") ? hit.getName() : prefix + "/" + hit.getName())));
- } else {
- list.add(prefix.equals("") ? hit.getName() : prefix + "/" + hit.getName());
- }
- }
- }
- return (String[]) list.toArray(new String[list.size()]);
- }
-
public static final GBeanInfo GBEAN_INFO;
static {
GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(Maven1Repository.class, "Repository");
-
infoFactory.addAttribute("root", URI.class, true);
-
infoFactory.addReference("ServerInfo", ServerInfo.class, "GBean");
-
infoFactory.addAttribute("resolveToServer", Boolean.TYPE, true);
-
infoFactory.addInterface(Maven1Repository.class);
-
infoFactory.setConstructor(new String[]{"root", "ServerInfo", "resolveToServer"});
-
GBEAN_INFO = infoFactory.getBeanInfo();
}
Modified: geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/repository/Maven2Repository.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/repository/Maven2Repository.java?view=diff&rev=508724&r1=508723&r2=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/repository/Maven2Repository.java (original)
+++ geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/repository/Maven2Repository.java Sat Feb 17 00:01:26 2007
@@ -17,28 +17,22 @@
package org.apache.geronimo.system.repository;
import java.io.File;
-import java.io.FilenameFilter;
import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.kernel.repository.WritableListableRepository;
import org.apache.geronimo.system.serverinfo.ServerInfo;
/**
* @version $Rev$ $Date$
*/
-public class Maven2Repository extends AbstractRepository implements WritableListableRepository {
+public class Maven2Repository extends org.apache.geronimo.kernel.repository.Maven2Repository {
+
private static final Log log = LogFactory.getLog(Maven2Repository.class);
public Maven2Repository(URI root, ServerInfo serverInfo, boolean resolveToServer) {
- super(root, serverInfo, resolveToServer);
+ super(new ServerInfoRootResolver(serverInfo, resolveToServer).resolve(root));
log.debug("Maven2Repository(root = " + root + ", resolveToServer = "
+ resolveToServer + ") rootFile = "
+ rootFile.getAbsolutePath());
@@ -47,162 +41,6 @@
public Maven2Repository(File rootFile) {
super(rootFile);
}
-
- public File getLocation(Artifact artifact) {
- if(!artifact.isResolved()) {
- throw new IllegalArgumentException("Artifact "+artifact+" is not fully resolved");
- }
- File path = new File(rootFile, artifact.getGroupId().replace('.', File.separatorChar));
- path = new File(path, artifact.getArtifactId());
- path = new File(path, artifact.getVersion().toString());
- path = new File(path, artifact.getArtifactId() + "-" + artifact.getVersion() + "." + artifact.getType());
-
- return path;
- }
-
- public SortedSet list() {
- return listInternal(null, null, null);
- }
-
- public SortedSet list(Artifact query) {
- if(query.getGroupId() != null) { // todo: see if more logic can be shared with the other case
- File path = new File(rootFile, query.getGroupId().replace('.', File.separatorChar));
- path = new File(path, query.getArtifactId());
- if(!path.canRead() || !path.isDirectory()) {
- return new TreeSet();
- }
-
- SortedSet artifacts = new TreeSet();
-
- File[] versionDirs = path.listFiles();
- for (int i = 0; i < versionDirs.length; i++) {
- File versionDir = versionDirs[i];
- if (versionDir.canRead() && versionDir.isDirectory()) {
- String version = versionDir.getName();
- if(query.getVersion() != null && !query.getVersion().toString().equals(version)) {
- continue;
- }
- // Assumes that artifactId is set
- final String filePrefix = query.getArtifactId() + "-" + version + ".";
- File[] list = versionDir.listFiles(new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return name.startsWith(filePrefix);
- }
- });
- for (int j = 0; j < list.length; j++) {
- File file = list[j];
- String end = file.getName().substring(filePrefix.length());
- if(query.getType() != null && !query.getType().equals(end)) {
- continue;
- }
- if(end.indexOf('.') < 0) {
- artifacts.add(new Artifact(query.getGroupId(), query.getArtifactId(), version, end));
- }
- }
- }
- }
- return artifacts;
- } else {
- return listInternal(query.getArtifactId(), query.getType(), query.getVersion() == null ? null : query.getVersion().toString());
- }
- }
-
- private SortedSet listInternal(String artifactMatch, String typeMatch, String versionMatch) {
- SortedSet artifacts = new TreeSet();
- File[] groupIds = rootFile.listFiles();
- for (int i = 0; i < groupIds.length; i++) {
- File groupId = groupIds[i];
- if (groupId.canRead() && groupId.isDirectory()) {
- File[] versionDirs = groupId.listFiles();
- for (int j = 0; j < versionDirs.length; j++) {
- File versionDir = versionDirs[j];
- if (versionDir.canRead() && versionDir.isDirectory()) {
- artifacts.addAll(getArtifacts(null, versionDir, artifactMatch, typeMatch, versionMatch));
- }
- }
- }
- }
- return artifacts;
- }
-
- private List getArtifacts(String groupId, File versionDir, String artifactMatch, String typeMatch, String versionMatch) {
- // org/apache/xbean/xbean-classpath/2.2-SNAPSHOT/xbean-classpath-2.2-SNAPSHOT.jar
- List artifacts = new ArrayList();
- String artifactId = versionDir.getParentFile().getName();
-
- File[] files = versionDir.listFiles();
- for (int i = 0; i < files.length; i++) {
- File file = files[i];
- if (file.canRead()) {
- if (file.isDirectory()) {
- File test = new File(file, "META-INF");
- if(test.exists() && test.isDirectory() && test.canRead() && groupId != null) {
- String version = versionDir.getName();
- String fileHeader = artifactId + "-" + version + ".";
-
- String fileName = file.getName();
- if (fileName.startsWith(fileHeader)) {
- // type is everything after the file header
- String type = fileName.substring(fileHeader.length());
-
- if (!type.endsWith(".sha1") && !type.endsWith(".md5")) {
- if(artifactMatch != null && !artifactMatch.equals(artifactId)) {
- continue;
- }
- if(typeMatch != null && !typeMatch.equals(type)) {
- continue;
- }
- if(versionMatch != null && !versionMatch.equals(version)) {
- continue;
- }
- artifacts.add(new Artifact(groupId,
- artifactId,
- version,
- type));
- }
- }
- } else { // this is just part of the path to the artifact
- String nextGroupId;
- if (groupId == null) {
- nextGroupId = artifactId;
- } else {
- nextGroupId = groupId + "." + artifactId;
- }
-
- artifacts.addAll(getArtifacts(nextGroupId, file, artifactMatch, typeMatch, versionMatch));
- }
- } else if (groupId != null) {
- String version = versionDir.getName();
- String fileHeader = artifactId + "-" + version + ".";
-
- String fileName = file.getName();
- if (fileName.startsWith(fileHeader)) {
- // type is everything after the file header
- String type = fileName.substring(fileHeader.length());
-
- if (!type.endsWith(".sha1") && !type.endsWith(".md5")) {
- if(artifactMatch != null && !artifactMatch.equals(artifactId)) {
- continue;
- }
- if(typeMatch != null && !typeMatch.equals(type)) {
- continue;
- }
- if(versionMatch != null && !versionMatch.equals(version)) {
- continue;
- }
- artifacts.add(new Artifact(groupId,
- artifactId,
- version,
- type
- ));
- }
- }
- }
- }
- }
- return artifacts;
- }
-
public static final GBeanInfo GBEAN_INFO;
Added: geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/repository/ServerInfoRootResolver.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/repository/ServerInfoRootResolver.java?view=auto&rev=508724
==============================================================================
--- geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/repository/ServerInfoRootResolver.java (added)
+++ geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/repository/ServerInfoRootResolver.java Sat Feb 17 00:01:26 2007
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.system.repository;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.geronimo.system.serverinfo.ServerInfo;
+
+/**
+ * @version $Rev: 476049 $ $Date: 2006-11-17 15:35:17 +1100 (Fri, 17 Nov 2006) $
+ */
+public class ServerInfoRootResolver {
+ private final ServerInfo serverInfo;
+ private final boolean resolveToServer;
+
+ public ServerInfoRootResolver(ServerInfo serverInfo, boolean resolveToServer) {
+ this.serverInfo = serverInfo;
+ this.resolveToServer = resolveToServer;
+ }
+
+ public File resolve(URI root) {
+ if (root == null) throw new NullPointerException("root is null");
+
+ if (!root.toString().endsWith("/")) {
+ try {
+ root = new URI(root.toString() + "/");
+ } catch (URISyntaxException e) {
+ throw new RuntimeException("Invalid repository root (does not end with / ) and can't add myself", e);
+ }
+ }
+
+ URI resolvedUri;
+ if (serverInfo != null) {
+ resolvedUri = resolveToServer ? serverInfo.resolveServer(root) : serverInfo.resolve(root);
+ } else {
+ resolvedUri = root;
+ }
+
+ if (!resolvedUri.getScheme().equals("file")) {
+ throw new IllegalStateException("FileSystemRepository must have a root that's a local directory (not " + resolvedUri + ")");
+ }
+
+ File rootFile = new File(resolvedUri);
+ return rootFile;
+ }
+
+}
Modified: geronimo/server/trunk/modules/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/pom.xml?view=diff&rev=508724&r1=508723&r2=508724
==============================================================================
--- geronimo/server/trunk/modules/pom.xml (original)
+++ geronimo/server/trunk/modules/pom.xml Sat Feb 17 00:01:26 2007
@@ -65,6 +65,7 @@
<module>geronimo-corba-builder</module>
<module>geronimo-deploy-config</module>
<module>geronimo-deploy-jsr88</module>
+ <module>geronimo-deploy-jsr88-bootstrapper</module>
<module>geronimo-deploy-tool</module>
<module>geronimo-deployment</module>
<module>geronimo-derby</module>