To create an instance of the Factory Method Pattern, perform the same steps as for the Singleton Pattern.
要创建Factory方法模式的实例,执行同Singleton模式相同的步骤。
The factory method pattern, as its name implies, defines the implementation of a method used to churn out objects.
而工厂方法模式,顾名思义,定义的是一个用来大量产出对象的方法的实现。
The Factory Method Pattern defines an interface for creating an object, but lets subclasses decide which class to instantiate.
工厂方法模式定义了一个创建对象的接口,但由子类决定实例化的逻辑。
You use the factory method pattern when an application needs to create objects whose type depend on the implementation of subclasses.
您可以在应用程序需要创建其类型依赖于子类的实现的对象时,使用工厂方法模式。
Patterns (such as the Factory Method mentioned in this article) are an important tool for understanding and discussing object-oriented design.
模式(如本文中提到的Factory Method模式)是理解和讨论面向对象设计的重要工具。
Create the SecurityManager instance based on the configuration (using Shiro’s Factory concept that represents the Factory Method design pattern).
根据配置创建SecurityManager实例(使用Shiro的工厂概念,它表述了 工厂方法设计模式);
Concrete classes provide the appropriate implementation for their respective base class. The Factory Method Pattern consists of the following classes.
concrete类为它们各自的基类提供恰当的实现。
The Factory Method Pattern is a creational pattern that defines an interface for creating an object but lets subclasses decide which actual class to instantiate.
Factory方法模式是一个创建的模式,它定义一个用来创建对象的接口,而让子类来决定实例化哪个类。
Apply the Extract method refactoring to this creation code, creating the factory method (discussed on page 110 of Fowler's book; see the Resources section for more information).
将抽取方法重构应用于这个创建代码,创建工厂方法(在Fowler书籍的第110页中讨论;有关更多信息,请参阅参考资料一节)。
At this point, you may be tempted to go one step further and replace the factory method with a full-fledged abstract factory object, as detailed in Design Patterns by Erich Gamma, et al.
此时,您可能很想更进一步并用成熟的抽象工厂对象替换工厂方法,如ErichGamma等人在设计模式中详细描述的那样。
Once data is initialized, Seam can place the resulting object into one of the available scopes where it can be read over and over without further participation of the factory method.
一旦初始化数据之后,Seam就可以将生成的对象放到一个可用的作用域中,然后就可以在其中反复读取,而不再需要借助工厂方法。
Because we overrode the factory method to write this test, it turns out that we no longer have any test coverage of the original creation code (which is now inside the base class's factory method).
因为我们覆盖了工厂方法来编写这个测试,所以其结果是:我们的测试不再包括任何原始创建代码(现在它在基类的工厂方法内部)。
Remember that once these options are set, they affect all instances obtained from the factory after the method invocation.
请记住,一旦设置了这些选项,在调用该方法之后,它们将影响所有从类厂获得的实例。
The singleton, builder, and factory method design patterns are considered creational patterns, as they assist in the construction of objects.
单例、生成器和工厂方法设计模式被视为是创建型的模式,因它们可协助对象的构建。
This section offers a step-by-step description of the Extract and Override factory method refactoring.
本节将循序渐进地描述“抽取”和“覆盖”工厂方法重构。
The new element creation technique (lines 15-16) differs both by the use of a QName object to represent the element name and by calling a method of the saved factory to build the element.
通过使用QName对象来表示元素名称和通过调用已保存的工厂的方法来构建元素可以区别新元素的创建技术(第 15-16 行)。
The solution here is to provide a method parameter with a factory method for the items to read, as shown in Listing 2.
这里的解决方案是为要读取的条目提供一个带工厂方法的方法参数,如清单2所示。
This is another rather boring line of code: Just call newTransformer() on your factory and supply the method with the XSL stylesheet you want to use. Listing 4 shows you what to do
这是另一段相当令人厌烦的代码:只在工厂上调用newTransformer(),并为该方法提供要使用的XSL样式表。
You can retrieve an MXBean instance from a static factory method that gives you direct access to the locally running JVM's MXBean interface.
您可以从一个静态工厂方法获得一个MXBean实例,该方法可以使您直接访问本地运行的JVM的MXBean接口。
The @Factory annotation attaches a method to the creation process of an outjected variable, specified in the value of the annotation, when that variable has no value bound to it.
@Factory注释向已提取变量的创建过程附加了一个方法,这是在注释的值中指定的,当该变量没有绑定任何值时就会使 用该方法。
The code in Listing 2 takes as input the actual XML instance and USES the parse method of the Factory class of AutomobilePolicyDocument to get an instance of AutomobilePolicyDocument.
清单2的代码接受输入的xml实例,并使用AutomobilePolicyDocumentFactory类的parse方法获得AutomobilePolicyDocument实例。
The example gave a client and server bundle (both in the same VM), and the client found the server via a factory method.
文中的例子给出了一个client和一个serverbundle(两者在同一个VM中),client通过工厂方法找到server。
This can be as simple as invoking the base class's factory method and asserting that the returned object is of the correct type. For example.
这与调用基类的工厂方法并断言返回对象具有正确类型一样简单。
In this way, the object returned from the static factory method could implement any number of interfaces defined when I create the proxy.
用这种方式,静态工厂方法返回的对象可以实现建立代理时所定义的任意数量的接口。
This factory method instantiates the collection of course objects by delegating the work to the service layer.
该工厂方法通过将这项工作委托给服务层来实例化课程对象集合。
The factory implementation produced by the wizard offers a convenient shortcut that allows overriding of the basic factory method so a URL can be passed to the factory when the stub is created.
由向导生成的工厂实现提供了一个简化操作,就是允许覆写基本的工厂方法,因此当存根被创建时URL就可以被传递到工厂。
After the new instance is created, the factory provides a method for obtaining a SAX-capable parser.
新实例创建之后,工厂提供一种方法用于获得具有SAX功能的解析器。
After the new instance is created, the factory provides a method for obtaining a SAX-capable parser.
新实例创建之后,工厂提供一种方法用于获得具有SAX功能的解析器。
应用推荐