gpt4 book ai didi

java - 如何捕获 WTObject 的修订事件?

转载 作者:行者123 更新时间:2023-11-29 05:47:11 24 4
gpt4 key购买 nike

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

一些示例代码片段会有所帮助。运行良好的事件如下:

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);
}
}

是否有像 Revise 事件这样的单独事件以这种方式捕获?我该怎么做?

谢谢。

最佳答案

这是您的 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 命令行实用程序)

关于java - 如何捕获 WTObject 的修订事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15429038/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com