Applying license changes to all files
[appc.git] / appc-adapters / appc-dmaap-adapter / appc-dmaap-adapter-bundle / src / main / java / org / openecomp / appc / adapter / messaging / dmaap / AppcDmaapAdapterActivator.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * =============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * 
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  * ============LICENSE_END=========================================================
23  */
24
25 package org.openecomp.appc.adapter.messaging.dmaap;
26
27 import org.openecomp.appc.configuration.ConfigurationFactory;
28 import com.att.eelf.configuration.EELFLogger;
29 import com.att.eelf.configuration.EELFManager;
30 import org.osgi.framework.BundleActivator;
31 import org.osgi.framework.BundleContext;
32 import org.osgi.framework.ServiceRegistration;
33
34 import java.util.Properties;
35
36 /**
37  * This activator is used to initialize and terminate the connection pool to one or more providers.
38  * <p>
39  * The CDP abstraction layer supports multiple types of providers, with each provider supporting multiple tenants. The
40  * "connection" to a specific tenant on a specific provider is represented by a "context" object. These context objects
41  * are authenticated to a specific tenant on the provider, but can be reused from one request to another. Contexts are
42  * slow to set up and are resource intensive, so they are cached. However, the contexts for a specific tenant on a
43  * specific provider must be cached separately.
44  * </p>
45  * <p>
46  * Activation of the bundle creates an empty cache which is organized first by provider type, then by tenant name, with
47  * the contents being an empty pool of contexts for that provider/tenant combination. The pool is created on first use,
48  * and retained for as long as the bundle is active.
49  * </p>
50  * <p>
51  * When the bundle is deactivated, the cache is torn down with all contexts being closed.
52  * </p>
53  */
54 public class AppcDmaapAdapterActivator implements BundleActivator {
55     private ServiceRegistration registration = null;
56
57     /**
58      * The logger to be used
59      */
60     private static final EELFLogger LOG = EELFManager.getInstance().getLogger(AppcDmaapAdapterActivator.class);
61
62     /**
63      * Called when this bundle is started so the Framework can perform the bundle-specific activities necessary to start
64      * this bundle. This method can be used to register services or to allocate any resources that this bundle needs.
65      * <p>
66      * This method must complete and return to its caller in a timely manner.
67      * </p>
68      *
69      * @param bundleContext
70      *            The execution context of the bundle being started.
71      * @throws java.lang.Exception
72      *             If this method throws an exception, this bundle is marked as stopped and the Framework will remove
73      *             this bundle's listeners, unregister all services registered by this bundle, and release all services
74      *             used by this bundle.
75      * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
76      */
77     @Override
78     public void start(final BundleContext bundleContext) throws Exception {
79         LOG.info("Starting Bundle " + getName());
80     }
81
82     /**
83      * Called when this bundle is stopped so the Framework can perform the bundle-specific activities necessary to stop
84      * the bundle. In general, this method should undo the work that the BundleActivator.start method started. There
85      * should be no active threads that were started by this bundle when this bundle returns. A stopped bundle must not
86      * call any Framework objects.
87      * <p>
88      * This method must complete and return to its caller in a timely manner.
89      * </p>
90      *
91      * @param ctx
92      *            The execution context of the bundle being stopped.
93      * @throws java.lang.Exception
94      *             If this method throws an exception, the bundle is still marked as stopped, and the Framework will
95      *             remove the bundle's listeners, unregister all services registered by the bundle, and release all
96      *             services used by the bundle. *
97      * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
98      */
99     @Override
100     public void stop(BundleContext ctx) throws Exception {
101         LOG.info("Stopped Bundle " + getName());
102     }
103
104     public String getName() {
105         return "DMaaP Adapter";
106     }
107
108 }