【问题标题】:Other frameworks with compile time/ runtime "mixins" feature like Spring Roo for Java其他具有编译时/运行时“混合”功能的框架,例如 Spring Roo for Java
【发布时间】:2011-05-30 16:33:47
【问题描述】:

我想知道有什么框架可以自动将方法注入 Java 类,类似于 Spring Roo 的“mixins”。

例如,在 Spring roo 中,我们对类进行如下污染:

    @RooEntity public class Hello {
        private String world;
    }

并且 Roo 框架在编译时生成所有必要的方法如下:

 public class Hello {
  private String world {..}
  public String getWorld() {..}
  public void setWorld(String world) {..}
  public Long getId() {..}
  public void setId(Long id) {..}
  public Integer getVersion() {..}
  public void setVersion(Integer version) {..}
  public String toString() {..}
  public void persist() {..}
  public void remove() {..}
  public void flush() {..}
  public static Long countHellos() {..}
  public static Hello findHello(Long id) {..}
  public static List findAllHellos() {..}
  public static List findHelloEntries(int start, int finish) {..}
  // there are even more methods
 }

我不想使用 Spring Roo,但想要一些其他框架来解决这个问题。

提前致谢。

阿布舍克

【问题讨论】:

  • 经过大量搜索后,我找到了 Lombok 项目,它提供了类似的东西 projectlombok.org

标签: java aop spring-roo code-injection mixins


【解决方案1】:

试试 Sculptor:
概述:“sites.google.com/site/fornaxsculptor/”
真实的东西:http://fornax.itemis.de/confluence/display/fornax/Sculptor+(CSC)

有许多教程可供您随时学习。

它的作用远不止实体生成。它可以在几秒钟内为您构建完整的 DDD 层。您还可以使用 JSF、Smartclient 和 Eclipse Rich GUI 构建 GUI。

多年来,我们一直将其用于生产项目。 Sculptor 博客上的成功故事。如果您有任何问题,欢迎访问“groups.google.com/group/fornax-platform/”

对不起,短链接,因为“防止垃圾邮件”,不能提交多个:-)

【讨论】:

    【解决方案2】:

    Spring Roo 的 mixin 基于 AspectJ inter-type declarations。至少 Roo 只生成 .aj 文件,而 AspectJ 将其编织到“普通”java 文件中。 -- 所以如果你没有找到任何你想要的框架,然后构建你自己的代码生成器,例如基于XText

    顺便说一句:我不知道除了 Roo 以外的任何其他人都这样做,但我记得(75% 肯定)Roos 的一些想法基于其他框架。 (但我找不到我读过的那篇文章。)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多