Services

As an extension to the JaernCloud language, Services provide a means of implementing advanced business logic that is best suited for traditional languages such as C#. In fact, any existing CLR language can be used to implement services thanks to the Dynamic Language Runtime.

As a general rule, it's time to use a service when the query capabilities of nodes no longer suffice to represent the business logic. Another example is cases where a service can encapsulate the complexities of an advanced API and present a clean interface to the node model.

A service is made available to nodes in program tree using bind interface to implementation in object scope. The following examples uses a service to determine whether the current user has permissions to delete "items".

bind ISomeBusinessLogic to RolePermissions in application

page#index {
	
	// make some items available for the view
	item foreach item in model#items;

	// find out if the user can delete items
	canDeleteItems : ISomeBusinessLogic.CanDeleteItems;

	// example 1: nested node
	if canDeleteItems {
		-> doDeleteitems {
			// this action is only invokable if canDeleteItems is true
			// do the operation here
		}
	}

	// example 2: inline if
	-> doDeleteItems if canDeleteItems {
		// this action is only invokable if canDeleteItems is true
		// do the operation here
	}
}

Implementing Services

TODO: Describe use of T4 to generate partial classes for integration with C#

TODO: Describe service extensions methods on nodes. For example a buy action on a model node.

Last edited Oct 1, 2010 at 7:45 PM by jimmeyer, version 5

Comments

No comments yet.