2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.config.facade.xml.strategy;
12 import javax.management.InstanceAlreadyExistsException;
13 import javax.management.ObjectName;
14 import org.opendaylight.controller.config.facade.xml.exception.ConfigHandlingException;
15 import org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml.AttributeConfigElement;
16 import org.opendaylight.controller.config.facade.xml.mapping.config.ServiceRegistryWrapper;
17 import org.opendaylight.controller.config.util.ConfigTransactionClient;
18 import org.opendaylight.controller.config.util.xml.DocumentedException;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
22 public class MissingInstanceHandlingStrategy extends AbstractEditConfigStrategy {
24 private static final Logger LOG = LoggerFactory.getLogger(MissingInstanceHandlingStrategy.class);
27 void handleMissingInstance(Map<String, AttributeConfigElement> configuration, ConfigTransactionClient ta,
28 String module, String instance, ServiceRegistryWrapper services) throws ConfigHandlingException {
30 ObjectName on = ta.createModule(module, instance);
31 LOG.trace("New instance for {} {} created under name {}", module, instance, on);
32 } catch (InstanceAlreadyExistsException e1) {
33 throw new ConfigHandlingException(String.format("Unable to create instance for %s : %s.", module, instance),
34 e1, DocumentedException.ErrorType.APPLICATION, DocumentedException.ErrorTag.OPERATION_FAILED,
35 DocumentedException.ErrorSeverity.ERROR);
40 void executeStrategy(Map<String, AttributeConfigElement> configuration, ConfigTransactionClient ta,
41 ObjectName objectName, ServiceRegistryWrapper services) {