Ich fand einen Platz in der Quelle, wo es AnwName erhalten:
glassfish3 \ Glassfish \ Module \ Container-common.jar com/sun/Unternehmen/Behälter/common/Umsetz/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;
}
und Application.getAppName (es) in Create
glassfish3 \ Glassfish \ Module \ dol.jar! Com/sun/Unternehmen/deployment/Anwendung .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;
}
Wie Sie es in Anwendung speichern getaggt Namen können tut. Warum nicht "displayName" verwenden? Trotzdem , ich werde versuchen, einen anderen Weg finden, um Versionsinformationen zu bekommen ... eingestellt werden kann/Lese-Glasfischen application.xml/version-identifier
Update: Glasfischen erstellen Ordner mit der Version in (Domäne | Knoten)/Anwendungen/AppName ~ Version. So können wir einige Ressourcenpfad analysieren :)
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;
}
Viel Spaß! Vielleicht hat jemand eine schönere Lösung?
Bedeckt dies Ihre Frage: http://blog.payara.fish/deploying-multiple-application-versions-on-payara-server? (Payara basiert auf Glassfish). – simdevmon
simdevmon, es zeigen nur Multiversion-Bereitstellungen. Nicht sagen, wie man die aktuelle Anwendungsversion bekommt. – lunicon