Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you read <a href="http://static.springsource.org/spring-python/1.2.x/sphinx/html/objects-other-formats.html#springjavaconfig" rel="nofollow">http://static.springsource.org/spring-python/1.2.x/sphinx/html/objects-other-formats.html#springjavaconfig</a> for more details, this should give you more clarity of what SpringJavaConfig and Spring Python does. For one thing, it only supports Spring 2.5 XML format, and doesn't include the extra namespace stuff. It is also geared for configuring Python objects in a Python system, not Java objects in a Python system. The idea is to simply provide a smoother way to transition from Java to Python without having to rewrite your configuration files.</p> <pre><code>from springpython.config import PythonConfig from springpython.config import Object from com.framework.fetchers import CsvFileDataFetcher class YourAppContext(PythonConfig): def __init__(self): self.props = {} with open("relative/path/to/your/prop.properties") as f: for line in f.readlines(): key, value = line.split("=") self.props[key] = value @Object def csvDataFetcher(self): return CsvFileDataFetcher() </code></pre> <p>Access your app context with this:</p> <pre><code>from springpython.context import ApplicationContext ctx = ApplicationContext(YourAppContext()) service = ctx.get_object("csvDataFetcher") </code></pre> <p>From here on, you can refer to ctx.props to access the prop values. Pay note, Spring Python doesn't have an autowiring, so properties are not automatically injected into things. But it's pretty easy to parse the file using pure Python code, and have it nicely tucked into your app context, which in turn can be injected into relevant objects.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload