与其他应用程序集成 > Windchill Workgroup Manager 文档 > NX > 管理和配置 > 使用 NX 配置业务实践 > 配置命名和编号 > 自定义命名服务
  
自定义命名服务
命名服务使用 Windchill 服务委派机制,允许您为要创建的新 CAD 文档指定以下项目:
设置 CAD 文档的编号。
设置 CAD 文档的名称。
* 
命名服务只适用于上载操作。
由命名策略和自定义系统所使用的优先级顺序如下所示。
命名
1. 命名服务自定义。
2. 命名的参数集 (命名参数)。
3. 文件名称。如果基于文件名称 (CAD 名称) 对名称进行分配,首选项“上载丢弃名称文件扩展名”才有效。
编号
1. 命名服务自定义。
2. 编号的参数集 (“编号参数”)。
3. 文件名称。如果基于文件名称 (CAD 名称) 对名称进行分配,首选项“上载丢弃名称文件扩展名”才有效。
如果标准的 Windchill 命名和编号策略无法满足您公司的需求,则可以自定义服务以基于此自定义逻辑为 CAD 文档分配名称和编号。使用以下步骤来自定义命名服务:
1. 创建一个实现接口 EPMDocumentNamingDelegate 的 Java 类。接口定义如下。
package com.ptc.windchill.uwgm.proesrv.c11n;
public interface EPMDocumentNamingDelegate
{
public void validateDocumentIdentifier

(DocIdentifier docIdentifier);
}
类 DocIdentifier 的定义如下:
package com.ptc.windchill.uwgm.proesrv.c11n;
import java.util.HashMap;
public class DocIdentifier
{
private String m_modelName;

private String m_docName;

private String m_docNumber;

private HashMap m_parameters;
public DocIdentifier(String modelName, String docName,

String docNumber, HashMap params)
{ m_modelName = modelName; m_docName= docName;
m_docNumber= docNumber;
m_parameters= params; }
/** get the CAD Name for the model **/
public String getModelName()
{ return m_modelName; }
/** get the EPMDocument name for the model **/
public String getDocName()
{ return m_docName; }
/** set the EPMDocument name for the model **/
public void setDocName(String docname)
{ m_docName = docname; }
/** set the EPMDocument number for the model **/
public void setDocNumber(String docnumber)
{ m_docNumber = docnumber; }
/** get the EPMDocument number for the model **/
public String getDocNumber()
{ return m_docNumber; }
/** get the Pro/E designated parameters for the model.

These are name-value pairs indexed by the name **/
public HashMap getParameters()
{ return m_parameters; }
}
2. 在新类中,使用以下方法实现了为 CAD 文档 (EPMDocument) 命名/编号的业务逻辑:
public void validateDocumentIdentifier(DocIdentifier docIdentifier)
DocumentIdentifier 对象针对将由“上载服务”创建的 CAD 文档,具有 CAD 文档名称和编号的信息。
使用
DocIdentifier.getModelName()
获取此 DocIdentifier 对象表示的 CAD 文档的 CAD 名称。
已指定 CAD 应用程序的参数可用于设置 CAD 文档编号/命名。
使用
DocIdentifier.getParameters()
获取关联参数。
使用 DocIdentifier 的设置方法设置新名称/编号值。如果可行,“上载服务”会使用这些建议。可在以下位置找到实现的示例:
<Windchill home>/codebase/com/ptc/windchill/uwgm/proesrv/

c11n/EPMDefaultDocumentNamingDelegate.java
3. 编辑 site.xconf 文件 (可见于 <Windchill>) 来添加下列特性,以指明服务器上自定义服务的可用性:
<Service context="default" name="com.ptc.windchill.uwgm.proesrv.c11n.

EPMDocumentNamingDelegate" targetFile="codebase/service.properties">
<Option cardinality="singleton" requestor="wt.epm.EPMDocument"

serviceClass="com.ptc.windchill.uwgm.proesrv.c11n.EPMDefaultDocument

NamingDelegate"/>
</Service>
然后,使用 xconfmanager 工具将更改应用于 service.properties 文件 (运行
xconfmanager -p
)
使用类路径代替 serviceClass 的值 (即,使用类路径替换
com.ptc.windchill.uwgm.proesrv.c11n.EPMDefaultDocumentNami ngDelegate
)。
4. 重新启动“方法”服务器。