-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Jonas Kunz
authored
Sep 9, 2020
1 parent
5f0f70c
commit 75c306c
Showing
4 changed files
with
162 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...erver/src/main/java/rocks/inspectit/oce/eum/server/configuration/model/InitiatorType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package rocks.inspectit.oce.eum.server.configuration.model; | ||
|
||
import rocks.inspectit.oce.eum.server.beacon.Beacon; | ||
|
||
/** | ||
* Types of initiators for beacons. | ||
* These correspond to values for the http.initiator fields of beacons. | ||
*/ | ||
public enum InitiatorType { | ||
DOCUMENT { | ||
@Override | ||
boolean isEqualToBeaconHttpInitiator(String httpInitiatorValue) { | ||
return httpInitiatorValue == null || "".equals(httpInitiatorValue); | ||
} | ||
}, | ||
XHR { | ||
@Override | ||
boolean isEqualToBeaconHttpInitiator(String httpInitiatorValue) { | ||
return "xhr".equalsIgnoreCase(httpInitiatorValue); | ||
} | ||
}, | ||
SPA_SOFT { | ||
@Override | ||
boolean isEqualToBeaconHttpInitiator(String httpInitiatorValue) { | ||
return "spa".equalsIgnoreCase(httpInitiatorValue); | ||
} | ||
}, | ||
SPA_HARD { | ||
@Override | ||
boolean isEqualToBeaconHttpInitiator(String httpInitiatorValue) { | ||
return "spa_hard".equalsIgnoreCase(httpInitiatorValue); | ||
} | ||
}; | ||
|
||
abstract boolean isEqualToBeaconHttpInitiator(String httpInitiatorValue); | ||
|
||
/** | ||
* Checks if the given beacon has an initiator matching this {@link InitiatorType}. | ||
* | ||
* @param beacon the beacon to check | ||
* | ||
* @return true, if the initiator matches | ||
*/ | ||
public boolean hasInitiator(Beacon beacon) { | ||
return isEqualToBeaconHttpInitiator(beacon.get("http.initiator")); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters