User bio
404 bio not found
Member since Nov 9, 2015
Pinned posts:
Replies:

Sure! I have this class (extending %JSON.Adaptor rather than using https://github.com/intersystems/isc-json would be almost as good):

Class pkg.isc.mcp.message.BaseRequest Extends (Ens.Request, %pkg.isc.json.adaptor)
{

/// This method is called by the Management Portal to determine
/// the content type that will be returned by the <method>%ShowContents</method>
/// Override to application/json for pkg.isc.mcp.types.BaseModel.cls extends both
/// %XML.Adaptor and %pkg.isc.json.adaptor but returns JSON
Method %GetContentType() As %String
{
  Quit "application/json"
}

Storage Default
{
<Type>%Storage.Persistent</Type>
}

}

With a subclass, pkg.isc.mcp.message.ToolCallRequest, that has a few more properties.

This shows up in the visual trace OOTB as:

A relevant note / tool I (re-?)discovered today: for critical sequences where an interrupt could leave the system in an inconsistent state, you can use the BREAK command to disable/enable Ctrl+C.

See: https://docs.intersystems.com/iris20191/csp/docbook/DocBook.UI.Page.cls?...

Here's some sample code covering both the "tracking variable" and "destructor" patterns:

Class TSL.Breakfest Extends %RegisteredObject
{
 
ClassMethod Run()
{
	Set initialInterruptState = $ZJob\4#2
	Try {
		// Should be able to break during this
		Hang 5
		Set e = 1/0
	} Catch e {
		// Should not be able to break starting here.
		Break 0
		Write !,"bad stuff happened"
		Hang 2
	}
	Break 0
	// Should not be able to break during this
	Hang 2
	Write !,"Got to the end of the critical cleanup step."
	Break initialInterruptState
}
 
ClassMethod RunObject()
{
	Set inst = ..%New()
	Hang 2
	Write !,"Killing inst..."
	Kill inst
}
 
/// This callback method is invoked by the <METHOD>%Close</METHOD> method to 
/// provide notification that the current object is being closed.
/// 
/// <P>The return value of this method is ignored.
Method %OnClose() As %Status [ Private, ServerOnly = 1 ]
{
	Set initialInterruptState = $ZJob\4#2
	// Concern: what if the <INTERRUPT> hits exactly here between Set and Break? Extremely hard to test. Not sure if this could happen.
	Break 0
	Hang 2
	Write !,"Finished %OnClose"
	Break initialInterruptState
	Quit $$$OK
}
 
}
Open Exchange applications:
Certifications & Credly badges:
Global Masters badges:
Followers:
Following: