2 * Copyright (c) 2013 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
8 package org.opendaylight.controller.config.spi;
10 import javax.annotation.concurrent.NotThreadSafe;
12 import org.opendaylight.controller.config.api.ModuleIdentifier;
13 import org.opendaylight.controller.config.api.annotations.RequireInterface;
14 import org.opendaylight.yangtools.concepts.Identifiable;
18 * Represents one service that is to be configured. These methods need to be
19 * implemented in addition to the usual attribute getters/setters. Dependencies
20 * should always be injected as ObjectName references to the corresponding
23 * In order to guide dependency resolution, the setter method should be
24 * annotated with {@link RequireInterface}.
27 * Thread safety note: implementations of this interface are not required to be
28 * thread safe as thread safety is enforced by configuration manager.
32 public interface Module extends Identifiable<ModuleIdentifier>{
34 * This method will be called as first phase in two phase commit. Instance
35 * can check attributes, but is not allowed to do any kind of work that
36 * could leave any resources open. It is prohibited to call
37 * {@link #getInstance()} on dependent {@link Module} because it would
38 * destroy separation between validation and commit phase.
44 * Returns 'live' object that was configured using this object. It is
45 * allowed to call this method only after all ConfigBeans were validated. In
46 * this method new resources might be opened or old instance might be
47 * modified. Note that when obtaining dependent Module using
48 * {@link org.opendaylight.controller.config.api.DependencyResolver#validateDependency(Class, javax.management.ObjectName, String)}
49 * a proxy will be created that will disallow calling this method before
50 * second commit phase begins.
52 * @return closeable instance: After bundle update the factory might be able
53 * to copy old configuration into new one without being able to cast
54 * Module or the instance. Thus to clean up old instance, it will
57 AutoCloseable getInstance();