GithubHelp home page GithubHelp logo

stateis0 / exp Goto Github PK

View Code? Open in Web Editor NEW
575.0 575.0 81.0 1.23 MB

Java extension plugin and hot swap plugin(Java 扩展点/插件系统,支持热插拔,旨在解决大部分软件的功能定制问题)

License: Apache License 2.0

Java 100.00%

exp's Introduction

  GitHub

我是莫那鲁道 👋

  • 🔭 I’m Java engineer
  • 🌱 I’m working in hangzhou
  • 👯 I’m like openSource
  • 😄 Pronouns: 莫那鲁道

Languages and Tools

My Projects

lu-raft-kv

exp

My Summary

exp's People

Contributors

alg-psy avatar jujiale avatar lin1005q avatar neo0820 avatar stateis0 avatar zhanglijun1217 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

exp's Issues

请教通过MyBatis模板生成的代码 Controller类里面包含的服务接口应该如何转化呢?

如题,例如test_simplecodeController类里面有个这样的服务类,然后是通过服务类test_simplecodeService调用业务逻辑的,

@Autowired
private Test_simplecodeService test_simplecodeService;

目前插件加载后直接调用Controller类好像没有办法直接实例化接口,提示 Error creating bean with name 'kpaas.third.plugin.Test_simplecodeController___kpaas_1.0.0': Unsatisfied dependency expressed through field 'test_simplecodeService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'Test_simplecodeService': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [kpaas.service.Test_simplecodeService]: Specified class is an interface

如果使用了插件,这里要对test_simplecodeService做什么改造 才能被test_simplecodeController类使用呢?

插件卸载之后没有将对应的bean移除,导致重新加载插件时候会报错。

建议在cn.think.in.java.open.exp.adapter.springboot2.SpringBootObjectStore类中加上,卸载插件的时候,顺便将对应的bean移除。
/**
* bean移除
* @param beanName
*/
public void unregisterBean(String beanName){
log.info("unregisterBean->beanName:{}",beanName);
beanDefinitionRegistry.removeBeanDefinition(beanName);
}

private void unRegisterCallback(Class<?> aClass, String pluginId) {
String name = UniqueNameUtil.getName(aClass, pluginId);
RestUrlScanComponent urlComponent = cache.get(name);
if (urlComponent != null) {
unregisterBean(name);
urlComponent.unRegister();
cache.remove(name);
}
}

请教一个加载插件的安全问题

如果把这个热加载插件做成一个开放能力,插件由其他开发者提供,有没有安全机制可以控制插件代码的执行范围,类似沙箱机制,就算里面有恶意代码也不会影响操作系统和主程序运行,比如只能操作指定的操作目录,禁止高危函数等。

对某些模块作用的疑问

不太明白各模块的作用,比如example-springboot2,它是主应用吗?如果是的话,拓展接口不应该在这个模块里面吗,同时example-plugin-a-v1插件又是怎么被使用的呢?

SimpleJavaAppMain的main方法启动报错。

    expAppContext = Bootstrap.bootstrap("/Users/liushao/Downloads/exp-main/exp-plugins/","/Users/liushao/Downloads/exp-main/example/simple-java-app/");

启动后报错如下:
14:48:36.491 [main] INFO cn.think.in.java.open.exp.core.impl.Bootstrap - 准备安装插件, 压缩包路径: /Users/liushao/Downloads/exp-main/exp-plugins/example-plugin-b-v2-1.0-SNAPSHOT-1.0-SNAPSHOT.zip
14:48:36.540 [main] INFO cn.think.in.java.open.exp.classloader.support.ClassLoaderFinder - dir /Users/liushao/Downloads/exp-main/example/simple-java-app//cn.think.in.java.open.exp.example.b_2.0.0 isParentMode = parent-first
14:49:04.279 [main] ERROR cn.think.in.java.open.exp.core.impl.Bootstrap - java.lang.NoClassDefFoundError: Lorg/mybatis/spring/SqlSessionTemplate; ---->>>> /Users/liushao/Downloads/exp-main/exp-plugins/example-plugin-b-v2-1.0-SNAPSHOT-1.0-SNAPSHOT.zip
java.lang.RuntimeException: java.lang.NoClassDefFoundError: Lorg/mybatis/spring/SqlSessionTemplate;

is needEnhancer judge logic correct?

hello, I find in the class open.exp.adapter.springboot.common.starter there has logic as below:
`

  public static boolean needEnhancer(Object o) {
          return !(o instanceof ExPIntercept);
      }


  public static Object getEnhancer(Object b, String pluginId) {
      if (!needEnhancer(b)) {
          return b;
      }
      Enhancer enhancer = new Enhancer();
      enhancer.setInterfaces(new Class[]{ExPIntercept.class});
      enhancer.setSuperclass(b.getClass());
      enhancer.setNamingPolicy(new DefaultNamingPolicy() {
          @Override
          protected String getTag() {
              return super.getTag() + "$$MDC$$" + pluginId;
          }
      });
      enhancer.setCallback(new MDCExpMethodInterceptor(pluginId, b));
      return enhancer.create();
  }

`

as the getEnhancer method, if the b instanceof ExPIntercept return false, the Enhancer enhancer = new Enhancer(); could reach, but it set the ExPIntercept as it's Interface, so I think if reach this code, the param b is instanceof ExPIntercept.

if I am right, If it is right, I will submit pr to fix this.

获取主应用属性

您好,想问一下,如果想获取主应用的某个对象,有办法获取吗?

view支持

非前后端分类项目:jsp/thymeleaf 是否支持呀?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.