Change the package name from openo to onap
[holmes/common.git] / holmes-actions / src / main / java / org / onap / holmes / common / dropwizard / ioc / utils / ServiceBinder.java
1 /**
2  * Copyright 2017 ZTE Corporation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.onap.holmes.common.dropwizard.ioc.utils;
17
18 import java.util.Set;
19
20 import org.glassfish.hk2.utilities.binding.AbstractBinder;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
23
24 /**
25  * @author hu.rui
26  *
27  */
28 public class ServiceBinder extends AbstractBinder {
29         
30         private static final Logger LOG = LoggerFactory.getLogger(ServiceBinder.class);
31         
32         final Set<Class<?>> klasses;
33
34         public ServiceBinder(Set<Class<?>> services) {
35                 this.klasses = services;
36         }
37
38         @Override
39         protected void configure() {
40                 for (Class<?> klass : this.klasses) {
41                         
42                         try{
43                                 LOG.info("start active class:"+klass.getName());
44                                 addActiveDescriptor(klass);
45                         }catch(Exception e){
46                                 LOG.info("active class error:"+klass.getName(),e);
47                         }
48                         
49                         
50                 }
51         }
52 }