<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright (c) 2014 Red Hat, Inc..
  All rights reserved. This program and the accompanying materials
  are made available under the terms of the GNU Public License v3.0
  which accompanies this distribution, and is available at
  http://www.gnu.org/licenses/gpl.html
  
  Contributors:
      Red Hat, Inc. - initial API and implementation
-->
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
       version="1.1" bean-discovery-mode="all">
      
  <alternatives>
    <stereotype>org.commonjava.indy.inject.Production</stereotype>

    <class>org.commonjava.indy.flat.data.DataFileStoreDataManager</class>
  </alternatives>
  
  <decorators>
    <class>org.commonjava.indy.autoprox.data.AutoProxDataManagerDecorator</class>
    <class>org.commonjava.indy.content.index.IndexingContentManagerDecorator</class>
    <class>org.commonjava.indy.content.index.IndexingDirectContentAccessDecorator</class>
    <class>org.commonjava.indy.koji.content.KojiContentManagerDecorator</class>
  </decorators>
      
</beans>

<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright (c) 2014 Red Hat, Inc..
  All rights reserved. This program and the accompanying materials
  are made available under the terms of the GNU Public License v3.0
  which accompanies this distribution, and is available at
  http://www.gnu.org/licenses/gpl.html
  
  Contributors:
      Red Hat, Inc. - initial API and implementation
-->
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
       version="1.1" bean-discovery-mode="all">
      
  <alternatives>
    <stereotype>org.commonjava.indy.inject.Production</stereotype>

    <class>org.commonjava.indy.flat.data.DataFileStoreDataManager</class>
  </alternatives>
  
  <decorators>
    <!-- ordering is CRITICAL here. First declaration is outermost in decoration chain -->
    <class>org.commonjava.indy.koji.content.KojiContentManagerDecorator</class>
    <class>org.commonjava.indy.content.index.IndexingContentManagerDecorator</class>

    <class>org.commonjava.indy.autoprox.data.AutoProxDataManagerDecorator</class>

    <class>org.commonjava.indy.content.index.IndexingDirectContentAccessDecorator</class>
  </decorators>
      
</beans>

Change the decorator ordering for ContentManager to make failover to koji work.
Change the decorator ordering for ContentManager to make failover to koji work.

KojiContentManagerDecorator is designed to execute ONLY when normal content
retrieval fails. In this case, it will query into Koji to see if a matching
build exists, then wire up a RemoteRepository to proxy that build. In subsequent
requests for that content, the normal content retrieval logic will apply, using
the new RemoteRepository.

Because of this, KojiContentManagerDecorator should be the outermost (or among
the outermost, in the event we implement another failover-style decorator).
Putting this inside other decorators risks exposing it to implementation details
of those decorators that can circumvent the failover behavior, which only works
in the context of group content retrieval.

This change reorders the ContentManager decorators, and adds a comment to the
beans.xml in deployments/launchers/savant to note the importance of ordering.
