Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] how embedded Jetty can use Spring managed beans ?

thank you. The example is for 6.0 I think. I am trying Jetty 7.0 and Spring 3.0.

This is my configuration. It works when I access http://localhost:8080/ but I can not figure out how to define my own servlet at a specific context path. Appreciate your help !

<?xml version="1.0" encoding="UTF-8"?>
       xsi:schemaLocation="http://www.springframework.org/schema/beans 

<!-- Annotation 
     Scan for @Repository, @Service, @Controller, @Component,
-->
    <context:component-scan base-package="com.metaverse"/>
    
<!-- This activates post-processors for annotation-based configuration 
     Activates @Autowired for Controllers, ...
-->  
    <context:annotation-config/> 
<!-- define Jetty stuff -->
   <bean id="Server" class="org.eclipse.jetty.server.Server" init-method="start" destroy-method="stop">
   <!-- Optional -->
<property name="threadPool">  
       <bean id="ThreadPool" class="org.eclipse.jetty.util.thread.QueuedThreadPool">
         <property name="minThreads" value="10"/>
         <property name="maxThreads" value="100"/>
       </bean>
     </property>  
    
     <!-- Required -->
<property name="connectors">
       <list>
         <bean id="Connector" class="org.eclipse.jetty.server.nio.SelectChannelConnector">
           <property name="port" value="8080"/>
           <property name="host" value="localhost"/>
         </bean>
       </list>
     </property>
 
  <!-- Required -->
     <property name="handler">
       <bean id="handlers" class="org.eclipse.jetty.server.handler.HandlerList">
       <property name="handlers">
           <list>
           <bean class="org.eclipse.jetty.server.handler.ResourceHandler">
             <property name="directoriesListed" value="false"/>
             <property name="welcomeFiles">
               <list>
                 <value>index.html</value>
               </list>
             </property>
             <property name="resourceBase" value="."/>
           </bean>          
          
<bean class="org.eclipse.jetty.servlet.ServletHandler">
<property name="servlets">
<list>
 <bean class="org.eclipse.jetty.servlet.ServletHolder">
   <property name="name" value="hello"/>
   <property name="displayName" value="hello"/>
  <property name="servlet">
  <bean class="com.metaverse.servlet.HelloServlet">
               </bean>  
  </property>
  <property name="initParameters">
  <map>
   <entry key="resourceBase" value="/hello"/>
  </map>
  </property>
 </bean>
</list>
</property>
</bean>
</list>
         </property>
       </bean>
     </property>
    
   </bean> 

</beans>

In my main class, I only have one line of code:

 ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");

that simple ?!

 
rgds,
canal



From: Julio Viegas <julioviegas@xxxxxxxxxxxxxxx>
To: JETTY user mailing list <jetty-users@xxxxxxxxxxx>
Sent: Fri, January 15, 2010 11:52:11 PM
Subject: Re: [jetty-users] how embedded Jetty can use Spring managed beans ?

Maybe the following link can help you to do it:
http://roopindersingh.com/2008/12/10/spring-and-jetty-integration/

Rgrds,
JV -- http://julioviegas.com

On 15 Jan 2010 12:53, "go canal" <gocanal@xxxxxxxxx> wrote:

Hi,
I have an embedded Jetty, now I wanted to use Spring to manage service beans. How can I get the beans from my  Jetty servlet ?
 
thanks
canal



_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users



Back to the top