Class ComputedFact

  extended by com.novell.zos.jdl.ComputedFact

public class ComputedFact
extends java.lang.Object

ComputedFact is the base class for creating custom Computed Facts.

Computed Facts provide the ability to create custom calculations that extend the built-in factsets for a Grid Object. The Computed Fact is meant to be used in constraints.

Example to calculate how many instances of the job named "foo" that the user in the current job context is running. This value of this computed fact can be used in a constraint to limit the number of instances of a particular job that a user can run:

  class ActiveFooJobs(ComputedFact):

      def compute(self):
          count = 0
          ctx = self.getContext()
          if ctx == None:
              print "No context"
              jobInstance = ctx.getJobInstance()
              if jobInstance == None:
                  print "No job instance in context"
                  activejobs = getMatrix().getActiveJobs()
                  for j in activejobs:
                      state = j.getFact("jobinstance.state.string")
                      if j.getFact("") == "foo" and \
                          j.getFact("") == ctx.getFact("") and \
                          (state == "Running" or state == "Starting"):
          return count
In order to use a Computed Fact you must create a class that subclasses ComputedFact in a file and deploy that file to the server. The ComputedFact subclass name is not required to match the Computed Fact filename. The filename is the defined Computed Fact name. To use the Computed Fact, you must create a linked fact referencing the deployed ComputedFact. The linked fact is then used in constraints.

Method Summary
 ComputedFactContext getContext()
          Retrieve the context object for this Computed Fact instance.
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail


public ComputedFactContext getContext()
Retrieve the context object for this Computed Fact instance.

The context object allows read-only access to the Grid Objects in the evaluation context. For example, when a computed fact is evaluated in the context of a Start constraint, the context object provides access to the Job Instance's factset.

ComputedFactContext for this computed fact evaluation. None if there is no context

Copyright (c) 2008 Novell, Inc. All rights reserved.