示例代码
写入自定义委派
自定义委派将实现 PrincipaMatchDelegate 并覆盖 match(…) API,以提供一些自定义逻辑。以下示例显示了按用户名查找匹配的逻辑:
public WTPrincipal match(WTPrincipal querySpec) throws WTException {
if (querySpec == null || !(querySpec instanceof WTUser)) {
if (logger.isDebugEnabled()) logger.debug("Input principal is null");
return null;
}
// Clone right away to avoid auto-inflate when calling getters
WTUser querySpecClone = (WTUser) querySpec.cloneAsInflated();
String userName = ((WTUser) querySpecClone).getName();
if (userName == null || userName.trim().isEmpty()) return null;
WTPrincipal result = null;
String userNames[] = new String[] { userName };
result = OrganizationServicesHelper.manager.findPersistedUser
userNames, null /* email */, null /* fullName */, null /* surname
*/, null /* status */, null /* internal */, Boolean.FALSE /* disabled */);
return result;
}
Windchill 代码中的使用示例
<Windchill>\codebase\service.properties
<Windchill>\codebase\wt\org\delegate\PrincipalMatchDelegate.class
<Windchill>\codebase\wt\org\delegate\ImportedUserByUserNameMatchDelegate.class
<Windchill>\codebase\wt\org\delegate\ImportedUserByEmailIdMatchDelegate.class
<Windchill>\codebase\wt\org\delegate\ImportedUserByUserNameMatchDelegate.class
<Windchill>\codebase\wt\org\delegate\ReplicatedUserForActivationByUserNameMatchDelegate.class
<Windchill>\codebase\wt\org\delegate\ReplicatedUserForActivationByEmailIdMatchDelegate.class
随附的示例
<Windchill>\prog_examples\principal\principalmatchdelegate\ImportedUserByUserNameMatchDelegate.java
<Windchill>\prog_examples\principal\principalmatchdelegate\ReplicatedUserForActivationByUserNameMatchDelegate.java
相关的包/类 Javadoc
wt.org.delegate
这对您有帮助吗?