gpt4 book ai didi

dependencies - webmethods 包依赖

转载 作者:行者123 更新时间:2023-12-02 03:03:43 26 4
gpt4 key购买 nike

我想在设计器之外使用单独的 java 程序收集 webmethods 集成服务器特定包的依赖关系。

这些依赖项存储在文件系统中的什么位置?

谢谢

最佳答案

在包级别声明的包依赖项存储在包 list 文件中: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 &lt;lachlan@permafro.st&gt;</value>
<value name="webappLoad">yes</value>
</Values>

解析此 XML 的最简单方法是使用 com.wm.util.coder.IDataXMLCoder来自 webMethods Integration Server 客户端 JAR 的对象 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();
}
}
<小时/>

如果包依赖项未在包 list 中声明,您可以通过使用类似于从 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;
}

关于dependencies - webmethods 包依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23757488/

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