付きリスト・アプリケーション プリントのappplication名のasadmin
$:!
glassfish3 \ GlassFishの\モジュール\コンテナ-common.jarをCOM /日/ createApplication
に設定された企業/容器/共通/ IMPL/
JavaModuleNamingProxyの.class
private String getAppName() throws NamingException {
ComponentEnvManager namingMgr = (ComponentEnvManager)this.habitat.getComponent(ComponentEnvManager.class);
String appName = null;
if (namingMgr != null) {
JndiNameEnvironment env = namingMgr.getCurrentJndiNameEnvironment();
BundleDescriptor bd = null;
if ((env instanceof EjbDescriptor)) {
bd = ((EjbDescriptor)env).getEjbBundleDescriptor();
} else if ((env instanceof BundleDescriptor)) {
bd = (BundleDescriptor)env;
}
if (bd != null) {
Application app = bd.getApplication();
appName = app.getAppName(); // <-- HERE!
}
}
if (appName == null)
throw new NamingException("Could not resolve java:app/AppName");
return appName;
}
とApplication.getAppName()
glassfish3 \ GlassFishの\モジュール\ dol.jar!COM /日/企業/展開/ アプリケーションの.class
public static Application createApplication(Habitat habitat, String name, ModuleDescriptor <BundleDescriptor> newModule) {
Application application = new Application(habitat);
application.setVirtual(true);
if ((name == null) && (newModule.getDescriptor() != null)) {
name = ((BundleDescriptor)newModule.getDescriptor()).getDisplayName();
}
String untaggedName = VersioningUtils.getUntaggedName(name);
if (name != null) {
application.setDisplayName(untaggedName);
application.setName(untaggedName);
application.setAppName(untaggedName);
}
newModule.setStandalone(true);
newModule.setArchiveUri(untaggedName);
if (newModule.getDescriptor() != null) {
((BundleDescriptor)newModule.getDescriptor()).setApplication(application);
}
application.addModule(newModule);
return application;
}
あなたはそれがアプリケーション内でタグ付けされた名前を保存doesntの見ることができるように。なぜdisplayNameを使用しないのですか?それでも 、私はバージョン情報を取得するための別の方法を見つけてみますが... GlassFishの-application.xmlの/バージョン識別子を読む/設定することができる
更新:のglassfishは、バージョンのフォルダを作成します(ドメイン|ノード) /アプリケーション/ appName〜バージョン。だから我々はいくつかのリソースのパスを分析することができます:)
static final Pattern APP_VER = Pattern.compile("/applications/([^~/]+)(?:~([^/]*))?");
public String getAppVersion() {
URL res = getClass().getResource("/META-INF/somefile.xml");
if (res != null) {
Matcher ver = APP_VER.matcher(res.getPath());
if (ver.find())
return ver.group(2);
}
return null;
}
楽しんでください!たぶん誰かがもっと美しい解決策を持っているでしょうか
これはあなたの質問をカバーしていますか?http://blog.payara.fish/deploying-multiple-application-versions-on-payara-server? (PayaraはGlassfishをベースにしています)。 – simdevmon
simdevmonは、マルチバージョン展開を示しています。現在のアプリケーションのバージョンを取得する方法については言及していません。 – lunicon