我想在设计师之外收集webmethods集成服务器的特定包的依赖关系,以及一个单独的java程序。
这些依赖项存储在文件系统中的哪个位置?
谢谢
答案 0 :(得分:4)
在包级别声明的包依赖关系存储在包清单文件中:IntegrationServer/packages/<packageName>/manifest.v3
。
例如,manifest包中的Tundra文件包含一个<record name="requires"...>
元素,列出了它依赖的三个包(WmFlatFile,WmPublic和WmRoot):
<?xml version="1.0" encoding="UTF-8"?>
<Values version="2.0">
<value name="enabled">yes</value>
<value name="system_package">no</value>
<value name="version">0.0.13</value>
<record name="startup_services" javaclass="com.wm.util.Values">
<null name="tundra.support:access"/>
</record>
<null name="shutdown_services"/>
<null name="replication_services"/>
<record name="requires" javaclass="com.wm.util.Values">
<value name="WmFlatFile">*.*</value>
<value name="WmPublic">*.*</value>
<value name="WmRoot">*.*</value>
</record>
<value name="listACL">Default</value>
<value name="description">A package of cool services for webMethods Integration Server 7.1 or higher</value>
<value name="publisher">Lachlan Dowding <lachlan@permafro.st></value>
<value name="webappLoad">yes</value>
</Values>
解析此XML的最简单方法是使用webMethods Integration Server客户端JAR com.wm.util.coder.IDataXMLCoder
中的wm-isclient.jar
对象。这是一个简单的例子:
public static String[] getDependencies(String packageName) throws java.io.IOException {
String filename = ".../IntegrationServer/packages/" + packageName + "/manifest.v3";
java.io.InputStream in = null;
try {
in = new java.io.BufferedInputStream(new java.io.FileInputStream(filename));
com.wm.util.coder.XMLCoderWrapper codec = new com.wm.util.coder.XMLCoderWrapper();
com.wm.data.IData manifestDocument = codec.decode(in);
com.wm.data.IDataCursor manifestCursor = manifestDocument.getCursor();
com.wm.data.IData requiresDocument = com.wm.data.IDataUtil.getIData(manifestCursor, "requires");
manifestCursor.destroy();
java.util.List<String> dependencies = new java.util.ArrayList<String>();
if (requiresDocument != null) {
com.wm.data.IDataCursor requiresCursor = requiresDocument.getCursor();
while(requiresCursor.next()) {
String dependency = requiresCursor.getKey();
String version = (String)requiresCursor.getValue();
dependencies.add(dependency);
}
requiresCursor.destroy();
}
return dependencies.toArray(new String[dependencies.size()]);
} finally {
if (in != null) in.close();
}
}
如果未在包清单中声明包依赖关系,则可以通过使用类似于从Tundra.java中剔除的以下方法的代码检查包中每个服务的引用来计算它们:
import com.wm.app.b2b.server.ns.NSDependencyManager;
import com.wm.app.b2b.server.Package;
import com.wm.app.b2b.server.ns.Namespace;
import com.wm.data.IData;
import com.wm.data.IDataCursor;
import com.wm.data.IDataFactory;
import com.wm.data.IDataUtil;
import com.wm.lang.ns.DependencyManager;
import com.wm.lang.ns.NSNode;
import com.wm.lang.ns.NSService;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
...
/**
* Returns the list of services that are dependent on the services in the given package.
*
* @param packageName The package to get dependents for.
* @return The list of dependents for the given package.
*/
private static IData getDependents(String packageName) {
return getDependents(getPackage(packageName));
}
/**
* Returns the list of services that are dependent on the services in the given package.
*
* @param pkg The package to get dependents for.
* @return The list of dependents for the given package.
*/
private static IData getDependents(Package pkg) {
DependencyManager manager = NSDependencyManager.current();
Namespace namespace = Namespace.current();
SortedSet<String> packages = new TreeSet<String>();
SortedMap<String, IData> nodes = new TreeMap<String, IData>();
Enumeration services = pkg.getLoaded();
while(services.hasMoreElements()) {
String service = (String)services.nextElement();
if (service != null) {
NSNode node = namespace.getNode(service);
if (node != null) {
IData results = manager.getDependent(node, null);
if (results != null) {
IDataCursor resultsCursor = results.getCursor();
IData[] referencedBy = IDataUtil.getIDataArray(resultsCursor, "referencedBy");
resultsCursor.destroy();
if (referencedBy != null) {
for (IData dependent : referencedBy) {
if (dependent != null) {
IDataCursor dependentCursor = dependent.getCursor();
String name = IDataUtil.getString(dependentCursor, "name");
dependentCursor.destroy();
String[] parts = name.split("\\/");
if (parts.length > 1) {
if (!pkg.getName().equals(parts[0])) {
IData result = IDataFactory.create();
IDataCursor resultCursor = result.getCursor();
IDataUtil.put(resultCursor, "package", parts[0]);
IDataUtil.put(resultCursor, "node", parts[1]);
resultCursor.destroy();
packages.add(parts[0]);
nodes.put(name, result);
}
}
}
}
}
}
}
}
}
IData output = IDataFactory.create();
IDataCursor cursor = output.getCursor();
IDataUtil.put(cursor, "packages", packages.toArray(new String[packages.size()]));
IDataUtil.put(cursor, "packages.length", packages.size());
IDataUtil.put(cursor, "nodes", nodes.values().toArray(new IData[nodes.size()]));
IDataUtil.put(cursor, "nodes.length", nodes.size());
cursor.destroy();
return output;
}