Web是一个多用户环境,所以在一个静态对象中(如singleton)保持应用状态是有可能引起问题的。
The web is a multiunser environment, so holding application state in static objects such as singletons is likely to cause issues
注意:这些类中的所有方法都是静态的,所以测试开发人员不需要将这个类实例化为一个对象就可以使用这些方法。
Note: All methods in these classes are static, so the test developer does not need to instantiate an object of this type to use them.
一个更优雅且根本上更灵活的解决方案就是使用静态横切来对预期对象添加行为。
A more elegant and ultimately more flexible solution is to employ static crosscutting to add the behavior to desired objects.
静态横切和动态横切的区别在于它不修改一个给定对象的执行行为。
Static crosscutting differs from dynamic crosscutting in that it does not modify the execution behavior of a given object.
其他两个构造方法只是调用静态方法IndexReader . open把你的文件路径或Directory对象转换成一个IndexReader。
The other two constructors just turn your file path or Directory object into an IndexReader by calling the static method IndexReader.open .
该关系分别为这四个业务对象的非主键state属性定义一个静态关系。
The relationship defines a static relationship for the non-primary key state property for each of the four business objects.
方法调度通过把对象作为参数,来调用一个名为“ClassOf”的静态方法予以实现。
Method dispatch starts by calling a static "ClassOf" method with the object as argument.
MessageDiges t类有一个笨拙的基于工厂的静态方法api,它不是面向对象的,并且你被迫去捕获那些永远都不必捕获的CheckedExceptions。
It has an awkward static method factory-based API instead of an object-oriented one, and you are forced to catch checked exceptions that may never need to be caught.
本文讨论了两个潜在的区域,该区域为RationalPerformance Tester提供了强大的扩展点:通过一个超类来进行对象扩展,以及通过静态的方法来使用可再用设施。
This article discusses two potential areas that can provide powerful extension points for Rational Performance Tester: object extension via a super class, and reusable utilities via static methods.
给定一个对象(比如下面定义的Foo),静态横切使得创建新方法、添加附加的构造函数,甚至改变继承层次都变得十分简单。
Given an object (such as Foo, defined below), static crosscutting makes it quite simple to create new methods, add additional constructors, and even alter the inheritance hierarchy.
这种模式的典型实现方式是创建一个抽象类,其中具有静态方法create,这个方法返回的是实现了这个抽象类的一个具体对象。
Typically this is implemented by having an abstract class that has a static create method that returns a concrete object implementing the abstract class.
这一示例应用程序将字符串对象泄漏到一个静态hashmap中。
This sample application leaks string objects into a static HashMap.
因为这是一个静态实现,而且不能在XmlObject中存储实例变量,所以需要在别处存储对更改感兴趣的对象的列表。
Since this is a static implementation and you cannot store instance variables in XmlObjects, you need to store the list of interested parties elsewhere.
包含四个角色的静态关系(一个角色对应一个业务对象)。
A static relationship containing four roles (a role for each business object).
当一个属性不具有静态修饰符时,就称其是一个对象属性,因为该属性对类的每个实例都是惟一的。
When an attribute does not have the static modifier, it is said to be an object attribute, as that property is unique for each instance of the class.
该指南建议您在应用程序启动时使用一个静态最终变量来创建这个对象,然后根据需要获取该对象。
The guide recommends you use a static final variable to create the object once at application startup and then get this object when needed.
使用静态工厂方法创建一个msg对象。
这通常是一个保留静态引用的类对象;例如,清单1的内存泄漏示例中的MyClass对象。
This is often a class object which holds a static reference; for example, the MyClass object in the memory leak example in Listing 1.
但小心多线程静态因为整个班都要被锁定,而不是一个对象。这会导致并发瓶颈。
But be careful with multithreading with statics since the whole class has to be locked rather than just one object. This can lead to concurrency bottlenecks.
这个函数返回一个对象静态域的值。
This function returns the value of a static field of anobject.
这个函数返回一个对象实例(非静态)域的值。
This function returns the value of an instance (nonstatic) field of an object.
当抛出一个表达式的时候,被抛出对象的静态编译时类型将决定异常对象的类型。
When an exception is thrown, the static, compile-time type of the thrown object determines the type of the exception object.
这个函数设置一个对象的静态域的值。
The value to set is a reference to either a java. lang. Object, or asubclass thereof.
这个函数返回一个对象静态域的值。
This function returns the value of a static field of an object.
当一个对象被创建时,它接收的静态成员,能值被改变?
When an object is created, does it receive the static member, and can that value be changed?
但小心多线程静态因为整个班都要被锁定,而不是一个对象。
But be careful with multithreading with statics since the whole class has to be locked rather than just one object.
这个函数设置一个对象实例(非静态)域的值。
This function sets the value of an instance (nonstatic) field of an object.
为什么这二代码声明一个方法范围变量并将其分配给一个静态的,类级别的对象?
Why does this DI code declare a method-scope var and then assign it to a static, class-level object?
尽管你的确可以在显示器上移动图形对象,但是GDI通常是一个仅有有限的动画支持的静态显示系统。
Although you can certainly move graphics objects around the display, GDI is generally a static display system with only limited animation support.
尽管你的确可以在显示器上移动图形对象,但是GDI通常是一个仅有有限的动画支持的静态显示系统。
Although you can certainly move graphics objects around the display, GDI is generally a static display system with only limited animation support.
应用推荐