// Path: sample-web-app/src/main/java/com/example/config/AppConfig.java
// @Configuration
// public class AppConfig {	
// 	@Bean( destroyMethod = "shutdown" )
// 	public SpringBus cxf() {
// 		return new SpringBus();
// 	}
// 	
// 	@Bean @DependsOn( "cxf" )
// 	public Server jaxRsServer() {
// 		JAXRSServerFactoryBean factory = RuntimeDelegate.getInstance().createEndpoint( jaxRsApiApplication(), JAXRSServerFactoryBean.class );
// 		factory.setServiceBeans( Arrays.< Object >asList( peopleRestService() ) );
// 		factory.setAddress( "/" + factory.getAddress() );
// 		factory.setProviders( Arrays.< Object >asList( jsonProvider() ) );
// 		return factory.create();
// 	}
// 	
// 	@Bean 
// 	public JaxRsApiApplication jaxRsApiApplication() {
// 		return new JaxRsApiApplication();
// 	}
// 	
// 	@Bean 
// 	public PeopleRestService peopleRestService() {
// 		return new PeopleRestService();
// 	}
// 	
// 	@Bean 
// 	public PeopleService peopleService() {
// 		return new PeopleService();
// 	}
// 		
// 	@Bean
// 	public JacksonJsonProvider jsonProvider() {
// 		return new JacksonJsonProvider();
// 	}
// }


import java.io.IOException;
import java.net.URISyntaxException;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.HandlerCollection;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import com.example.config.AppConfig;
package com.example;




public class Starter {
  public static void main(final String[] args) throws Exception {

    Server server = new Server(8080);
    HandlerCollection handlerCollection = new HandlerCollection();
    server.setHandler(handlerCollection);

    addSpringContext(handlerCollection);

    // Default one, resourceHandler takes everything
    addStaticContext(handlerCollection);

    server.start();
    server.join();
  }

  static private void addSpringContext(HandlerCollection collection) {
    final ServletHolder servletHolder = new ServletHolder(new CXFServlet());
    final ServletContextHandler context = new ServletContextHandler();
    context.setContextPath("/");

    context.addServlet(servletHolder, "/rest/*");
    context.addEventListener(new ContextLoaderListener());

    context.setInitParameter("contextClass", AnnotationConfigWebApplicationContext.class.getName());
// Path: sample-web-app/src/main/java/com/example/config/AppConfig.java
// @Configuration
// public class AppConfig {	
// 	@Bean( destroyMethod = "shutdown" )
// 	public SpringBus cxf() {
// 		return new SpringBus();
// 	}
// 	
// 	@Bean @DependsOn( "cxf" )
// 	public Server jaxRsServer() {
// 		JAXRSServerFactoryBean factory = RuntimeDelegate.getInstance().createEndpoint( jaxRsApiApplication(), JAXRSServerFactoryBean.class );
// 		factory.setServiceBeans( Arrays.< Object >asList( peopleRestService() ) );
// 		factory.setAddress( "/" + factory.getAddress() );
// 		factory.setProviders( Arrays.< Object >asList( jsonProvider() ) );
// 		return factory.create();
// 	}
// 	
// 	@Bean 
// 	public JaxRsApiApplication jaxRsApiApplication() {
// 		return new JaxRsApiApplication();
// 	}
// 	
// 	@Bean 
// 	public PeopleRestService peopleRestService() {
// 		return new PeopleRestService();
// 	}
// 	
// 	@Bean 
// 	public PeopleService peopleService() {
// 		return new PeopleService();
// 	}
// 		
// 	@Bean
// 	public JacksonJsonProvider jsonProvider() {
// 		return new JacksonJsonProvider();
// 	}
// }


// Path: sample-web-app/src/main/java/com/example/Starter.java
import java.io.IOException;
import java.net.URISyntaxException;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.HandlerCollection;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import com.example.config.AppConfig;

package com.example;




public class Starter {
  public static void main(final String[] args) throws Exception {

    Server server = new Server(8080);
    HandlerCollection handlerCollection = new HandlerCollection();
    server.setHandler(handlerCollection);

    addSpringContext(handlerCollection);

    // Default one, resourceHandler takes everything
    addStaticContext(handlerCollection);

    server.start();
    server.join();
  }

  static private void addSpringContext(HandlerCollection collection) {
    final ServletHolder servletHolder = new ServletHolder(new CXFServlet());
    final ServletContextHandler context = new ServletContextHandler();
    context.setContextPath("/");

    context.addServlet(servletHolder, "/rest/*");
    context.addEventListener(new ContextLoaderListener());

    context.setInitParameter("contextClass", AnnotationConfigWebApplicationContext.class.getName());
    context.setInitParameter("contextConfigLocation", AppConfig.class.getName());