著名 Java 软件包的用例
我正在浏览一些 Java 软件包(Guice、GWT、JAX-RS 等),我的头很晕,因为我真的不知道这些特定软件包发挥作用时的用例。 这些教程似乎向您展示了如何使用他们的包做某事,但没有告诉您为什么您想要使用他们的包(或者在某些情况下您不会)。
所以我想知道人们是否可以为 Java 库发布一些用例(或“不用例”),这可能并不明显,以补充 规范的什么是好的免费 Java 库问题。 我对 Guice 特别感兴趣,但这是一个更普遍的问题。
编辑:如果您知道有一个非常好的网页可以回答特定包的此问题(例如解释 Hibernate 或 JAXB 或其他内容的用例),请链接到它。
I am browsing some of the Java software packages (Guice, GWT, JAX-RS, etc.) and my head is spinning quite a bit because I don't really know the use cases when these particular software packages shine. The tutorials seem to show you how to do something with their package, but not why you would want to use their package (or in which cases you would not).
So I'm wondering if people could post some use cases (or "don't use cases") for Java libraries for which this may not be obvious, to complement the canonical what-are-good-free-Java-libraries question. I have a particular interest regarding Guice but it's kind of a more general question.
edit: if you are aware of a really good webpage that answers this question for a particular package (e.g. explains use cases for Hibernate or JAXB or whatever), please link to it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(12)
应用程序配置
Guice 是一个辅助应用程序的库配置。 那是; 您的应用程序将被编写为一堆交互的类,这些类通过它们导出的接口相互通信(这是很好的编程实践,因为它有助于测试和维护)。 Guice 帮助您将这些类连接和配置在一起,以形成真正的运行配置。
Spring 也解决了同样的问题,但从 XML 角度开始,而 guice 是 <代码>注释驱动。 然而,Spring 远不止于此,它包含许多使开源软件集成变得简单的内容。 这是非常值得探索的。
然而,这个领域还有其他解决方案,例如 PicoContainer 和 NanoContainer (它们的受欢迎程度要低得多,可能是由于缺乏文档)
Application Configuration
Guice is a library which aids in application configuration. That is; your application will be written as a bunch of interacting classes which communicate with one another via interfaces they export (which is good programming practice as it aids in testing and maintenance). Guice helps you wire and configure these classes together to make a real, running configuration.
Spring also solves the same problem but started from an XML perspective whereas guice is
annotation
-driven. Spring is so much more than this, however, and contains much that makes integration of Open Source software simple. It is well worth exploring.There are other solutions in this space, however, like PicoContainer and NanoContainer (which caught on much less, probably due to their lack of documentation)
Apache Commons
Apache 有大量的东西,但最明显的是 commons 库,其中包含一些(大部分是无用的) ) 集合、Digester(可以更轻松地将自定义 XML 配置集成到您的应用程序中)、net 网络工具包(用于 FTP 等)。
Apache Commons
There's a ton of stuff from Apache but most obvious are the commons libraries, which contain some (mostly useless) collections, the Digester which makes it easier to integrate custom XML config into your application, the net networking toolkit (for FTP and things like that).
如果您想将内容持久保存在数据库中,请使用某种持久性框架,而不是在裸 JDBC 上手工编写 SQL; 你会避免很多麻烦。
Hibernate 是一个流行的选择,但是任何实现 JPA 就可以了。
If you want to persist stuff in a database, use some kind of persistence framework rather than handcrafted SQL on naked JDBC; you'll avoid loads of hassle.
Hibernate is a popular choice, but anything implementing JPA will do.
GlazedLists:用于查看/编辑/导航/过滤/排序的 GUI 适配器框架/使用 JTable 或 JTree 绑定对象列表。 (例如,如果您有一个
MP3
对象列表,其中包含各种字段,如艺术家、标题、专辑、流派等。这使得映射MP3
的字段变得非常容易对象到 JTable 的列,按照您想要的方式格式化,而无需编写太多代码。)适合存储在内存中的中小型对象列表:您必须使用 GlazedLists 的
BasicEventList 和其他关联类作为集合实现,而不是您自己的任意
List<>
,除非您想实现EventList
接口的所有方法。因此,这使得封装预先存在的存储机制(例如数据库)变得困难。 我已经在 5000 到 50000 计数范围内的项目列表上使用过它,并且速度相当快。GlazedLists: a GUI adapter framework for viewing/editing/navigating/filtering/sorting/binding lists of objects with a JTable or JTree. (e.g. if you have a list of
MP3
objects with various fields like Artist, Title, Album, Genre, etc. it makes it very easy to map the fields of theMP3
object to the columns of a JTable, formatted the way you want, without having to write much code.)Good for small-to-moderately-large lists of objects stored in memory: you have to use GlazedLists'
BasicEventList
and other associated classes as the collection implementations, rather than your own arbitraryList<>
, unless you want to implement all of the methods of theEventList
interface... so this makes it hard to encapsulate preexisting storage mechanisms (like a database, for instance). I've used it onList<>
s of items in the 5000- to 50000-count range and it is fairly fast.Web 开发
GWT 是一个 google 工具包,可让您编写 Java 用户然后 GWT 将接口代码(尽管是受限制的子集)编译成 javascript,以便可以通过 Web 浏览器查看。 这使得开发富互联网应用程序 (RIA) 变得很容易。
Web Development
GWT is a google toolkit which allows you to write Java user interface code (albeit a restricted subset) which GWT then compiles into javascript so that it is viewable via a web-browser. This makes it easy (ish) to develop rich internet applications (RIAs).
调度软件
Quartz 是一个开源调度库,它允许您执行复杂的类似 cron 的(甚至定制的)作业调度、持久作业状态等
Scheduling Software
Quartz is an open source scheduling library which allows you to do complex cron-like (or even bespoke) scheduling of jobs, persist job state etc
用于测试的 JUnit、TestNG 和 EasyMock(还有很多其他的,这些是我们使用的)。
JUnit 允许您轻松创建作为测试一部分运行的方法,EasyMock 允许您创建要传递的“模拟”(或假)对象,该对象将以非常特定的方式响应,您可以使用它来测试依赖于测试期间不存在的框架或运行环境。
JUnit, TestNG and EasyMock for testing (there are many others, those are the ones we use).
JUnit allows you to easily create methods that run as part of a test, EasyMock allows you to create "Mock" (or fake) objects to pass in that will respond in very specific ways which you can use to test a method that relies on a framework or running environment that isn't there during testing.
构建系统
Ant 是一个 Java 构建系统,您可以通过它构建部署并运行您的 Java 应用程序(以及更多其他应用程序)通过您在
XML
中定义的配置文件。Maven 是另一个构建系统,它的存在是因为它试图解决项目的问题具有多个依赖项和相互依赖项(仅使用
ant
可能会变得丑陋)。Build Systems
Ant is a Java build system, whereby you can build deploy and run your Java application (and a whole lot more besides) via a configuration file which you define in
XML
.Maven is another build system which exists because it tries to solve the problem of projects with multiple dependencies and inter-dependencies (which can get ugly using only
ant
).首先定义您的问题,然后通过 FOSS 寻找解决方案(如果有帮助的话)。 那里的图书馆太多了,疯狂地列出很多图书馆是不切实际的。
First define your problem and then go searching for a solution via FOSS if that helps. There are just too many libraries out there and it would not be practical to go crazy and list lots of them.
JGoodies Forms:为 Swing (FormLayout) 提供强大且易于理解的布局管理器。
Swing 通过 JDK 提供了许多布局管理器,但创建复杂的布局可能很困难。 要么您最终使用大量的 JPanel,每个 JPanel 都有不同的布局管理器,要么您花费数小时试图理解 GridBagLayout。 FormLayout 通过使用简单的语言来描述布局,提供了一种创建复杂布局的简单方法。 这种语言可以轻松地在纸上模拟表单,然后将其转换为代码。
JGoodies Forms: Provides a powerful layout manager for Swing (FormLayout) that remains easy to understand.
Swing provides a number of layout managers with the JDK but creating complex layouts can be difficult. Either you end up using a really large number of JPanels each with different layout managers or you spend hours trying to understand GridBagLayout. FormLayout provides a simple way to create complex layouts by using a simple language to describe the layout. This language makes it easy to mock up you forms on paper and then convert it to code.
工作流程软件
OSWorkflow是一个开源项目,用于定义定制工作流程(通过
XML
)。 这些工作流程可以是持久的并挂接到您的 Java 代码中Workflow Software
OSWorkflow is an open-source project for the definition of bespoke workflows (via
XML
). These workflows can be persistent and hook into your Java code优秀的 Java 数值库列表:
http://commons.apache.org/math/
http://dsd.lbl.gov/~hoschek/colt/
http://gams.nist.gov/javanumerics/jama/
对于数字很有用,显然:)
List of good numerical Java libraries:
http://commons.apache.org/math/
http://dsd.lbl.gov/~hoschek/colt/
http://gams.nist.gov/javanumerics/jama/
Useful for numerics, obviously :)