text: <?xml version="1.0" encoding="UTF-8"?>
  <!--
      Copyright (C) 2011 Talend Inc. - www.talend.com
  -->
  <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:jaxrs="http://cxf.apache.org/jaxrs"
        xsi:schemaLocation="
           http://www.springframework.org/schema/beans 
           http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
           http://cxf.apache.org/jaxrs
           http://cxf.apache.org/schemas/jaxrs.xsd">
  
       
       <!-- Restaurant Reservations Application -->
       
       <!-- 
           WebClient which Restaurant Reservations uses to access Social.com users' calendars at Social.com.
           Note that the Social.com address provided to this service is different from
           the one used by Social.com users themselves, which is "http://localhost:${http.port}/services/social/calendar".
           Social.com is OAuth-protected at "http://localhost:${http.port}/services/thirdPartyAccess/calendar" while
           "http://localhost:${http.port}/services/social/calendar" is protected by a Basic Authentication filter.
       -->
       
       <bean id="socialServiceClient" class="org.apache.cxf.jaxrs.client.WebClient" factory-method="create">
           <constructor-arg type="java.lang.String" value="http://localhost:${http.port}/examples/thirdPartyAccess/calendar"/>
       </bean>
       
       <!-- WebClient for requesting a temporarily Access OAuth token, 
            it is used after the authorization service (in socialApp context) redirects the user back
            to the callback URI. Once the access token is obtained, the service uses it to access the user's
            calendar 
       -->
       
       <bean id="atServiceClientFactory" class="org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean">
           <property name="address" value="http://localhost:${http.port}/examples/oauth/token"/>
           <property name="headers">
              <map>
                 <entry key="Accept" value="application/json"/>
              </map>
           </property>
       </bean>
       
       <bean id="atServiceClient" factory-bean="atServiceClientFactory" factory-method="createWebClient"/>
       
       <!-- WebClient for talking to a partner Restaurant application,
            it is used after a user calendar's has been checked 
       -->
       
       <bean id="restaurantServiceClientFactory" class="org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean">
           <property name="address" value="http://localhost:${http.port}/examples/restaurant/reception"/>
           <property name="headers">
              <map>
                 <entry key="Content-Type" value="application/x-www-form-urlencoded"/>
                 <entry key="Accept" value="text/plain"/>
              </map>
           </property>
       </bean>
       
       <bean id="restaurantServiceClient" factory-bean="restaurantServiceClientFactory" factory-method="createWebClient"/>
       
       <!-- 
         Utility OAuthClientManager which encapsulates the interaction with the OAuth Server
       -->  
       
       <bean id="oauthClient" class="oauth2.thirdparty.OAuthClientManager">
           <property name="authorizationURI" value="http://localhost:${http.port}/examples/social/authorize"/>
           <property name="accessTokenService" ref="atServiceClient"/>
       </bean>
       
       <!-- Restaurant Reservations Service Bean -->     
       <bean id="restaurantReserveService" class="oauth2.thirdparty.RestaurantReservationService">
           <property name="oAuthClientManager" ref="oauthClient"/>
           <property name="socialService" ref="socialServiceClient"/>
           <property name="restaurantService" ref="restaurantServiceClient"/>
       </bean>
       
       <!-- The security filter for Restaurant Reservations -->
       <!-- It's a primitive implementation which only recognizes a single user, to be improved... -->
       <bean id="thirdPartySecurityContext" class="oauth2.thirdparty.SecurityContextFilter">
           <property name="users">
              <map>
                <entry key="barry@restaurant.com" value="5678"/>
              </map>
           </property>
           <property name="realm" value="Reservations"/>
       </bean>
       
       <!-- The Restaurant Reservations View Support
           Responses to requests with URIs ending with /reservations/reserve/complete and
           /reservations/reserve/failure will be redirected to "/forms/reservationConfirm.jsp"
           and "/forms/reservationFailure.jsp" respectively.
           
           In both cases the response beans (oauth.common.ReservationConfirmation and oauth.common.ReservationFailure)
           will be available to view handlers as HttpServletRequest "data" attribute. 
           
           Note that restaurantReserveService will use JAX-RS Response.seeOther() call to redirect a user
           to a failure handler if a /complete reservation requests fails for whatever reasons 
           (no authorization key is available after the authorization service redirects the user back to it, no
           access token can be obtained, etc)   
       --> 
       <bean id="reserveRegistrationViews" class="org.apache.cxf.jaxrs.provider.RequestDispatcherProvider">
           <property name="resourcePaths">
              <map>
                <entry key="/reservations/reserve/complete" value="/forms/reservationConfirm.jsp"/>
                <entry key="/reservations/reserve/failure" value="/forms/reservationFailure.jsp"/>
              </map>
           </property>
           <property name="beanName" value="data"/>
           <!--  
           <property name="logRedirects" value="true"/>
           -->
       </bean>
       
       <!-- Restaurant Reservations Service Endpoint --> 
       <jaxrs:server id="reservationsServer" address="/reservations">
          <jaxrs:serviceBeans>
             <ref bean="restaurantReserveService"/>
          </jaxrs:serviceBeans>
          <jaxrs:providers>
             <ref bean="thirdPartySecurityContext"/>
             <ref bean="reserveRegistrationViews"/>
          </jaxrs:providers>
       </jaxrs:server>
       
            
  </beans>
  
  