简体   繁体   English

Java应用程序对象……它存储在哪里?

[英]Java application object… where is it stored?

I'm thinking about using the java application object to implement a simple cache, to save a few configuration variables, and a couple of xml with often used info... 我正在考虑使用Java应用程序对象实现简单的缓存,保存一些配置变量以及一些带有常用信息的xml ...

I'd like to know where is the application data phisically stored (a system file, in memory, db), how can it be configured, and if there's any kind of limitation, like space, concurrency, etc... 我想知道应用程序数据的物理存储位置(系统文件,内存,数据库),如何配置以及是否存在任何限制,例如空间,并发性等。

Besides, any other concern regarding scalabitlity (both, in size and in concurrency) would be appreciated... 此外,关于可伸缩性(大小和并发性)的任何其他担忧将不胜感激。

And if anybody can point me some place to find more info, I'll be very glad... 如果有人可以指点我寻找更多信息的地方,我将非常高兴...

thanks a lot 非常感谢

Objects are stored in the heap. 对象存储在堆中。 Heap spaced can be managed through the VM's configuration file. 可以通过VM的配置文件来管理间隔的堆。

A constructor call is more complicated than an ordinary subroutine or function call. 构造函数调用比普通的子例程或函数调用更为复杂。 It is helpful to understand the exact steps that the computer goes through to execute a constructor call: 了解计算机执行构造函数调用所经过的确切步骤是有帮助的:

  1. First, the computer gets a block of unused memory in the heap, large enough to hold an object of the specified type. 首先,计算机在堆中获取一块未使用的内存,其大小足以容纳指定类型的对象。
  2. It initializes the instance variables of the object. 它初始化对象的实例变量。 If the declaration of an instance variable specifies an initial value, then that value is computed and stored in the instance variable. 如果实例变量的声明指定了初始值,则将计算该值并将其存储在实例变量中。 Otherwise, the default initial value is used. 否则,将使用默认初始值。
  3. The actual parameters in the constructor, if any, are evaluated, and the values are assigned to the formal parameters of the constructor. 评估构造函数中的实际参数(如果有),并将值分配给构造函数的形式参数。
  4. The statements in the body of the constructor, if any, are executed. 如果存在,则执行构造函数主体中的语句。
  5. A reference to the object is returned as the value of the constructor call. 返回对该对象的引用作为构造函数调用的值。

The end result of this is that you have a reference to a newly constructed object. 最终结果是您对一个新构造的对象有一个引用。 You can use this reference to get at the instance variables in that object or to call its instance methods. 您可以使用此引用来获取该对象中的实例变量或调用其实例方法。

http://www.faqs.org/docs/javap/c5/s2.html http://www.faqs.org/docs/javap/c5/s2.html

Here are some of the VM configuration parameters 以下是一些虚拟机配置参数

http://www.caucho.com/resin-3.0/performance/jvm-tuning.xtp http://www.caucho.com/resin-3.0/performance/jvm-tuning.xtp

I once wrote a Cache for xml objects (to call them somehow). 我曾经为xml对象编写了一个Cache(以某种方式调用它们)。 A Map with a String key (filename) and a reference to the Object (parsed xml file) sufficed. 具有字符串键(文件名)和对对象的引用(已解析的xml文件)的Map就足够了。 In addition to that, the cache was a singleton (synchronized). 除此之外,缓存是一个单例(已同步)。 Did the same for caching compiled JasperReports (i got a notable speed bump here, because reports where no longer compiled every single time) 对缓存已编译的JasperReports进行了同样的操作(我在这里有了明显的提速,因为不再每次都重新编译报告)

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

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