From VisualWorks®, 7.6 of February 1, 2008 on February 1, 2008 at 1:11:00 pm (Dialog confirm: 'You are filing-in a Parcel source file!\\While this is possible it will not have\the same effect as loading the parcel.\None of the Parcel''s prerequisites will\be loaded and none of its load actions\will be performed.\\Are you sure you want to file-in?' withCRs) ifFalse: [self error: 'Parcel file-in abandoned. Choose terminate or close.'] <class> <name>QueueBrowser</name> <environment>MQ</environment> <super>UI.ApplicationModel</super> <private>false</private> none portNumber serverChannel queueName hostName qm q connected messageList2 queueNameList <imports></imports> <category>UIApplications-New</category> <attributes> <package>MQ-Browser</package> </attributes> </class> <comment> MQ.QueueBrowser
QueueBrowser is a simple browser for MQ. It allows the naming of an MQ host, its server channel and (optional) aport number, in order to connect to a queue manager. A queue name can be specified, which then can be browsed and emptied. A test message can be send to that queue, too. Instance Variables: connected <ValueModel> connection status of the queueManager hostName <ValueModel> the hostName messageList2 <SelectionInList> list of message objects fetched from the queue portNumber <ValueHolder> the port number q <BrowseQueue> the queue qm <RemoteQueueManager> the queueManager queueName <ValueModel> name of the queue serverChannel <ValueModel> name of the serverChannel
</comment> <methods> MQ.QueueBrowser <category>actions</category>
browseQueue "Browse the queue and display its messages in the dataSet" | messages m | (qm notNil and: [qm isConnected]) ifFalse: [self connect. qm isConnected ifFalse: [^self]]. q := qm getBrowseQueue: self queueName value. q browseFirst. q noWait. messages := List new. [m := q getIncomingMessage. q browseNext. m isNil] whileFalse: [messages add: m]. self messageList2 list: messages. Transcript show: 'Messages: ' , messages size printString; cr
connect "Connect to the queue manager" | pn | (pn := self portNumber value) = 0 ifTrue: ["Zero is the default model of an Number input field, but MQ manager interface regards it as decent port number value and will fail with this setting (MQRC_Q_MGR_NOT_AVAILABLE). Force input field back to nil." self portNumber value: (pn := nil)]. (qm := QueueManager setDevelopment new: #remote threaded: false) host: self hostName value; port: pn; channel: self serverChannel value; connect. self connected value: qm isConnected
disconnect "Disconnect from the queue manager" qm isConnected ifTrue: [qm disconnect]. self connected value: qm isConnected
emptyQueue "Fetch all messages from the queue" | m | (qm notNil and: [qm isConnected]) ifFalse: [self connect. qm isConnected ifFalse: [^self]]. q := qm getReceiverQueue: self queueName value. q noWait. [m := q getIncomingMessage. m isNil] whileFalse. q close. q := nil. self browseQueue
sendTestMessage | m | (qm notNil and: [qm isConnected]) ifFalse: [self connect. qm isConnected ifFalse: [^self]]. q := qm getSenderQueue: self queueName value. m := q newAsynchronousMessage. m data: 'This is a Test!'. q put: m. q close. q := nil. self browseQueue
</methods> <methods> MQ.QueueBrowser <category>interface closing</category>
closeRequest "Propperly close the queue and disconnect from the queue manager" q close. qm disconnect. super closeRequest
</methods> <methods> MQ.QueueBrowser <category>aspects</category>
connected "This method was generated by UIDefiner. Any edits made here may be lost whenever methods are automatically defined. The initialization provided below may have been preempted by an initialize method." ^connected isNil ifTrue: [connected := false asValue] ifFalse: [connected]
hostName "Answer the ValueHolder with the name of the host that runs the MQ manager. Return: ValueHolder on: String" ^hostName isNil ifTrue: [| setup aString | aString := (setup := self mqSetup) isNil ifTrue: [String new] ifFalse: [setup host]. hostName := aString asValue] ifFalse: [hostName]
messageList2 "This method was generated by UIDefiner. Any edits made here may be lost whenever methods are automatically defined. The initialization provided below may have been preempted by an initialize method." ^messageList2 isNil ifTrue: [messageList2 := SelectionInList new] ifFalse: [messageList2]
portNumber "Answer the ValueHolder with the MQ service port number. Return: ValueHolder on: Integer" ^portNumber isNil ifTrue: [portNumber := nil asValue] ifFalse: [portNumber]
queueName "This is the default request queue for SiView requests." ^queueName isNil ifTrue: [queueName := self queueNameList value first asValue. queueName onChangeSend: #updateForNewQueueName to: self. queueName] ifFalse: [queueName]
queueNameList "Answer the ValueHolder with the list of existing and browsable queue names. Return: ValueHolder on: (List of: String)" ^queueNameList isNil ifTrue: [| list | list := #('ARM.DEV_REQUEST01' 'ASP.EDC_REQUEST05' 'CEI.ORANGE_TEST01' 'CEI.PINK_TEST01' 'CEI.BLUE_TEST01'). #{MQ.MQTestServices} ifDefinedDo: [:theClass | theClass isHeegEnvironment ifTrue: ["replace default list which is proper for AMD with Heeg queue name list" list := #(#FirstQueueName #SecondQueueName #ModelQueueName #BlueQueueName) collect: [:each | theClass asNameSpace dataAt: each ifAbsent: []]]]. list := list asSet. (QueueManager registry reject: [:each | each == 0 | each isNil]) do: [:each | each allQueues do: [:aQueue | list add: aQueue queueName trimBlanks]]. queueNameList := list asSortedCollection asList asValue] ifFalse: [queueNameList]
selMsg ^ self messageList2 selectionHolder
serverChannel "Answer the ValueHolder with the name of the MQ manager connect channel. Return: ValueHolder on: String" ^serverChannel isNil ifTrue: [| setup aString | aString := (setup := self mqSetup) isNil ifTrue: [String new] ifFalse: [setup channelName]. serverChannel := aString asValue] ifFalse: [serverChannel]
</methods> <methods> MQ.QueueBrowser <category>testing</category>
hasMessages "Answer true if the messages list is not empty, false otherwise" ^self messageList2 list isEmpty not
isMessageSelected "Answer true if some element in the messages list is selected, false otherwise" ^self messageList2 selection notNil
</methods> <methods> MQ.QueueBrowser <category>initialize-release</category>
initialize self connected onChangeSend: #updateButtonStatus to: self
</methods> <methods> MQ.QueueBrowser <category>menu actions</category>
inspectAllMessages "Open an Inspector with all messages." self messageList2 list asArray inspect
inspectMessage "Open an Inspector on the selected message." self messageList2 selection inspect
</methods> <methods> MQ.QueueBrowser <category>private</category>
mqSetup "Answer the MQ setup for this platform. Settings are known for tests only, so return nil if tests are not loaded." ^#{MQTestConfiguration} ifDefinedDo: [:theClass | theClass current]
updateButtonStatus "Button for connect shall be enabled only if not connected. Button for disconnect shall be enabled only if connected." | isConnected | isConnected := self connected value. (self wrapperAt: #ConnectButton) isEnabled: isConnected not. (self wrapperAt: #DisconnectButton) isEnabled: isConnected
</methods> <methods> MQ.QueueBrowser <category>interface opening</category>
postOpenWith: aBuilder self updateButtonStatus
</methods> <methods> MQ.QueueBrowser <category>updating</category>
updateForNewQueueName queueNameList value detect: [ :e | e = queueName value ] ifNone: [queueNameList value add: queueName value]. self browseQueue
</methods> <methods> MQ.MQMessage <category>printing</category>
correlIDString "Answer the string contents of structure field 'CorrelId' (w/o null bytes or white space)" ^self correlationID asString trimMQTrailer
</methods> <methods> MQ.MQMessage <category>user interface</category>
inspectorExtraAttributes ^Array with: (Tools.Trippy.DerivedAttribute label: 'message ID' valueBlock: [self messageID]) with: (Tools.Trippy.DerivedAttribute label: 'correl ID' valueBlock: [self correlationID]) with: (Tools.Trippy.DerivedAttribute label: 'data string' valueBlock: [self shortDataString])
</methods> <methods> MQ.MQMessage <category>printing</category>
messageIDString ^ self messageID asString
putDateNiceString "Answer the string contents of structure field 'PutDate', with date token characters inserted for a nice date print string look, e.g. '20040927' -> '2004-09-27' " | raw aStream | (raw := self putDateString) isEmpty ifTrue: [^raw]. aStream := raw readStream. ^((String new: raw size + 10) writeStream) nextPutAll: (aStream next: 4); nextPut: $-; nextPutAll: (aStream next: 2); nextPut: $-; nextPutAll: (aStream next: 2); contents
putDateString "Answer the string contents of structure field 'PutDate' (w/o white space)" ^self putDate asString trimBlanks
putDateTimeNiceString "Answer the string contents of structure field 'PutDate'+'PutTime', with time token characters inserted for a nice timestamp print string look, e.g. '2004092715290526' -> '2004-09-27 15:29:05.26' " | raw aStream | (raw := self putDateString) isEmpty ifTrue: [^raw]. raw := raw, self putTimeString. aStream := raw readStream. ^((String new: raw size + 10) writeStream) nextPutAll: (aStream next: 4); nextPut: $-; nextPutAll: (aStream next: 2); nextPut: $-; nextPutAll: (aStream next: 2); space; nextPutAll: (aStream next: 2); nextPut: $:; nextPutAll: (aStream next: 2); nextPut: $:; nextPutAll: (aStream next: 2); nextPut: $.; nextPutAll: aStream upToEnd; contents
putTimeString "Answer the string contents of structure field 'PutTime' (w/o white space)" ^self putTime asString trimBlanks
shortDataString "Answer data bytes as String, limited to maximum length" | bytes maxLength | (bytes := self data) isNil ifTrue: [^'nil']. (bytes allSatisfy: [:byte | byte = 0]) ifTrue: [^'(ByteArray new: ', bytes size printString, ')']. bytes size > (maxLength := 1024) ifTrue: [bytes := (bytes copyFrom: 1 to: maxLength) , #[46 46 46]]. ^bytes asString
userIdentifierString "Answer the string contents of structure field 'UserIdentifier' (w/o white space)" ^self userIdentifier asString trimBlanks
</methods> <methods> MQ.QueueBrowser class <category>resources</category>
listMenu "Tools.MenuEditor new openOnClass: self andSelector: #listMenu" <resource: #menu> ^#(#{UI.Menu} #( #(#{UI.MenuItem} #rawLabel: '&Inspect' #value: #inspectMessage #enablementSelector: #isMessageSelected #labelImage: #(#{UI.ResourceRetriever} #{Tools.ToolbarIconLibrary} #inspect ) #helpText: 'Open an Inspector on the selected message' ) #(#{UI.MenuItem} #rawLabel: 'Inspect &All' #value: #inspectAllMessages #enablementSelector: #hasMessages #helpText: 'Open an Inspector with all messages' ) ) #(2 ) nil ) decodeAsLiteralArray
</methods> <methods> MQ.QueueBrowser class <category>interface specs</category>
windowSpec "Tools.UIPainter new openOnClass: self andSelector: #windowSpec" <resource: #canvas> ^#(#{UI.FullSpec} #window: #(#{UI.WindowSpec} #label: 'MQ-Browser' #bounds: #(#{Graphics.Rectangle} 640 512 1209 964 ) ) #component: #(#{UI.SpecCollection} #collection: #( #(#{UI.LabelSpec} #layout: #(#{Core.Point} 8 13 ) #name: #lblQueueName #label: 'Queue-Name:' ) #(#{UI.ComboBoxSpec} #layout: #(#{Graphics.Rectangle} 108 11 475 35 ) #name: #cbQueueName #model: #queueName #helpText: 'Enter or select a queue name' #isReadOnly: false #comboList: #queueNameList ) #(#{UI.ActionButtonSpec} #layout: #(#{Graphics.Rectangle} 481 8 565 38 ) #name: #BrowseButton #model: #browseQueue #helpText: 'Browse the selected queue' #label: 'Browse ...' #defaultable: true ) #(#{UI.DataSetSpec} #properties: #(#{UI.PropertyListDictionary} #showHorizontalLines true #allowColumnResizing true #showVerticalLines true #allowColumnReordering false #showLineNumbers true ) #layout: #(#{Graphics.LayoutFrame} 8 0 46 0 -6 1 -133 1 ) #name: #Dataset1 #model: #messageList2 #menu: #listMenu #columns: #( #(#{UI.DataSetColumnSpec} #properties: #(#{UI.PropertyListDictionary} #allowSorting true #labelFromApplication false ) #labelIsImage: false #width: 30 #rendererType: #rowSelector #editorType: #rowSelector #noScroll: true ) #(#{UI.DataSetColumnSpec} #properties: #(#{UI.PropertyListDictionary} #allowSorting true #labelFromApplication false ) #model: #'selMsg messageIDString' #label: 'MsgID' #labelFont: #default #labelIsImage: false #width: 80 #rendererType: #Text #editorType: #None #font: #fixed #noScroll: false ) #(#{UI.DataSetColumnSpec} #properties: #(#{UI.PropertyListDictionary} #allowSorting true #labelFromApplication false ) #model: #'selMsg correlIDString' #label: 'Correl ID' #labelFont: #default #labelIsImage: false #width: 80 #rendererType: #Text #editorType: #None #noScroll: false ) #(#{UI.DataSetColumnSpec} #properties: #(#{UI.PropertyListDictionary} #allowSorting true #labelFromApplication false ) #model: #'selMsg putDateTimeNiceString' #label: 'Put Date' #labelFont: #default #labelIsImage: false #width: 80 #rendererType: #Text #editorType: #None #noScroll: false ) #(#{UI.DataSetColumnSpec} #properties: #(#{UI.PropertyListDictionary} #allowSorting true #labelFromApplication false ) #model: #'selMsg userIdentifierString' #label: 'User' #labelFont: #default #labelIsImage: false #width: 60 #rendererType: #Text #editorType: #None #noScroll: false ) #(#{UI.DataSetColumnSpec} #properties: #(#{UI.PropertyListDictionary} #allowSorting true #labelFromApplication false ) #model: #'selMsg shortDataString' #label: 'Data' #labelFont: #default #labelIsImage: false #width: 400 #rendererType: #Text #editorType: #None #font: #systemDefault #noScroll: false ) ) #labelsAsButtons: false ) #(#{UI.ActionButtonSpec} #layout: #(#{Graphics.LayoutFrame} 331 0 -122 1 452 0 -100 1 ) #name: #btnSendTest #model: #sendTestMessage #helpText: 'Send a test message to the selected queue' #label: 'Send Testmessage' #defaultable: true ) #(#{UI.ActionButtonSpec} #layout: #(#{Graphics.LayoutFrame} 459 0 -122 1 550 0 -100 1 ) #name: #btnEmptyQueue #model: #emptyQueue #helpText: 'Remove all messages from the queue' #label: 'Empty queue' #defaultable: true ) #(#{UI.DividerSpec} #layout: #(#{Graphics.LayoutFrame} 8 0 -98 1 -8 1 -94 1 ) #name: #Divider1 ) #(#{UI.LabelSpec} #layout: #(#{Graphics.LayoutOrigin} 7 0 -83 1 ) #name: #lblHostname #label: 'Host:' ) #(#{UI.InputFieldSpec} #layout: #(#{Graphics.LayoutFrame} 110 0 -84 1 386 0 -62 1 ) #name: #txtHostname #model: #hostName ) #(#{UI.LabelSpec} #layout: #(#{Graphics.LayoutOrigin} 7 0 -55 1 ) #name: #lblPortNumber #label: 'Port:' ) #(#{UI.InputFieldSpec} #layout: #(#{Graphics.LayoutFrame} 110 0 -56 1 385 0 -34 1 ) #name: #txtPortNumber #model: #portNumber #type: #number #formatString: '0;[Red]-0' ) #(#{UI.LabelSpec} #layout: #(#{Graphics.LayoutOrigin} 7 0 -29 1 ) #name: #lblServerChannel #label: 'Server Channel:' ) #(#{UI.InputFieldSpec} #layout: #(#{Graphics.LayoutFrame} 110 0 -30 1 385 0 -8 1 ) #name: #txtServerChannel #model: #serverChannel ) #(#{UI.ActionButtonSpec} #layout: #(#{Graphics.LayoutFrame} 428 0 -87 1 554 0 -54 1 ) #name: #ConnectButton #model: #connect #helpText: 'You are NOT connected right now!' #label: 'Connect' #defaultable: true ) #(#{UI.ActionButtonSpec} #layout: #(#{Graphics.LayoutFrame} 428 0 -51 1 554 0 -18 1 ) #name: #DisconnectButton #model: #disconnect #helpText: 'You are connected!' #label: 'Disconnect' #defaultable: true ) ) ) )
</methods> <methods> Tools.VisualLauncher <category>actions</category>
openMQBrowser "Open the WebSphere MQ Queue Browser." <menuItem: 'MQ-Browser' icon: nil nameKey: nil menu: #(#menuBar #tools ) position: 100.0> MQ.QueueBrowser open
</methods> "Imported Classes:" self error: 'Attempting to file-in parcel imports. Choose terminate or close' <class> <name>ApplicationModel</name> <environment>UI</environment> <super>UI.Model</super> <private>false</private> none builder uiSession eventHandlers savedWindowInformation <imports></imports> <category>UIBuilder-Framework</category> <attributes> <package>UIBuilder-Framework</package> </attributes> </class> <class> <name>MQMessage</name> <environment>MQ</environment> <super>Core.Object</super> <private>false</private> none messageHndl data targetQueue reportOptions msgTypeNumber <imports></imports> <category>MQ-Domain</category> <attributes> <package>MQ-Domain</package> </attributes> </class> <class> <name>VisualLauncher</name> <environment>Tools</environment> <super>UI.ApplicationModel</super> <private>false</private> none menuBar toolBar textCollector toolDock <imports></imports> <category>Tools-Misc</category> <attributes> <package>Tools-Misc</package> </attributes> </class>