1

我正在使用 Windchill 10.0 M030。我创建了一个捕获一些操作的 Windchill 服务。我已经完成了删除、签入和状态更改事件的捕获,但我不知道如何捕获对象的修订事件。有人可以帮我吗?

一些示例代码片段会有所帮助。工作正常的事件如下:

public void notifyEvent(KeyedEvent event) throws RemoteException,
            WTException {


        if (event instanceof PersistenceManagerEvent) {
            notifyEvent((PersistenceManagerEvent) event);
        }
        if (event instanceof WorkInProgressServiceEvent) {
            notifyEvent((WorkInProgressServiceEvent) event);
        }
        if (event instanceof EPMWorkspaceManagerEvent) {
            notifyEvent((EPMWorkspaceManagerEvent) event);
        }

        if (event instanceof LifeCycleServiceEvent) {
            notifyEvent((LifeCycleServiceEvent) event);
        }
    }

是否有任何单独的事件,如修改事件以这种方式被捕获?我怎样才能做到这一点?

谢谢你。

4

1 回答 1

3

这是您的 ListenerAdapter 的代码:

public class VersionEventListenerAdapter extends ServiceEventListenerAdapter {

public VersionEventListenerAdapter(String serviceId) {
    super(serviceId);
}

public void notifyVetoableEvent(Object event) throws WTException, WTPropertyVetoException {
    if (!(event instanceof KeyedEvent)) {
        return;
    }

    Object target = ((KeyedEvent) event).getEventTarget();
    Object eventType = ((KeyedEvent) event).getEventType();

    if (eventType.equals(VersionControlServiceEvent.NEW_VERSION)
    {
       /** Call your business code here 
           example : yourMethod(target);
        **/
    }
}

然后服务注册监听器

public class MyStandardListenerService extends StandardManager implements MyListenerServiceInterface {

private static final long serialVersionUID = 1L;

protected synchronized void performStartupProcess() throws ManagerException {

    VersionEventListenerAdapter versionEventListenerAdapter = new VersionEventListenerAdapter(getName());
    getManagerService().addEventListener(versionEventListenerAdapter, VersionControlServiceEvent.generateEventKey(VersionControlServiceEvent.NEW_VERSION));

}

public static MyStandardListenerService newMyStandardListenerService() throws WTException {
    MyStandardListenerService instance = new MyStandardListenerService();
    instance.initialize();
    return instance;
}

这个新服务需要在 wt.properties 中注册。有关如何注册它的更多详细信息,请参阅定制器指南(使用 xconfmanager 命令行实用程序)

于 2013-03-15T10:32:10.837 回答