@Resource(name="config") private TomeeConfiguration config; In a managed class to inject it. If you do a new tomee does nothing.
Le mar. 27 nov. 2018 04:48, Kean Erickson <[email protected]> a écrit : > Thank you, that sounds like it'll work. I'm finding that getProperties() on > my configuration file returns null though, I'm wondering if I'm using the > right Properties class (java.util.Properties)? > > 1. Here's my WEB-INF/resources.xml class (I removed the package name) > -------------------------------------------------------- > <Resource id="config" class-name=".....TomeeConfiguration"> > UserName = postgres > </Resource> > -------------------------------------------------------- > > > 2. Here's my TomeeConfiguration class (taken from the old documentation's > example): > -------------------------------------------------------- > package .....; > import java.util.Properties; > > public class TomeeConfiguration { > private Properties properties; > > public Properties getProperties() { > return properties; > } > public void setProperties(final Properties properties) { > this.properties = properties; > } > } > -------------------------------------------------------- > > 3. Then after the container has been prepared, I try the following, but > c.getProperties() returns null. > -------------------------------------------------------- > TomeeConfiguration c = new TomeeConfiguration(); > String tomeeUsername = c.getProperties().getProperty("UserName"); > -------------------------------------------------------- > > > I'm wondering what I'm missing? > Thanks for your time, > -Kean > > > On Mon, Nov 26, 2018 at 4:05 AM Jonathan Gallimore < > [email protected]> wrote: > > > Hi > > > > Yes - you can also define resources at the application level, by defining > > resources in WEB-INF/resources.xml in your .war file. The syntax is > pretty > > much the same as tomee.xml, but with <resources> as the top level tag as > > opposed to <tomee>. The will use the application classpath, eliminating > the > > requirement to add your resource class to lib/. > > > > Let us know how you get on - if you're stuck, I can dig out an example. > > > > Kind Regards > > > > Jon > > > > On Sun, Nov 25, 2018 at 10:47 PM Romain Manni-Bucau < > [email protected] > > > > > wrote: > > > > > Guess you want to read > > > http://tomee.apache.org/admin/configuration/index.html - doc is more > > > complete and up to date. > > > > > > Le dim. 25 nov. 2018 23:44, Kean Erickson <[email protected]> a > > > écrit : > > > > > > > The docs mention a way of obtaining properties in code from a > resource > > in > > > > Tomee.xml, under "Custom resources" > > > > > > > > http://tomee.apache.org/application-resources.html > > > > > > > > ..such that I could denote a class-name on the resource pointing to a > > > > configuration class (which would be pretty boilerplate, judging by > the > > > > example). But in order to do this, I have to package the config class > > in > > > > TomEE's /lib directory. This introduces some complications in my > case, > > > for > > > > other reasons.. I was wondering if there's any other way to obtain > > these > > > > resource properties without having to add anything to TomEE's > > classpath. > > > > > > > > Thanks, > > > > -Kean > > > > > > > > > >
