Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Frost2012-09-28 12:06:44 -0400
committerChristopher Frost2012-09-28 12:06:44 -0400
commit13c245124e5a7e31cdd56c1b9a94c9647e43c240 (patch)
tree8e146e3cf2309621398381f5da3a2bc5be71b5db
parent61aee20325e5ba01540c33abd2cc0bc7bd4bc0ad (diff)
downloadorg.eclipse.virgo.kernel-13c245124e5a7e31cdd56c1b9a94c9647e43c240.tar.gz
org.eclipse.virgo.kernel-13c245124e5a7e31cdd56c1b9a94c9647e43c240.tar.xz
org.eclipse.virgo.kernel-13c245124e5a7e31cdd56c1b9a94c9647e43c240.zip
388436 New deployment system that avoids the Windows upload bug
-rw-r--r--org.eclipse.virgo.kernel.deployer/.classpath2
-rw-r--r--org.eclipse.virgo.management.console/src/main/java/org/eclipse/virgo/management/console/UploadServlet.java50
-rw-r--r--org.eclipse.virgo.management.console/src/main/webapp/WEB-INF/layouts/artifacts.html6
-rw-r--r--org.eclipse.virgo.management.console/src/main/webapp/js/artifacts.js66
-rw-r--r--org.eclipse.virgo.management.console/src/main/webapp/js/dumps.js2
-rw-r--r--org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/ArtifactsJSTests.java13
-rw-r--r--org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/stubs/types/Element.java3
-rw-r--r--org.eclipse.virgo.management.console/template.mf2
8 files changed, 70 insertions, 74 deletions
diff --git a/org.eclipse.virgo.kernel.deployer/.classpath b/org.eclipse.virgo.kernel.deployer/.classpath
index d7ea6ce0..dc2d9407 100644
--- a/org.eclipse.virgo.kernel.deployer/.classpath
+++ b/org.eclipse.virgo.kernel.deployer/.classpath
@@ -51,7 +51,7 @@
<classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.virgo.kernel.services"/>
<classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.virgo.kernel.artifact"/>
<classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.mirrored/org.eclipse.equinox.event/1.2.100.v20111010-1614/org.eclipse.equinox.event-1.2.100.v20111010-1614.jar"/>
- <classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.nano/org.eclipse.virgo.nano.deployer.api/3.6.0.D-20120926150825/org.eclipse.virgo.nano.deployer.api-3.6.0.D-20120926150825.jar" sourcepath="/IVY_CACHE/org.eclipse.virgo.nano/org.eclipse.virgo.nano.deployer.api/3.5.0.D-20120615071853/org.eclipse.virgo.nano.deployer.api-sources-3.5.0.D-20120615071853.jar"/>
+ <classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.nano/org.eclipse.virgo.nano.deployer.api/3.6.0.D-20120926150825/org.eclipse.virgo.nano.deployer.api-3.6.0.D-20120926150825.jar" sourcepath="/IVY_CACHE/org.eclipse.virgo.nano/org.eclipse.virgo.nano.deployer.api/3.6.0.D-20120926150825/org.eclipse.virgo.nano.deployer.api-sources-3.6.0.D-20120926150825.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.nano/org.eclipse.virgo.nano.deployer.hot/3.6.0.D-20120926150825/org.eclipse.virgo.nano.deployer.hot-3.6.0.D-20120926150825.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.nano/org.eclipse.virgo.nano.core/3.6.0.D-20120926150825/org.eclipse.virgo.nano.core-3.6.0.D-20120926150825.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.eclipse.virgo.mirrored/org.eclipse.osgi.services/3.3.0.v20120307-2102/org.eclipse.osgi.services-3.3.0.v20120307-2102.jar" sourcepath="/IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi.services/3.3.0.v20110513/org.eclipse.osgi.services-sources-3.3.0.v20110513.jar"/>
diff --git a/org.eclipse.virgo.management.console/src/main/java/org/eclipse/virgo/management/console/UploadServlet.java b/org.eclipse.virgo.management.console/src/main/java/org/eclipse/virgo/management/console/UploadServlet.java
index df5e9e3e..1c919e43 100644
--- a/org.eclipse.virgo.management.console/src/main/java/org/eclipse/virgo/management/console/UploadServlet.java
+++ b/org.eclipse.virgo.management.console/src/main/java/org/eclipse/virgo/management/console/UploadServlet.java
@@ -13,8 +13,15 @@ package org.eclipse.virgo.management.console;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
+import java.lang.management.ManagementFactory;
+import java.net.URI;
+import java.util.ArrayList;
import java.util.List;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.management.openmbean.CompositeDataSupport;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
@@ -35,9 +42,13 @@ import org.slf4j.LoggerFactory;
*/
public class UploadServlet extends HttpServlet {
+ private static final String[] DEPLOYMENT_IDENTITY_FIELDS = new String[]{"type", "symbolicName", "version"};
+
private static final int HTTP_RESPONSE_INTERNAL_SERVER_ERROR = 500;
private static final String ORG_ECLIPSE_VIRGO_KERNEL_HOME = "org.eclipse.virgo.kernel.home";
+
+ private static final String DEPLOYER_MBEAN_NAME = "org.eclipse.virgo.kernel:category=Control,type=Deployer";
private static final long serialVersionUID = 1L;
@@ -45,6 +56,8 @@ public class UploadServlet extends HttpServlet {
private static final Logger log = LoggerFactory.getLogger(UploadServlet.class);
+ private MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
+
private String serverHome = null;
private BundleContext bundleContext = null;
@@ -73,10 +86,9 @@ public class UploadServlet extends HttpServlet {
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
response.setContentType("text/html");
- PrintWriter writer = response.getWriter();
- writer.append("<ol id=\"uploadLocations\">");
@SuppressWarnings("unchecked")
List<FileItem> items = (List<FileItem>) upload.parseRequest(request);
+ List<File> uploadedFiles = new ArrayList<File>();
for (FileItem fileItem : items) {
if (!fileItem.isFormField()) {
String name = fileItem.getName();
@@ -84,17 +96,45 @@ public class UploadServlet extends HttpServlet {
File uploadedFile = new File(stagingDir, name);
fileItem.write(uploadedFile);
log.info(String.format("Uploaded artifact of size (%db) to %s", fileItem.getSize(), uploadedFile.getPath()));
- writer.append("<li>" + uploadedFile.getAbsolutePath() + "</li>");
+ uploadedFiles.add(uploadedFile);
}
}
}
- writer.append("</ol>");
- writer.close();
+ doDeployment(uploadedFiles, response);
} catch (Exception e) {
log.error(e.toString());
response.sendError(HTTP_RESPONSE_INTERNAL_SERVER_ERROR);
}
}
+
+ private void doDeployment(List<File> uploadedFiles, HttpServletResponse response) throws MalformedObjectNameException, NullPointerException, IOException{
+ ObjectName objectName = new ObjectName(DEPLOYER_MBEAN_NAME);
+ PrintWriter writer = response.getWriter();
+ writer.append("<ol id=\"uploadResults\">");
+ for (File file : uploadedFiles) {
+ URI uri = file.toURI();
+ try {
+ Object invoke = this.mBeanServer.invoke(objectName, "deploy", new Object[]{uri.toString()}, new String[]{String.class.getName()});
+ writer.append("<li>" + file.getName() + " deployed as " + getDeploymentIdentity(invoke) + "</li>");
+ } catch (Exception e) {
+ writer.append("<li>" + file.getName() + " failed to deploy '" + e.getMessage() + "'</li>");
+ }
+ }
+ writer.append("</ol>");
+ writer.close();
+ }
+
+ private String getDeploymentIdentity(Object deploymentIdentity) {
+ StringBuilder builder = new StringBuilder();
+ if(deploymentIdentity instanceof CompositeDataSupport){
+ CompositeDataSupport deploymentIdentityInstance = (CompositeDataSupport) deploymentIdentity;
+ Object[] all = deploymentIdentityInstance.getAll(DEPLOYMENT_IDENTITY_FIELDS);
+ builder.append(all[0]);
+ builder.append(" - ").append(all[1]);
+ builder.append(": ").append(all[2]);
+ }
+ return builder.toString();
+ }
private File createStagingDirectory() throws IOException {
File pathReference = new File(String.format("%s%s", this.serverHome, STAGING_DIR));
diff --git a/org.eclipse.virgo.management.console/src/main/webapp/WEB-INF/layouts/artifacts.html b/org.eclipse.virgo.management.console/src/main/webapp/WEB-INF/layouts/artifacts.html
index 8b67ff93..2fae1153 100644
--- a/org.eclipse.virgo.management.console/src/main/webapp/WEB-INF/layouts/artifacts.html
+++ b/org.eclipse.virgo.management.console/src/main/webapp/WEB-INF/layouts/artifacts.html
@@ -11,10 +11,10 @@
<li><input name="1" type="file" size="70"></input></li>
</ul>
</form>
- <div id="add-upload-box" class="upload-control" onclick="uploadManager.addUploadBox()"></div>
- <div id="minus-upload-box" class="upload-control" onclick="uploadManager.minusUploadBox()"></div>
+ <div id="add-upload-box" class="upload-control"></div>
+ <div id="minus-upload-box" class="upload-control"></div>
- <iframe id = "upload-target-id" name="upload-target" src="" onload="uploadManager.uploadComplete()"></iframe>
+ <iframe id="upload-target-id" name="upload-target" src=""></iframe>
<div class="button-container">
<div class="control-cap-left"></div>
diff --git a/org.eclipse.virgo.management.console/src/main/webapp/js/artifacts.js b/org.eclipse.virgo.management.console/src/main/webapp/js/artifacts.js
index e2e16994..1c32dffd 100644
--- a/org.eclipse.virgo.management.console/src/main/webapp/js/artifacts.js
+++ b/org.eclipse.virgo.management.console/src/main/webapp/js/artifacts.js
@@ -14,6 +14,9 @@
*/
function pageinit(){
uploadManager = new UploadManager();
+ $('#upload-target-id').load(uploadManager.deployComplete);
+ $('#add-upload-box').click(uploadManager.addUploadBox);
+ $('#minus-upload-box').click(uploadManager.minusUploadBox);
util.doQuery('search/org.eclipse.virgo.kernel:type=ArtifactModel,*', function (response){
tree = new Tree();
tree.setup(response.value, 'type');
@@ -42,7 +45,7 @@ var Tree = function() {
$.each(mbeans, function(index, mbean){
var artifact = new Artifact(util.readObjectName(mbean));
var artifactFilterValue = artifact[filter];
- if(-1 == filterMatches.indexOf(artifactFilterValue)){
+ if(-1 == $.inArray(artifactFilterValue, filterMatches)){
filterMatches.push(artifactFilterValue);
};
@@ -438,62 +441,21 @@ var UploadManager = function() {
$('#upload-list').append(self.getUploadFormElement('1'));
};
- this.uploadComplete = function(){
+ this.deployComplete = function(){
if(self.uploading){
- self.uploading = false;
var iframe = $('#upload-target-id');
- var locationLIs = $('#uploadLocations', iframe[0].contentDocument).children();
- var URLs = new Array();
- $.each(locationLIs, function(i, locationLI){
- var location = $(locationLI).text();
- URLs.push('file:' + location);
- });
- var numURLs = URLs.length;
- var error = false;
- self.deploy(URLs, function(){
- if (--numURLs == 0 && !error){
- alert("Deployment successful");
- }
- }, function(){
- --numURLs;
- error = true;
+ var results = $('#uploadResults', iframe[0].contentDocument).children();
+
+ var resultString = '';
+ $.each(results, function(i, result){
+ resultString = resultString + '\n' + $(result).text();
});
- self.resetForm();
- }
- };
-
- this.deploy = function(URLs, successFunction, failureFunction){
- var artifact = URLs.shift();
- var done = URLs.length == 0;
-
- var request = new Array();
- request.push({
- "type":"EXEC",
- "mbean":"org.eclipse.virgo.kernel:category=Control,type=Deployer",
- "operation":"deploy(java.lang.String)",
- "arguments":[artifact]
- });
-
- util.doBulkQuery(request, function(response){
- var error = response[0].error;
- if (error){
- console.log(error);
- alert(error);
- failureFunction();
- }else{
- successFunction();
- }
- }, function(xmlHttpRequest, textStatus, errorThrown){
- console.log(xmlHttpRequest, textStatus, errorThrown);
- alert('Deployment failed \'' + textStatus + '\': ' + xmlHttpRequest + ' ' + errorThrown);
- failureFunction();
- });
-
- // Tail recursion instead of a loop. Variety is the spice of life.
- if (!done){
- self.deploy(URLs, successFunction, failureFunction);
+ alert('Deployment result\n\n' + resultString);
+ self.resetForm();
+ self.uploading = false;
}
};
+
this.getUploadFormElement = function(number){
var uploadBox = $('<input />');
diff --git a/org.eclipse.virgo.management.console/src/main/webapp/js/dumps.js b/org.eclipse.virgo.management.console/src/main/webapp/js/dumps.js
index a099535c..256b12f9 100644
--- a/org.eclipse.virgo.management.console/src/main/webapp/js/dumps.js
+++ b/org.eclipse.virgo.management.console/src/main/webapp/js/dumps.js
@@ -235,7 +235,7 @@ var QuasiDataSource = function(dumpFolder){
self.updateData = function(callback){
util.doQuery('exec/org.eclipse.virgo.kernel:type=Medic,name=StateDumpInspector/listBundles/' + self.dumpFolder, function(response){
- //console.log(response.value);
+ console.log(response.value);
self.bundles = {};
$.each(response.value, function(index, item){
self.bundles[item.identifier] = { 'SymbolicName': item.symbolicName,
diff --git a/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/ArtifactsJSTests.java b/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/ArtifactsJSTests.java
index bdf98983..50ea6774 100644
--- a/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/ArtifactsJSTests.java
+++ b/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/ArtifactsJSTests.java
@@ -72,19 +72,10 @@ public class ArtifactsJSTests extends AbstractJSTests {
Element element4 = (Element) ((Function) scope.get("Element", scope)).construct(context, scope, new Object[]{"#uploadLocations"});
element3.setContentDocument(element4);
Dollar.setDollarLookupResultForIds(new Scriptable[]{element3}, 1);
- ScriptableObject.callMethod(uploadManager, "uploadComplete", new Object[]{});
+ ScriptableObject.callMethod(uploadManager, "deployComplete", new Object[]{});
assertFalse((Boolean) Context.jsToJava(ScriptableObject.getProperty(uploadManager, "uploading"), Boolean.class));
-
- readString("var URLs = ['artifact'];");
- Scriptable URLs = (Scriptable) scope.get("URLs", scope);
-
- readString("var successFunction = function(response){};");
- Function successFunction = (Function) scope.get("successFunction", scope);
-
- readString("var failureFunction = function(xmlHttpRequest, textStatus, errorThrown){};");
- Function failureFunction = (Function) scope.get("failureFunction", scope);
+ assertTrue(alertMsg.startsWith("Deployment result"));
- ScriptableObject.callMethod(uploadManager, "deploy", new Object[]{URLs, successFunction, failureFunction});
}
@Test
diff --git a/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/stubs/types/Element.java b/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/stubs/types/Element.java
index 5b807ad7..9e45dd0e 100644
--- a/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/stubs/types/Element.java
+++ b/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/stubs/types/Element.java
@@ -110,6 +110,9 @@ public class Element extends ParentStub {
CLICK_COUNT++;
}
+ public void jsFunction_load() {
+ }
+
public void jsFunction_submit() {
this.isSubmitted = true;
}
diff --git a/org.eclipse.virgo.management.console/template.mf b/org.eclipse.virgo.management.console/template.mf
index 68ed02a8..41e04a7e 100644
--- a/org.eclipse.virgo.management.console/template.mf
+++ b/org.eclipse.virgo.management.console/template.mf
@@ -16,6 +16,6 @@ Import-Template:
org.osgi.framework.*;version="0",
org.osgi.service.*;version="0",
org.osgi.util.tracker.*;version="0",
- javax.management;version="0",
+ javax.management.*;version="0",
javax.security.*;version="0"
Excluded-Exports: *

Back to the top