Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added basic completion of header names for JMS for #5
- Loading branch information
Showing
7 changed files
with
2,560 additions
and
418 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module Camel { | ||
export var jmsHeaderSchema = { | ||
definitions: { | ||
headers: { | ||
properties: { | ||
JMSCorrelationID: { | ||
type: "java.lang.String" | ||
}, | ||
JMSDeliveryMode: { | ||
"type": "string", | ||
"enum": [ | ||
"PERSISTENT", | ||
"NON_PERSISTENT" | ||
] | ||
}, | ||
JMSDestination: { | ||
type: "javax.jms.Destination" | ||
}, | ||
JMSExpiration: { | ||
type: "long" | ||
}, | ||
JMSPriority: { | ||
type: "int" | ||
}, | ||
JMSReplyTo: { | ||
type: "javax.jms.Destination" | ||
}, | ||
JMSType: { | ||
type: "java.lang.String" | ||
}, | ||
JMSXGroupId: { | ||
type: "java.lang.String" | ||
} | ||
} | ||
}, | ||
"javax.jms.Destination": { | ||
type: "java.lang.String" | ||
} | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,102 +1,119 @@ | ||
module Camel { | ||
export function SendMessageController($scope, workspace:Workspace, localStorage) { | ||
var LANGUAGE_FORMAT_PREFERENCE = "defaultLanguageFormat"; | ||
var sourceFormat = workspace.getLocalStorage(LANGUAGE_FORMAT_PREFERENCE) || "javascript"; | ||
$scope.message = ""; | ||
// TODO Remove this if possible | ||
$scope.codeMirror = undefined; | ||
var options = { | ||
mode: { | ||
name: sourceFormat | ||
}, | ||
// Quick hack to get the codeMirror instance. | ||
onChange: function(codeMirror) { | ||
if(!$scope.codeMirror) { | ||
$scope.codeMirror = codeMirror; | ||
} | ||
export function SendMessageController($scope, workspace:Workspace, localStorage) { | ||
var LANGUAGE_FORMAT_PREFERENCE = "defaultLanguageFormat"; | ||
var sourceFormat = workspace.getLocalStorage(LANGUAGE_FORMAT_PREFERENCE) || "javascript"; | ||
$scope.message = ""; | ||
// TODO Remove this if possible | ||
$scope.codeMirror = undefined; | ||
var options = { | ||
mode: { | ||
name: sourceFormat | ||
}, | ||
// Quick hack to get the codeMirror instance. | ||
onChange: function (codeMirror) { | ||
if (!$scope.codeMirror) { | ||
$scope.codeMirror = codeMirror; | ||
} | ||
}; | ||
$scope.codeMirrorOptions = CodeEditor.createEditorSettings(options); | ||
} | ||
}; | ||
$scope.codeMirrorOptions = CodeEditor.createEditorSettings(options); | ||
|
||
$scope.headers = []; | ||
$scope.headers = []; | ||
|
||
$scope.addHeader = () => { | ||
$scope.headers.push({name: "", value: ""}); | ||
}; | ||
$scope.addHeader = () => { | ||
$scope.headers.push({name: "", value: ""}); | ||
}; | ||
|
||
// lets add a default header | ||
$scope.addHeader(); | ||
// lets add a default header | ||
$scope.addHeader(); | ||
|
||
$scope.removeHeader = (header) => { | ||
$scope.headers = $scope.headers.remove(header); | ||
}; | ||
$scope.removeHeader = (header) => { | ||
$scope.headers = $scope.headers.remove(header); | ||
}; | ||
|
||
// TODO Find out what this does | ||
$scope.$watch('workspace.selection', function () { | ||
workspace.moveIfViewInvalid(); | ||
}); | ||
//$scope.defaultHeaderNames = [ "JMSPriority", "JMSType", "breadCrumbId" ]; | ||
$scope.defaultHeaderNames = () => { | ||
var answer = []; | ||
if (isJmsEndpoint()) { | ||
angular.forEach(Camel.jmsHeaderSchema.definitions.headers.properties, (value, name) => { | ||
answer.push(name); | ||
}); | ||
} | ||
return answer; | ||
}; | ||
|
||
/** save the sourceFormat in preferences for later | ||
* Note, this would be controller specific preferences and not the global, overriding, preferences */ | ||
// TODO Use ng-selected="changeSourceFormat()" - Although it seemed to fire multiple times.. | ||
$scope.$watch('codeMirrorOptions.mode.name', function(newValue, oldValue) { | ||
workspace.setLocalStorage(LANGUAGE_FORMAT_PREFERENCE, newValue) | ||
}); | ||
// TODO Find out what this does | ||
$scope.$watch('workspace.selection', function () { | ||
workspace.moveIfViewInvalid(); | ||
}); | ||
|
||
var sendWorked = () => { | ||
$scope.message = ""; | ||
notification("success", "Message sent!"); | ||
}; | ||
/** save the sourceFormat in preferences for later | ||
* Note, this would be controller specific preferences and not the global, overriding, preferences */ | ||
// TODO Use ng-selected="changeSourceFormat()" - Although it seemed to fire multiple times.. | ||
$scope.$watch('codeMirrorOptions.mode.name', function (newValue, oldValue) { | ||
workspace.setLocalStorage(LANGUAGE_FORMAT_PREFERENCE, newValue) | ||
}); | ||
|
||
$scope.autoFormat = () => { | ||
setTimeout(() => { | ||
CodeEditor.autoFormatEditor($scope.codeMirror); | ||
}, 50); | ||
}; | ||
var sendWorked = () => { | ||
$scope.message = ""; | ||
notification("success", "Message sent!"); | ||
}; | ||
|
||
$scope.sendMessage = () => { | ||
var body = $scope.message; | ||
var selection = workspace.selection; | ||
if (selection) { | ||
var mbean = selection.objectName; | ||
if (mbean) { | ||
var headers = null; | ||
if ($scope.headers.length) { | ||
headers = {}; | ||
angular.forEach($scope.headers, (object) => { | ||
var key = object.name; | ||
if (key) { | ||
headers[key] = object.value; | ||
} | ||
}); | ||
} | ||
$scope.autoFormat = () => { | ||
setTimeout(() => { | ||
CodeEditor.autoFormatEditor($scope.codeMirror); | ||
}, 50); | ||
}; | ||
|
||
var jolokia = workspace.jolokia; | ||
// if camel then use a different operation on the camel context mbean | ||
var callback = onSuccess(sendWorked); | ||
if (selection.domain === "org.apache.camel") { | ||
var uri = selection.title; | ||
mbean = getSelectionCamelContextMBean(workspace); | ||
if (mbean) { | ||
if (headers) { | ||
jolokia.execute(mbean, "sendBodyAndHeaders(java.lang.String, java.lang.Object, java.util.Map)", uri, body, headers, callback); | ||
} else { | ||
jolokia.execute(mbean, "sendStringBody(java.lang.String, java.lang.String)", uri, body, callback); | ||
} | ||
} else { | ||
notification("error", "Could not find CamelContext MBean!"); | ||
$scope.sendMessage = () => { | ||
var body = $scope.message; | ||
var selection = workspace.selection; | ||
if (selection) { | ||
var mbean = selection.objectName; | ||
if (mbean) { | ||
var headers = null; | ||
if ($scope.headers.length) { | ||
headers = {}; | ||
angular.forEach($scope.headers, (object) => { | ||
var key = object.name; | ||
if (key) { | ||
headers[key] = object.value; | ||
} | ||
} else { | ||
var user = localStorage["activemqUserName"]; | ||
var pwd = localStorage["activemqPassword"]; | ||
}); | ||
} | ||
|
||
var jolokia = workspace.jolokia; | ||
// if camel then use a different operation on the camel context mbean | ||
var callback = onSuccess(sendWorked); | ||
if (selection.domain === "org.apache.camel") { | ||
var uri = selection.title; | ||
mbean = getSelectionCamelContextMBean(workspace); | ||
if (mbean) { | ||
if (headers) { | ||
jolokia.execute(mbean, "sendTextMessage(java.util.Map, java.lang.String, java.lang.String, java.lang.String)", headers, body, user, pwd, callback); | ||
jolokia.execute(mbean, "sendBodyAndHeaders(java.lang.String, java.lang.Object, java.util.Map)", uri, body, headers, callback); | ||
} else { | ||
jolokia.execute(mbean, "sendTextMessage(java.lang.String, java.lang.String, java.lang.String)", body, user, pwd, callback); | ||
jolokia.execute(mbean, "sendStringBody(java.lang.String, java.lang.String)", uri, body, callback); | ||
} | ||
} else { | ||
notification("error", "Could not find CamelContext MBean!"); | ||
} | ||
} else { | ||
var user = localStorage["activemqUserName"]; | ||
var pwd = localStorage["activemqPassword"]; | ||
if (headers) { | ||
jolokia.execute(mbean, "sendTextMessage(java.util.Map, java.lang.String, java.lang.String, java.lang.String)", headers, body, user, pwd, callback); | ||
} else { | ||
jolokia.execute(mbean, "sendTextMessage(java.lang.String, java.lang.String, java.lang.String)", body, user, pwd, callback); | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
}; | ||
|
||
function isJmsEndpoint() { | ||
// TODO check for the jms/activemq endpoint in camel or if its an activemq endpoint | ||
//var selection = workspace.selection; | ||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.