Java Spring mutliple ApplicationContext -
the definition of spring applicationcontext
ambiguous, finish whole book of tutorial still cannot understand applicationcontext
stand for.
according spring api, applicationcontext
is:
central interface provide configuration application. read-only while application running, may reloaded if implementation supports this.
the root interface accessing spring bean container. basic client view of bean container.
from above, questions are:
1) keep seeing book mentioned "container", container refer to? 1 container mean 1 java process? or 1 container refer 1 applicationcontext
object?
2) if instantiate 2 applicationcontext
in 1 java application (both in main
body), these 2 interfaces 1 central container? or 2 separate instances? see code below, difference between context1
, context2
? if there singleton in beans.xml
, invoked context1
, context2
, 2 separated instances or same instance?
applicationcontext context1 = new classpathxmlapplicationcontext("beans.xml"); applicationcontext context2 = new classpathxmlapplicationcontext("beans.xml");
quite surprise couldn't find document clarify basic ambiguity, if answer reference somewhere please state it, eager read , can't wait understand concept.
by container refer core spring inversion of control container. container provides way initialize/bootstrap application (loading configuration in xml files or annotations), through use of reflection, , manage lifecycle of java objects, called beans or managed objects.
during initial phase, not have (normally, yet possible) control in application, instead initialized state application when bootstrapping done (or nothing, in case fails).
it replacement, or possibly addition, called ejb3 container; yet, spring provided 1 fails adhere ejb defined standard. historically, adoption of ejb has been limited complexity of specification, spring being newly created project having ejb3 comparable features running on j2se jvm , without ejb container, , easier configuration.
applicationcontext
(as interface, , direct implementation flavours) mean of implementing ioc container, opposed beanfactory
, (a sparsely used and) more direct way of managing beans, way provides base implementation features applicationcontext.
as per second question, can have multiple instances of applicationcontexts, in case, isolated, each own configuration.
Comments
Post a Comment