You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by am...@apache.org on 2006/04/16 08:35:13 UTC
svn commit: r394439 [1/3] - in /geronimo/branches/1.1: ./
applications/console-core/src/java/org/apache/geronimo/console/util/
applications/console-standard/src/java/org/apache/geronimo/console/car/
applications/console-standard/src/webapp/WEB-INF/view...
Author: ammulder
Date: Sat Apr 15 23:35:09 2006
New Revision: 394439
URL: http://svn.apache.org/viewcvs?rev=394439&view=rev
Log:
Services can be deployed with a JAR and plan, or a plan in the JAR at
META-INF/geronimo-service.xml (GERONIMO-1859)
Improvements to configuration import/export, including more metadata
and no installations just to gather metadata
Improved handling for Artifacts that are missing parts (effectively
wildcards)
Added:
geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/MultipleMatchesException.java (with props)
geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationList.java (with props)
geronimo/branches/1.1/modules/system/src/test-data/geronimo-plugins.xml (with props)
geronimo/branches/1.1/modules/system/src/test-repo/m1/junk/
geronimo/branches/1.1/modules/system/src/test-repo/m1/junk/propertiess/
geronimo/branches/1.1/modules/system/src/test-repo/m1/junk/propertiess/junk-1.5.properties (with props)
geronimo/branches/1.1/modules/system/src/test-repo/m2/junk/
geronimo/branches/1.1/modules/system/src/test-repo/m2/junk/junk/
geronimo/branches/1.1/modules/system/src/test-repo/m2/junk/junk/1.5/
geronimo/branches/1.1/modules/system/src/test-repo/m2/junk/junk/1.5/junk-1.5.properties (with props)
geronimo/branches/1.1/modules/system/src/test/org/apache/geronimo/system/configuration/ConfigInstallerTest.java (with props)
Modified:
geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/util/KernelManagementHelper.java
geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/BaseImportExportHandler.java
geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/DownloadCARHandler.java
geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/GeronimoAsMavenServlet.java
geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/ListHandler.java
geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/apache/jk/results.jsp
geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/apache/jk/webApps.jsp
geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/car/download.jsp
geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/car/list.jsp
geronimo/branches/1.1/configs/j2ee-system/src/plan/plan.xml
geronimo/branches/1.1/maven.xml
geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java
geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java
geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/DeployUtils.java
geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationResolver.java
geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java
geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Artifact.java
geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ArtifactManager.java
geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ArtifactResolver.java
geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactManager.java
geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactResolver.java
geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ListableRepository.java
geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java
geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactManagerTest.java
geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.java
geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/EnvironmentBuilder.java
geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
geronimo/branches/1.1/modules/service-builder/src/test/org/apache/geronimo/deployment/service/ServiceConfigBuilderTest.java
geronimo/branches/1.1/modules/system/maven.xml
geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigInstallerGBean.java
geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationInstaller.java
geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationMetadata.java
geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/repository/Maven1Repository.java
geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/repository/Maven2Repository.java
geronimo/branches/1.1/modules/system/src/schema/config-list.xsd
geronimo/branches/1.1/modules/system/src/test/org/apache/geronimo/system/repository/AbstractRepositoryTest.java
geronimo/branches/1.1/modules/system/src/test/org/apache/geronimo/system/repository/Maven1RepositoryTest.java
geronimo/branches/1.1/modules/system/src/test/org/apache/geronimo/system/repository/Maven2RepositoryTest.java
geronimo/branches/1.1/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/BaseConfigInstaller.java
Modified: geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/util/KernelManagementHelper.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/util/KernelManagementHelper.java?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/util/KernelManagementHelper.java (original)
+++ geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/util/KernelManagementHelper.java Sat Apr 15 23:35:09 2006
@@ -42,6 +42,7 @@
import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
import org.apache.geronimo.kernel.GBeanNotFoundException;
import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.management.State;
import org.apache.geronimo.kernel.config.ConfigurationInfo;
import org.apache.geronimo.kernel.config.ConfigurationManager;
import org.apache.geronimo.kernel.config.ConfigurationModuleType;
@@ -772,8 +773,11 @@
if(type == null || type.getValue() == info.getType().getValue()) {
results.add(new ConfigurationData(info.getConfigID(), configuration, null, info.getState(), info.getType(), kernel.getAbstractNameFor(getModuleForConfiguration(info.getConfigID()))));
}
- if(includeChildModules && info.getType().getValue() == ConfigurationModuleType.EAR.getValue()) {
+ if(includeChildModules && info.getType().getValue() == ConfigurationModuleType.EAR.getValue() && info.getState().toInt() == State.RUNNING_INDEX) {
J2EEApplication app = (J2EEApplication) getModuleForConfiguration(info.getConfigID());
+ if(app == null) {
+ throw new IllegalStateException("Unable to load children for J2EE Application '"+info.getConfigID()+"' (no J2EEApplication found)");
+ }
Object[] modules = null;
if(type == null) {
modules = app.getModulesInstances();
@@ -843,7 +847,6 @@
result = config.findGBean(new AbstractNameQuery(ResourceAdapterModule.class.getName()));
} else if(type.equals(ConfigurationModuleType.WAR)) {
result = config.findGBean(new AbstractNameQuery(WebModule.class.getName()));
- System.out.println("CL: "+WebModule.class.getClassLoader());
} else {
return null;
}
Modified: geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/BaseImportExportHandler.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/BaseImportExportHandler.java?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/BaseImportExportHandler.java (original)
+++ geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/BaseImportExportHandler.java Sat Apr 15 23:35:09 2006
@@ -24,6 +24,7 @@
* @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $
*/
public abstract class BaseImportExportHandler extends MultiPageAbstractHandler {
+ protected static final String CONFIG_LIST_SESSION_KEY = "console.plugins.ConfigurationList";
protected static final String INDEX_MODE = "index";
protected static final String LIST_MODE = "list";
protected static final String DOWNLOAD_MODE = "download";
Modified: geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/DownloadCARHandler.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/DownloadCARHandler.java?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/DownloadCARHandler.java (original)
+++ geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/DownloadCARHandler.java Sat Apr 15 23:35:09 2006
@@ -26,13 +26,16 @@
import javax.portlet.PortletException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
+import javax.security.auth.login.FailedLoginException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.console.MultiPageModel;
import org.apache.geronimo.console.util.PortletManager;
import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.MissingDependencyException;
import org.apache.geronimo.system.configuration.ConfigurationMetadata;
import org.apache.geronimo.system.configuration.DownloadResults;
+import org.apache.geronimo.system.configuration.ConfigurationList;
/**
* Handler for the initial download screen.
@@ -64,8 +67,26 @@
String repo = request.getParameter("repository");
String user = request.getParameter("repo-user");
String pass = request.getParameter("repo-pass");
- ConfigurationMetadata config;
- config = PortletManager.getCurrentServer(request).getConfigurationInstaller().loadDependencies(new URL(repo), user, pass, new ConfigurationMetadata(Artifact.create(configId), null, null, false, false));
+ ConfigurationMetadata config = null;
+ try {
+ ConfigurationList list = (ConfigurationList) request.getPortletSession(true).getAttribute(CONFIG_LIST_SESSION_KEY);
+ if(list == null) {
+ list = PortletManager.getCurrentServer(request).getConfigurationInstaller().listConfigurations(new URL(repo), user, pass);
+ request.getPortletSession(true).setAttribute(CONFIG_LIST_SESSION_KEY, list);
+ }
+ for (int i = 0; i < list.getConfigurations().length; i++) {
+ ConfigurationMetadata metadata = list.getConfigurations()[i];
+ if(metadata.getConfigId().toString().equals(configId)) {
+ config = metadata;
+ break;
+ }
+ }
+ } catch (FailedLoginException e) {
+ throw new PortletException("Invalid login for Maven repository '"+repo+"'", e);
+ }
+ if(config == null) {
+ throw new PortletException("No configuration found for '"+configId+"'");
+ }
request.setAttribute("configId", configId);
request.setAttribute("dependencies", config.getDependencies());
request.setAttribute("repository", repo);
@@ -80,8 +101,30 @@
boolean proceed = Boolean.valueOf(request.getParameter("proceed")).booleanValue();
if(proceed) {
String configId = request.getParameter("configId");
+
+ ConfigurationList installList;
+ try {
+ ConfigurationList list = (ConfigurationList) request.getPortletSession(true).getAttribute(CONFIG_LIST_SESSION_KEY);
+ if(list == null) {
+ list = PortletManager.getCurrentServer(request).getConfigurationInstaller().listConfigurations(new URL(repo), user, pass);
+ request.getPortletSession(true).setAttribute(CONFIG_LIST_SESSION_KEY, list);
+ }
+ installList = ConfigurationList.createInstallList(list, Artifact.create(configId));
+ } catch (FailedLoginException e) {
+ throw new PortletException("Invalid login for Maven repository '"+repo+"'", e);
+ }
+ if(installList == null) {
+ throw new PortletException("No configuration found for '"+configId+"'");
+ }
+
DownloadResults results;
- results = PortletManager.getCurrentServer(request).getConfigurationInstaller().install(new URL(repo), user, pass, Artifact.create(configId));
+ try {
+ results = PortletManager.getCurrentServer(request).getConfigurationInstaller().install(installList, user, pass);
+ } catch (FailedLoginException e) {
+ throw new PortletException("Invalid login for Maven repository '"+repo+"'", e);
+ } catch (MissingDependencyException e) {
+ throw new PortletException(e.getMessage(), e);
+ }
List dependencies = new ArrayList();
for (int i = 0; i < results.getDependenciesInstalled().length; i++) {
Artifact uri = results.getDependenciesInstalled()[i];
Modified: geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/GeronimoAsMavenServlet.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/GeronimoAsMavenServlet.java?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/GeronimoAsMavenServlet.java (original)
+++ geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/GeronimoAsMavenServlet.java Sat Apr 15 23:35:09 2006
@@ -37,6 +37,7 @@
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.OutputKeys;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.apache.commons.logging.Log;
@@ -52,8 +53,12 @@
import org.apache.geronimo.kernel.config.ConfigurationStore;
import org.apache.geronimo.kernel.config.ConfigurationUtil;
import org.apache.geronimo.kernel.config.NoSuchStoreException;
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.config.NoSuchConfigException;
+import org.apache.geronimo.kernel.config.InvalidConfigException;
import org.apache.geronimo.kernel.repository.Artifact;
import org.apache.geronimo.kernel.repository.Repository;
+import org.apache.geronimo.kernel.repository.Dependency;
import org.apache.geronimo.system.serverinfo.ServerInfo;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -72,7 +77,7 @@
throw new ServletException("No configId specified for CAR download");
}
Kernel kernel = KernelRegistry.getSingleKernel();
- if(path.equals("/geronimo-configs.xml")) {
+ if(path.equals("/geronimo-plugins.xml")) {
try {
generateConfigFile(kernel, response.getWriter());
} catch (Exception e) {
@@ -162,7 +167,7 @@
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.newDocument();
- Element root = doc.createElement("geronimo-config-list");
+ Element root = doc.createElement("geronimo-plugin-list");
doc.appendChild(root);
List stores = mgr.listStores();
for (int i = 0; i < stores.size(); i++) {
@@ -177,15 +182,39 @@
createText(doc, config, "category", "Geronimo Deployments");
createText(doc, config, "geronimo-version", version);
if(info.getConfigID().toString().indexOf("jetty") > -1) {
- createText(doc, config, "prerequisite", "geronimo/jetty");
+ writePrerequisite(doc, config, "geronimo/jetty/*/car", "Jetty", "Tomcat");
+ createText(doc, config, "prerequisite", "geronimo/jetty/car");
} else if(info.getConfigID().toString().indexOf("tomcat") > -1) {
- createText(doc, config, "prerequisite", "geronimo/tomcat");
+ createText(doc, config, "prerequisite", "geronimo/tomcat/car");
+ writePrerequisite(doc, config, "geronimo/tomcat/*/car", "Tomcat", "Jetty");
+ }
+ try {
+ ConfigurationData data = mgr.getStoreForConfiguration(info.getConfigID()).loadConfiguration(info.getConfigID());
+ List deps = data.getEnvironment().getDependencies();
+ for (int k = 0; k < deps.size(); k++) {
+ Dependency dep = (Dependency) deps.get(k);
+ createText(doc, config, "dependency", dep.getArtifact().toString());
+ }
+ } catch (Exception e) {
+ log.warn("Unable to generate dependencies for configuration "+info.getConfigID(), e);
}
}
}
TransformerFactory xfactory = TransformerFactory.newInstance();
Transformer xform = xfactory.newTransformer();
+ xform.setOutputProperty(OutputKeys.INDENT, "yes");
xform.transform(new DOMSource(doc), new StreamResult(out));
+ }
+
+ private void writePrerequisite(Document doc, Element config, String configId, String server, String notServer) {
+ Element prereq = doc.createElement("prerequisite");
+ config.appendChild(prereq);
+ createText(doc, prereq, "id", configId);
+ createText(doc, prereq, "description",
+ "This is a web application or web-related module, configured for the " +
+ server +" web container. It will not run on "+notServer+" versions of " +
+ "Geronimo. If you need a "+notServer+" version of this application, " +
+ "you'll need to get it from another "+notServer+" Geronimo installation.");
}
private void createText(Document doc, Element parent, String name, String text) {
Modified: geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/ListHandler.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/ListHandler.java?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/ListHandler.java (original)
+++ geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/ListHandler.java Sat Apr 15 23:35:09 2006
@@ -27,11 +27,13 @@
import javax.portlet.PortletException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
+import javax.security.auth.login.FailedLoginException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.console.MultiPageModel;
import org.apache.geronimo.console.util.PortletManager;
import org.apache.geronimo.system.configuration.ConfigurationMetadata;
+import org.apache.geronimo.system.configuration.ConfigurationList;
import java.util.Collections;
import java.util.Collection;
import java.util.Iterator;
@@ -75,11 +77,16 @@
return getMode()+BEFORE_ACTION;
}
- private void loadFromRepository(RenderRequest request, String repository, String username, String password) throws IOException {
- ConfigurationMetadata[] data = PortletManager.getCurrentServer(request).getConfigurationInstaller().listConfigurations(new URL(repository), username, password);
+ private void loadFromRepository(RenderRequest request, String repository, String username, String password) throws IOException, PortletException {
+ ConfigurationList data;
+ try {
+ data = PortletManager.getCurrentServer(request).getConfigurationInstaller().listConfigurations(new URL(repository), username, password);
+ } catch (FailedLoginException e) {
+ throw new PortletException("Invalid login for Maven repository '"+repository+"'", e);
+ }
Map results = new HashMap();
- for (int i = 0; i < data.length; i++) {
- ConfigurationMetadata metadata = data[i];
+ for (int i = 0; i < data.getConfigurations().length; i++) {
+ ConfigurationMetadata metadata = data.getConfigurations()[i];
List values = (List) results.get(metadata.getCategory());
if(values == null) {
values = new ArrayList();
@@ -93,5 +100,6 @@
Collections.sort(list);
}
request.setAttribute("categories", results);
+ request.getPortletSession(true).setAttribute(CONFIG_LIST_SESSION_KEY, data);
}
}
Modified: geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/apache/jk/results.jsp
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/apache/jk/results.jsp?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/apache/jk/results.jsp (original)
+++ geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/apache/jk/results.jsp Sat Apr 15 23:35:09 2006
@@ -118,7 +118,7 @@
<p>With those steps completed, Apache should be ready to go! Start Geronimo and restart Apache
and try accessing a Geronimo web application through an Apache URL. If there are any problems,
-check the Apache error log, and the mod_jk error log (at ${model.logFilePath}).</p>
+check the Apache error log, and the mod_jk error log (at <tt>${model.logFilePath}</tt>).</p>
<p><a href="<portlet:actionURL portletMode="view">
<portlet:param name="mode" value="index-before" />
Modified: geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/apache/jk/webApps.jsp
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/apache/jk/webApps.jsp?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/apache/jk/webApps.jsp (original)
+++ geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/apache/jk/webApps.jsp Sat Apr 15 23:35:09 2006
@@ -3,16 +3,16 @@
<portlet:defineObjects/>
<p><b>Apache mod_jk</b> -- Web App Selection</p>
-<p>For each web application available in Geronimo, select:</p>
+<p>For each web application <i>currently running</i> in Geronimo, select:</p>
<dl>
- <dt>Through Apache</dt>
+ <dt><b>Through Apache</b></dt>
<dd>Whether the web application should be exposed through Apache</dd>
- <dt>Static Content</dt>
+ <dt><b>Static Content</b></dt>
<dd>Whether Apache should serve static content for the web application (instead of all
content being handled by Geronimo)</dd>
- <dt>Dynamic Paths</dt>
+ <dt><b>Dynamic Paths</b></dt>
<dd>If Apache is serving static content, which URL paths should be passed to Geronimo
- (e.g. <tt>/servlet/*</tt> or <tt>/sample/*.jsp</tt>)</dd>
+ (e.g. <tt>/servlet/*</tt> or <tt>*.jsp</tt>)</dd>
</dl>
<!-- FORM TO COLLECT DATA FOR THIS PAGE -->
@@ -37,20 +37,15 @@
<th>Dynamic Paths</th>
</tr>
<c:forEach var="web" items="${model.webApps}" varStatus="status">
+ <c:if test="${web.running}">
<tr>
<td>${web.name}</td>
- <c:choose>
- <c:when test="${web.running}">
<td align="center"><input type="checkbox" name="webapp.${status.index}.enabled"<c:if test="${model.webApps[status.index].enabled}"> checked="checked"</c:if> /></td>
<td align="center"><input type="checkbox" name="webapp.${status.index}.serveStaticContent"<c:if test="${model.webApps[status.index].serveStaticContent}"> checked="checked"</c:if> /></td>
<td><input type="text" name="webapp.${status.index}.dynamicPattern" size="20" maxlength="250"
value="${model.webApps[status.index].dynamicPattern}"/></td>
- </c:when>
- <c:otherwise>
- <td colspan="3"><i>Web app is not running</i></td>
- </c:otherwise>
- </c:choose>
</tr>
+ </c:if>
</c:forEach>
<!-- SUBMIT BUTTON -->
Modified: geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/car/download.jsp
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/car/download.jsp?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/car/download.jsp (original)
+++ geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/car/download.jsp Sat Apr 15 23:35:09 2006
@@ -4,16 +4,9 @@
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
<portlet:defineObjects/>
-<p>Downloaded ${configId}</p>
+<p>Processing ${configId}...</p>
-<p>Parent Configurations</p>
-<ul>
-<c:forEach var="config" items="${parents}">
- <li>${config}</li>
-</c:forEach>
-</ul>
-
-<p>JAR Dependencies</p>
+<p>Dependencies</p>
<ul>
<c:forEach var="jar" items="${dependencies}">
<li>${jar}</li>
Modified: geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/car/list.jsp
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/car/list.jsp?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/car/list.jsp (original)
+++ geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/car/list.jsp Sat Apr 15 23:35:09 2006
@@ -14,11 +14,26 @@
<ul>
<c:forEach var="entry" items="${category.value}">
<c:choose>
- <c:when test="${entry.installed}">
- <li>${entry.description}</li>
+ <c:when test="${entry.installed || !entry.eligible}">
+ <li>${entry.name}
+ <c:choose>
+ <c:when test="${entry.installed}">
+ (already installed)
+ </c:when>
+ <c:otherwise>
+ <c:if test="${!entry.eligible}">
+ <c:forEach var="prereq" items="${entry.prerequisites}">
+ <c:if test="${!prereq.present}">
+ (${prereq.configIdWithStars} is not installed)
+ </c:if>
+ </c:forEach>
+ </c:if>
+ </c:otherwise>
+ </c:choose>
+ </li>
</c:when>
<c:otherwise>
- <li><a href="<portlet:actionURL><portlet:param name="configId" value="${entry.configId}"/><portlet:param name="repository" value="${repository}"/><portlet:param name="repo-user" value="${repouser}"/><portlet:param name="repo-pass" value="${repopass}"/><portlet:param name="mode" value="download-before"/></portlet:actionURL>">${entry.description}<c:if test="${entry.description ne entry.configId}"> (${entry.version})</c:if></a></li>
+ <li><a href="<portlet:actionURL><portlet:param name="configId" value="${entry.configId}"/><portlet:param name="repository" value="${repository}"/><portlet:param name="repo-user" value="${repouser}"/><portlet:param name="repo-pass" value="${repopass}"/><portlet:param name="mode" value="download-before"/></portlet:actionURL>">${entry.name}<c:if test="${entry.name ne entry.configId}"> (${entry.version})</c:if></a></li>
</c:otherwise>
</c:choose>
</c:forEach>
Modified: geronimo/branches/1.1/configs/j2ee-system/src/plan/plan.xml
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/configs/j2ee-system/src/plan/plan.xml?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/configs/j2ee-system/src/plan/plan.xml (original)
+++ geronimo/branches/1.1/configs/j2ee-system/src/plan/plan.xml Sat Apr 15 23:35:09 2006
@@ -101,6 +101,9 @@
<reference name="ConfigManager">
<name>ConfigurationManager</name>
</reference>
+ <reference name="ServerInfo">
+ <name>ServerInfo</name>
+ </reference>
</gbean>
<!-- Logging service -->
Modified: geronimo/branches/1.1/maven.xml
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/maven.xml?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/maven.xml (original)
+++ geronimo/branches/1.1/maven.xml Sat Apr 15 23:35:09 2006
@@ -344,7 +344,7 @@
-->
<j:if test="${context.getVariable('module.types') == null}">
- <j:set var="module.types" value="modules,applications,plugins"/>
+ <j:set var="module.types" value="modules,applications,plugins,openejb/modules"/>
</j:if>
<j:if test="${context.getVariable('modules') == null}">
Modified: geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java (original)
+++ geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java Sat Apr 15 23:35:09 2006
@@ -36,8 +36,7 @@
import org.apache.geronimo.gbean.AbstractName;
import org.apache.geronimo.gbean.AbstractNameQuery;
import org.apache.geronimo.kernel.jmx.KernelDelegate;
-import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.system.configuration.ConfigurationMetadata;
+import org.apache.geronimo.system.configuration.ConfigurationList;
import org.apache.geronimo.system.configuration.DownloadResults;
/**
@@ -126,12 +125,12 @@
}
}
- public ConfigurationMetadata[] listConfigurations(URL mavenRepository, String username, String password) throws IOException {
+ public ConfigurationList listConfigurations(URL mavenRepository, String username, String password) throws IOException {
Set set = kernel.listGBeans(new AbstractNameQuery("org.apache.geronimo.system.configuration.ConfigurationInstaller"));
for (Iterator it = set.iterator(); it.hasNext();) {
AbstractName name = (AbstractName) it.next();
try {
- return (ConfigurationMetadata[]) kernel.invoke(name, "listConfigurations", new Object[]{mavenRepository, username, password}, new String[]{URL.class.getName(), String.class.getName(), String.class.getName()});
+ return (ConfigurationList) kernel.invoke(name, "listConfigurations", new Object[]{mavenRepository, username, password}, new String[]{URL.class.getName(), String.class.getName(), String.class.getName()});
} catch (Exception e) {
e.printStackTrace();
throw new IOException("Unable to list configurations: "+e.getMessage());
@@ -140,26 +139,12 @@
return null;
}
- public ConfigurationMetadata loadDependencies(URL mavenRepository, String username, String password, ConfigurationMetadata source) throws IOException {
+ public DownloadResults install(ConfigurationList installList, String username, String password) throws IOException {
Set set = kernel.listGBeans(new AbstractNameQuery("org.apache.geronimo.system.configuration.ConfigurationInstaller"));
for (Iterator it = set.iterator(); it.hasNext();) {
AbstractName name = (AbstractName) it.next();
try {
- return (ConfigurationMetadata) kernel.invoke(name, "loadDependencies", new Object[]{mavenRepository, username, password, source}, new String[]{URL.class.getName(), ConfigurationMetadata.class.getName(), String.class.getName(), String.class.getName()});
- } catch (Exception e) {
- e.printStackTrace();
- throw new IOException("Unable to load dependencies: "+e.getMessage());
- }
- }
- return null;
- }
-
- public DownloadResults install(URL mavenRepository, String username, String password, Artifact configId) throws IOException {
- Set set = kernel.listGBeans(new AbstractNameQuery("org.apache.geronimo.system.configuration.ConfigurationInstaller"));
- for (Iterator it = set.iterator(); it.hasNext();) {
- AbstractName name = (AbstractName) it.next();
- try {
- return (DownloadResults) kernel.invoke(name, "install", new Object[]{mavenRepository, username, password, configId}, new String[]{URL.class.getName(), String.class.getName(), String.class.getName(), Artifact.class.getName()});
+ return (DownloadResults) kernel.invoke(name, "install", new Object[]{installList, username, password}, new String[]{ConfigurationList.class.getName(), String.class.getName(), String.class.getName()});
} catch (Exception e) {
e.printStackTrace();
throw new IOException("Unable to install configurations: "+e.getMessage());
Modified: geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java (original)
+++ geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java Sat Apr 15 23:35:09 2006
@@ -27,11 +27,14 @@
import java.util.List;
import java.util.Map;
import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.security.auth.login.FailedLoginException;
import org.apache.geronimo.common.DeploymentException;
import org.apache.geronimo.deployment.plugin.GeronimoDeploymentManager;
import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.MissingDependencyException;
import org.apache.geronimo.system.configuration.ConfigurationMetadata;
import org.apache.geronimo.system.configuration.DownloadResults;
+import org.apache.geronimo.system.configuration.ConfigurationList;
/**
* The CLI deployer logic to start.
@@ -59,18 +62,20 @@
DeploymentManager dmgr = connection.getDeploymentManager();
if(dmgr instanceof GeronimoDeploymentManager) {
GeronimoDeploymentManager mgr = (GeronimoDeploymentManager) dmgr;
- ConfigurationMetadata[] data;
+ ConfigurationList data;
URL repository;
try {
repository = new URL(args[0]);
data = mgr.listConfigurations(repository, null, null);
} catch (IOException e) {
throw new DeploymentException("Unable to list configurations", e);
+ } catch (FailedLoginException e) {
+ throw new DeploymentException("Invalid login for Maven repository '"+args[0]+"'");
}
Map categories = new HashMap();
List available = new ArrayList();
- for (int i = 0; i < data.length; i++) {
- ConfigurationMetadata metadata = data[i];
+ for (int i = 0; i < data.getConfigurations().length; i++) {
+ ConfigurationMetadata metadata = data.getConfigurations()[i];
List list = (List) categories.get(metadata.getCategory());
if(list == null) {
list = new ArrayList();
@@ -95,7 +100,7 @@
}
prefix += ": ";
}
- System.out.print(DeployUtils.reformat(prefix+metadata.getDescription()+" ("+metadata.getVersion()+")", 8, 72));
+ System.out.print(DeployUtils.reformat(prefix+metadata.getName()+" ("+metadata.getVersion()+")", 8, 72));
System.out.flush();
}
}
@@ -110,7 +115,7 @@
}
int selection = Integer.parseInt(answer);
ConfigurationMetadata target = ((ConfigurationMetadata) available.get(selection - 1));
- DownloadResults results = mgr.install(repository, null, null, target.getConfigId());
+ DownloadResults results = mgr.install(ConfigurationList.createInstallList(data, target.getConfigId()), null, null);
for (int i = 0; i < results.getDependenciesPresent().length; i++) {
Artifact uri = results.getDependenciesPresent()[i];
System.out.print(DeployUtils.reformat("Using existing dependency "+uri, 4, 72));
@@ -124,6 +129,10 @@
throw new DeploymentException("Unable to install configuration", e);
} catch(NumberFormatException e) {
throw new DeploymentException("Invalid response");
+ } catch (FailedLoginException e) {
+ throw new DeploymentException("Invalid login for Maven repository '"+repository+"'");
+ } catch (MissingDependencyException e) {
+ throw new DeploymentException(e.getMessage());
}
} else {
throw new DeploymentException("Cannot list repositories when connected to "+connection.getServerURI());
Modified: geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/DeployUtils.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/DeployUtils.java?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/DeployUtils.java (original)
+++ geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/DeployUtils.java Sat Apr 15 23:35:09 2006
@@ -195,8 +195,10 @@
target = new File(module, "META-INF/geronimo-ra.xml");
} else if(new File(module, "META-INF/application-client.xml").canRead()) {
target = new File(module, "META-INF/geronimo-application-client.xml");
+ } else {
+ target = new File(module, "META-INF/geronimo-service.xml");
}
- if(target != null && target.canRead()) {
+ if(target.canRead()) {
Reader in = new BufferedReader(new FileReader(target));
return extractModuleIdFromPlan(in);
}
@@ -220,6 +222,8 @@
entry = input.getJarEntry("META-INF/geronimo-ra.xml");
} else if(input.getJarEntry("META-INF/application-client.xml") != null) {
entry = input.getJarEntry("META-INF/geronimo-application-client.xml");
+ } else {
+ entry = input.getJarEntry("META-INF/geronimo-service.xml");
}
if(entry != null) {
Reader in = new BufferedReader(new InputStreamReader(input.getInputStream(entry)));
@@ -307,6 +311,9 @@
}
public void endDocument() throws SAXException {
+ if(type.equals("")) {
+ type = "car";
+ }
configId = groupId+"/"+artifactId+"/"+version+"/"+type;
}
}
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationResolver.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationResolver.java?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationResolver.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationResolver.java Sat Apr 15 23:35:09 2006
@@ -155,7 +155,7 @@
}
// resolve the artifact
- artifact = artifactResolver.resolve(parents, artifact);
+ artifact = artifactResolver.resolveInClassLoader(artifact, parents);
// build a new dependency object to contain the resolved artifact
Dependency resolvedDependency = new Dependency(artifact, dependency.getImportType());
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java Sat Apr 15 23:35:09 2006
@@ -331,7 +331,7 @@
List dependencies = new ArrayList(environment.getDependencies());
for (ListIterator iterator = dependencies.listIterator(); iterator.hasNext();) {
Dependency dependency = (Dependency) iterator.next();
- Artifact resolvedArtifact = artifactResolver.resolve(dependency.getArtifact());
+ Artifact resolvedArtifact = artifactResolver.resolveInClassLoader(dependency.getArtifact());
if (isConfiguration(resolvedArtifact)) {
parentIds.add(resolvedArtifact);
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Artifact.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Artifact.java?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Artifact.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Artifact.java Sat Apr 15 23:35:09 2006
@@ -24,7 +24,7 @@
*/
public class Artifact implements Comparable, Serializable {
private static final long serialVersionUID = -3459638899709893444L;
- public static final String DEFAULT_GROUP_ID = "Unspecified";
+ public static final String DEFAULT_GROUP_ID = "unspecified";
private final String groupId;
private final String artifactId;
@@ -32,7 +32,7 @@
private final String type;
public Artifact(String groupId, String artifactId, String version, String type) {
- this(groupId, artifactId, version == null? null: new Version(version), type);
+ this(groupId, artifactId, version == null ? null : new Version(version), type);
}
public Artifact(String groupId, String artifactId, Version version, String type) {
@@ -45,10 +45,15 @@
public static Artifact create(String id) {
String[] parts = id.split("/");
- if (parts.length != 4) {
- throw new IllegalArgumentException("Invalid id: " + id);
- }
- return new Artifact(parts[0], parts[1], parts[2], parts[3]);
+ if (parts.length != 4) {
+ throw new IllegalArgumentException("Invalid id: " + id);
+ }
+ for (int i = 0; i < parts.length; i++) {
+ if (parts[i].equals("")) {
+ parts[i] = null;
+ }
+ }
+ return new Artifact(parts[0], parts[1], parts[2], parts[3]);
}
public String getGroupId() {
@@ -89,6 +94,7 @@
private static int GREATER = 1;
private static int LESS = -1;
+
private static int safeCompare(Comparable left, Comparable right) {
if (left == null) {
if (right != null) return LESS;
@@ -153,6 +159,7 @@
/**
* see if this artifact matches the other artifact (which is more specific than this one)
+ *
* @param otherArtifact the more specific artifact we are comparing with
* @return whether the other artifact is consistent with everything specified in this artifact.
*/
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ArtifactManager.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ArtifactManager.java?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ArtifactManager.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ArtifactManager.java Sat Apr 15 23:35:09 2006
@@ -25,5 +25,5 @@
public interface ArtifactManager {
void loadArtifacts(Artifact artifact, Set artifacts);
void unloadAllArtifacts(Artifact artifact);
- SortedSet getLoadedArtifacts(String groupId, String artifactId, String type);
+ SortedSet getLoadedArtifacts(Artifact query);
}
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ArtifactResolver.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ArtifactResolver.java?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ArtifactResolver.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ArtifactResolver.java Sat Apr 15 23:35:09 2006
@@ -23,11 +23,72 @@
* @version $Rev$ $Date$
*/
public interface ArtifactResolver {
- LinkedHashSet resolve(Collection artifacts) throws MissingDependencyException;
- LinkedHashSet resolve(Collection parentConfigurations, Collection artifacts) throws MissingDependencyException;
+ /**
+ * Used to generate a fully-populated Artifact from a partially-populated Artifact
+ * when you're about to deploy/save a new artifact. That is, this method comes up
+ * with reasonable default values that hopefully do not conflict with anything
+ * that's already deployed.
+ *
+ * @param source The artifact to complete (normally partially-populated)
+ * @param defaultType The type to use for the resulting artifact if the source
+ * artifact doesn't have a type set
+ *
+ * @return If the source artifact is fully populated (e.g. artifact.isResolved()
+ * == true) then it will be returned. Otherwise a new fully-populated
+ * artifact is returned.
+ */
+ Artifact generateArtifact(Artifact source, String defaultType);
- Artifact resolve(Artifact artifact) throws MissingDependencyException;
+ /**
+ * Used to search for existing artifacts that match the supplied artifact (which
+ * may be partially-populated). Preference is given to artifacts that are already
+ * loaded, to reduce duplication. If nothing can be found that's an error,
+ * because something depends on this.
+ */
+ Artifact resolveInClassLoader(Artifact source) throws MissingDependencyException;
+ /**
+ * Used to search for existing artifacts that match the supplied artifact (which
+ * may be partially-populated). Preference is given to artifacts that are already
+ * loaded, or that exist in the parent configurations, to reduce duplication. If
+ * nothing can be found that's an error, because something depends on this.
+ */
+ Artifact resolveInClassLoader(Artifact source, Collection parentConfigurations) throws MissingDependencyException;
+ /**
+ * Used to search for existing artifacts that match the supplied artifact (which
+ * may be partially-populated). Preference is given to artifacts that are already
+ * loaded, to reduce duplication. If nothing can be found that's an error,
+ * because something depends on this.
+ *
+ * @return A sorted set ordered in the same way the input was ordered, with
+ * entries of type Artifact
+ */
+ LinkedHashSet resolveInClassLoader(Collection artifacts) throws MissingDependencyException;
+ /**
+ * Used to search for existing artifacts that match the supplied artifact (which
+ * may be partially-populated). Preference is given to artifacts that are already
+ * loaded, or that exist in the parent configurations, to reduce duplication. If
+ * nothing can be found that's an error, because something depends on this.
+ *
+ * @return A sorted set ordered in the same way the input was ordered, with
+ * entries of type Artifact
+ */
+ LinkedHashSet resolveInClassLoader(Collection artifacts, Collection parentConfigurations) throws MissingDependencyException;
- Artifact resolve(Collection parentConfigurations, Artifact artifact) throws MissingDependencyException;
+ /**
+ * Used to search for existing artifacts in the server that match the supplied
+ * artifact (which may be partially-populated). This method expects either no
+ * results or one result (multiple matches is an error).
+ *
+ * @return A matching artifact, or null of there were no matches
+ */
+ Artifact queryArtifact(Artifact artifact) throws MultipleMatchesException;
+
+ /**
+ * Used to search for existing artifacts in the server that match the supplied
+ * artifact (which may be partially-populated).
+ *
+ * @return The matching artifacts, which may be 0, 1, or many
+ */
+ Artifact[] queryArtifacts(Artifact artifact);
}
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactManager.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactManager.java?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactManager.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactManager.java Sat Apr 15 23:35:09 2006
@@ -34,7 +34,7 @@
*/
public class DefaultArtifactManager implements ArtifactManager {
private final Map artifactsByLoader = new HashMap();
- private final Map artifactsByTemplate = new HashMap();
+ private final Map artifactsByArtifact = new HashMap();
public void loadArtifacts(Artifact loader, Set artifacts) {
if (!loader.isResolved()) throw new IllegalArgumentException("loader is not a resolved artifact: " + loader);
@@ -48,27 +48,26 @@
synchronized (this) {
if (artifactsByLoader.containsKey(loader)) throw new IllegalArgumentException("loader has already declared artifacts: "+ loader);
artifactsByLoader.put(loader, artifacts);
- addArtifactByTempate(loader);
+ processArtifact(loader);
for (Iterator iterator = artifacts.iterator(); iterator.hasNext();) {
Artifact artifact = (Artifact) iterator.next();
- addArtifactByTempate(artifact);
+ processArtifact(artifact);
}
}
}
- private void addArtifactByTempate(Artifact artifact) {
- Artifact template = new Artifact(artifact.getGroupId(),artifact.getArtifactId(), (Version) null, artifact.getType());
- List versions = (List) artifactsByTemplate.get(template);
- if (versions == null) {
- versions = new ArrayList();
- artifactsByTemplate.put(template, versions);
+ private void processArtifact(Artifact artifact) {
+ List values = (List) artifactsByArtifact.get(artifact.getArtifactId());
+ if (values == null) {
+ values = new ArrayList();
+ artifactsByArtifact.put(artifact.getArtifactId(), values);
}
- versions.add(artifact);
+ values.add(artifact);
}
public synchronized void unloadAllArtifacts(Artifact loader) {
- removeArtifactByTempate(loader);
+ removeArtifact(loader);
Collection artifacts = (Collection) artifactsByLoader.remove(loader);
if (artifacts == null) {
@@ -77,28 +76,32 @@
for (Iterator iterator = artifacts.iterator(); iterator.hasNext();) {
Artifact artifact = (Artifact) iterator.next();
- removeArtifactByTempate(artifact);
+ removeArtifact(artifact);
}
}
- private void removeArtifactByTempate(Artifact artifact) {
- Artifact template = new Artifact(artifact.getGroupId(),artifact.getArtifactId(), (Version) null, artifact.getType());
- List versions = (List) artifactsByTemplate.get(template);
- if (versions != null) {
- versions.remove(artifact);
- if (versions.isEmpty()) {
- artifactsByTemplate.remove(template);
+ private void removeArtifact(Artifact artifact) {
+ List values = (List) artifactsByArtifact.get(artifact.getArtifactId());
+ if (values != null) {
+ values.remove(artifact);
+ if (values.isEmpty()) {
+ artifactsByArtifact.remove(artifact.getArtifactId());
}
}
}
- public SortedSet getLoadedArtifacts(String groupId, String artifactId, String type) {
- Artifact template = new Artifact(groupId, artifactId, (Version) null, type);
- List versions = (List) artifactsByTemplate.get(template);
- if (versions != null) {
- return new TreeSet(versions);
+ public SortedSet getLoadedArtifacts(Artifact query) {
+ List values = (List) artifactsByArtifact.get(query.getArtifactId());
+ SortedSet results = new TreeSet();
+ if (values != null) {
+ for (int i = 0; i < values.size(); i++) {
+ Artifact test = (Artifact) values.get(i);
+ if(query.matches(test)) {
+ results.add(test);
+ }
+ }
}
- return new TreeSet();
+ return results;
}
public static final GBeanInfo GBEAN_INFO;
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactResolver.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactResolver.java?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactResolver.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactResolver.java Sat Apr 15 23:35:09 2006
@@ -22,7 +22,6 @@
import java.util.LinkedHashSet;
import java.util.SortedSet;
import java.util.TreeSet;
-
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
import org.apache.geronimo.kernel.config.Configuration;
@@ -44,60 +43,91 @@
this.repositories = repositories;
}
- public LinkedHashSet resolve(Collection artifacts) throws MissingDependencyException {
- return this.resolve(Collections.EMPTY_SET, artifacts);
+
+ public Artifact generateArtifact(Artifact source, String defaultType) {
+ if(source.isResolved()) {
+ return source;
+ }
+ String groupId = source.getGroupId() == null ? Artifact.DEFAULT_GROUP_ID : source.getGroupId();
+ String artifactId = source.getArtifactId();
+ String type = source.getType() == null ? defaultType : source.getType();
+ Version version = source.getVersion() == null ? new Version(Long.toString(System.currentTimeMillis())) : source.getVersion();
+
+ return new Artifact(groupId, artifactId, version, type);
+ }
+
+ public Artifact queryArtifact(Artifact artifact) throws MultipleMatchesException {
+ Artifact[] all = queryArtifacts(artifact);
+ if(all.length > 1) {
+ throw new MultipleMatchesException(artifact);
+ }
+ return all.length == 0 ? null : all[0];
+ }
+
+ public Artifact[] queryArtifacts(Artifact artifact) {
+ LinkedHashSet set = new LinkedHashSet();
+ for (Iterator iterator = repositories.iterator(); iterator.hasNext();) {
+ ListableRepository repository = (ListableRepository) iterator.next();
+ set.addAll(repository.list(artifact));
+ }
+ return (Artifact[]) set.toArray(new Artifact[set.size()]);
}
- public LinkedHashSet resolve(Collection parentConfigurations, Collection artifacts) throws MissingDependencyException {
+ public LinkedHashSet resolveInClassLoader(Collection artifacts) throws MissingDependencyException {
+ return resolveInClassLoader(artifacts, Collections.EMPTY_SET);
+ }
+
+ public LinkedHashSet resolveInClassLoader(Collection artifacts, Collection parentConfigurations) throws MissingDependencyException {
LinkedHashSet resolvedArtifacts = new LinkedHashSet();
for (Iterator iterator = artifacts.iterator(); iterator.hasNext();) {
Artifact artifact = (Artifact) iterator.next();
if (!artifact.isResolved()) {
- artifact = resolve(parentConfigurations, artifact);
+ artifact = resolveInClassLoader(artifact, parentConfigurations);
}
resolvedArtifacts.add(artifact);
}
return resolvedArtifacts;
}
- public Artifact resolve(Artifact artifact) throws MissingDependencyException {
- return this.resolve(Collections.EMPTY_SET, artifact);
+ public Artifact resolveInClassLoader(Artifact source) throws MissingDependencyException {
+ return resolveInClassLoader(source, Collections.EMPTY_SET);
}
- public Artifact resolve(Collection parentConfigurations, Artifact artifact) throws MissingDependencyException {
- if (artifact.getType() == null) {
- throw new IllegalArgumentException("Type not set " + artifact);
+ public Artifact resolveInClassLoader(Artifact source, Collection parentConfigurations) throws MissingDependencyException {
+ // Some tests break if we acntually try to search for fully-resolved artifacts
+ if(source.isResolved()) {
+ return source;
}
+// if (artifact.getType() == null) {
+// throw new IllegalArgumentException("Type not set " + artifact);
+// }
+//
+// String groupId = source.getGroupId();
+// if (groupId == null) {
+// groupId = Artifact.DEFAULT_GROUP_ID;
+// }
- String groupId = artifact.getGroupId();
- if (groupId == null) {
- groupId = Artifact.DEFAULT_GROUP_ID;
- }
+// Version version = source.getVersion();
- Version version = artifact.getVersion();
- if (version == null) {
- // check if we have any existing artifacts loaded
- version = resolveVersion(parentConfigurations, groupId, artifact.getArtifactId(), artifact.getType());
- if (version == null) {
- throw new MissingDependencyException("Unable to resolve dependency " + artifact);
- }
+ Artifact working = resolveVersion(parentConfigurations, source);
+ if (working == null || !working.isResolved()) {
+ throw new MissingDependencyException("Unable to resolve dependency " + source);
}
- return new Artifact(groupId, artifact.getArtifactId(), version, artifact.getType());
+ return working;
}
- private Version resolveVersion(Collection parentConfigurations, String groupId, String artifactId, String type) {
+ private Artifact resolveVersion(Collection parentConfigurations, Artifact working) {
SortedSet existingArtifacts;
if (artifactManager != null) {
- existingArtifacts = artifactManager.getLoadedArtifacts(groupId, artifactId, type);
+ existingArtifacts = artifactManager.getLoadedArtifacts(working);
} else {
existingArtifacts = new TreeSet();
}
// if we have exactly one artifact loaded use its' version
if (existingArtifacts.size() == 1) {
- Artifact existingArtifact = (Artifact) existingArtifacts.first();
- return existingArtifact.getVersion();
+ return (Artifact) existingArtifacts.first();
}
// if we have no existing loaded artifacts grab the highest version from the repository
@@ -105,83 +135,79 @@
SortedSet list = new TreeSet();
for (Iterator iterator = repositories.iterator(); iterator.hasNext();) {
ListableRepository repository = (ListableRepository) iterator.next();
- list.addAll(repository.list(groupId, artifactId, type));
+ list.addAll(repository.list(working));
}
if (list.isEmpty()) {
return null;
}
- Artifact repositoryArtifact = (Artifact) list.last();
- return repositoryArtifact.getVersion();
+ return (Artifact) list.last();
}
// more than one version of the artifact was loaded...
// if one of parents already loaded the artifact, use that version
- Version version = searchParents(parentConfigurations, groupId, artifactId, type);
- if (version != null) {
- return version;
+ Artifact artifact = searchParents(parentConfigurations, working);
+ if (artifact != null) {
+ return artifact;
}
// it wasn't declared by the parent so just use the highest verstion already loaded
- Artifact repositoryArtifact = (Artifact) existingArtifacts.last();
- return repositoryArtifact.getVersion();
+ return (Artifact) existingArtifacts.last();
}
- private Version searchParents(Collection parentConfigurations, String groupId, String artifactId, String type) {
+ private Artifact searchParents(Collection parentConfigurations, Artifact working) {
for (Iterator iterator = parentConfigurations.iterator(); iterator.hasNext();) {
Configuration configuration = (Configuration) iterator.next();
// check if this parent matches the groupId, artifactId, and type
- if (matches(configuration.getId(), groupId, artifactId, type)) {
- return configuration.getId().getVersion();
+ if (matches(configuration.getId(), working)) {
+ return configuration.getId();
}
Environment environment = configuration.getEnvironment();
if (environment.isInverseClassLoading()) {
// Search dependencies of the configuration before searching the parents
- Version version = getArtifactVersion(configuration.getDependencies(), groupId, artifactId, type);
- if (version != null) {
- return version;
+ Artifact artifact = getArtifactVersion(configuration.getDependencies(), working);
+ if (artifact != null) {
+ return artifact;
}
// wasn't declared in the dependencies, so search the parents of the configuration
- version = searchParents(configuration.getClassParents(), groupId, artifactId, type);
- if (version != null) {
- return version;
+ artifact = searchParents(configuration.getClassParents(), working);
+ if (artifact != null) {
+ return artifact;
}
} else {
// Search the parents before the dependencies of the configuration
- Version version = searchParents(configuration.getClassParents(), groupId, artifactId, type);
- if (version != null) {
- return version;
+ Artifact artifact = searchParents(configuration.getClassParents(), working);
+ if (artifact != null) {
+ return artifact;
}
// wasn't declared in a parent check the dependencies of the configuration
- version = getArtifactVersion(configuration.getDependencies(), groupId, artifactId, type);
- if (version != null) {
- return version;
+ artifact = getArtifactVersion(configuration.getDependencies(), working);
+ if (artifact != null) {
+ return artifact;
}
}
}
return null;
}
- private Version getArtifactVersion(Collection artifacts, String groupId, String artifactId, String type) {
+ private Artifact getArtifactVersion(Collection artifacts, Artifact query) {
for (Iterator iterator = artifacts.iterator(); iterator.hasNext();) {
Artifact artifact = (Artifact) iterator.next();
- if (matches(artifact, groupId, artifactId, type)) {
- return artifact.getVersion();
+ if (matches(artifact, query)) {
+ return artifact;
}
}
return null;
}
- private boolean matches(Artifact artifact, String groupId, String artifactId, String type) {
- return groupId.equals(artifact.getGroupId()) &&
- artifactId.equals(artifact.getArtifactId()) &&
- type.equals(artifact.getType());
+ private boolean matches(Artifact candidate, Artifact query) {
+ return query.matches(candidate);
}
public static final GBeanInfo GBEAN_INFO;
@@ -204,4 +230,4 @@
public static GBeanInfo getGBeanInfo() {
return GBEAN_INFO;
}
-}
+}
\ No newline at end of file
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ListableRepository.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ListableRepository.java?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ListableRepository.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ListableRepository.java Sat Apr 15 23:35:09 2006
@@ -31,5 +31,10 @@
*/
public SortedSet list();
- public SortedSet list(String groupId, String artifactId, String type);
+ /**
+ * Gets a list of all the available items matching the specified artifact,
+ * which is normally incomplete (so the results all match whatever fields
+ * are specified on the argument Artifact).
+ */
+ public SortedSet list(Artifact query);
}
Added: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/MultipleMatchesException.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/MultipleMatchesException.java?rev=394439&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/MultipleMatchesException.java (added)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/MultipleMatchesException.java Sat Apr 15 23:35:09 2006
@@ -0,0 +1,47 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed 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;
+
+/**
+ * Indicates that you tried to resolve a partially-populated artifact to
+ * a real artifact expecting one match but you got multiple matches.
+ *
+ * Note there is a separate method to call if you expect multiple matches.
+ *
+ * @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $
+ */
+public class MultipleMatchesException extends Exception {
+ private final Artifact artifact;
+
+ public MultipleMatchesException(Artifact query) {
+ super();
+ artifact = query;
+ }
+
+ public MultipleMatchesException(Artifact query, String message) {
+ super(message);
+ artifact = query;
+ }
+
+ /**
+ * Gets the artifact used as a query argument that matched multiple real
+ * artifacts available in the server.
+ */
+ public Artifact getArtifact() {
+ return artifact;
+ }
+}
Propchange: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/MultipleMatchesException.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java Sat Apr 15 23:35:09 2006
@@ -141,13 +141,11 @@
return new TreeSet(configurations.keySet());
}
- public SortedSet list(String groupId, String artifactId, String type) {
+ public SortedSet list(Artifact query) {
TreeSet artifacts = new TreeSet();
for (Iterator iterator = configurations.keySet().iterator(); iterator.hasNext();) {
Artifact artifact = (Artifact) iterator.next();
- if (artifact.getGroupId().equals(groupId) &&
- artifact.getArtifactId().equals(artifactId) &&
- artifact.getType().equals(type)) {
+ if (query.matches(artifact)) {
artifacts.add(artifact);
}
}
Modified: geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactManagerTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactManagerTest.java?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactManagerTest.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactManagerTest.java Sat Apr 15 23:35:09 2006
@@ -42,30 +42,30 @@
artifacts2.add(private2);
artifactManager.loadArtifacts(loader2, artifacts2);
- SortedSet loadedArtifacts = artifactManager.getLoadedArtifacts("private1", "artifact", "jar");
+ SortedSet loadedArtifacts = artifactManager.getLoadedArtifacts(new Artifact("private1", "artifact", (Version)null, "jar"));
assertEquals(Collections.singleton(private1), loadedArtifacts);
- loadedArtifacts = artifactManager.getLoadedArtifacts("loaderGroup", "loaderArtifact1", "car");
+ loadedArtifacts = artifactManager.getLoadedArtifacts(new Artifact("loaderGroup", "loaderArtifact1", (Version)null, "car"));
assertEquals(Collections.singleton(loader1), loadedArtifacts);
- loadedArtifacts = artifactManager.getLoadedArtifacts("private2", "artifact", "jar");
+ loadedArtifacts = artifactManager.getLoadedArtifacts(new Artifact("private2", "artifact", (Version)null, "jar"));
assertEquals(Collections.singleton(private2), loadedArtifacts);
- loadedArtifacts = artifactManager.getLoadedArtifacts("loaderGroup", "loaderArtifact2", "car");
+ loadedArtifacts = artifactManager.getLoadedArtifacts(new Artifact("loaderGroup", "loaderArtifact2", (Version)null, "car"));
assertEquals(Collections.singleton(loader2), loadedArtifacts);
artifactManager.unloadAllArtifacts(loader1);
- loadedArtifacts = artifactManager.getLoadedArtifacts("private1", "artifact", "jar");
+ loadedArtifacts = artifactManager.getLoadedArtifacts(new Artifact("private1", "artifact", (Version)null, "jar"));
assertEquals(Collections.EMPTY_SET, loadedArtifacts);
- loadedArtifacts = artifactManager.getLoadedArtifacts("loaderGroup", "loaderArtifact1", "car");
+ loadedArtifacts = artifactManager.getLoadedArtifacts(new Artifact("loaderGroup", "loaderArtifact1", (Version)null, "car"));
assertEquals(Collections.EMPTY_SET, loadedArtifacts);
- loadedArtifacts = artifactManager.getLoadedArtifacts("private2", "artifact", "jar");
+ loadedArtifacts = artifactManager.getLoadedArtifacts(new Artifact("private2", "artifact", (Version)null, "jar"));
assertEquals(Collections.singleton(private2), loadedArtifacts);
- loadedArtifacts = artifactManager.getLoadedArtifacts("loaderGroup", "loaderArtifact2", "car");
+ loadedArtifacts = artifactManager.getLoadedArtifacts(new Artifact("loaderGroup", "loaderArtifact2", (Version)null, "car"));
assertEquals(Collections.singleton(loader2), loadedArtifacts);
}
@@ -86,11 +86,11 @@
artifacts.add(version1);
artifacts.add(version2);
- SortedSet loadedArtifacts = artifactManager.getLoadedArtifacts("version", "version", "jar");
+ SortedSet loadedArtifacts = artifactManager.getLoadedArtifacts(new Artifact("version", "version", (Version)null, "jar"));
assertEquals(artifacts, loadedArtifacts);
artifactManager.unloadAllArtifacts(loader1);
- loadedArtifacts = artifactManager.getLoadedArtifacts("version", "version", "jar");
+ loadedArtifacts = artifactManager.getLoadedArtifacts(new Artifact("version", "version", (Version)null, "jar"));
assertEquals(Collections.singleton(version2), loadedArtifacts);
}
@@ -105,12 +105,12 @@
Artifact loader2 = new Artifact("loaderGroup", "loaderArtifact2", "1", "car");
artifactManager.loadArtifacts(loader2, Collections.singleton(artifact));
- SortedSet loadedArtifacts = artifactManager.getLoadedArtifacts("dupe", "dupe", "jar");
+ SortedSet loadedArtifacts = artifactManager.getLoadedArtifacts(new Artifact("dupe", "dupe", (Version)null, "jar"));
assertEquals(Collections.singleton(artifact), loadedArtifacts);
artifactManager.unloadAllArtifacts(loader1);
- loadedArtifacts = artifactManager.getLoadedArtifacts("dupe", "dupe", "jar");
+ loadedArtifacts = artifactManager.getLoadedArtifacts(new Artifact("dupe", "dupe", (Version)null, "jar"));
assertEquals(Collections.singleton(artifact), loadedArtifacts);
}
}
Modified: geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.java?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.java Sat Apr 15 23:35:09 2006
@@ -24,15 +24,12 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
-import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
-
import junit.framework.TestCase;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.gbean.AbstractName;
import org.apache.geronimo.kernel.Jsr77Naming;
import org.apache.geronimo.kernel.config.Configuration;
import org.apache.geronimo.kernel.config.ConfigurationData;
@@ -57,7 +54,7 @@
ArtifactResolver artifactResolver = new DefaultArtifactResolver(artifactManager, mockRepository);
Artifact unresolvedArtifact = new Artifact("version", "version", (Version) null, "jar");
- Artifact artifact = artifactResolver.resolve(unresolvedArtifact);
+ Artifact artifact = artifactResolver.resolveInClassLoader(unresolvedArtifact);
assertEquals(version3, artifact);
}
@@ -69,7 +66,7 @@
ArtifactResolver artifactResolver = new DefaultArtifactResolver(artifactManager, mockRepository);
Artifact unresolvedArtifact = new Artifact("version", "version", (Version) null, "jar");
- Artifact artifact = artifactResolver.resolve(unresolvedArtifact);
+ Artifact artifact = artifactResolver.resolveInClassLoader(unresolvedArtifact);
assertEquals(version2, artifact);
}
@@ -84,7 +81,7 @@
ArtifactResolver artifactResolver = new DefaultArtifactResolver(artifactManager, mockRepository);
Artifact unresolvedArtifact = new Artifact("version", "version", (Version) null, "jar");
- Artifact artifact = artifactResolver.resolve(unresolvedArtifact);
+ Artifact artifact = artifactResolver.resolveInClassLoader(unresolvedArtifact);
assertEquals(version2, artifact);
}
@@ -120,7 +117,7 @@
parents.add(parent);
Artifact unresolvedArtifact = new Artifact("version", "version", (Version) null, "jar");
- Artifact artifact = artifactResolver.resolve(parents, unresolvedArtifact);
+ Artifact artifact = artifactResolver.resolveInClassLoader(unresolvedArtifact, parents);
assertEquals(version1, artifact);
}
@@ -129,7 +126,7 @@
throw new UnsupportedOperationException();
}
- public SortedSet list(String groupId, String artifactId, String type) {
+ public SortedSet list(Artifact query) {
TreeSet set = new TreeSet();
set.add(version1);
set.add(version2);
Modified: geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/EnvironmentBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/EnvironmentBuilder.java?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/EnvironmentBuilder.java (original)
+++ geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/EnvironmentBuilder.java Sat Apr 15 23:35:09 2006
@@ -54,7 +54,7 @@
Environment environment = new Environment();
if (environmentType != null) {
if (environmentType.isSetConfigId()) {
- environment.setConfigId(toArtifact(environmentType.getConfigId()));
+ environment.setConfigId(toArtifact(environmentType.getConfigId(), "car"));
}
if (environmentType.isSetDependencies()) {
@@ -179,7 +179,7 @@
LinkedHashSet artifacts = new LinkedHashSet();
for (int i = 0; i < artifactTypes.length; i++) {
ArtifactType artifactType = artifactTypes[i];
- Artifact artifact = toArtifact(artifactType);
+ Artifact artifact = toArtifact(artifactType, "jar");
artifacts.add(artifact);
}
return artifacts;
@@ -196,7 +196,7 @@
}
private static Dependency toDependency(ArtifactType artifactType) {
- Artifact artifact = toArtifact(artifactType);
+ Artifact artifact = toArtifact(artifactType, "jar");
if (ImportType.CLASSES.equals(artifactType.getImport())) {
return new Dependency(artifact, org.apache.geronimo.kernel.repository.ImportType.CLASSES);
} else if (ImportType.SERVICES.equals(artifactType.getImport())) {
@@ -209,9 +209,9 @@
}
//TODO make private
- static Artifact toArtifact(ArtifactType artifactType) {
+ static Artifact toArtifact(ArtifactType artifactType, String defaultType) {
String groupId = artifactType.isSetGroupId() ? artifactType.getGroupId().trim() : null;
- String type = artifactType.isSetType() ? artifactType.getType().trim() : "jar";
+ String type = artifactType.isSetType() ? artifactType.getType().trim() : defaultType;
String artifactId = artifactType.getArtifactId().trim();
String version = artifactType.isSetVersion() ? artifactType.getVersion().trim() : null;
return new Artifact(groupId, artifactId, version, type);
Modified: geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java?rev=394439&r1=394438&r2=394439&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java (original)
+++ geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java Sat Apr 15 23:35:09 2006
@@ -27,12 +27,15 @@
import java.util.Collections;
import java.util.jar.JarFile;
import java.beans.PropertyEditorManager;
+import java.net.URI;
+import java.net.URL;
import javax.xml.namespace.QName;
import org.apache.geronimo.common.DeploymentException;
import org.apache.geronimo.deployment.ConfigurationBuilder;
import org.apache.geronimo.deployment.DeploymentContext;
+import org.apache.geronimo.deployment.util.DeploymentUtil;
import org.apache.geronimo.deployment.xbeans.AttributeType;
import org.apache.geronimo.deployment.xbeans.ConfigurationDocument;
import org.apache.geronimo.deployment.xbeans.ConfigurationType;
@@ -59,6 +62,7 @@
import org.apache.geronimo.kernel.repository.Artifact;
import org.apache.geronimo.kernel.repository.Environment;
import org.apache.geronimo.kernel.repository.Repository;
+import org.apache.geronimo.schema.SchemaConversionUtils;
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
@@ -115,13 +119,23 @@
}
}
- public Object getDeploymentPlan(File planFile, JarFile module) throws DeploymentException {
- if (planFile == null) {
+ public Object getDeploymentPlan(File planFile, JarFile jarFile) throws DeploymentException {
+ if (planFile == null && jarFile == null) {
return null;
}
try {
- XmlObject xmlObject = XmlBeansUtil.parse(planFile);
+ XmlObject xmlObject;
+ if (planFile != null) {
+ xmlObject = XmlBeansUtil.parse(planFile.toURL());
+ } else {
+ URL path = DeploymentUtil.createJarURL(jarFile, "META-INF/geronimo-service.xml");
+ xmlObject = XmlBeansUtil.parse(path);
+ }
+ if(xmlObject == null) {
+ return null;
+ }
+
XmlCursor cursor = xmlObject.newCursor();
try {
cursor.toFirstChild();
@@ -157,13 +171,13 @@
return environment.getConfigId();
}
- public DeploymentContext buildConfiguration(boolean inPlaceDeployment, Object plan, JarFile unused, Collection configurationStores, ConfigurationStore targetConfigurationStore) throws IOException, DeploymentException {
+ public DeploymentContext buildConfiguration(boolean inPlaceDeployment, Object plan, JarFile jar, Collection configurationStores, ConfigurationStore targetConfigurationStore) throws IOException, DeploymentException {
ConfigurationType configType = (ConfigurationType) plan;
- return buildConfiguration(configType, configurationStores, targetConfigurationStore);
+ return buildConfiguration(inPlaceDeployment, configType, jar, configurationStores, targetConfigurationStore);
}
- public DeploymentContext buildConfiguration(ConfigurationType configurationType, Collection configurationStores, ConfigurationStore targetConfigurationStore) throws DeploymentException, IOException {
+ public DeploymentContext buildConfiguration(boolean inPlaceDeployment, ConfigurationType configurationType, JarFile jar, Collection configurationStores, ConfigurationStore targetConfigurationStore) throws DeploymentException, IOException {
Environment environment = EnvironmentBuilder.buildEnvironment(configurationType.getEnvironment(), defaultEnvironment);
Artifact configId = environment.getConfigId();
@@ -175,6 +189,15 @@
}
DeploymentContext context = new DeploymentContext(outfile, null,environment, ConfigurationModuleType.SERVICE, naming, repositories, configurationStores);
+ if(jar != null) {
+ if(inPlaceDeployment) {
+ //todo: add the JAR to the configuration Class Path and do whatever else we need to (may need to set in-place directory on the DeploymentContext just above?)
+ throw new UnsupportedOperationException("In-place deployments are not supported yet for services");
+ } else {
+ File file = new File(jar.getName());
+ context.addIncludeAsPackedJar(URI.create(file.getName()), jar);
+ }
+ }
try {
ClassLoader cl = context.getClassLoader();
Re: svn commit: r394439 [1/3] - in /geronimo/branches/1.1: ./ applications/console-core/src/java/org/apache/geronimo/console/util/
applications/console-standard/src/java/org/apache/geronimo/console/car/ applications/console-standard/src/webapp/WEB-INF/view...
Posted by Gianny Damour <gi...@optusnet.com.au>.
ammulder@apache.org wrote:
>Author: ammulder
>Date: Sat Apr 15 23:35:09 2006
>New Revision: 394439
>
>URL: http://svn.apache.org/viewcvs?rev=394439&view=rev
>Log:
>Services can be deployed with a JAR and plan, or a plan in the JAR at
> META-INF/geronimo-service.xml (GERONIMO-1859)
>Improvements to configuration import/export, including more metadata
> and no installations just to gather metadata
>Improved handling for Artifacts that are missing parts (effectively
> wildcards)
>
>
>
<snip>
>Modified: geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
>URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java?rev=394439&r1=394438&r2=394439&view=diff
>==============================================================================
>--- geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java (original)
>+++ geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java Sat Apr 15 23:35:09 2006
>@@ -27,12 +27,15 @@
>
>
<snip>
>
> DeploymentContext context = new DeploymentContext(outfile, null,environment, ConfigurationModuleType.SERVICE, naming, repositories, configurationStores);
>+ if(jar != null) {
>+ if(inPlaceDeployment) {
>+ //todo: add the JAR to the configuration Class Path and do whatever else we need to (may need to set in-place directory on the DeploymentContext just above?)
>+ throw new UnsupportedOperationException("In-place deployments are not supported yet for services");
>+ } else {
>+ File file = new File(jar.getName());
>+ context.addIncludeAsPackedJar(URI.create(file.getName()), jar);
>+ }
>+ }
> try {
> ClassLoader cl = context.getClassLoader();
>
>
>
I have refactored DeploymentContext to easily add support for in-place
deployment of services (in a few words InPlaceEARContext has been
removed and DeploymentContext delegates to two distinct strategies).
Aaron, if you plan to work on in-place deployment of services, then I
think that I will get to that tomorrow during the day - so, if you can
wait until then...
Thanks,
Gianny