Skip to content

Commit

Permalink
Merge pull request #1759 from dnwick/master
Browse files Browse the repository at this point in the history
Upgrade to log4j2 from log4j1
  • Loading branch information
dnwick authored Feb 4, 2022
2 parents b225b04 + 9763f2e commit 95f31f1
Show file tree
Hide file tree
Showing 392 changed files with 2,879 additions and 1,182 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@
* CAMEL_CASE_PATTERN: regex pattern for check the camelCase naming convention.
*/
public class AbstractAnnotationProcessor {

protected static final Pattern CORE_PACKAGE_PATTERN = Pattern.compile("^io.siddhi.core.");
protected static final Pattern PARAMETER_NAME_PATTERN = Pattern.compile("^[a-z][a-z0-9]*(\\.[a-z][a-z0-9]*)*$");
protected static final String REPETITIVE_PARAMETER_NOTATION = "...";
protected static final Pattern CAMEL_CASE_PATTERN = Pattern.compile("^(([a-z][a-z0-9]+)([A-Z]{0,1}[a-z0-9]*)*)$");
protected String extensionClassFullName;

public AbstractAnnotationProcessor(String extensionClassFullName) {

this.extensionClassFullName = extensionClassFullName;
}

Expand Down Expand Up @@ -90,6 +92,7 @@ public void basicParameterValidation(String name, String description, String nam
* exception with proper message.
*/
public void parameterValidation(Parameter[] parameters) throws AnnotationValidationException {

for (Parameter parameter : parameters) {
String parameterName = parameter.name();
//Check if the @Parameter name is empty.
Expand Down Expand Up @@ -205,6 +208,7 @@ public void parameterOverloadValidation(ParameterOverload[] parameterOverloads,
* exception with proper message.
*/
public void returnAttributesValidation(ReturnAttribute[] returnAttributes) throws AnnotationValidationException {

for (ReturnAttribute returnAttribute : returnAttributes) {
String returnAttributeName = returnAttribute.name();
//Check if the @ReturnAttributes name is empty.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@
* This processor will extend the validation rules for validate Aggregation Attribute specific annotation contents.
*/
public class AggregationAttributeValidationAnnotationProcessor extends AbstractAnnotationProcessor {

public AggregationAttributeValidationAnnotationProcessor(String extensionClassFullName) {

super(extensionClassFullName);
}

@Override
public void parameterValidation(Parameter[] parameters) throws AnnotationValidationException {

for (Parameter parameter : parameters) {
String parameterName = parameter.name();
//Check if the @Parameter name is empty.
Expand Down Expand Up @@ -63,6 +66,7 @@ public void parameterValidation(Parameter[] parameters) throws AnnotationValidat

@Override
public void returnAttributesValidation(ReturnAttribute[] returnAttributes) throws AnnotationValidationException {

if (returnAttributes.length == 0) {
//Throw error if the @ReturnAttributes empty.
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
* This processor will extend the validation rules for validate Distribution Strategy specific annotation contents.
*/
public class DistributionStrategyValidationAnnotationProcessor extends AbstractAnnotationProcessor {

public DistributionStrategyValidationAnnotationProcessor(String extensionClassFullName) {

super(extensionClassFullName);
}

Expand Down Expand Up @@ -64,6 +66,7 @@ public void basicParameterValidation(String name, String description, String nam

@Override
public void parameterValidation(Parameter[] parameters) throws AnnotationValidationException {

if (parameters != null && parameters.length > 0) {
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Parameter " +
"cannot be annotated in class {0}. As this class extends from super class {1}.",
Expand All @@ -73,6 +76,7 @@ public void parameterValidation(Parameter[] parameters) throws AnnotationValidat

@Override
public void returnAttributesValidation(ReturnAttribute[] returnAttributes) throws AnnotationValidationException {

if (returnAttributes != null && returnAttributes.length > 0) {
//Throw error for other classes as only in the classes extending
//StreamProcessor or StreamFunctionProcessor allowed to have more than one ReturnAttribute.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@
* This processor will extend the validation rules for validate Function Executor specific annotation contents.
*/
public class FunctionExecutorValidationAnnotationProcessor extends AbstractAnnotationProcessor {

public FunctionExecutorValidationAnnotationProcessor(String extensionClassFullName) {

super(extensionClassFullName);
}

@Override
public void parameterValidation(Parameter[] parameters) throws AnnotationValidationException {

for (Parameter parameter : parameters) {
String parameterName = parameter.name();
//Check if the @Parameter name is empty.
Expand Down Expand Up @@ -72,6 +75,7 @@ public void parameterValidation(Parameter[] parameters) throws AnnotationValidat

@Override
public void returnAttributesValidation(ReturnAttribute[] returnAttributes) throws AnnotationValidationException {

if (returnAttributes.length == 0) {
//Throw error if the @ReturnAttributes empty.
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @ReturnAttribute " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@
* annotation contents.
*/
public class IncrementalAggregationAttributeValidationAnnotationProcessor extends AbstractAnnotationProcessor {

public IncrementalAggregationAttributeValidationAnnotationProcessor(String extensionClassFullName) {

super(extensionClassFullName);
}

@Override
public void parameterValidation(Parameter[] parameters) throws AnnotationValidationException {

for (Parameter parameter : parameters) {
String parameterName = parameter.name();
//Check if the @Parameter name is empty.
Expand Down Expand Up @@ -64,6 +67,7 @@ public void parameterValidation(Parameter[] parameters) throws AnnotationValidat

@Override
public void returnAttributesValidation(ReturnAttribute[] returnAttributes) throws AnnotationValidationException {

if (returnAttributes.length == 0) {
//Throw error if the @ReturnAttributes empty.
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
* This processor will extend the validation rules for validate script specific annotation contents.
**/
public class ScriptValidationAnnotationProcessor extends AbstractAnnotationProcessor {

public ScriptValidationAnnotationProcessor(String extensionClassFullName) {

super(extensionClassFullName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@
* messager : the messager used to report errors, warnings, and other notices when validation error throws..
*/
public class SiddhiAnnotationProcessor extends AbstractProcessor {

private final List<Class<? extends Annotation>> annotationsClasses = new ArrayList<>();
private Messager messager;

@Override
public synchronized void init(ProcessingEnvironment env) {

super.init(env);
messager = env.getMessager();

Expand Down Expand Up @@ -194,6 +196,7 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment

@Override
public Set<String> getSupportedAnnotationTypes() {

HashSet<String> annotationTypes = new HashSet<>();
for (Class<? extends Annotation> annotationClass : annotationsClasses) {
annotationTypes.add(annotationClass.getCanonicalName());
Expand All @@ -203,10 +206,12 @@ public Set<String> getSupportedAnnotationTypes() {

@Override
public SourceVersion getSupportedSourceVersion() {

return SourceVersion.RELEASE_8;
}

private String getMatchingSuperClass(Element elementToValidate, String[] superClassNames) {

TypeMirror superType = ((TypeElement) elementToValidate).getSuperclass();
String superClass = null;
// Looping the inheritance hierarchy to check if the element inherits at least one of the super
Expand All @@ -225,6 +230,7 @@ private String getMatchingSuperClass(Element elementToValidate, String[] superCl
}

public void showBuildError(String message, Element element) {

messager.printMessage(Diagnostic.Kind.ERROR, message, element);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
public class SinkMapperValidationAnnotationProcessor extends AbstractAnnotationProcessor {

public SinkMapperValidationAnnotationProcessor(String extensionClassFullName) {

super(extensionClassFullName);
}

Expand Down Expand Up @@ -63,6 +64,7 @@ public void basicParameterValidation(String name, String description, String nam

@Override
public void returnAttributesValidation(ReturnAttribute[] returnAttributes) throws AnnotationValidationException {

if (returnAttributes != null && returnAttributes.length > 0) {
//Throw error for other classes as only in the classes extending
//StreamProcessor or StreamFunctionProcessor allowed to have more than one ReturnAttribute.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
* This processor will extend the validation rules for validate Sink specific annotation contents.
*/
public class SinkValidationAnnotationProcessor extends AbstractAnnotationProcessor {

public SinkValidationAnnotationProcessor(String extensionClassFullName) {

super(extensionClassFullName);
}

Expand All @@ -48,7 +50,8 @@ public void basicParameterValidation(String name, String description, String nam
if (namespace.isEmpty()) {
//The namespace cannot be null or empty as @Extension extends from namespace reserved super class.
throw new AnnotationValidationException(MessageFormat.format("The @Extension -> namespace " +
"cannot be null or empty, annotated class {1} extends from namespace reserved super class {2}.",
"cannot be null or empty, annotated class {1} extends from namespace reserved super " +
"class {2}.",
name, extensionClassFullName, AnnotationConstants.SINK_SUPER_CLASS));
} else {
//Check if namespace provided matches with the reserved namespace.
Expand All @@ -62,6 +65,7 @@ public void basicParameterValidation(String name, String description, String nam

@Override
public void returnAttributesValidation(ReturnAttribute[] returnAttributes) throws AnnotationValidationException {

if (returnAttributes != null && returnAttributes.length > 0) {
//Throw error for other classes as only in the classes extending
//StreamProcessor or StreamFunctionProcessor allowed to have more than one ReturnAttribute.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
* This processor will extend the validation rules for validate Source Mapping specific annotation contents.
*/
public class SourceMapperValidationAnnotationProcessor extends AbstractAnnotationProcessor {

public SourceMapperValidationAnnotationProcessor(String extensionClassFullName) {

super(extensionClassFullName);
}

Expand Down Expand Up @@ -63,6 +65,7 @@ public void basicParameterValidation(String name, String description, String nam

@Override
public void parameterValidation(Parameter[] parameters) throws AnnotationValidationException {

for (Parameter parameter : parameters) {
String parameterName = parameter.name();
//Check if the @Parameter name is empty.
Expand Down Expand Up @@ -106,6 +109,7 @@ public void parameterValidation(Parameter[] parameters) throws AnnotationValidat

@Override
public void returnAttributesValidation(ReturnAttribute[] returnAttributes) throws AnnotationValidationException {

if (returnAttributes != null && returnAttributes.length > 0) {
//Throw error for other classes as only in the classes extending
//StreamProcessor or StreamFunctionProcessor allowed to have more than one ReturnAttribute.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
* This processor will extend the validation rules for validate Source specific annotation contents.
*/
public class SourceValidationAnnotationProcessor extends AbstractAnnotationProcessor {

public SourceValidationAnnotationProcessor(String extensionClassFullName) {

super(extensionClassFullName);
}

Expand Down Expand Up @@ -63,6 +65,7 @@ public void basicParameterValidation(String name, String description, String nam

@Override
public void parameterValidation(Parameter[] parameters) throws AnnotationValidationException {

for (Parameter parameter : parameters) {
String parameterName = parameter.name();
//Check if the @Parameter name is empty.
Expand Down Expand Up @@ -106,6 +109,7 @@ public void parameterValidation(Parameter[] parameters) throws AnnotationValidat

@Override
public void returnAttributesValidation(ReturnAttribute[] returnAttributes) throws AnnotationValidationException {

if (returnAttributes != null && returnAttributes.length > 0) {
//Throw error for other classes as only in the classes extending
//StreamProcessor or StreamFunctionProcessor allowed to have more than one ReturnAttribute.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
* This processor will extend the validation rules for validate Store specific annotation contents.
*/
public class StoreValidationAnnotationProcessor extends AbstractAnnotationProcessor {

public StoreValidationAnnotationProcessor(String extensionClassFullName) {

super(extensionClassFullName);
}

Expand Down Expand Up @@ -63,6 +65,7 @@ public void basicParameterValidation(String name, String description, String nam

@Override
public void parameterValidation(Parameter[] parameters) throws AnnotationValidationException {

for (Parameter parameter : parameters) {
String parameterName = parameter.name();
//Check if the @Parameter name is empty.
Expand Down Expand Up @@ -106,6 +109,7 @@ public void parameterValidation(Parameter[] parameters) throws AnnotationValidat

@Override
public void returnAttributesValidation(ReturnAttribute[] returnAttributes) throws AnnotationValidationException {

if (returnAttributes != null && returnAttributes.length > 0) {
//Throw error for other classes as only in the classes extending
//StreamProcessor or StreamFunctionProcessor allowed to have more than one ReturnAttribute.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@
* This processor will extend the validation rules for validate Stream Function specific annotation contents.
*/
public class StreamFunctionProcessorValidationAnnotationProcessor extends AbstractAnnotationProcessor {

public StreamFunctionProcessorValidationAnnotationProcessor(String extensionClassFullName) {

super(extensionClassFullName);
}

@Override
public void parameterValidation(Parameter[] parameters) throws AnnotationValidationException {

for (Parameter parameter : parameters) {
String parameterName = parameter.name();
//Check if the @Parameter name is empty.
Expand Down Expand Up @@ -71,6 +74,7 @@ public void parameterValidation(Parameter[] parameters) throws AnnotationValidat

@Override
public void returnAttributesValidation(ReturnAttribute[] returnAttributes) throws AnnotationValidationException {

for (ReturnAttribute returnAttribute : returnAttributes) {
String returnAttributeName = returnAttribute.name();
//Check if the @ReturnAttributes name is empty.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@
* This processor will extend the validation rules for validate Stream Processor specific annotation contents.
*/
public class StreamProcessorValidationAnnotationProcessor extends AbstractAnnotationProcessor {

public StreamProcessorValidationAnnotationProcessor(String extensionClassFullName) {

super(extensionClassFullName);
}

@Override
public void parameterValidation(Parameter[] parameters) throws AnnotationValidationException {

for (Parameter parameter : parameters) {
String parameterName = parameter.name();
//Check if the @Parameter name is empty.
Expand Down Expand Up @@ -71,6 +74,7 @@ public void parameterValidation(Parameter[] parameters) throws AnnotationValidat

@Override
public void returnAttributesValidation(ReturnAttribute[] returnAttributes) throws AnnotationValidationException {

for (ReturnAttribute returnAttribute : returnAttributes) {
String returnAttributeName = returnAttribute.name();
//Check if the @ReturnAttributes name is empty.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@
* This processor will extend the validation rules for validate Window Processor specific annotation contents.
*/
public class WindowProcessorValidationAnnotationProcessor extends AbstractAnnotationProcessor {

public WindowProcessorValidationAnnotationProcessor(String extensionClassFullName) {

super(extensionClassFullName);
}

@Override
public void parameterValidation(Parameter[] parameters) throws AnnotationValidationException {

for (Parameter parameter : parameters) {
String parameterName = parameter.name();
//Check if the @Parameter name is empty.
Expand Down Expand Up @@ -71,6 +74,7 @@ public void parameterValidation(Parameter[] parameters) throws AnnotationValidat

@Override
public void returnAttributesValidation(ReturnAttribute[] returnAttributes) throws AnnotationValidationException {

if (returnAttributes != null && returnAttributes.length > 0) {
//Throw error for other classes as only in the classes extending
//StreamProcessor or StreamFunctionProcessor allowed to have more than one ReturnAttribute.
Expand Down
Loading

0 comments on commit 95f31f1

Please sign in to comment.