/** * Copyright (c) 2009-2012 EBM WebSourcing, 2012-2015 Linagora * * This program/library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 2.1 of the License, or (at your * option) any later version. * * This program/library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program/library; If not, see * for the GNU Lesser General Public License version 2.1. */ package org.ow2.petals.microkernel.configuration; import org.ow2.petals.clientserverapi.configuration.ContainerConfiguration; import org.ow2.petals.topology.generated.Container; import org.ow2.petals.topology.generated.RegistryService; import org.ow2.petals.topology.generated.TransportService; import org.ow2.petals.topology.generated.WebServiceService; /** * @author Christophe Hamerling - EBM WebSourcing */ public class ContainerConfigurationHelper { /** * Create an initial container configuration bean from the JAXB element * * @param container * @return */ public static final void fill(ContainerConfiguration containerConfiguration, Container container) { containerConfiguration.setName(container.getName()); containerConfiguration.setDescription(container.getDescription()); containerConfiguration.setUser(container.getUser()); containerConfiguration.setPassword(container.getPassword()); if (container.getHost() != null) { containerConfiguration.setHost(container.getHost()); } if (container.getType() != null) { switch (container.getType()) { case MASTER: containerConfiguration.setRegistryMode(ContainerConfiguration.RegistryMode.MASTER); break; case SLAVE: containerConfiguration.setRegistryMode(ContainerConfiguration.RegistryMode.SLAVE); break; case PEER: containerConfiguration.setRegistryMode(ContainerConfiguration.RegistryMode.PEER); break; case STANDALONE: containerConfiguration.setRegistryMode(ContainerConfiguration.RegistryMode.STANDALONE); break; } } // JMX Service if (container.getJmxService() != null) { containerConfiguration.setJmxRMIConnectorPort(container.getJmxService().getRmiPort()); } // Transport Service final TransportService transportService = container.getTransportService(); if (transportService != null) { containerConfiguration.setTCPPort(transportService.getTcpPort()); } final RegistryService registryService = container.getRegistryService(); if (registryService != null) { if (registryService.getPort() != null) { containerConfiguration.setRegistryPort(registryService.getPort().intValue()); } } final WebServiceService webServiceService = container.getWebserviceService(); if (webServiceService != null) { if (webServiceService.getPort() != 0) { containerConfiguration.setWebservicePort(webServiceService.getPort()); } if (webServiceService.getPrefix() != null) { containerConfiguration.setWebservicePrefix(webServiceService.getPrefix()); } } } }