Removed checkstyle warnings.
[bgpcep.git] / bgp / parser-spi / src / main / java / org / opendaylight / protocol / bgp / parser / spi / pojo / ServiceLoaderBGPExtensionProviderContext.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.protocol.bgp.parser.spi.pojo;
9
10 import java.util.ServiceLoader;
11
12 import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderActivator;
13 import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext;
14
15 public final class ServiceLoaderBGPExtensionProviderContext {
16     private static final class Holder {
17         private static final BGPExtensionProviderContext INSTANCE;
18
19         static {
20             try {
21                 INSTANCE = create();
22             } catch (final Exception e) {
23                 throw new ExceptionInInitializerError(e);
24             }
25         }
26     }
27
28     public static BGPExtensionProviderContext create() {
29         final BGPExtensionProviderContext ctx = new SimpleBGPExtensionProviderContext();
30
31         final ServiceLoader<BGPExtensionProviderActivator> loader = ServiceLoader.load(BGPExtensionProviderActivator.class);
32         for (BGPExtensionProviderActivator a : loader) {
33             a.start(ctx);
34         }
35
36         return ctx;
37     }
38
39     public static BGPExtensionProviderContext getSingletonInstance() {
40         return Holder.INSTANCE;
41     }
42
43     private ServiceLoaderBGPExtensionProviderContext() {
44
45     }
46 }