134130 opened a new issue, #28479:
URL: https://github.com/apache/shardingsphere/issues/28479
## Feature Request
The `@SingletonSPI`, annotation which is based on reflection, makes some
huddles just only using inner classes.
### Is your feature request related to a problem?
- I want to test `SQLStatementParserEngine` with below factory method.
```java
public final class SQLStatementParserEngineFactory {
public static SQLStatementParserEngine getSQLStatementParserEngine (
final DatabaseType databaseType,
final CacheOption sqlStatementCacheOption,
final CacheOption parseTreeCacheOption,
final boolean isParseComment
)
}
```
- In this case, I had an SPI error, which took about 2 days to resolve.
```
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException:
SPI-00001: No implementation class load from SPI
`org.apache.shardingsphere.sql.parser.spi.SQLDialectParserFacade` with type
`MySQL`.`.
```
- Since I used `getSQLStatementParserEngine()` Factory method with `new
MySQLDatabaseType()` not with `DatabaseTypeFactory.get("jdbc:mysql://")`, It
occurred SPI not found exception.
- The reason was `SQLDialectParserFacade` and its implements are annotated
with `@SingletonSPI`.
### Describe the feature you would like.
- Make `DatabaseType` as Enum or provide itself not only with
`@SingletonSPI`.
- `@SingletonSPI` makes some huddles to use inner APIs since it works
based on reflection.
- I think the `DatabaseType` could be considered as Enum (also, it is
singleton already).
- Let's provide `DatabaseType`'s implements as Enum, not only with like
`TypedSPILoader.getService()`.
## Relates
-
https://apacheshardingsphere.slack.com/archives/C026MLH7F34/p1695200318558779
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail:
[email protected]
For queries about this service, please contact Infrastructure at:
[email protected]