简体   繁体   English

缝的设计问题

[英]Design problem with Seam

I have a clever program which given a file containing very specific metadata of a database, an entire project is generated for me in eclipse. 我有一个聪明的程序,给定一个包含非常特定的数据库元数据的文件,整个项目都会在eclipse中为我生成。 It uses hibernate to access the database and provides basic crud functionality as well as provides xhtml interface. 它使用hibernate访问数据库,并提供基本的crud功能以及xhtml界面。

It all works great and virtually anything can be done so long as simple operations are required. 一切都很好,只要需要简单的操作,几乎可以做任何事情。 However, of course I'm expecting that sooner or later I'm going to need to modify this project to achieve some customized behavior. 但是,当然,我期望迟早要修改此项目以实现某些自定义行为。

I could just modify the project and never look back, but I'd be losing the tremendous advantage of being able to regenerate the project to add new tables and behaviors. 我可以只修改项目而从不回头,但是我将失去能够重新生成项目以添加新表和行为的巨大优势。 While I could generate a new project with my changes and apply those changes by hand, I'd rather not have to do this for every change I need to make. 尽管我可以使用所做的更改生成一个新项目并手动应用这些更改,但我宁愿不必对需要进行的每个更改执行此操作。

Unfortunately, the tool which generates this project can't be touched (for reasons that it's not our tool but a tool of a third party software company which produces project templates). 不幸的是,无法触摸生成该项目的工具(由于它不是我们的工具,而是产生项目模板的第三方软件公司的工具)。

I noticed that it heavily uses the Seam framework to instantiate generated classes (using @In(create = true) ). 我注意到它大量使用Seam框架实例化生成的类(使用@In(create = true) )。 Is there anyway to extend a generated class such that regenerating existing classes won't override my changes, yet have these extended classes be instantiated instead? 无论如何,有没有扩展生成的类,以便重新生成现有类不会覆盖我的更改,而是实例化了这些扩展类?

Is there some strategy that I can use in order to minimize modification to generated classes (ideal case would be to modify behavior simply by adding files to the project, though I realize that wouldn't be possible for xhtml files)? 我是否可以使用某种策略来最小化对生成的类的修改(理想情况是仅通过向项目中添加文件来修改行为,尽管我意识到xhtml文件是不可能的)? Any help would be appreciated, though I realize that some changes must be made to the tool before this would be possible (for example a factory?). 任何帮助将不胜感激,尽管我意识到必须对工具进行一些更改,然后才能进行此操作(例如,工厂?)。

This sounds to me like seam-gen too. 在我看来,这听起来也很像seam-gen。 This can help you: http://seamframework.org/Community/ModifyingSeamgen 这可以帮助您: http : //seamframework.org/Community/ModifyingSeamgen

I don't like seam-gen. 我不喜欢seam-gen。 It's a shortcut tool with a price. 这是有价的快捷工具。 See this post http://shervinasgari.blogspot.com/2010/10/why-you-should-not-use-seam-application.html 看到这篇文章http://shervinasgari.blogspot.com/2010/10/why-you-should-not-use-seam-application.html

I love Seam, but I don't use/like seam-gen. 我喜欢Seam,但是不喜欢/不喜欢seam-gen。 seam-gen don't fit for real-world apps. seam-gen不适合实际应用。

Besides this: 除此之外:

@In(create=true) BeanClass beanName

injects a bean with name "beanName" and type BeanClass, from some context. 从某些上下文中注入名称为“ beanName”的bean并键入BeanClass。 If that bean doesn't exists yet, then it will be created (because create=true). 如果那个bean还不存在,那么它将被创建(因为create = true)。 If it exists at some context (page, request, session, app, workflow, etc), it will be found it and it will be injected at property beanName. 如果它存在于某些上下文(页面,请求,会话,应用程序,工作流等)中,则会找到它并将其注入到属性beanName中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM