@@ -6,7 +6,140 @@ Other configuration formats
66PyContainerConfig - Spring Python's original XML format
77-------------------------------------------------------
88
9+ *PyContainerConfig * is a class that scans object definitions stored in the format
10+ defined by PyContainer, which was the original XML format used by Spring Python to define objects.
11+
12+ .. warning ::
13+
14+ PyContainer's format is deprecated
15+
16+ PyContainer's format and the original parser was useful for getting this
17+ project started. However, it has shown its age by not being easy to revise
18+ nor extend. So this format is being retired. This parser is solely provided
19+ to help sustain existing Spring Python apps until they can migrate to
20+ the :doc: `PythonConfig <objects-pythonconfig >`, :doc: `XMLConfig <objects-xmlconfig >`
21+ or the :doc: `YamlConfig <objects-yamlconfig >` format.
22+
23+ .. highlight :: xml
24+
25+ An important thing to note is that PyContainer used the term *component *, while
26+ Spring Python uses *object *. In order to support this legacy format, *component *
27+ will show up in *PyContainerConfig *-based configurations::
28+
29+ <?xml version="1.0" encoding="UTF-8"?>
30+ <components xmlns="http://www.springframework.org/springpython/schema/pycontainer-components"
31+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
32+ xsi:schemaLocation="http://www.springframework.org/springpython/schema/pycontainer-components
33+ http://springpython.webfactional.com/schema/context/spring-python-pycontainer-context-1.0.xsd">
34+
35+ <component id="MovieLister" class="springpythontest.support.testSupportClasses.MovieLister" scope="prototype">
36+ <property name="finder" local="MovieFinder"/>
37+ <property name="description" local="SingletonString"/>
38+ </component>
39+
40+ <component id="MovieFinder" class="springpythontest.support.testSupportClasses.ColonMovieFinder" scope="singleton">
41+ <property name="filename">"support/movies1.txt"</property>
42+ </component>
43+
44+ <component id="SingletonString" class="springpythontest.support.testSupportClasses.StringHolder">
45+ <property name="str">"There should only be one copy of this string"</property>
46+ </component>
47+ </components>
48+
49+ .. highlight :: python
50+
51+ The definitions stored in this file are fed in to a *PyContainerConfig * which
52+ scans it, and then sends the meta-data to the *ApplicationContext *. Then, when
53+ the application code requests an object named "MovieLister" from the container,
54+ the container utilizes an object factory to create an object and return it::
55+
56+ from springpython.context import ApplicationContext
57+ from springpython.config import PyContainerConfig
58+
59+ container = ApplicationContext(PyContainerConfig("app-context.xml"))
60+ service = container.get_object("MovieLister")
61+
62+
963.. _objects-other-formats-springjavaconfig :
1064
1165SpringJavaConfig
12- ----------------
66+ ----------------
67+
68+ .. highlight :: xml
69+
70+ The *SpringJavaConfig * is a class that scans object definitions stored in the
71+ format defined by the Spring Framework's original java version. This makes it
72+ even easier to migrate parts of an existing Spring Java application onto the
73+ Python platform.
74+
75+ .. note ::
76+
77+ This is about configuring Python objects NOT Java objects
78+
79+ It is important to point out that this has nothing to do with configuring
80+ Java-backed beans from Spring Python, or somehow injecting Java-backed beans
81+ magically into a Python object. This is PURELY for configuring Python-backed
82+ objects using a format that was originally designed for pure Java beans.
83+
84+ When ideas like "converting Java to Python" are mentioned, it is meant that
85+ re-writing certain parts of your app in Python would require a similar IoC
86+ configuration, however, for the Java and Python parts to integrate, you
87+ must utilize interoperable solutions like web service or other
88+ :doc: `remoting <remoting >` technologies.
89+
90+ ::
91+
92+ <?xml version="1.0" encoding="UTF-8"?>
93+ <beans xmlns="http://www.springframework.org/schema/beans"
94+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
95+ xsi:schemaLocation="http://www.springframework.org/schema/beans
96+ http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
97+
98+ <bean id="MovieLister" class="springpythontest.support.testSupportClasses.MovieLister" scope="prototype">
99+ <property name="finder" ref="MovieFinder"/>
100+ <property name="description"><ref bean="SingletonString"/></property>
101+ </bean>
102+
103+ <bean id="MovieFinder" class="springpythontest.support.testSupportClasses.ColonMovieFinder" scope="singleton">
104+ <property name="filename"><value>support/movies1.txt</value></property>
105+ </bean>
106+
107+ <bean id="SingletonString" class="springpythontest.support.testSupportClasses.StringHolder">
108+ <property name="str" value="There should only be one copy of this string"></property>
109+ </bean>
110+ </beans>
111+
112+ .. highlight :: python
113+
114+ The definitions stored in this file are fed in to a *SpringJavaConfig * which
115+ scans it, and then sends the meta-data to the *ApplicationContext *. Then, when
116+ the application code requests an object named "MovieLister" from the container,
117+ the container utilizes an object factory to create an object and return it::
118+
119+ from springpython.context import ApplicationContext
120+ from springpython.config import SpringJavaConfig
121+
122+ container = ApplicationContext(SpringJavaConfig("app-context.xml"))
123+ service = container.get_object("MovieLister")
124+
125+ Again, the only difference in your code is using *SpringJavaConfig * instead of
126+ *PyContainerConfig * on one line. Everything is the same, since it is all inside
127+ the *ApplicationContext *.
128+
129+
130+ .. note ::
131+
132+ What parts of Spring Java configuration are supported?
133+
134+ It is important to note that only spring-beans-2.5 has been tested at this
135+ point in time. It is possible that older versions of the XSD spec may also work.
136+
137+ Spring Java's other names spaces, like *tx * and *aop *, probably DON'T work. They
138+ haven't been tested, and there is no special code that will utilize their
139+ feature set.
140+
141+ How much of Spring Java will be supported? That is an open question, best
142+ discussed on `Spring Python's community forum <http://forum.springsource.org/forumdisplay.php?f=45 >`_.
143+ Basically, this is meant to ease current Java developers into Spring Python and/or
144+ provide a means to split up objects to support porting parts of your application
145+ into Python. There isn't any current intention of providing full blown support.
0 commit comments