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 2005/11/13 18:13:04 UTC
svn commit: r333063 - in /geronimo/trunk: applications/console-standard/
applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/
applications/console-standard/src/webapp/WEB-INF/view/databasemanager/
applications/cons...
Author: ammulder
Date: Sun Nov 13 09:12:52 2005
New Revision: 333063
URL: http://svn.apache.org/viewcvs?rev=333063&view=rev
Log:
Add the ability to show the generated deployment plan for a database
pool you're creating.
Clean some cruft out of the JSR-88 module (it's elsewhere)
When DConfigBeans save a plan, make it least a minimal effort to make
it look pretty.
Added:
geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/showPlan.jsp (with props)
Removed:
geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/databasemanager/
geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/DConfigBeanRootSupport.java
geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/DConfigBeanSupport.java
geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/DeploymentConfigurationSupport.java
geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/XmlBeanSupport.java
Modified:
geronimo/trunk/applications/console-standard/project.xml
geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/DatabasePoolPortlet.java
geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/confirmURL.jsp
geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/edit.jsp
geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/testConnection.jsp
geronimo/trunk/modules/deploy-config/src/java/org/apache/geronimo/deployment/plugin/XmlBeanSupport.java
Modified: geronimo/trunk/applications/console-standard/project.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/project.xml?rev=333063&r1=333062&r2=333063&view=diff
==============================================================================
--- geronimo/trunk/applications/console-standard/project.xml (original)
+++ geronimo/trunk/applications/console-standard/project.xml Sun Nov 13 09:12:52 2005
@@ -87,6 +87,11 @@
</dependency>
<dependency>
<groupId>geronimo</groupId>
+ <artifactId>geronimo-deploy-config</artifactId>
+ <version>${pom.currentVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>geronimo</groupId>
<artifactId>geronimo-test-ddbean</artifactId>
<version>${pom.currentVersion}</version>
</dependency>
Modified: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/DatabasePoolPortlet.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/DatabasePoolPortlet.java?rev=333063&r1=333062&r2=333063&view=diff
==============================================================================
--- geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/DatabasePoolPortlet.java (original)
+++ geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/DatabasePoolPortlet.java Sun Nov 13 09:12:52 2005
@@ -24,6 +24,7 @@
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.StringReader;
+import java.io.ByteArrayOutputStream;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
@@ -107,12 +108,14 @@
private static final String CONFIRM_URL_VIEW = "/WEB-INF/view/dbwizard/confirmURL.jsp";
private static final String TEST_CONNECTION_VIEW = "/WEB-INF/view/dbwizard/testConnection.jsp";
private static final String DOWNLOAD_VIEW = "/WEB-INF/view/dbwizard/selectDownload.jsp";
+ private static final String SHOW_PLAN_VIEW = "/WEB-INF/view/dbwizard/showPlan.jsp";
private static final String LIST_MODE = "list";
private static final String EDIT_MODE = "edit";
private static final String SELECT_RDBMS_MODE = "rdbms";
private static final String BASIC_PARAMS_MODE = "params";
private static final String CONFIRM_URL_MODE = "url";
private static final String TEST_CONNECTION_MODE = "test";
+ private static final String SHOW_PLAN_MODE = "plan";
private static final String DOWNLOAD_MODE = "download";
private static final String EDIT_EXISTING_MODE = "editExisting";
private static final String SAVE_MODE = "save";
@@ -125,6 +128,7 @@
private PortletRequestDispatcher confirmURLView;
private PortletRequestDispatcher testConnectionView;
private PortletRequestDispatcher downloadView;
+ private PortletRequestDispatcher planView;
public void init(PortletConfig portletConfig) throws PortletException {
super.init(portletConfig);
@@ -135,6 +139,7 @@
confirmURLView = portletConfig.getPortletContext().getRequestDispatcher(CONFIRM_URL_VIEW);
testConnectionView = portletConfig.getPortletContext().getRequestDispatcher(TEST_CONNECTION_VIEW);
downloadView = portletConfig.getPortletContext().getRequestDispatcher(DOWNLOAD_VIEW);
+ planView = portletConfig.getPortletContext().getRequestDispatcher(SHOW_PLAN_VIEW);
}
public void destroy() {
@@ -145,6 +150,7 @@
confirmURLView = null;
testConnectionView = null;
downloadView = null;
+ planView = null;
super.destroy();
}
@@ -292,10 +298,14 @@
actionRequest.getPortletSession(true).setAttribute("connectError", stack);
actionResponse.setRenderParameter(MODE_KEY, TEST_CONNECTION_MODE);
} else {
- save(actionRequest, data);
+ save(actionRequest, data, false);
}
} else if(mode.equals(SAVE_MODE)) {
- save(actionRequest, data);
+ save(actionRequest, data, false);
+ } else if(mode.equals(SHOW_PLAN_MODE)) {
+ String plan = save(actionRequest, data, true);
+ actionRequest.getPortletSession(true).setAttribute("deploymentPlan", plan);
+ actionResponse.setRenderParameter(MODE_KEY, SHOW_PLAN_MODE);
} else if(mode.equals(EDIT_EXISTING_MODE)) {
final String name = actionRequest.getParameter("adapterObjectName");
loadConnectionFactory(actionRequest, name, data.getObjectName(), data);
@@ -474,6 +484,8 @@
renderConfirmURL(renderRequest, renderResponse);
} else if(mode.equals(TEST_CONNECTION_MODE)) {
renderTestConnection(renderRequest, renderResponse);
+ } else if(mode.equals(SHOW_PLAN_MODE)) {
+ renderPlan(renderRequest, renderResponse);
}
} catch (Throwable e) {
log.error("Unable to render portlet", e);
@@ -595,6 +607,12 @@
testConnectionView.include(renderRequest, renderResponse);
}
+ private void renderPlan(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
+ // Pass on results
+ renderRequest.setAttribute("deploymentPlan", renderRequest.getPortletSession().getAttribute("deploymentPlan"));
+ planView.include(renderRequest, renderResponse);
+ }
+
private static String attemptConnect(PortletRequest request, PoolData data) throws SQLException, IllegalAccessException, InstantiationException {
Class driverClass = attemptDriverLoad(request, data);
Driver driver = (Driver) driverClass.newInstance();
@@ -613,7 +631,7 @@
} else throw new SQLException("Driver "+data.getDriverClass()+" does not accept URL "+data.url);
}
- private static void save(PortletRequest request, PoolData data) {
+ private static String save(PortletRequest request, PoolData data, boolean planOnly) {
if(data.objectName == null || data.objectName.equals("")) { // we're creating a new pool
data.name = data.name.replaceAll("\\s", "");
DeploymentManager mgr = PortletManager.getDeploymentManager(request);
@@ -694,22 +712,29 @@
if(data.idleTimeout != null && !data.idleTimeout.equals("")) {
pool.setIdleTimeoutMinutes(new Integer(data.idleTimeout));
}
- File tempFile = File.createTempFile("console-deployment",".xml");
- tempFile.deleteOnExit();
- log.debug("Writing database pool deployment plan to "+tempFile.getAbsolutePath());
- BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(tempFile));
- config.save(out);
- out.flush();
- out.close();
- Target[] targets = mgr.getTargets();
- ProgressObject po = mgr.distribute(targets, new File(url.getPath()), tempFile);
- waitForProgress(po);
- if(po.getDeploymentStatus().isCompleted()) {
- TargetModuleID[] ids = po.getResultTargetModuleIDs();
- po = mgr.start(ids);
+ if(planOnly) {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ config.save(out);
+ out.close();
+ return new String(out.toByteArray(), "US-ASCII");
+ } else {
+ File tempFile = File.createTempFile("console-deployment",".xml");
+ tempFile.deleteOnExit();
+ log.debug("Writing database pool deployment plan to "+tempFile.getAbsolutePath());
+ BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(tempFile));
+ config.save(out);
+ out.flush();
+ out.close();
+ Target[] targets = mgr.getTargets();
+ ProgressObject po = mgr.distribute(targets, new File(url.getPath()), tempFile);
waitForProgress(po);
if(po.getDeploymentStatus().isCompleted()) {
- System.out.println("Deployment completed successfully!");
+ TargetModuleID[] ids = po.getResultTargetModuleIDs();
+ po = mgr.start(ids);
+ waitForProgress(po);
+ if(po.getDeploymentStatus().isCompleted()) {
+ System.out.println("Deployment completed successfully!");
+ }
}
}
} catch (Exception e) {
@@ -718,6 +743,9 @@
if(mgr != null) mgr.release();
}
} else { // We're saving updates to an existing pool
+ if(planOnly) {
+ throw new UnsupportedOperationException("Can't update a plan for an existing deployment");
+ }
try {
JCAManagedConnectionFactory factory = (JCAManagedConnectionFactory) PortletManager.getManagedBean(request, data.getObjectName());
if(data.isGeneric()) {
@@ -740,6 +768,7 @@
log.error("Unable to save connection pool", e);
}
}
+ return null;
}
private static void waitForProgress(ProgressObject po) {
Modified: geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/confirmURL.jsp
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/confirmURL.jsp?rev=333063&r1=333062&r2=333063&view=diff
==============================================================================
--- geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/confirmURL.jsp (original)
+++ geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/confirmURL.jsp Sun Nov 13 09:12:52 2005
@@ -85,7 +85,8 @@
<tr>
<td></td>
<td><input type="submit" value="Test Connection" />
- <input type="button" value="Skip Test" onclick="document.<portlet:namespace/>DatabaseForm.test.value='false';document.<portlet:namespace/>DatabaseForm.submit();return false;" />
+ <input type="button" value="Skip Test and Deploy" onclick="document.<portlet:namespace/>DatabaseForm.test.value='false';document.<portlet:namespace/>DatabaseForm.submit();return false;" />
+ <input type="button" value="Skip Test and Show Plan" onclick="document.<portlet:namespace/>DatabaseForm.mode.value='plan';document.<portlet:namespace/>DatabaseForm.submit();return false;" />
</td>
</tr>
</table>
Modified: geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/edit.jsp
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/edit.jsp?rev=333063&r1=333062&r2=333063&view=diff
==============================================================================
--- geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/edit.jsp (original)
+++ geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/edit.jsp Sun Nov 13 09:12:52 2005
@@ -205,18 +205,27 @@
<td>
<c:choose> <%-- Don't know how to test a non-generic pool, so you can only save it --%>
<c:when test="${pool.generic}">
- <c:choose> <%-- Can't test after deployment because we don't know what JAR to put on the ClassPath --%>
+ <c:choose> <%-- Can't test after deployment because we don't know what JAR to put on the ClassPath, can't show plan becasue we can't update a plan --%>
<c:when test="${empty pool.objectName}">
<input type="submit" value="Test Connection" />
- <input type="button" value="Skip Test" onclick="document.<portlet:namespace/>DatabaseForm.test.value='false';document.<portlet:namespace/>DatabaseForm.submit();return false;" />
+ <input type="button" value="Skip Test and Deploy" onclick="document.<portlet:namespace/>DatabaseForm.test.value='false';document.<portlet:namespace/>DatabaseForm.submit();return false;" />
+ <input type="button" value="Skip Test and Show Plan" onclick="document.<portlet:namespace/>DatabaseForm.mode.value='plan';document.<portlet:namespace/>DatabaseForm.submit();return false;" />
</c:when>
<c:otherwise>
<input type="button" value="Save" onclick="document.<portlet:namespace/>DatabaseForm.mode.value='save';document.<portlet:namespace/>DatabaseForm.submit();return false;" />
</c:otherwise>
</c:choose>
</c:when>
- <c:otherwise>
+ <c:otherwise> <%-- Not a generic JDBC pool --%>
+ <c:choose>
+ <c:when test="${empty pool.objectName}"> <%-- If it's new we can preview the plan or save/deploy --%>
+ <input type="button" value="Deploy" onclick="document.<portlet:namespace/>DatabaseForm.mode.value='save';document.<portlet:namespace/>DatabaseForm.submit();return false;" />
+ <input type="button" value="Show Plan" onclick="document.<portlet:namespace/>DatabaseForm.mode.value='plan';document.<portlet:namespace/>DatabaseForm.submit();return false;" />
+ </c:when>
+ <c:otherwise> <%-- If it's existing we can only save --%>
<input type="button" value="Save" onclick="document.<portlet:namespace/>DatabaseForm.mode.value='save';document.<portlet:namespace/>DatabaseForm.submit();return false;" />
+ </c:otherwise>
+ </c:choose>
</c:otherwise>
</c:choose>
</td>
Added: geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/showPlan.jsp
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/showPlan.jsp?rev=333063&view=auto
==============================================================================
--- geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/showPlan.jsp (added)
+++ geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/showPlan.jsp Sun Nov 13 09:12:52 2005
@@ -0,0 +1,91 @@
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
+<portlet:defineObjects/>
+
+<p><b>Create Database Pool</b> -- Step 4: Test Connection</p>
+
+<!-- FORM TO COLLECT DATA FOR THIS PAGE -->
+<form name="<portlet:namespace/>DatabaseForm" action="<portlet:actionURL/>">
+ <input type="hidden" name="mode" value="save" />
+ <input type="hidden" name="user" value="${pool.user}" />
+ <input type="hidden" name="name" value="${pool.name}" />
+ <input type="hidden" name="dbtype" value="${pool.dbtype}" />
+ <input type="hidden" name="password" value="${pool.password}" />
+ <input type="hidden" name="driverClass" value="${pool.driverClass}" />
+ <input type="hidden" name="url" value="${pool.url}" />
+ <input type="hidden" name="urlPrototype" value="${pool.urlPrototype}" />
+ <input type="hidden" name="jar1" value="${pool.jar1}" />
+ <input type="hidden" name="jar2" value="${pool.jar2}" />
+ <input type="hidden" name="jar3" value="${pool.jar3}" />
+ <input type="hidden" name="minSize" value="${pool.minSize}" />
+ <input type="hidden" name="maxSize" value="${pool.maxSize}" />
+ <input type="hidden" name="idleTimeout" value="${pool.idleTimeout}" />
+ <input type="hidden" name="blockingTimeout" value="${pool.blockingTimeout}" />
+ <input type="hidden" name="adapterDisplayName" value="${pool.adapterDisplayName}" />
+ <input type="hidden" name="adapterDescription" value="${pool.adapterDescription}" />
+ <input type="hidden" name="rarPath" value="${pool.rarPath}" />
+ <c:forEach var="prop" items="${pool.properties}">
+ <input type="hidden" name="${prop.key}" value="${prop.value}" />
+ </c:forEach>
+ <c:forEach var="prop" items="${pool.urlProperties}">
+ <input type="hidden" name="${prop.key}" value="${prop.value}" />
+ </c:forEach>
+ <table border="0">
+ <!-- STATUS FIELD: Deployment Plan -->
+ <tr>
+ <th valign="top"><div align="right">Deployment Plan:</div></th>
+ <td><textarea rows="30" cols="60" readonly>${deploymentPlan}</textarea></td>
+ </tr>
+ <!-- SUBMIT BUTTON -->
+ <tr>
+ <td></td>
+ <td>
+<input type="submit" value="Deploy Pool" />
+<input type="button" value="Edit Settings" onclick="document.<portlet:namespace/>DatabaseForm.mode.value='edit';document.<portlet:namespace/>DatabaseForm.submit();return false;" />
+ </td>
+ </tr>
+ <!-- STATUS FIELD: Command-line guidance -->
+ <tr>
+ <th valign="top"><div align="right">Deploy Command:</div></th>
+ <td>To deploy a database pool from the command line using this plan,
+ copy and paste it to a file (say, <tt>plan-file.xml</tt>) and save
+ it. Then run a command like:<br />
+<pre>
+cd GERONIMO_HOME
+java -jar bin/deployer.jar deploy plan-file.xml \
+ ${pool.rarPath}
+</pre></td>
+ </tr>
+ <!-- STATUS FIELD: Embed in EAR guidance -->
+ <tr>
+ <th valign="top"><div align="right">Add to EAR:</div></th>
+ <td>Instead of deploying as a top-level database pool, you
+ can deploy this pool as part of an EAR. To add a database
+ pool to an EAR using this plan:
+<ol>
+ <li>Copy and paste the plan to a file</li>
+ <li>Save the plan file to the top level of your EAR</li>
+ <li>Copy the RAR file from <tt>GERONIMO_HOME/repository/${pool.rarPath}</tt>
+ to the top level of your EAR</li>
+ <li>Create a <tt>META-INF/geronimo-application.xml</tt> file in your EAR
+ that has a <tt>module</tt> entry like this (substituting the correct
+ RAR file name and plan file name):</li>
+</ol>
+<pre>
+<application
+ xmlns="http://geronimo.apache.org/xml/ns/j2ee/application-1.0"
+ configId="MyApplication">
+ <module>
+ <connector>rar-file-name</connector>
+ <alt-dd>plan-file-name.xml</alt-dd>
+ </module>
+</application>
+</pre></td>
+ </tr>
+ </table>
+</form>
+<!-- END OF FORM TO COLLECT DATA FOR THIS PAGE -->
+
+<p><a href="<portlet:actionURL portletMode="view">
+ <portlet:param name="mode" value="list" />
+ </portlet:actionURL>">Cancel</a></p>
Propchange: geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/showPlan.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Modified: geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/testConnection.jsp
URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/testConnection.jsp?rev=333063&r1=333062&r2=333063&view=diff
==============================================================================
--- geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/testConnection.jsp (original)
+++ geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/dbwizard/testConnection.jsp Sun Nov 13 09:12:52 2005
@@ -48,7 +48,7 @@
<c:if test="${!(empty connectError)}">
<tr>
<th><div align="right">Test Error:</div></th>
- <td><textarea rows="30" cols="50">${connectError}</textarea></td>
+ <td><textarea rows="30" cols="60" readonly>${connectError}</textarea></td>
</tr>
</c:if>
<!-- SUBMIT BUTTON -->
@@ -57,11 +57,12 @@
<td>
<c:choose>
<c:when test="${empty connectResult}">
-<input type="submit" value="Save Anyway" />
+<input type="submit" value="Deploy Anyway" />
<input type="button" value="Edit Settings" onclick="document.<portlet:namespace/>DatabaseForm.mode.value='edit';document.<portlet:namespace/>DatabaseForm.submit();return false;" />
<input type="button" value="Test Again" onclick="document.<portlet:namespace/>DatabaseForm.mode.value='process-url';document.<portlet:namespace/>DatabaseForm.submit();return false;" />
</c:when><c:otherwise>
-<input type="submit" value="Save" />
+<input type="submit" value="Deploy" />
+<input type="button" value="Show Plan" onclick="document.<portlet:namespace/>DatabaseForm.mode.value='plan';document.<portlet:namespace/>DatabaseForm.submit();return false;" />
</c:otherwise>
</c:choose>
</td>
Modified: geronimo/trunk/modules/deploy-config/src/java/org/apache/geronimo/deployment/plugin/XmlBeanSupport.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-config/src/java/org/apache/geronimo/deployment/plugin/XmlBeanSupport.java?rev=333063&r1=333062&r2=333063&view=diff
==============================================================================
--- geronimo/trunk/modules/deploy-config/src/java/org/apache/geronimo/deployment/plugin/XmlBeanSupport.java (original)
+++ geronimo/trunk/modules/deploy-config/src/java/org/apache/geronimo/deployment/plugin/XmlBeanSupport.java Sun Nov 13 09:12:52 2005
@@ -26,6 +26,7 @@
import org.apache.xmlbeans.SchemaTypeLoader;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlOptions;
/**
*
@@ -57,7 +58,11 @@
}
public void toXML(OutputStream outputStream) throws IOException {
- xmlObject.save(outputStream);
+ XmlOptions options = new XmlOptions();
+ options.setSavePrettyPrint();
+ options.setSavePrettyPrintIndent(4);
+ options.setUseDefaultNamespace();
+ xmlObject.save(outputStream, options);
}
public void fromXML(InputStream inputStream) throws XmlException, IOException {