Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

/* Change to your package name */

package com.aame.listen;

/* javac -classpath z:/Windchill/codebase -d z:/Windchill/codebase *.java */


/* xconfmanager -t codebase/wt.properties -s
wt.services.service.4160=com.acme.listen.ListenService/com.acme.listen.StandardList
enService -p */

/* Change to import you Service Interface */


import com.aame.listen.ListenService;

import java.lang.String;

/* Standard imports for services */ import


wt.services.ManagerException; import
wt.services.ServiceEventListenerAdapter;
import wt.services.StandardManager;
import wt. session. SessionContext;
import wt.session.SessionHelper;
import wt. session. SessionServerHelper;
import wt.session.SessionMgr;
import wt.util.DebugFlag;
import wt.util.DebugProperties;
import wt.util.DebugType;
import wt.util.DebugWriter;
import wt.util.WTException;

/* Changes required here:


* Imports necessary for listening to particular events, in this case
* check-in and check-out events */
import wt.vc.wip.Workable;
import wt.vc.wip.WorkInProgressServiceEvent;

/**
* Listens for pre/post checkin events. When an event is
* "heard", prints messages to the MethodServer log and console.
* <p>
* Use the <code>newStandardListenService</code> static factory method(s),
* not the <code>StandardListenService</code> constructor, to construct
* instances of this class. Instances must be constructed using the static
* factory(s), in order to ensure proper initialization of the instance.
* <p>
*
**/

* /* Change to your class name */


public final class StandardListenService extends StandardManager
implements ListenService {
/* Standard class identification string */
private static final String CLASSNAME =
StandardListenService.class.getName();
/* Standard debug variables for services */
private static final boolean DEBUG = DebugProperties.isDebugOn(CLASSNAME);
private static final DebugWriter LOG =
(DEBUG ? DebugProperties.getWriter(CLASSNAME) : null);
/* Standard getter for class name */
public String getConceptualClassname() {
return CLASSNAME;
}
/*
Standard default factory for the class.*/
public static StandardListenService newStandardListenService()
throws WTException {
StandardListenService instance = new StandardListenService();
instance. initialize();
return instance;
/*
* Initializations of event
listeners */
/* Override inherited method */
protected void performStartupProcess() throws ManagerException {
/* Standard debug output */
if (DEBUG && DebugProperties.isTrace(this))
LOG.enter(CLASSNAME,"performStartupProcess");
/* Standard way to become admin */
SessionContext prey = SessionContext.newContext();
try {
SessionHelper.manager.setAdministrator();
}
catch (WTException wte){
System.err.println("StandardListenService: failed to set Administrator (ok if
installation)");
return;
}
finally {
SessionContext.setContext(prev);

}
/* Change: Add event listeners here */
getManagerService().addEventListener(
* new ServiceEventListenerAdapter( this.getConceptualClassname() ) { public
void notifyVetoableEvent( Object event )
* throws WTException {
* final Workable target =
* ((WorkInProgressServiceEvent)event).getOriginalCopy();
System.out.println("Listen hears PRE_CHECKIN: "); System.out.print("
target:");
System.out.println(target.toString());
* }

* }

* WorkInProgressServiceEvent.generateEventKey(
* WorkInProgressServiceEvent.PRE_CHECKIN ));
* getManagerService().addEventListener(
* new ServiceEventListenerAdapter( this.getConceptualClassname() ) { public
void notifyVetoableEvent( Object event )
* throws WTException {
* final Workable target =
* ((WorkInProgressServiceEvent)event).getOriginalCopy();
System.out.println("Listen hears POST_CHECKIN: "); System.out.print("
target:");
System.out.println(target.toString());
}

},

WorkInProgressServiceEvent.generateEventKey(
WorkInProgressServiceEvent.POST_CHECKIN ));
/* Standard debug output */
if (DEBUG && DebugProperties.isTrace(this))
LOG.exit(CLASSNAME,"performStartupProcess");
}
}

You might also like