com.softwareag.mdm.service
Class ProgrammaticService

java.lang.Object
  extended bycom.softwareag.mdm.service.ProgrammaticService

public class ProgrammaticService
extends Object

This class provides the ability to log programmatically a user session so as to be able to execute procedures in a well-defined context, for example in a script or in a batch.

Usage of this class

For creating an instance of this class, the external program an authenticated session and a home:

 ProgrammaticService.createForSession(Session, AdaptationHome)

For updating the repository, for importing or exporting data, a Procedure.execute() method must be called in transactional container via:

 ProgrammaticService.execute(Procedure)

Code sample

 Session session = Repository.getDefault().createSessionFromLoginPassword("xxx", "yyy");
 AdaptationHome home = Repository.getDefault().lookupHome(BranchKey.forName("myBranch"));
 ProgrammaticService svc = ProgrammaticService.createForSession(session, home);
  // optional
 svc.setSessionTrackingInfo("My Script Sample");
 Procedure proc = new Procedure()
  {
 public void execute(ProcedureContext aContext) throws Exception
 {
 // ...
 }
 };
 ProcedureResult result = svc.execute(proc);
 if (result.hasFailed())
 // ...
 else
 //...
 


Method Summary
static ProgrammaticService createForLogin(String login, String password)
          Deprecated. Replaced by createForSession(Session, AdaptationHome).
static ProgrammaticService createForSession(Session aSession, AdaptationHome aHome)
          Instantiates a service that will execute as the session specified in the home specified.
 ProcedureResult execute(Procedure aProcedure)
          Executes the procedure specified.
 AdaptationHome getCurrentHome()
          Returns the current branch or version of this service.
 Session getSession()
          Returns the current session of this service.
 void setSessionTrackingInfo(String trackingInfo)
          Specifies session's tracking info.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createForLogin

public static ProgrammaticService createForLogin(String login,
                                                 String password)
Deprecated. Replaced by createForSession(Session, AdaptationHome).


createForSession

public static ProgrammaticService createForSession(Session aSession,
                                                   AdaptationHome aHome)
Instantiates a service that will execute as the session specified in the home specified.


execute

public ProcedureResult execute(Procedure aProcedure)
Executes the procedure specified. It calls in a transactional container the implementation of Procedure.execute(ProcedureContext).

Returns:
the result of the execution (particularly, whether it has thrown an exception).

getCurrentHome

public AdaptationHome getCurrentHome()
Returns the current branch or version of this service.


getSession

public Session getSession()
Returns the current session of this service.


setSessionTrackingInfo

public void setSessionTrackingInfo(String trackingInfo)
Specifies session's tracking info.

See Also:
Session.getTrackingInfo()


(report a bug)
webMethods MDM 4.2.8 [0558]
Copyright Software AG 2000-2007. All rights reserved.