-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not possible to create a CRUD repository as ExtensionPoint #26
Comments
I don't understand why you say that |
Oh well, you're right. I didn't marked
It's a so called CRUD repository which doesn't need a class: |
I guess I'll do further research and open up a pull request if it fixes this restriction. |
I was able to create a bean now with this method: protected Object createWithoutSpring(Class<?> extensionClass) {
try {
if (isClassAvailable("org.springframework.data.repository.Repository") && Repository.class.isAssignableFrom(extensionClass)) {
PluginWrapper pluginWrapper = pluginManager.whichPlugin(extensionClass);
if (pluginWrapper != null) {
Plugin plugin = pluginWrapper.getPlugin();
if (plugin instanceof SpringPlugin) {
JpaRepositoryFactoryBean repositoryFactoryBean = new JpaRepositoryFactoryBean(extensionClass);
ApplicationContext pluginContext = ((SpringPlugin) plugin).getApplicationContext();
repositoryFactoryBean.setEntityManager(pluginContext.getBean(EntityManager.class));
repositoryFactoryBean.setEntityPathResolver(pluginContext.getBeanProvider(EntityPathResolver.class));
repositoryFactoryBean.afterPropertiesSet();
return repositoryFactoryBean;
}
}
} else {
return extensionClass.newInstance();
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return null;
}
private boolean isClassAvailable(String className) {
try {
Class.forName(className);
return true;
} catch (ClassNotFoundException e) {
return false;
}
} But in the end I'm getting this exception:
I also had to add some dependencies in provided scope and update spring version:
Maybe it's just not possible. I don't know what to try else. |
development ? |
Were you able to get the CRUD Repository to work? |
I'm not able to autowire an Extension in an Extension: https://github.com/keering/keering/blob/master/plugins/widgets/chat/src/main/java/com/github/keering/plugins/widgets/chat/service/impl/ChatHistoryServiceImpl.java#L16
You can start the project by running:
$ ./gradlew build && cd build && java -jar app-1.0-SNAPSHOT.jar
The text was updated successfully, but these errors were encountered: