forked from google/tsunami-security-scanner
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Guice module for providing ScanResult from ClassGraph.
PiperOrigin-RevId: 320290436 Change-Id: I9eb0dc02fe06a1057cad4cafbcae3b003295338b
- Loading branch information
1 parent
e7f68dd
commit 18d52f5
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
common/src/main/java/com/google/tsunami/common/reflection/ClassGraphModule.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,35 @@ | ||
/* | ||
* Copyright 2020 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.google.tsunami.common.reflection; | ||
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
import com.google.inject.AbstractModule; | ||
import io.github.classgraph.ScanResult; | ||
|
||
/** Guice module for providing ClassGraph bindings. */ | ||
public final class ClassGraphModule extends AbstractModule { | ||
private final ScanResult scanResult; | ||
|
||
public ClassGraphModule(ScanResult scanResult) { | ||
this.scanResult = checkNotNull(scanResult); | ||
} | ||
|
||
@Override | ||
protected void configure() { | ||
bind(ScanResult.class).annotatedWith(RuntimeClassGraphScanResult.class).toInstance(scanResult); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
common/src/main/java/com/google/tsunami/common/reflection/RuntimeClassGraphScanResult.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,31 @@ | ||
/* | ||
* Copyright 2020 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.google.tsunami.common.reflection; | ||
|
||
import static java.lang.annotation.ElementType.FIELD; | ||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.PARAMETER; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
import javax.inject.Qualifier; | ||
|
||
/** Annotation for the ClassGraph {@link io.github.classgraph.ScanResult} at runtime. */ | ||
@Qualifier | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({PARAMETER, METHOD, FIELD}) | ||
public @interface RuntimeClassGraphScanResult {} |
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