具有编译时/运行时“mixins”的其他框架类似 Spring Roo for Java 的功能

发布于 2024-10-09 03:32:21 字数 941 浏览 7 评论 0原文

我想知道是否有任何框架可以自动将方法注入到 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,但想要一些其他框架来完成此操作。

提前致谢。

阿布舍克

I am wondering there is any framework which automatically injects methods into Java class similar to Spring Roo's "mixins".

For Example in Spring roo we defile class as follows:

    @RooEntity public class Hello {
        private String world;
    }

And the Roo framework generates all the necessary methods at compile time as follows:

 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
 }

I do not want to use Spring Roo but want some other framework that dose just this.

Thanks in advance.

Abhishek

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

江湖正好 2024-10-16 03:32:21

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

有许多教程可供您遵循和学习,

它的功能远不止实体生成,您还可以使用 JSF 构建 GUI。 、Smartclient 和 Eclipse Rich GUI

多年来我们一直在 Sculptor 博客上使用它。如果您有任何疑问,欢迎访问“groups.google.com/group/fornax-platform/”

。链接,由于“垃圾邮件预防”,无法提交多个链接:-)

Try Sculptor:
Overview: "sites.google.com/site/fornaxsculptor/"
Real stuff: http://fornax.itemis.de/confluence/display/fornax/Sculptor+(CSC)

Many tutorials are available which you can follow and learn as you go.

It does much more than entity generation. It can build you full DDD layer in seconds. You can build also GUI with JSF, Smartclient and Eclipse Rich GUI.

We are using it for production projects for years. Success story on Sculptor blog. If you have any questions, you are welcome on "groups.google.com/group/fornax-platform/"

Sorry for short links, can't submit more than one because of "spam prevention" :-)

心在旅行 2024-10-16 03:32:21

Spring Roo 的 mixin 基于 AspectJ 类型间声明 。至少 Roo 只生成 .aj 文件,而 AspectJ 将其编织到“普通”java 文件中。 -- 因此,如果您没有找到任何可以实现您想要的功能的框架,请构建您自己的代码生成器,例如基于 X文本

顺便说一句:除了 Roo 之外,我不知道还有其他人会这样做,但我记得(75% 确定)Roos 的一些想法是基于其他框架的。 (但我找不到我读过的文章。)

Spring Roo's mixin is based on AspectJ inter-type declarations. At least Roo only generates .aj files, and AspectJ woves that into the "normal" java files. -- So if you do not find any framework that does what you want, then build your own Code generator, for example based on XText.

By the way: I do not know any other than Roo that does it in this way, but I remember (75% sure) that some of Roos ideas based on an other Frameworks. (But I can't find the article where I have read that.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文