Class BinaryScannerUtil
- java.lang.Object
-
- io.openliberty.tools.common.plugins.util.BinaryScannerUtil
-
public abstract class BinaryScannerUtil extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classBinaryScannerUtil.AbstractIllegalTargetExceptionclassBinaryScannerUtil.FeatureModifiedExceptionclassBinaryScannerUtil.FeatureUnavailableExceptionclassBinaryScannerUtil.IllegalTargetComboExceptionclassBinaryScannerUtil.IllegalTargetExceptionclassBinaryScannerUtil.NoRecommendationExceptionclassBinaryScannerUtil.RecommendationSetException
-
Field Summary
Fields Modifier and Type Field Description static StringBINARY_SCANNER_CONFLICT_MESSAGE1static StringBINARY_SCANNER_CONFLICT_MESSAGE2static StringBINARY_SCANNER_CONFLICT_MESSAGE3static StringBINARY_SCANNER_CONFLICT_MESSAGE4static StringBINARY_SCANNER_CONFLICT_MESSAGE5static StringBINARY_SCANNER_EE_PREFIXstatic StringBINARY_SCANNER_INVALID_COMBO_MESSAGEstatic StringBINARY_SCANNER_INVALID_EE_MESSAGEstatic StringBINARY_SCANNER_INVALID_EEMPARG_MESSAGEstatic StringBINARY_SCANNER_INVALID_MP_MESSAGEstatic StringBINARY_SCANNER_MAVEN_ARTIFACT_IDstatic StringBINARY_SCANNER_MAVEN_GROUP_IDstatic StringBINARY_SCANNER_MAVEN_TYPEstatic StringBINARY_SCANNER_MAVEN_VERSIONstatic StringBINARY_SCANNER_MP_PREFIXstatic StringGENERATED_FEATURES_FILE_NAMEstatic StringGENERATED_FEATURES_FILE_PATH
-
Constructor Summary
Constructors Constructor Description BinaryScannerUtil(File binaryScanner)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static StringbuildInvalidArgExceptionMessage(String invalidEEArg, String invalidMPArg, String eeVersion, String mpVersion)Convenience method to build the string reported to the user when the exception is detected.static StringcomposeEEVersion(String ver)Create the string required by the binary scanner parameter targetJavaEE E.g.static StringcomposeMPVersion(String ver)Create the string required by the binary scanner parameter targetMicroProfile E.g.abstract voiddebug(String message)abstract voiddebug(String message, Throwable e)abstract voiderror(String message)abstract voidinfo(String message)abstract booleanisDebugEnabled()Set<String>reRunBinaryScanner(Set<String> allClassesDirectories, String logLocation, String targetJavaEE, String targetMicroProfile)The method is intended to call the binary scanner to generate a list of the optimal features for an application.Set<String>runBinaryScanner(Set<String> currentFeatureSet, List<String> classFiles, Set<String> allClassesDirectories, String logLocation, String targetJavaEE, String targetMicroProfile, boolean optimize)Call the binary scanner to generate a list of Liberty features to run an application.abstract voidwarn(String message)
-
-
-
Field Detail
-
BINARY_SCANNER_MAVEN_GROUP_ID
public static final String BINARY_SCANNER_MAVEN_GROUP_ID
- See Also:
- Constant Field Values
-
BINARY_SCANNER_MAVEN_ARTIFACT_ID
public static final String BINARY_SCANNER_MAVEN_ARTIFACT_ID
- See Also:
- Constant Field Values
-
BINARY_SCANNER_MAVEN_TYPE
public static final String BINARY_SCANNER_MAVEN_TYPE
- See Also:
- Constant Field Values
-
BINARY_SCANNER_MAVEN_VERSION
public static final String BINARY_SCANNER_MAVEN_VERSION
- See Also:
- Constant Field Values
-
GENERATED_FEATURES_FILE_NAME
public static final String GENERATED_FEATURES_FILE_NAME
- See Also:
- Constant Field Values
-
GENERATED_FEATURES_FILE_PATH
public static final String GENERATED_FEATURES_FILE_PATH
- See Also:
- Constant Field Values
-
BINARY_SCANNER_CONFLICT_MESSAGE1
public static final String BINARY_SCANNER_CONFLICT_MESSAGE1
- See Also:
- Constant Field Values
-
BINARY_SCANNER_CONFLICT_MESSAGE2
public static final String BINARY_SCANNER_CONFLICT_MESSAGE2
- See Also:
- Constant Field Values
-
BINARY_SCANNER_CONFLICT_MESSAGE3
public static final String BINARY_SCANNER_CONFLICT_MESSAGE3
- See Also:
- Constant Field Values
-
BINARY_SCANNER_CONFLICT_MESSAGE4
public static final String BINARY_SCANNER_CONFLICT_MESSAGE4
- See Also:
- Constant Field Values
-
BINARY_SCANNER_CONFLICT_MESSAGE5
public static final String BINARY_SCANNER_CONFLICT_MESSAGE5
- See Also:
- Constant Field Values
-
BINARY_SCANNER_INVALID_MP_MESSAGE
public static final String BINARY_SCANNER_INVALID_MP_MESSAGE
- See Also:
- Constant Field Values
-
BINARY_SCANNER_INVALID_EE_MESSAGE
public static final String BINARY_SCANNER_INVALID_EE_MESSAGE
- See Also:
- Constant Field Values
-
BINARY_SCANNER_INVALID_EEMPARG_MESSAGE
public static final String BINARY_SCANNER_INVALID_EEMPARG_MESSAGE
- See Also:
- Constant Field Values
-
BINARY_SCANNER_INVALID_COMBO_MESSAGE
public static final String BINARY_SCANNER_INVALID_COMBO_MESSAGE
- See Also:
- Constant Field Values
-
BINARY_SCANNER_EE_PREFIX
public static final String BINARY_SCANNER_EE_PREFIX
- See Also:
- Constant Field Values
-
BINARY_SCANNER_MP_PREFIX
public static final String BINARY_SCANNER_MP_PREFIX
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BinaryScannerUtil
public BinaryScannerUtil(File binaryScanner)
-
-
Method Detail
-
debug
public abstract void debug(String message)
-
error
public abstract void error(String message)
-
warn
public abstract void warn(String message)
-
info
public abstract void info(String message)
-
isDebugEnabled
public abstract boolean isDebugEnabled()
-
runBinaryScanner
public Set<String> runBinaryScanner(Set<String> currentFeatureSet, List<String> classFiles, Set<String> allClassesDirectories, String logLocation, String targetJavaEE, String targetMicroProfile, boolean optimize) throws PluginExecutionException, BinaryScannerUtil.NoRecommendationException, BinaryScannerUtil.RecommendationSetException, BinaryScannerUtil.FeatureModifiedException, BinaryScannerUtil.FeatureUnavailableException, BinaryScannerUtil.IllegalTargetException, BinaryScannerUtil.IllegalTargetComboException
Call the binary scanner to generate a list of Liberty features to run an application. It will scan the classFiles parameter or scan all the classes in the allClassesDirectories parameter depending on the optimize parameter. The currentFeatureSet parameter indicates the starting list of features and all the generated features will be compatible. The generated features will also be compatible with the indicated versions of Java EE or Jakarta EE and MicroProfile.- Parameters:
currentFeatureSet- - the features already specified in the server configurationclassFiles- - a set of class files for the scanner to handle. Should be a subset of allClassesDirectoriesallClassesDirectories- - the directories containing all the class files of the applicationlogLocation- - directory name relative to project or absolute path passed to binary scannertargetJavaEE- - generate features valid for the indicated version of EEtargetMicroProfile- - generate features valid for the indicated version of MicroProfileoptimize- - true value means to scan all the classes in allClassesDirectories rather than just the classes in the classFiles parameter. currentFeatureSet is still used as the basis of the feature set.- Returns:
- - a set of features that will allow the application to run in a Liberty server
- Throws:
PluginExecutionException- - any exception that prevents the scanner from runningBinaryScannerUtil.NoRecommendationException- - indicates a problem and there are no recommended featuresBinaryScannerUtil.RecommendationSetException- - indicates a problem but the scanner was able to generate a set of features that should work to run the applicationBinaryScannerUtil.FeatureModifiedException- - indicates a problem but the scanner was able to generate a set of features that should work if certain features are modifiedBinaryScannerUtil.FeatureUnavailableException- - indicates a problem between required features and required MP/EE levels but the scanner was able to generate a set of features that should be removedBinaryScannerUtil.IllegalTargetException- - indicates one or both of the MP or EE versions is not supported by the binary scannerBinaryScannerUtil.IllegalTargetComboException- - indicates the MP or EE version parameters are not supported by the binary scanner when used in combination with each other. E.g. EE 7 and MP 2.1
-
reRunBinaryScanner
public Set<String> reRunBinaryScanner(Set<String> allClassesDirectories, String logLocation, String targetJavaEE, String targetMicroProfile) throws PluginExecutionException
The method is intended to call the binary scanner to generate a list of the optimal features for an application. This optimal list can be reported to the user as a suggested list of features. In order to generate the optimal list we must scan all classes in the application and we do not consider the features already specified in the server configuration (server.xml).- Parameters:
allClassesDirectories- - the scanner will find all the class files in this set of directorieslogLocation- - directory name relative to project or absolute path passed to binary scannertargetJavaEE- - generate features valid for the indicated version of EEtargetMicroProfile- - generate features valid for the indicated version of MicroProfile- Returns:
- - a set of features that will allow the application to run in a Liberty server
- Throws:
PluginExecutionException- - any exception that prevents the scanner from running
-
composeEEVersion
public static String composeEEVersion(String ver)
Create the string required by the binary scanner parameter targetJavaEE E.g. ee7, ee8 etc- Parameters:
ver- the String value version number read from the build file (pom.xml, build.gradle) E.g. 8, 8.0, 8.0.0 etc. This is verified by the parser and cannot be blank.- Returns:
- String parameter passed to binary scanner
-
composeMPVersion
public static String composeMPVersion(String ver)
Create the string required by the binary scanner parameter targetMicroProfile E.g. mp1.3, mp4.1 etc- Parameters:
ver- the String value version number read from the build file (pom.xml, build.gradle) E.g. 1, 2.1 etc. This is verified by the parser and cannot be blank.- Returns:
- String parameter passed to binary scanner or null in case of error
-
buildInvalidArgExceptionMessage
public static String buildInvalidArgExceptionMessage(String invalidEEArg, String invalidMPArg, String eeVersion, String mpVersion)
Convenience method to build the string reported to the user when the exception is detected. This is used after the caller has analyzed the Java or Jakarta EE version number and the MicroProfile version number and generated argument values to pass to the binary scanner. If the binary scanner detects a problem and throws an exception it reports the invalid arguments. We must map the invalid arguments back to the user specified version number in order to fix the problem.- Parameters:
invalidEEArg- - the argument passed to the binary scanner which may be returned as invalid.invalidMPArg- - the argument passed to the binary scanner which may be returned as invalid.eeVersion- - the user specified version string from the build file used to generate the arg.mpVersion- - the user specified version string from the build file used to generate the arg.- Returns:
- a string we can report to the user to report an error or errors and guide the effort to fix it.
-
-