ShippingFeignConfiguration.java
/*
* Copyright 2005-2025 the original author or authors.
*
* 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.
*/
package org.openwms.wms.shipping.app;
import feign.auth.BasicAuthRequestInterceptor;
import org.openwms.core.SpringProfiles;
import org.openwms.wms.shipping.spi.FeignTransportUnitAllocator;
import org.openwms.wms.shipping.spi.FeignWmsTransportUnitAllocator;
import org.openwms.wms.shipping.spi.TransportUnitAllocator;
import org.openwms.wms.shipping.spi.common.TransportUnitAllocatorApi;
import org.openwms.wms.shipping.spi.wms.inventory.AllocatorApi;
import org.openwms.wms.shipping.spi.wms.inventory.transport.WmsTransportUnitAllocatorApi;
import org.openwms.wms.shipping.spi.wms.picking.PickingApi;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import static org.openwms.wms.shipping.ShippingProfiles.COMMON_ALLOCATION;
import static org.openwms.wms.shipping.ShippingProfiles.WMS_ALLOCATION;
/**
* A ShippingFeignConfiguration activates client stubs using Feign to connect to other services. This is deactivated when the service is
* packaged and deployed as part of a whole application.
*
* @author Heiko Scherrer
*/
@Profile(SpringProfiles.DISTRIBUTED)
@Configuration
@AutoConfigureOrder(0)
@EnableFeignClients(
basePackageClasses = {
AllocatorApi.class,
TransportUnitAllocatorApi.class,
PickingApi.class
})
public class ShippingFeignConfiguration {
@Bean
public BasicAuthRequestInterceptor basicAuthRequestInterceptor() {
return new BasicAuthRequestInterceptor("user", "sa");
}
@Profile(COMMON_ALLOCATION + "|| !" + WMS_ALLOCATION)
@Bean
TransportUnitAllocator commonTransportUnitAllocator(TransportUnitAllocatorApi transportUnitAllocatorApi) {
return new FeignTransportUnitAllocator(transportUnitAllocatorApi);
}
@Profile(WMS_ALLOCATION)
@Bean
TransportUnitAllocator wmsTransportUnitAllocator(WmsTransportUnitAllocatorApi transportUnitAllocatorApi) {
return new FeignWmsTransportUnitAllocator(transportUnitAllocatorApi);
}
}