Jan, Thanks! I didn't know you could do <Ref refid="Server"> from the web configuration but it makes sense. I will give it a try.
Thanks, Josh On Thu, Jan 30, 2020 at 4:53 AM Jan Bartel <[email protected]> wrote: > Josh, > > In your etc/test.xml file, set the shared resource as an attribute on the > Server: > <Configure id="Server" class="org.eclipse.jetty.server.Server"> > <Call name="setAttribute"> > <Arg>myserverfoo</Arg> > <Arg>HELLO</Arg> > </Call> > </Configure> > > In your webapps/servlet.xml, you can refer to the Server instance and > retrieve the attribute, and set it as a context attribute instead: > <Configure class="org.eclipse.jetty.webapp.WebAppContext"> > <Ref refid="Server"> > <Call id="myserverfoo" > name="getAttribute"><Arg>myserverfoo</Arg></Call> > </Ref> > > <Call name="setAttribute"> > <Arg>mycontextfoo</Arg> > <Arg><Ref refid="myserverfoo"/></Arg> > </Call> > </Configure> > > regards > Jan > > On Mon, 27 Jan 2020 at 22:40, Josh Spiegel <[email protected]> wrote: > >> Simone, >> >> Thanks again. Bug it seems the webapp configuration can't reference ids >> set by the server module. Am I missing something? Here is what I tried: >> >> *./webapps/servlet.xml* >> >> >> <Configure class="org.eclipse.jetty.webapp.WebAppContext"> >> >> >> <Set name="contextPath">/ServletExample</Set> >> >> >> <Set name="war">/Users/..../ServletExample.war</Set> >> >> >> <Get class="java.lang.System" name="out"> >> >> <Call name="println"> >> >> <Arg>######### SERVLET ##############</Arg> >> >> </Call> >> >> </Get> >> >> >> <Get class="java.lang.System" name="out"> >> >> <Call name="println"> >> >> <Arg><Ref refid="myContext"/></Arg> >> >> </Call> >> >> </Get> >> >> >> </Configure> >> >> *./modules/test.mod* >> >> [xml] >> >> etc/test.xml >> >> *./etc/test.xml* >> >> >> <Configure id="Server" class="org.eclipse.jetty.server.Server"> >> >> >> <Map id="myContext"> >> >> <Entry> >> >> <Item>test</Item> >> >> <Item>foo</Item> >> >> </Entry> >> >> </Map> >> >> >> <Get class="java.lang.System" name="out"> >> >> <Call name="println"> >> >> <Arg>######### test.xml ##############</Arg> >> >> </Call> >> >> </Get> >> >> >> <Get class="java.lang.System" name="out"> >> >> <Call name="println"> >> >> <Arg><Ref refid="myContext"/></Arg> >> >> </Call> >> >> </Get> >> >> >> </Configure> >> >> >> > java -jar start.jar --add-module=test >> >> 2020-01-27 13:38:20.070:INFO::main: Logging initialized @467ms to >> org.eclipse.jetty.util.log.StdErrLog >> >> ######### test.xml ############## >> >> {test=foo} >> >> 2020-01-27 13:38:20.286:INFO:oejs.Server:main: jetty-9.4.26.v20200117; >> built: 2020-01-17T12:35:33.676Z; git: >> 7b38981d25d14afb4a12ff1f2596756144edf695; jvm 1.8.0_201-b09 >> >> 2020-01-27 13:38:20.301:INFO:oejdp.ScanningAppProvider:main: Deployment >> monitor [file:///Users/..../jetty-distribution-9.4.26.v20200117/webapps/] >> at interval 1 >> >> ######### SERVLET ############## >> >> null >> >> Notice the servlet.xml reference to "myContext" prints null. >> >> Thanks, >> Josh >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> On Mon, Jan 27, 2020 at 7:24 AM Simone Bordet <[email protected]> >> wrote: >> >>> Hi, >>> >>> On Mon, Jan 27, 2020 at 3:58 PM Josh Spiegel <[email protected]> >>> wrote: >>> > >>> > Thanks. I can definitely break things up and use a module. However, >>> using webapps and configuring WebAppContext via mywar.xml doesn't seem to >>> work since the call to webAppContext.getServer() returns null at the time >>> the WebAppContext is configured. >>> >>> <Map id="myContext"> will allow you to obtain the map by using <Ref >>> refid="myContext"/> so you don't need the Server anymore. >>> >>> -- >>> Simone Bordet >>> ---- >>> http://cometd.org >>> http://webtide.com >>> Developer advice, training, services and support >>> from the Jetty & CometD experts. >>> _______________________________________________ >>> jetty-users mailing list >>> [email protected] >>> To change your delivery options, retrieve your password, or unsubscribe >>> from this list, visit >>> https://www.eclipse.org/mailman/listinfo/jetty-users >>> >> _______________________________________________ >> jetty-users mailing list >> [email protected] >> To change your delivery options, retrieve your password, or unsubscribe >> from this list, visit >> https://www.eclipse.org/mailman/listinfo/jetty-users > > > > -- > Jan Bartel <[email protected]> > www.webtide.com > *Expert assistance from the creators of Jetty and CometD* > > _______________________________________________ > jetty-users mailing list > [email protected] > To change your delivery options, retrieve your password, or unsubscribe > from this list, visit > https://www.eclipse.org/mailman/listinfo/jetty-users
_______________________________________________ jetty-users mailing list [email protected] To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users
