Reputation: 5850
I am using: org.mortbay.jetty.Server.
I am initiallizing the server like this:
private static Server server = null;
server = (Server)applicationContext.getBean("HQSimJettyServer");
How can i configure the server port after the getBean method? i can do it in the server constructor, but since i am using the getBean, i cant define the port in the consructor.
Secondly, how can i define the server response to include header and query parameters?
Right now i am using:
return Response.status(response_code).build();
Thanks.
Upvotes: 0
Views: 142
Reputation: 6173
If you're using spring then define the bean in the application.xml to call the constructor with arguments if your choice.
Spring way:
private static Server server = null;
server = (Server)applicationContext.getBean("HQSimJettyServer");
XML snippet:
<bean id="HQSimJettyServer" class="org.mortbay.jetty.Server" >
<constructor-arg value="10000"/>
</bean>
Alternative way (no Spring dependency):
Server s = new Server();
SocketConnector socketConnector = new SocketConnector();
socketConnector.setPort(10000);
s.addConnector(socketConnector);
Or simply:
Server s = new Server(10000);
You can of course combine the above if you wish to get the Server instance from Spring and then add Connectors in your code.
Upvotes: 1