自定义发布队列
本节包含用于 publish.publishqueue.priorities.filtermethodwvs.property publish.publishqueue.usesetworkers.filtermethod 的筛选器类的信息和示例代码。
publish.publishqueue.priorities.filtermethod
此方法将在提交发布作业时调用,允许设置优先级、队列集以及表示名称与说明。
[0] = 优先级 H、M、L
[1] = 应由 publish.publishqueue.setnames 配置的队列集名称。
[2] = 表示的新名称
[3] = 表示的新说明
任何返回字符串都可以为空,在这种情况下,现有值将保持不变。由特性 publish.publishqueue.priorities.filtermethod=com.ptc.wvs.server.publish.PTCWVSPublishFilters/publishqueueFiltermethod 控制。
publish.publishqueue.usesetworkers.filtermethod
将转换作业提交到 CADAgent 时,将调用此方法。为返回工作器队列集及其应使用的 CADAgent,将设置的表示名称和说明,(如果此作业可以使用具有包含返回值的 queueset 特性的工作器)。这不必与正在使用的实际发布队列集相同。例如,对于相同集内的装配和部件,您可以使用专用的工作器。
由特性 publish.publishqueue.usesetworkers.filtermethod=com.ptc.wvs.server.publish.MyPublishFilters/publishUsesetworkersFiltermethod 控制。
用例
如果未将任何工作器配置为专用工作器,系统将拾取当前空闲的工作器,并通过该工作器发布作业。此工作器不是专用工作器,因为未配置任何 usesetworkers.filtermethod
如果您仅有专用工作器,且尚未定义 usesetworkers.filtermethod,则结果将是错误消息:“错误:未发现可用、类型为 PROE 的工作器”。
如果要通过专用工作器发送作业,则必须编写 UsesetworkersFiltermethod 方法。定义后,作业将提交至专用工作器。
具体步骤如下:
1. xconfmanager -s publish.publishqueue.priorities.filtermethod=com.ptc.wvs.server.publish.PTCWVSPublishFilters/publishqueueFiltermethod -t codebase/WEB-INF/conf/wvs.properties -p
2. 要编译 java 文件,请在 windchill shell 中运行以下命令
a. set CLASSPATH = %CLASSPATH%; %WT_HOME%\srclib\tool\Annotations.jar
b. cd codebase\com\ptc\wvs\server\publish
c. javac PTCWVSPublishFilters.java
3. 重新启动 Windchill。
示例代码
package com.ptc.wvs.server.publish;
import wt.epm.EPMDocument;
import wt.fc.Persistable;
import wt.fc.QueryResult;
import wt.representation.Representation;
import java.io.File;
import java.util.Properties;
/**
* Example methods for the Dedicated Publisher Queue Set and Worker
* enhancement
*/
public class PTCWVSPublishFilters
{
/**
* publish.publishqueue.priorities.filtermethod
*
* This method is called when a publish job is being submitted and
* allows the priority, queue set and
* representation name and descrition to be set
* return [0] = priority H, M L
* [1] = queue set name which should have been confgured by
* "publish.publishqueue.setnames"
* [2] = new name for representation
* [3] = new description for representation
* Any of the return strings can be null, in which case the
* existing value is unchanged.
* Controlled by property
* publish.publishqueue.priorities.filtermethod=
* com.ptc.wvs.server.publish.
* PTCWVSPublishFilters/publishqueueFiltermethod
*
**/
public static String[] publishqueueFiltermethod(Persistable p,
Integer requestType, Integer requestSource,
String requestQueuePriority, String requestQueueSet,
String repName, String repDesc)
{
String[] ret = {null, null, null, null};

if( p instanceof EPMDocument ) {
EPMDocument epmdoc = (EPMDocument)p;
if( epmdoc.getAuthoringApplication().toString().toUpperCase().equals("PROE") )
{
if(epmdoc.getDocType().toString().equals("CADDRAWING")){
ret[0]="L";
}
if(epmdoc.getDocType().toString().equals("CADCOMPONENT")){
ret[0]="M";
}
if(epmdoc.getDocType().toString().equals("CADASSEMBLY")){
ret[0]="H";
}
if (epmdoc.getDocType().toString().equals("CADDRAWING")) {
ret[1]="PROEDRW";
}
if (epmdoc.getDocType().toString().equals("CADCOMPONENT")) {
ret[1]="PROEPRT";
}
if (epmdoc.getDocType().toString().equals("CADASSEMBLY")) {
ret[1]="PROEASM";
}
ret[2]="SITHIK_PROE_REP";
ret[3]="SITHIK_PROE_DESC";
}
System.out.println("publishqueueFiltermethod outputs:");
System.out.println(" Queue Set: " + ret[1]);
System.out.println(" Priority: " + ret[0]);
System.out.println(" RepName: " + ret[2]);
System.out.println(" RepDesc: " + ret[3]);
}
return ret;
}

/**
* publish.publishqueue.usesetworkers.filtermethod
*
* This method will be called when a conversion job is being
* submitted to the CADAgent representation name and description
* to be set return the worker queue set the the
* CADAGent should use, ie this job will be able to use a
* worker that has the "queueset" property that includes the
* return value. There is not reason that this has to be the
* same as the actual publsihing queue set that is being used,
* for example you could have dedicated worker for assemblies
* and parts from the same set.
* Controlled by property
* publish.publishqueue.usesetworkers.filtermethod=
* com.ptc.wvs.server.publish.MyPublishFilters/
* publishUsesetworkersFiltermethod
*
**/
public static String publishUsesetworkersFiltermethod(Persistable p,
String workerType,
String cadType, String fileName,
String requestQueuePriority,
String requestQueueSet)
{
System.out.println("publishqueueUsesetworkersFiltermethod : " + p + " " +
workerType + " " + cadType +
" " + fileName + " " + requestQueuePriority + " " + requestQueueSet);
String ret = "DEFAULT";
if( p instanceof EPMDocument ) {
EPMDocument epmdoc = (EPMDocument)p;
System.out.println( "Input docType: " + epmdoc.getDocType().toString() );
System.out.println( "Input AuthApp: " + epmdoc.getAuthoringApplication().toString().toUpperCase() );
if( epmdoc.getAuthoringApplication().toString().toUpperCase().equals("PROE") )
{
if (epmdoc.getDocType().toString().equals("CADDRAWING")) {
ret="PROEDRW";
}
if (epmdoc.getDocType().toString().equals("CADCOMPONENT")) {
ret="PROEPRT";
}
if (epmdoc.getDocType().toString().equals("CADASSEMBLY")) {
ret="PROEASM";
}
}
}
System.out.println("WorkerSet: " + ret);
return ret;
}

public static void main(String args[])
{
System.out.println("hook " + args[0]);
System.out.println("EXITSTATUS:1");
}
}
示例特性文件
<Property name="publish.publishqueue.usesetworkers.forqueueset.PROEDRW"
overridable="true" targetFile="codebase/WEB-INF/conf/wvs.properties"
value="PROE"/>
<Property name="wt.queue.removeCompleted.PublisherQueuePROEDRW1"
overridable="true" targetFile="codebase/wt.properties" value="false"/>
<Property name="wt.queue.removeCompleted.PublisherQueuePROEDRW2"
overridable="true" targetFile="codebase/wt.properties" value="false"/>
<AddToProperty name="publish.publishqueue.setnames" value="PROEDRW"/>
<Property name="publish.publishqueue.usesetworkers.forqueueset.PROEASM"
overridable="true" targetFile="codebase/WEB-INF/conf/wvs.properties"
value="PROE"/>
<Property name="wt.queue.removeCompleted.PublisherQueuePROEASM1"
overridable="true" targetFile="codebase/wt.properties" value="false"/>
<Property name="wt.queue.removeCompleted.PublisherQueuePROEASM2"
overridable="true" targetFile="codebase/wt.properties" value="false"/>
<AddToProperty name="publish.publishqueue.setnames" value="PROEASM"/>
<Property name="publish.publishqueue.usesetworkers.forqueueset.PROEPRT"
overridable="true" targetFile="codebase/WEB-INF/conf/wvs.properties"
value="PROE"/>
<Property name="wt.queue.removeCompleted.PublisherQueuePROEPRT1"
overridable="true" targetFile="codebase/wt.properties" value="false"/>
<Property name="wt.queue.removeCompleted.PublisherQueuePROEPRT2"
overridable="true" targetFile="codebase/wt.properties" value="false"/>
<AddToProperty name="publish.publishqueue.setnames" value="PROEPRT"/>

<Property name="publish.publishqueue.priorities.filtermethod"
overridable="true"
targetFile="codebase/WEB-INF/conf/wvs.properties"
value="com.ptc.wvs.server.publish.PTCWVSPublishFilters/
publishqueueFiltermethod"/>
<Property name="publish.publishqueue.usesetworkers.filtermethod"
overridable="true"
targetFile="codebase/WEB-INF/conf/wvs.properties"
value="com.ptc.wvs.server.publish.
PTCWVSPublishFilters/publishUsesetworkersFiltermethod"/>

<Property name="wt.queue.max.processQueues"
overridable="true"
targetFile="codebase/wt.properties" value="60"/>
编译 Java 文件
根据 java 文件的部署位置。
1. set CLASSPATH = %CLASSPATH%; %WT_HOME%\srclib\tool\Annotations.jar
2. cd codebase\com\ptc\wvs\server\publish
3. javac PTCWVSPublishFilters.java
这对您有帮助吗?