<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~~~~~~licensing~~~~~~
  system-management-api
  ==========
  Copyright (C) 2020 - 2021 EmDev LLC
  ==========
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
  
       http://www.apache.org/licenses/LICENSE-2.0
  
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  ~~~~~~/licensing~~~~~~
  -->

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
           xmlns:cxf="http://cxf.apache.org/blueprint/core"
           xmlns:jaxws="http://cxf.apache.org/blueprint/jaxws"
           xsi:schemaLocation="
             http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
             http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd
             ">

    <cxf:bus>
        <cxf:features>
            <cxf:logging/>
        </cxf:features>
    </cxf:bus>

    <cm:property-placeholder persistent-id="ru.entaxy.esb.system.management" update-strategy="reload">
        <cm:default-properties>
            <cm:property name="system-management.endpoint.address" value="/system-management"/>
            <cm:property name="system-management.endpoint.master" value="true"/>
        </cm:default-properties>
    </cm:property-placeholder>

    <jaxws:server serviceClass="ru.entaxy.esb.system.management.soap.SystemManagementService"
                  address="${system-management.endpoint.address}"
                  start="${system-management.endpoint.master}">
        <jaxws:serviceBean>
            <ref component-id="systemManagementService"/>
        </jaxws:serviceBean>
        <jaxws:inInterceptors>
            <ref component-id="authInterceptor"/>
            <ref component-id="serviceInterceptor"/>
            <ref component-id="soapHeaderInterceptor"/>
        </jaxws:inInterceptors>
    </jaxws:server>

    <reference id="serviceInterceptor" interface="org.apache.cxf.phase.PhaseInterceptor"
               filter="(type=service)"/>
    <reference id="authInterceptor" interface="org.apache.cxf.phase.PhaseInterceptor"
               filter="(type=authentication)"/>
    <bean id="soapHeaderInterceptor" class="ru.entaxy.esb.system.common.interceptor.SoapHeaderInterceptor">
        <property name="namespaceUri" value="http://www.entaxy.ru/system-management-service/"/>
    </bean>

    <bean id="systemManagementService" class="ru.entaxy.esb.system.management.SystemManagementServiceImpl">
        <property name="profileManager" ref="profileManager"/>
        <property name="bridgeProfileManager" ref="bridgeProfileManager"/>
        <property name="connectorManager" ref="connectorManager"/>
        <property name="permissionManager" ref="permissionManager"/>

        <property name="mapper" ref="mapper"/>
    </bean>

    <bean id="mapper" class="ru.entaxy.esb.system.management.mapper.MapperImpl"/>

    <reference id="profileManager"
               interface="ru.entaxy.esb.system.management.profile.manager.ProfileManager"
               timeout="30000"
               availability="mandatory"/>

    <reference id="bridgeProfileManager"
               interface="ru.entaxy.esb.system.management.bridge.profile.manager.BridgeProfileManager"
               timeout="30000"
               availability="mandatory"/>

    <reference id="connectorManager"
               interface="ru.entaxy.esb.system.management.connector.manager.ConnectorManager"
               timeout="30000"
               availability="mandatory"/>

    <reference id="permissionManager"
               interface="ru.entaxy.esb.system.management.permission.manager.PermissionManager"
               timeout="30000"
               availability="mandatory"/>

</blueprint>
