48
48
import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .TESTSUITE_FINISHED ;
49
49
import static com .ericsson .eiffel .remrem .semantics .EiffelEventType .TESTSUITE_STARTED ;
50
50
51
+ import java .io .IOException ;
51
52
import java .io .InputStream ;
52
53
import java .io .InputStreamReader ;
54
+ import java .net .URL ;
53
55
import java .util .ArrayList ;
54
56
import java .util .Collection ;
57
+ import java .util .Enumeration ;
55
58
import java .util .HashMap ;
56
59
import java .util .Map ;
60
+ import java .util .jar .Attributes ;
61
+ import java .util .jar .JarFile ;
62
+ import java .util .jar .Manifest ;
57
63
58
64
import javax .annotation .PostConstruct ;
59
65
import javax .inject .Named ;
@@ -127,11 +133,13 @@ public class SemanticsService implements MsgService {
127
133
private static final String DOMAIN_ID = "domainId" ;
128
134
private static final String PROTOCOL = "eiffel" ;
129
135
private static final String DOT = "." ;
136
+ private static final String SEMANTICS_EDITION_NAME = "semanticsEditionName" ;
130
137
private final ArrayList <String > supportedEventTypes = new ArrayList <String >();
131
138
public static final Logger log = LoggerFactory .getLogger (SemanticsService .class );
132
139
private Event event = new Event ();
133
140
public static String purlSerializer ;
134
141
private boolean purlSerializerFlag = false ;
142
+ private static String editionName ;
135
143
private static Gson gson = new Gson ();
136
144
private static Map <EiffelEventType , Class <? extends Event >> eventTypes = SemanticsService .eventType ();
137
145
@@ -460,4 +468,33 @@ public static Source setSerializerGav(Source source) {
460
468
source .setSerializer (serializer );
461
469
return source ;
462
470
}
463
- }
471
+
472
+ @ Override
473
+ public String getProtocolEdition () {
474
+ Enumeration <?> files ;
475
+ try {
476
+ files = Thread .currentThread ()
477
+ .getContextClassLoader ()
478
+ .getResources (JarFile .MANIFEST_NAME );
479
+ while (files .hasMoreElements ()) {
480
+ try {
481
+ final URL url = (URL ) files .nextElement ();
482
+ final InputStream inputStream = url .openStream ();
483
+ if (inputStream != null ) {
484
+ final Manifest manifest = new Manifest (inputStream );
485
+ final Attributes mainAttribs = manifest .getMainAttributes ();
486
+ final String edition = mainAttribs .getValue (SEMANTICS_EDITION_NAME );
487
+ if (edition != null ) {
488
+ editionName = edition ;
489
+ }
490
+ }
491
+ } catch (Exception e ) {
492
+ // Silently ignore wrong manifests on classpath?
493
+ }
494
+ }
495
+ } catch (IOException e ) {
496
+ // Silently ignore wrong manifests on classpath?
497
+ }
498
+ return editionName ;
499
+ }
500
+ }
0 commit comments