<modelVersion>4.0.0</modelVersion>\r
\r
<parent>\r
- <groupId>org.openo.holmes.actions</groupId>\r
+ <groupId>org.onap.holmes.actions</groupId>\r
<artifactId>holmes-actions-parent</artifactId>\r
- <version>1.1.0-SNAPSHOT</version>\r
+ <version>1.0.0-SNAPSHOT</version>\r
</parent>\r
\r
<name>holmes-actions-service</name>\r
<groupId>org.apache.activemq</groupId>\r
<artifactId>activemq-pool</artifactId>\r
</dependency>\r
- <dependency>\r
- <groupId>org.openo.common-services.common-utilities</groupId>\r
- <artifactId>baseservice-i18n</artifactId>\r
- </dependency>\r
<dependency>\r
<groupId>org.antlr</groupId>\r
<artifactId>stringtemplate</artifactId>\r
<groupId>org.jdom</groupId>\r
<artifactId>jdom</artifactId>\r
</dependency>\r
- <dependency>\r
- <groupId>org.openo.common-services.common-utilities</groupId>\r
- <artifactId>dropwizard-ioc-container</artifactId>\r
- </dependency>\r
<dependency>\r
<groupId>org.easymock</groupId>\r
<artifactId>easymock</artifactId>\r
<artifactId>consumer</artifactId>\r
<version>${jaxrs.consumer.version}</version>\r
</dependency>\r
+ <dependency>\r
+ <groupId>org.glassfish.jersey.containers</groupId>\r
+ <artifactId>jersey-container-servlet-core</artifactId>\r
+ <version>${jersey.version}</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>net.sf.json-lib</groupId>\r
+ <artifactId>json-lib</artifactId>\r
+ <version>2.4</version>\r
+ <classifier>jdk15</classifier>\r
+ </dependency>\r
</dependencies>\r
<build>\r
<resources>\r
* See the License for the specific language governing permissions and\r
* limitations under the License.\r
*/\r
-package org.openo.holmes.common.api.entity;\r
+package org.onap.holmes.common.api.entity;\r
\r
import com.fasterxml.jackson.annotation.JsonProperty;\r
import java.util.Date;\r
* See the License for the specific language governing permissions and\r
* limitations under the License.\r
*/\r
-package org.openo.holmes.common.api.entity;\r
+package org.onap.holmes.common.api.entity;\r
\r
import com.fasterxml.jackson.annotation.JsonProperty;\r
import java.io.Serializable;\r
-import org.openo.holmes.common.api.stat.Alarm;\r
+import org.onap.holmes.common.api.stat.Alarm;\r
\r
import lombok.Getter;\r
import lombok.NoArgsConstructor;\r
* See the License for the specific language governing permissions and\r
* limitations under the License.\r
*/\r
-package org.openo.holmes.common.api.entity;\r
+package org.onap.holmes.common.api.entity;\r
\r
import com.fasterxml.jackson.annotation.JsonProperty;\r
import java.util.Date;\r
*/\r
\r
\r
-package org.openo.holmes.common.api.entity;\r
+package org.onap.holmes.common.api.entity;\r
\r
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;\r
import lombok.AllArgsConstructor;\r
* limitations under the License.\r
*/\r
\r
-package org.openo.holmes.common.api.entity;\r
+package org.onap.holmes.common.api.entity;\r
\r
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;\r
import java.util.ArrayList;\r
* limitations under the License.\r
*/\r
\r
-package org.openo.holmes.common.api.stat;\r
+package org.onap.holmes.common.api.stat;\r
\r
import java.io.Serializable;\r
import java.io.StringReader;\r
* See the License for the specific language governing permissions and\r
* limitations under the License.\r
*/\r
-package org.openo.holmes.common.api.stat;\r
+package org.onap.holmes.common.api.stat;\r
\r
import java.io.Serializable;\r
\r
* See the License for the specific language governing permissions and\r
* limitations under the License.\r
*/\r
-package org.openo.holmes.common.api.stat;\r
+package org.onap.holmes.common.api.stat;\r
\r
import java.io.Serializable;\r
\r
* limitations under the License.\r
*/\r
\r
-package org.openo.holmes.common.config;\r
+package org.onap.holmes.common.config;\r
\r
import com.fasterxml.jackson.annotation.JsonProperty;\r
import java.util.HashMap;\r
* See the License for the specific language governing permissions and\r
* limitations under the License.\r
*/\r
-package org.openo.holmes.common.config;\r
+package org.onap.holmes.common.config;\r
\r
-import org.openo.holmes.common.constant.AlarmConst;\r
+import org.onap.holmes.common.constant.AlarmConst;\r
\r
public class MicroServiceConfig {\r
\r
* See the License for the specific language governing permissions and\r
* limitations under the License.\r
*/\r
-package org.openo.holmes.common.constant;\r
+package org.onap.holmes.common.constant;\r
\r
public interface AlarmConst {\r
\r
\r
String MQ_TOPIC_NAME_ALARM = "topic://voss/fm/alarm";\r
\r
- String NFVO_PATH = "/openoapi/umc/v1/fm/curalarms/findAll";\r
+ String NFVO_PATH = "/onapapi/umc/v1/fm/curalarms/findAll";\r
\r
int NFVO_STATUS_OK = 200;\r
\r
--- /dev/null
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.common.dropwizard.ioc.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * basic services for identification
+ * @author hu.rui
+ *
+ */
+@Target({ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface BaseService {
+
+}
--- /dev/null
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.common.dropwizard.ioc.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * lazy loading of related services
+ * @author hu.rui
+ *
+ */
+@Target({ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface Lazy {
+
+}
--- /dev/null
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.common.dropwizard.ioc.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * load on after basic services
+ * @author hu.rui
+ *
+ */
+@Target({ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface PostBaseService {
+
+}
--- /dev/null
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.common.dropwizard.ioc.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * prior to basic service loading
+ * @author hu.rui
+ *
+ */
+@Target({ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface PreBaseService {
+
+}
--- /dev/null
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.common.dropwizard.ioc.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * load before general service
+ * @author hu.rui
+ *
+ */
+@Target({ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface PreLoad {
+
+}
--- /dev/null
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.common.dropwizard.ioc.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ *
+ * load before general service,after PreLoad
+ * @author hu.rui
+ *
+ */
+@Target({ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface PreServiceLoad {
+
+}
--- /dev/null
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.common.dropwizard.ioc.bundle;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import javax.ws.rs.Path;
+import javax.ws.rs.ext.Provider;
+
+import org.eclipse.jetty.util.component.LifeCycle;
+import org.glassfish.hk2.api.ServiceLocator;
+import org.glassfish.hk2.api.ServiceLocatorFactory;
+import org.glassfish.hk2.utilities.ServiceLocatorUtilities;
+import org.glassfish.hk2.utilities.binding.AbstractBinder;
+import org.glassfish.jersey.servlet.ServletProperties;
+import org.jvnet.hk2.annotations.Service;
+import org.onap.holmes.common.dropwizard.ioc.annotation.BaseService;
+import org.onap.holmes.common.dropwizard.ioc.annotation.Lazy;
+import org.onap.holmes.common.dropwizard.ioc.annotation.PostBaseService;
+import org.onap.holmes.common.dropwizard.ioc.annotation.PreBaseService;
+import org.onap.holmes.common.dropwizard.ioc.annotation.PreLoad;
+import org.onap.holmes.common.dropwizard.ioc.annotation.PreServiceLoad;
+import org.onap.holmes.common.dropwizard.ioc.utils.ServiceBinder;
+import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
+import org.reflections.Reflections;
+import org.reflections.scanners.SubTypesScanner;
+import org.reflections.scanners.TypeAnnotationsScanner;
+import org.reflections.util.ClasspathHelper;
+import org.reflections.util.ConfigurationBuilder;
+import org.reflections.util.FilterBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.codahale.metrics.health.HealthCheck;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.Lists;
+
+import io.dropwizard.Configuration;
+import io.dropwizard.ConfiguredBundle;
+import io.dropwizard.configuration.ConfigurationSourceProvider;
+import io.dropwizard.lifecycle.Managed;
+import io.dropwizard.lifecycle.ServerLifecycleListener;
+import io.dropwizard.servlets.tasks.Task;
+import io.dropwizard.setup.Bootstrap;
+import io.dropwizard.setup.Environment;
+
+/**
+ * complete the integration of hK2 container and dropwizard
+ *
+ * @author hu.rui
+ *
+ */
+
+public class AutoConfigBundle<T extends Configuration> implements ConfiguredBundle<T> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(AutoConfigBundle.class);
+
+ private ServiceLocator locator;
+ private Reflections reflections;
+ private Set<Class<?>> services;
+
+ private Bootstrap<?> bootstrap;
+
+
+ AutoConfigBundle(final String packageName) {
+ this(Lists.newArrayList(packageName));
+ }
+
+ AutoConfigBundle(List<String> packageNames) {
+ FilterBuilder filterBuilder = new FilterBuilder();
+
+ packageNames.stream().forEach(packageName -> {
+ filterBuilder.include(FilterBuilder.prefix(packageName));
+ });
+ ConfigurationBuilder reflectionCfg = new ConfigurationBuilder();
+
+ packageNames.stream().forEach(packageName -> {
+ reflectionCfg.addUrls(ClasspathHelper.forPackage(packageName));
+ });
+
+ reflectionCfg.filterInputsBy(filterBuilder).setScanners(new SubTypesScanner(),
+ new TypeAnnotationsScanner());
+ reflections = new Reflections(reflectionCfg);
+
+ locator = ServiceLocatorFactory.getInstance().create("dw-hk2");
+
+ ServiceLocatorHolder.setLocator(locator);
+
+ }
+
+ public static <T extends Configuration> AutoConfigBundleBuider<T> newBuilder() {
+ return new AutoConfigBundleBuider<T>();
+ }
+
+ @Override
+ public void initialize(final Bootstrap<?> bootstrap) {
+
+ this.bootstrap = bootstrap;
+ registerPreLoadService();
+
+ LOG.debug("Intialzing auto config bundle.");
+ }
+
+ private void registerPreLoadService() {
+
+ registerService(PreLoad.class);
+
+ }
+
+
+ @Override
+ public void run(final T configuration, final Environment environment) throws Exception {
+
+ registerConfigurationProvider(configuration, environment);
+
+
+ registerEnvironment(environment);
+ registerObjectMapper(environment);
+
+ environment.getApplicationContext().getServletContext()
+ .setAttribute(ServletProperties.SERVICE_LOCATOR, locator);
+
+ registerService(PreBaseService.class);
+ registerService(BaseService.class);
+ registerService(PostBaseService.class);
+ this.registerService(PreServiceLoad.class);
+
+
+ registerServices();
+
+ // registerManaged(environment);
+ registerLifecycle(environment);
+ registerServerLifecycleListeners(environment);
+ registerJettyLifeCycleListener(environment);
+ registerTasks(environment);
+ registerHealthChecks(environment);
+ registerProviders(environment);
+ registerResources(environment);
+
+ environment.lifecycle().manage(new ServiceLocatorManaged(locator));
+
+ }
+
+
+
+ private void registerProviders(Environment environment) {
+ reflections.getSubTypesOf(Provider.class).stream().filter(services::contains)
+ .forEach(providerKlass -> {
+ try {
+ environment.jersey().register(locator.getService(providerKlass));
+ } catch (Exception e) {
+ LOG.warn("", e);
+ }
+
+ LOG.info("Registering Dropwizard Provider, class name : {}", providerKlass.getName());
+
+ });
+
+ }
+
+ private void registerTasks(Environment environment) {
+ reflections.getSubTypesOf(Task.class).stream().filter(services::contains).forEach(taskKlass -> {
+ try {
+ environment.admin().addTask(locator.getService(taskKlass));
+ } catch (Exception e) {
+ LOG.warn("", e);
+ }
+ LOG.info("Registering Dropwizard Task, class name : {}", taskKlass.getName());
+ });
+
+ }
+
+ private void registerJettyLifeCycleListener(Environment environment) {
+ reflections.getSubTypesOf(LifeCycle.Listener.class).stream().filter(services::contains)
+ .forEach(lifecycleListenerKlass -> {
+
+ try {
+ environment.lifecycle()
+ .addLifeCycleListener(locator.getService(lifecycleListenerKlass));
+ } catch (Exception e) {
+ LOG.warn("", e);
+ }
+ LOG.info("Registering Dropwizard lifecycleListener, class name : {}",
+ lifecycleListenerKlass.getName());
+ });
+
+ }
+
+ private void registerServerLifecycleListeners(Environment environment) {
+
+ reflections.getSubTypesOf(ServerLifecycleListener.class).stream().filter(services::contains)
+ .forEach(serverLifecycleListenerKlass -> {
+ try {
+ environment.lifecycle()
+ .addServerLifecycleListener(locator.getService(serverLifecycleListenerKlass));
+ } catch (Exception e) {
+ LOG.warn("", e);
+ }
+ LOG.info("Registering Dropwizard serverLifecycleListener, class name : {}",
+ serverLifecycleListenerKlass.getName());
+ });
+
+ }
+
+ private void registerLifecycle(Environment environment) {
+ reflections.getSubTypesOf(LifeCycle.class).stream().filter(services::contains)
+ .forEach(lifeCycleKlass -> {
+ try {
+ environment.lifecycle().manage(locator.getService(lifeCycleKlass));
+ } catch (Exception e) {
+ LOG.warn("", e);
+ }
+ LOG.info("Registering Dropwizard LifeCycle, class name : {}", lifeCycleKlass.getName());
+ });
+ }
+
+ /*
+ * private void registerManaged(Environment environment) {
+ *
+ * reflections.getSubTypesOf(Managed.class).stream().filter(services::contains)
+ * .forEach(managedKlass -> { try {
+ * environment.lifecycle().manage(locator.getService(managedKlass)); } catch (Exception e) {
+ * LOG.warn("", e); } LOG.info("Registering Dropwizard managed, class name : {}",
+ * managedKlass.getName()); });
+ *
+ * }
+ */
+
+ private void registerObjectMapper(Environment environment) {
+
+ final ObjectMapper objectMapper = environment.getObjectMapper();
+
+ ServiceLocatorUtilities.bind(locator, new AbstractBinder() {
+ @Override
+ protected void configure() {
+ bind(objectMapper).to(ObjectMapper.class);
+
+ LOG.info("Registering Dropwizard objectMapper, class name : {}",
+ objectMapper.getClass().getName());
+ }
+ });
+
+ }
+
+ private void registerEnvironment(final Environment environment) {
+
+ ServiceLocatorUtilities.bind(locator, new AbstractBinder() {
+ @Override
+ protected void configure() {
+ bind(environment).to(Environment.class);
+
+ LOG.info("Registering Dropwizard environment, class name : {}",
+ environment.getClass().getName());
+ }
+ });
+
+ }
+
+ private void registerConfigurationProvider(final T configuration, final Environment environment) {
+
+ ServiceLocatorUtilities.bind(locator, new AbstractBinder() {
+ @Override
+ protected void configure() {
+ bind(configuration);
+ LOG.info("Registering Dropwizard Configuration class name:{}",
+ configuration.getClass().getName());
+ if (configuration instanceof Configuration) {
+ bind((Configuration) configuration).to(Configuration.class);
+ LOG.info("Registering Dropwizard Configuration class name:{}",
+ Configuration.class.getName());
+ }
+
+ }
+ });
+
+ registerSubConfigure(configuration, environment);
+
+ }
+
+ private void registerSubConfigure(final T configuration, final Environment environment) {
+ final List<Field> subDeclaredFields =
+ Arrays.asList(configuration.getClass().getDeclaredFields());
+ List<Field> parentDeclaredFields = Arrays.asList(Configuration.class.getDeclaredFields());
+
+ List<Field> filtersubDeclaredFields = subDeclaredFields.stream()
+ .filter(subDeclaredField -> !subDeclaredField.getType().isPrimitive())
+ .filter(subDeclaredField -> !subDeclaredField.getType().equals(String.class))
+ .filter(subDeclaredField -> !parentDeclaredFields.contains(subDeclaredField))
+ .collect(Collectors.toList());
+
+ ServiceLocatorUtilities.bind(locator, new AbstractBinder() {
+ @Override
+ protected void configure() {
+ filtersubDeclaredFields.forEach(subField -> {
+ subField.setAccessible(true);
+ try {
+ Object subConfig = subField.get(configuration);
+ if (subConfig != null) {
+ bind(subConfig);
+ LOG.info("Registering Dropwizard Sub Configuration class name {}",
+ subConfig.getClass().getName());
+ }
+
+ } catch (Exception e) {
+ LOG.error("bind sub config:{} fail", subField);
+ }
+ });
+ }
+ });
+
+ }
+
+ private void registerServices() {
+ services = this.reflections.getTypesAnnotatedWith(Service.class, true);
+ if (!services.isEmpty()) {
+ ServiceLocatorUtilities.bind(locator, new ServiceBinder(services));
+
+ services.forEach(s -> {
+ LOG.info("Registering Dropwizard service, class name : {}", s.getName());
+ });
+
+ services.stream().filter(serviceClazz -> (serviceClazz.getAnnotation(Lazy.class) == null))
+ .peek(serviceClazz -> LOG.info("active service, class name : {}", serviceClazz.getName()))
+ .forEach(serviceClazz -> {
+ try {
+ long startTime = System.currentTimeMillis();
+ locator.getService(serviceClazz);
+ LOG.info("active service, class name : {},cost time:{}", serviceClazz.getName(),
+ (System.currentTimeMillis() - startTime));
+ } catch (Exception e) {
+ LOG.warn("", e);
+ }
+
+ });
+
+ } else {
+ LOG.warn("Registering Dropwizard service is empty");
+
+ }
+
+ }
+
+ private void registerResources(final Environment environment) {
+ reflections.getTypesAnnotatedWith(Path.class).stream().forEach(resourceClass -> {
+
+ LOG.info("begin Registering Dropwizard resource, class name : {}", resourceClass.getName());
+ try {
+ Object resourceObject = locator.getService(resourceClass);
+ if (resourceObject != null) {
+ environment.jersey().register(resourceObject);
+ LOG.info("Registering Dropwizard resource, class name : {}", resourceClass.getName());
+ } else {
+ LOG.warn(resourceClass.getName() + " not use Service annotation");
+ }
+ } catch (Exception e) {
+ LOG.error("", e);
+ }
+
+
+ });
+ }
+
+ private void registerHealthChecks(final Environment env) {
+
+ reflections.getSubTypesOf(HealthCheck.class).stream().filter(services::contains)
+ .forEach(healthCheckKlass -> {
+ try {
+ env.healthChecks().register(healthCheckKlass.getName(),
+ locator.getService(healthCheckKlass));
+ } catch (Exception e) {
+ LOG.warn("", e);
+ }
+ LOG.info("Registering Dropwizard healthCheck, class name : {}",
+ healthCheckKlass.getName());
+ });
+
+ }
+
+
+
+ private void registerService(Class<? extends Annotation> annotationClazz) {
+
+ Set<Class<?>> services = this.reflections.getTypesAnnotatedWith(annotationClazz, true);
+ if (!services.isEmpty()) {
+ ServiceLocatorUtilities.bind(locator, new ServiceBinder(services));
+
+ services.forEach(s -> {
+ LOG.info("{} Registering service, class name : {}", annotationClazz.getName(),
+ s.getName());
+ });
+
+ services.stream().filter(serviceClazz -> (serviceClazz.getAnnotation(Lazy.class) == null))
+ .peek(serviceClazz -> LOG.info("active service, class name : {}", serviceClazz.getName()))
+ .forEach(serviceClazz -> {
+ try {
+ long startTime = System.currentTimeMillis();
+ locator.getService(serviceClazz);
+ LOG.info("active service, class name : {},cost time:{}", serviceClazz.getName(),
+ (System.currentTimeMillis() - startTime));
+ } catch (Exception e) {
+ LOG.warn("", e);
+ }
+
+ });
+
+ } else {
+ LOG.warn("Registering {} service is empty", annotationClazz.getName());
+
+ }
+
+ }
+}
--- /dev/null
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.common.dropwizard.ioc.bundle;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import io.dropwizard.Configuration;
+
+public class AutoConfigBundleBuider<T extends Configuration> {
+
+ private static final String DEFAULT_PACKAGE_NAME="org.onap";
+
+ private List<String> packageNames=new ArrayList<>();
+
+ public AutoConfigBundleBuider(){
+ packageNames.add( DEFAULT_PACKAGE_NAME);
+ }
+
+ public AutoConfigBundleBuider<T> addPackageName(String packageName) {
+ this.packageNames.add(packageName);
+ return this;
+ }
+
+
+ public AutoConfigBundle<T> build() {
+ return new AutoConfigBundle<T>(packageNames);
+ }
+}
--- /dev/null
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.common.dropwizard.ioc.bundle;
+
+import io.dropwizard.Application;
+import io.dropwizard.Configuration;
+import io.dropwizard.setup.Bootstrap;
+import io.dropwizard.setup.Environment;
+
+/**
+ * complete IOC container startup
+ *
+ * @author hu.rui2
+ *
+ */
+public abstract class IOCApplication<T extends Configuration> extends Application<T> {
+
+
+ @Override
+ public void initialize(Bootstrap<T> bootstrap) {
+ super.initialize(bootstrap);
+ bootstrap.addBundle(new AutoConfigBundleBuider().build());
+ }
+
+ @Override
+ public void run(T configuration, Environment environment) throws Exception {
+
+ }
+}
--- /dev/null
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.common.dropwizard.ioc.bundle;
+
+import org.glassfish.hk2.api.ServiceLocator;
+
+import io.dropwizard.lifecycle.Managed;
+
+/**
+ * Life cycle management for IOC containers
+ * @author hu.rui
+ *
+ */
+public class ServiceLocatorManaged implements Managed{
+
+
+
+ private ServiceLocator locator;
+
+
+
+ public ServiceLocatorManaged(ServiceLocator locator) {
+ super();
+ this.locator = locator;
+ }
+
+ @Override
+ public void start() throws Exception {
+
+
+ }
+
+ @Override
+ public void stop() throws Exception {
+ locator.shutdown();
+ }
+
+}
--- /dev/null
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.common.dropwizard.ioc.utils;
+
+import java.util.Set;
+
+import org.glassfish.hk2.utilities.binding.AbstractBinder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author hu.rui
+ *
+ */
+public class ServiceBinder extends AbstractBinder {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ServiceBinder.class);
+
+ final Set<Class<?>> klasses;
+
+ public ServiceBinder(Set<Class<?>> services) {
+ this.klasses = services;
+ }
+
+ @Override
+ protected void configure() {
+ for (Class<?> klass : this.klasses) {
+
+ try{
+ LOG.info("start active class:"+klass.getName());
+ addActiveDescriptor(klass);
+ }catch(Exception e){
+ LOG.info("active class error:"+klass.getName(),e);
+ }
+
+
+ }
+ }
+}
--- /dev/null
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.common.dropwizard.ioc.utils;
+
+import org.glassfish.hk2.api.ServiceLocator;
+
+/**
+ * @author hu.rui
+ *
+ */
+public class ServiceLocatorHolder {
+
+ private static ServiceLocator locator;
+
+ public static ServiceLocator getLocator() {
+ return locator;
+ }
+
+ public static void setLocator(ServiceLocator locator) {
+ ServiceLocatorHolder.locator = locator;
+ }
+
+}
* See the License for the specific language governing permissions and\r
* limitations under the License.\r
*/\r
-package org.openo.holmes.common.exception;\r
+package org.onap.holmes.common.exception;\r
\r
public class CorrelationException extends Exception {\r
\r
* limitations under the License.\r
*/\r
\r
-package org.openo.holmes.common.msb;\r
+package org.onap.holmes.common.msb;\r
\r
import javax.ws.rs.Consumes;\r
import javax.ws.rs.POST;\r
import javax.ws.rs.Produces;\r
import javax.ws.rs.QueryParam;\r
import javax.ws.rs.core.MediaType;\r
-import org.openo.holmes.common.api.entity.ServiceRegisterEntity;\r
+import org.onap.holmes.common.api.entity.ServiceRegisterEntity;\r
\r
-@Path("/openoapi/microservices/v1/services")\r
+@Path("/onapapi/microservices/v1/services")\r
public interface MicroserviceBusRest {\r
\r
@Path("")\r
* See the License for the specific language governing permissions and\r
* limitations under the License.\r
*/\r
-package org.openo.holmes.common.producer;\r
+package org.onap.holmes.common.producer;\r
\r
import java.io.Serializable;\r
import javax.inject.Inject;\r
import lombok.extern.slf4j.Slf4j;\r
import org.glassfish.hk2.api.IterableProvider;\r
import org.jvnet.hk2.annotations.Service;\r
-import org.openo.holmes.common.api.entity.CorrelationResult;\r
-import org.openo.holmes.common.api.stat.Alarm;\r
-import org.openo.holmes.common.api.stat.AplusResult;\r
-import org.openo.holmes.common.config.MQConfig;\r
-import org.openo.holmes.common.constant.AlarmConst;\r
+import org.onap.holmes.common.api.stat.Alarm;\r
+import org.onap.holmes.common.constant.AlarmConst;\r
+import org.onap.holmes.common.api.entity.CorrelationResult;\r
+import org.onap.holmes.common.api.stat.AplusResult;\r
+import org.onap.holmes.common.config.MQConfig;\r
import org.apache.activemq.ActiveMQConnectionFactory;\r
\r
@Service\r
* See the License for the specific language governing permissions and\r
* limitations under the License.\r
*/\r
-package org.openo.holmes.common.utils;\r
+package org.onap.holmes.common.utils;\r
\r
import io.dropwizard.db.DataSourceFactory;\r
import io.dropwizard.jdbi.DBIFactory;\r
* See the License for the specific language governing permissions and\r
* limitations under the License.\r
*/\r
-package org.openo.holmes.common.utils;\r
+package org.onap.holmes.common.utils;\r
\r
import javax.ws.rs.WebApplicationException;\r
import javax.ws.rs.core.MediaType;\r
* See the License for the specific language governing permissions and\r
* limitations under the License.\r
*/\r
-package org.openo.holmes.common.utils;\r
+package org.onap.holmes.common.utils;\r
\r
import com.fasterxml.jackson.core.JsonProcessingException;\r
import com.fasterxml.jackson.databind.ObjectMapper;\r
* See the License for the specific language governing permissions and\r
* limitations under the License.\r
*/\r
-package org.openo.holmes.common.utils;\r
+package org.onap.holmes.common.utils;\r
\r
import java.util.List;\r
\r
* See the License for the specific language governing permissions and\r
* limitations under the License.\r
*/\r
-package org.openo.holmes.common.utils;\r
+package org.onap.holmes.common.utils;\r
\r
import java.util.Locale;\r
import javax.servlet.http.HttpServletRequest;\r
-import org.openo.holmes.common.constant.AlarmConst;\r
+import org.onap.holmes.common.constant.AlarmConst;\r
\r
public class LanguageUtil {\r
\r
* limitations under the License.\r
*/\r
\r
-package org.openo.holmes.common.utils;\r
+package org.onap.holmes.common.utils;\r
\r
import com.eclipsesource.jaxrs.consumer.ConsumerFactory;\r
import java.io.IOException;\r
import lombok.extern.slf4j.Slf4j;\r
import org.jvnet.hk2.annotations.Service;\r
-import org.openo.holmes.common.api.entity.ServiceRegisterEntity;\r
-import org.openo.holmes.common.config.MicroServiceConfig;\r
-import org.openo.holmes.common.msb.MicroserviceBusRest;\r
+import org.onap.holmes.common.msb.MicroserviceBusRest;\r
+import org.onap.holmes.common.api.entity.ServiceRegisterEntity;\r
+import org.onap.holmes.common.config.MicroServiceConfig;\r
\r
@Slf4j\r
@Service\r
* See the License for the specific language governing permissions and\r
* limitations under the License.\r
*/\r
-package org.openo.holmes.common.utils;\r
+package org.onap.holmes.common.utils;\r
\r
import javax.servlet.http.HttpServletRequest;\r
-import org.openo.holmes.common.constant.AlarmConst;\r
+import org.onap.holmes.common.constant.AlarmConst;\r
\r
public class UserUtil {\r
\r
+++ /dev/null
-{
- "ENGINE_CONTENT_ILLEGALITY": "The rule content have error:{0}",
- "ENGINE_DEPLOY_RULE_FAILED": "Deploy rule failed",
- "ENGINE_DELETE_RULE_NULL": "The rule do not exist :{0}",
- "ENGINE_DELETE_RULE_FAILED": "The rule remove failed :{0}",
- "ENGINE_INSERT_RULE_CACHE_FAILED": "insert rule failed in cache",
- "ENGINE_DELETE_RULE_FAILED_FROM_CACHE": "delete rule failed in cache",
- "ENGINE_CONTAINS_PACKAGE": "Is included in the package name, please amend",
- "ENGINE_QUERY_CACHE_FAILED": "Failed query cache",
- "DSA_QUERY_CURRENT_ALARM_FAILED":"query current alarm failed",
- "DSA_REQUEST_ANALYSIS_ERROR":"request analysis error",
- "DSA_REQUEST_EXECUTE_FAILED":"send request failed",
- "DSA_HTTP_CLIENT_CLOSE_FAILED":"httpclient close failed",
- "EXCEPTION_DB_RULE_NOT_EXIST_ERROR": "This rule does not exist in the database.",
- "EXCEPTION_DB_RULE_SAVE_ERROR": "Error saving rule to database",
- "EXCEPTION_DB_RULE_GET_ERROR": "Error when get rule from database",
- "EXCEPTION_REQUEST_IS_EMPTY": "The request object is empty",
- "RULE_MANAGEMENT_CALL_DELETE_RULE_REST_FAILED": "Delete rules from engine call interface failure ",
- "RULE_MANAGEMENT_DELETE_RULE_FAILED":"To delete rules from the engine failure",
- "RULE_MANAGEMENT_CALL_DEPLOY_RULE_REST_FAILED": "From the rules engine calls the deployment of interface failure",
- "RULE_MANAGEMENT_CALL_CHECK_RULE_REST_FAILED": "From the rules engine calls the check of interface failure",
- "RULE_MANAGEMENT_CREATE_QUERY_SQL_FAILED": "Create query exception",
- "RULE_MANAGEMENT_QUERY_RULE_FAILED": "Query rule failed",
- "RULE_MANAGEMENT_REQUEST_OBJECT_IS_EMPTY": "Request object is empty",
- "RULE_MANAGEMENT_RULE_NOT_EXIST_DATABASE": "Rule does not exist",
- "RULE_MANAGEMENT_REPEAT_RULE_NAME": "Rule name repetition",
- "RULE_MANAGEMENT_RULE_NAME_CANNOT_BE_EMPTY": "Rule name cannot be empty",
- "RULE_MANAGEMENT_DATA_FORMAT_ERROR": "Data format error",
- "RULE_MANAGEMENT_PARAMETER_ENABLED_ERROR": "Parameter enabled can only be 0 (not enabled) and 1 (enabled)",
- "RULE_MANAGEMENT_DB_ERROR": "db error",
- "RULE_MANAGEMENT_PARSE_DEPLOY_RESULT_ERROR":"Parsing call deployment rule return the result of the failure",
- "RULE_MANAGEMENT_CHECK_NO_PASS":"Content inspection not by rule",
- "RULE_MANAGEMENT_CONTENT_CANNOT_BE_EMPTY":"Content cannot be empty"
-}
+++ /dev/null
-{\r
- "ENGINE_CONTENT_ILLEGALITY": "规则内容有误:{0}",\r
- "ENGINE_DEPLOY_RULE_FAILED": "部署规则失败",\r
- "ENGINE_DELETE_RULE_NULL": "引擎不包含这个规则:{0}",\r
- "ENGINE_DELETE_RULE_FAILED": "删除规则失败{0}",\r
- "ENGINE_INSERT_RULE_CACHE_FAILED": "插入数据到缓存失败",\r
- "ENGINE_DELETE_RULE_FAILED_FROM_CACHE": "从缓存删除数据失败",\r
- "ENGINE_CONTAINS_PACKAGE": "package 名字已包含,请修改",\r
- "ENGINE_QUERY_CACHE_FAILED":"查询缓存失败",\r
- "DSA_QUERY_CURRENT_ALARM_FAILED":"查询当前所有告警失败",\r
- "DSA_REQUEST_ANALYSIS_ERROR":"解析请求数据失败",\r
- "DSA_REQUEST_EXECUTE_FAILED":"发送请求失败",\r
- "DSA_HTTP_CLIENT_CLOSE_FAILED":"httpclient 关闭失败",\r
- "RULE_MANAGEMENT_CALL_DELETE_RULE_REST_FAILED": "从引擎调用删除规则接口失败",\r
- "RULE_MANAGEMENT_DELETE_RULE_FAILED":"从引擎中删除规则失败",\r
- "RULE_MANAGEMENT_CALL_DEPLOY_RULE_REST_FAILED": "从引擎调用部署规则接口失败",\r
- "RULE_MANAGEMENT_CALL_CHECK_RULE_REST_FAILED": "从引擎调用校验规则接口失败",\r
- "RULE_MANAGEMENT_CREATE_QUERY_SQL_FAILED": "创建查询语句异常",\r
- "RULE_MANAGEMENT_QUERY_RULE_FAILED": "查询规则失败",\r
- "RULE_MANAGEMENT_REQUEST_OBJECT_IS_EMPTY":"请求对象为空",\r
- "RULE_MANAGEMENT_RULE_NOT_EXIST_DATABASE": "规则不存在",\r
- "RULE_MANAGEMENT_REPEAT_RULE_NAME" : "规则名字重复",\r
- "RULE_MANAGEMENT_RULE_NAME_CANNOT_BE_EMPTY" : "规则名字不能为空",\r
- "RULE_MANAGEMENT_DATA_FORMAT_ERROR": "数据格式异常",\r
- "RULE_MANAGEMENT_PARAMETER_ENABLED_ERROR" : "参数enabled只能为0(未启用)和1(启用)",\r
- "RULE_MANAGEMENT_DB_ERROR" : "数据库异常",\r
- "RULE_MANAGEMENT_PARSE_DEPLOY_RESULT_ERROR":"解析调用部署规则返回的结果错误",\r
- "RULE_MANAGEMENT_CHECK_NO_PASS":"规则内容检查不通过",\r
- "RULE_MANAGEMENT_CONTENT_CANNOT_BE_EMPTY":"规则内容不能为空"\r
-\r
-}\r
+++ /dev/null
-/**\r
- * Copyright 2017 ZTE Corporation.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.openo.holmes.common.utils;\r
-\r
-import com.fasterxml.jackson.core.JsonProcessingException;\r
-import java.util.Arrays;\r
-import java.util.Locale;\r
-import java.util.Map;\r
-import java.util.Optional;\r
-import lombok.extern.slf4j.Slf4j;\r
-import org.openo.baseservice.i18n.I18n;\r
-\r
-@Slf4j\r
-public class I18nProxy {\r
-\r
- /*-----------------------Engine------------------------------- */\r
- public static final String ENGINE_CONTENT_ILLEGALITY = "ENGINE_CONTENT_ILLEGALITY";\r
- public static final String ENGINE_DEPLOY_RULE_FAILED = "ENGINE_DEPLOY_RULE_FAILED";\r
- public static final String ENGINE_DELETE_RULE_NULL = "ENGINE_DELETE_RULE_NULL";\r
- public static final String ENGINE_DELETE_RULE_FAILED = "ENGINE_DELETE_RULE_FAILED";\r
- public static final String ENGINE_INSERT_RULE_CACHE_FAILED = "ENGINE_INSERT_RULE_CACHE_FAILED";\r
- public static final String ENGINE_DELETE_RULE_FAILED_FROM_CACHE = "ENGINE_DELETE_RULE_FAILED_FROM_CACHE";\r
- public static final String ENGINE_CONTAINS_PACKAGE = "ENGINE_CONTAINS_PACKAGE";\r
- public static final String ENGINE_QUERY_CACHE_FAILED = "ENGINE_QUERY_CACHE_FAILED";\r
- /*-----------------------DSA ------------------------------- */\r
- public static final String DSA_QUERY_CURRENT_ALARM_FAILED = "DSA_QUERY_CURRENT_ALARM_FAILED";\r
- public static final String DSA_REQUEST_ANALYSIS_FAILED = "DSA_REQUEST_ANALYSIS_ERROR";\r
- public static final String DSA_REQUEST_EXECUTE_FAILED = "DSA_REQUEST_EXECUTE_FAILED";\r
- public static final String DSA_HTTP_CLIENT_CLOSE_FAILED = "DSA_HTTP_CLIENT_CLOSE_FAILED";\r
-\r
- /*-----------------------Rule Management------------------------------- */\r
- public static final String RULE_MANAGEMENT_CALL_DELETE_RULE_REST_FAILED = "RULE_MANAGEMENT_CALL_DELETE_RULE_REST_FAILED";\r
- public static final String RULE_MANAGEMENT_DELETE_RULE_FAILED = "RULE_MANAGEMENT_DELETE_RULE_FAILED";\r
- public static final String RULE_MANAGEMENT_CALL_DEPLOY_RULE_REST_FAILED = "RULE_MANAGEMENT_CALL_DEPLOY_RULE_REST_FAILED";\r
- public static final String RULE_MANAGEMENT_CALL_CHECK_RULE_REST_FAILED = "RULE_MANAGEMENT_CALL_CHECK_RULE_REST_FAILED";\r
- public static final String RULE_MANAGEMENT_CREATE_QUERY_SQL_FAILED = "RULE_MANAGEMENT_CREATE_QUERY_SQL_FAILED";\r
- public static final String RULE_MANAGEMENT_QUERY_RULE_FAILED = "RULE_MANAGEMENT_QUERY_RULE_FAILED";\r
- public static final String RULE_MANAGEMENT_REQUEST_OBJECT_IS_EMPTY = "RULE_MANAGEMENT_REQUEST_OBJECT_IS_EMPTY";\r
- public static final String RULE_MANAGEMENT_RULE_NAME_CANNOT_BE_EMPTY = "RULE_MANAGEMENT_RULE_NAME_CANNOT_BE_EMPTY";\r
- public static final String RULE_MANAGEMENT_RULE_NOT_EXIST_DATABASE = "RULE_MANAGEMENT_RULE_NOT_EXIST_DATABASE";\r
- public static final String RULE_MANAGEMENT_REPEAT_RULE_NAME = "RULE_MANAGEMENT_REPEAT_RULE_NAME";\r
- public static final String RULE_MANAGEMENT_DATA_FORMAT_ERROR = "RULE_MANAGEMENT_DATA_FORMAT_ERROR";\r
- public static final String RULE_MANAGEMENT_PARAMETER_ENABLED_ERROR = "RULE_MANAGEMENT_PARAMETER_ENABLED_ERROR";\r
- public static final String RULE_MANAGEMENT_DB_ERROR = "RULE_MANAGEMENT_DB_ERROR";\r
- public static final String RULE_MANAGEMENT_PARSE_DEPLOY_RESULT_ERROR = "RULE_MANAGEMENT_PARSE_DEPLOY_RESULT_ERROR";\r
- public static final String RULE_MANAGEMENT_CHECK_NO_PASS = "RULE_MANAGEMENT_CHECK_NO_PASS";\r
- public static final String RULE_MANAGEMENT_CONTENT_CANNOT_BE_EMPTY = "RULE_MANAGEMENT_CONTENT_CANNOT_BE_EMPTY";\r
- private Optional<I18n> optional = null;\r
-\r
- private I18nProxy() {\r
- optional = I18n.getInstance("correlation");\r
- }\r
-\r
- private static class I18nProxyHolder {\r
-\r
- private static final I18nProxy INSTANCE = new I18nProxy();\r
-\r
- private I18nProxyHolder() {\r
-\r
- }\r
- }\r
-\r
- public static I18nProxy getInstance() {\r
- return I18nProxyHolder.INSTANCE;\r
- }\r
-\r
- public String getValue(Locale locale, String key) {\r
- return optional.get().getLabelValue(key, locale);\r
- }\r
-\r
- public String getValueByArgs(Locale locale, String key, String[] arguments) {\r
- return optional.get().getLabelValue(key, locale, arguments);\r
- }\r
-\r
- public Map<String, String> getValue(String key) {\r
- return optional.get().getLabelValues(key);\r
- }\r
-\r
- public String jsonI18n(String key) {\r
-\r
- return optional.get().getCanonicalLabelValues(key);\r
- }\r
-\r
- public String i18nWithArgs(String key, String[] args) {\r
- String value = "";\r
- try {\r
- value = JacksonUtil.beanToJson(optional.get().getLabelValues(key, args));\r
- } catch (JsonProcessingException e) {\r
- log.warn("get i18n error, key is :" + key, e);\r
- } catch (IllegalArgumentException e) {\r
- log.warn("get i18n error IllegalArgumentException, key is :" + key + ",args is : " + Arrays.toString(args),\r
- e);\r
- }\r
-\r
- return value;\r
- }\r
-\r
-}\r
* limitations under the License.
*/
-package org.openo.holmes.common.api.entity;
+package org.onap.holmes.common.api.entity;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.junit.Before;
import org.junit.After;
-import sun.util.resources.cldr.ga.LocaleNames_ga;
public class AlarmsCorrelationTest {
* limitations under the License.
*/
-package org.openo.holmes.common.api.entity;
+package org.onap.holmes.common.api.entity;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.openo.holmes.common.api.stat.Alarm;
+import org.onap.holmes.common.api.stat.Alarm;
public class CorrelationResultTest {
* limitations under the License.
*/
-package org.openo.holmes.common.api.entity;
+package org.onap.holmes.common.api.entity;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
* limitations under the License.\r
*/\r
\r
-package org.openo.holmes.common.api.entity;\r
+package org.onap.holmes.common.api.entity;\r
\r
import static org.hamcrest.core.IsEqual.equalTo;\r
import static org.junit.Assert.assertThat;\r
* limitations under the License.\r
*/\r
\r
-package org.openo.holmes.common.api.entity;\r
+package org.onap.holmes.common.api.entity;\r
\r
import static org.hamcrest.core.IsEqual.equalTo;\r
import static org.junit.Assert.assertThat;\r
* limitations under the License.
*/
-package org.openo.holmes.common.api.stat;
+package org.onap.holmes.common.api.stat;
import java.util.Date;
import static org.hamcrest.core.IsEqual.equalTo;
* limitations under the License.
*/
-package org.openo.holmes.common.config;
+package org.onap.holmes.common.config;
import org.junit.Test;
import org.junit.Before;
* limitations under the License.\r
*/\r
\r
-package org.openo.holmes.common.config;\r
+package org.onap.holmes.common.config;\r
\r
import static org.hamcrest.core.IsEqual.equalTo;\r
import static org.junit.Assert.assertThat;\r
* limitations under the License.
*/
-package org.openo.holmes.common.exception;
+package org.onap.holmes.common.exception;
import org.junit.Test;
import org.junit.Before;
* limitations under the License.
*/
-package org.openo.holmes.common.producer;
+package org.onap.holmes.common.producer;
import static org.easymock.EasyMock.anyBoolean;
import static org.easymock.EasyMock.anyInt;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.openo.holmes.common.api.entity.CorrelationResult;
-import org.openo.holmes.common.api.stat.Alarm;
-import org.openo.holmes.common.config.MQConfig;
+import org.onap.holmes.common.api.stat.Alarm;
+import org.onap.holmes.common.api.entity.CorrelationResult;
+import org.onap.holmes.common.config.MQConfig;
import org.powermock.api.easymock.PowerMock;
import org.powermock.modules.junit4.rule.PowerMockRule;
import org.powermock.reflect.Whitebox;
* limitations under the License.
*/
-package org.openo.holmes.common.utils;
+package org.onap.holmes.common.utils;
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.expect;
* limitations under the License.
*/
-package org.openo.holmes.common.utils;
-
-import static org.openo.holmes.common.utils.ExceptionUtil.buildExceptionResponse;
+package org.onap.holmes.common.utils;
import org.junit.Test;
@Test
public void testBuildExceptionResponse() throws Exception {
- buildExceptionResponse("test");
+ ExceptionUtil.buildExceptionResponse("test");
}
*/\r
\r
\r
-package org.openo.holmes.common.utils;\r
+package org.onap.holmes.common.utils;\r
\r
import static org.hamcrest.core.IsEqual.equalTo;\r
import static org.junit.Assert.assertThat;\r
\r
import org.junit.Test;\r
-import org.openo.holmes.common.utils.bean.TestBean;\r
+import org.onap.holmes.common.utils.bean.TestBean;\r
\r
public class JacksonUtilTest {\r
\r
*/\r
\r
\r
-package org.openo.holmes.common.utils;\r
+package org.onap.holmes.common.utils;\r
\r
import static org.hamcrest.core.IsEqual.equalTo;\r
import static org.junit.Assert.assertThat;\r
*/\r
\r
\r
-package org.openo.holmes.common.utils;\r
+package org.onap.holmes.common.utils;\r
\r
import static org.hamcrest.core.IsEqual.equalTo;\r
import static org.junit.Assert.assertThat;\r
import org.easymock.EasyMock;\r
import org.junit.Before;\r
import org.junit.Test;\r
-import org.openo.holmes.common.constant.AlarmConst;\r
+import org.onap.holmes.common.constant.AlarmConst;\r
import org.powermock.api.easymock.PowerMock;\r
\r
\r
* limitations under the License.\r
*/\r
\r
-package org.openo.holmes.common.utils;\r
+package org.onap.holmes.common.utils;\r
\r
import com.eclipsesource.jaxrs.consumer.ConsumerFactory;\r
import javax.ws.rs.QueryParam;\r
import org.easymock.EasyMock;\r
import org.junit.Rule;\r
import org.junit.Test;\r
-import org.openo.holmes.common.api.entity.ServiceRegisterEntity;\r
-import org.openo.holmes.common.config.MicroServiceConfig;\r
-import org.openo.holmes.common.msb.MicroserviceBusRest;\r
+import org.onap.holmes.common.msb.MicroserviceBusRest;\r
+import org.onap.holmes.common.api.entity.ServiceRegisterEntity;\r
+import org.onap.holmes.common.config.MicroServiceConfig;\r
import org.powermock.api.easymock.PowerMock;\r
import org.powermock.core.classloader.annotations.PrepareForTest;\r
import org.powermock.modules.junit4.rule.PowerMockRule;\r
serviceRegisterEntity.setServiceName("holmes-rule-mgmt");\r
serviceRegisterEntity.setProtocol("REST");\r
serviceRegisterEntity.setVersion("v1");\r
- serviceRegisterEntity.setUrl("/openoapi/holmes-rule-mgmt/v1");\r
+ serviceRegisterEntity.setUrl("/onapapi/holmes-rule-mgmt/v1");\r
serviceRegisterEntity.setSingleNode(MicroServiceConfig.getServiceIp(), "9101", 0);\r
serviceRegisterEntity.setVisualRange("1|0");\r
return serviceRegisterEntity;\r
* limitations under the License.
*/
-package org.openo.holmes.common.utils;
+package org.onap.holmes.common.utils;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
*/\r
\r
\r
-package org.openo.holmes.common.utils.bean;\r
+package org.onap.holmes.common.utils.bean;\r
\r
import java.io.Serializable;\r
\r
+++ /dev/null
-/**\r
- * Copyright 2016 ZTE Corporation.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-\r
-package org.openo.holmes.common.utils;\r
-\r
-import static org.hamcrest.core.IsEqual.equalTo;\r
-import static org.junit.Assert.assertThat;\r
-\r
-import java.util.Locale;\r
-import java.util.Map;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-\r
-public class I18nProxyTest {\r
-\r
- private I18nProxy i18nProxy;\r
-\r
- @Before\r
- public void setUp() {\r
- i18nProxy = I18nProxy.getInstance();\r
- }\r
-\r
- @Test\r
- public void getValue_locale_and_key() {\r
- String result = i18nProxy.getValue(new Locale("zh"), "test");\r
- assertThat(result, equalTo(null));\r
- }\r
- @Test\r
- public void getValueByArgs(){\r
- String result = i18nProxy.getValueByArgs(new Locale("zh"), "test",new String[]{"1"});\r
- assertThat(result,equalTo(null));\r
- }\r
- @Test\r
- public void getValue_by_key(){\r
- Map<String,String> result = i18nProxy.getValue("test");\r
- assertThat(result, equalTo(null));\r
- }\r
- @Test\r
- public void jsonI18n(){\r
- String result = i18nProxy.jsonI18n("test");\r
- assertThat(result,equalTo(null));\r
- }\r
- @Test\r
- public void i18nWithArgs(){\r
- String result = i18nProxy.i18nWithArgs("test",new String[]{});\r
- assertThat(result,equalTo("null"));\r
- }\r
-}
\ No newline at end of file
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
<modelVersion>4.0.0</modelVersion>\r
<parent>\r
- <groupId>org.openo.oparent</groupId>\r
- <artifactId>oparent</artifactId>\r
- <version>1.1.0-SNAPSHOT</version>\r
- <relativePath>../oparent</relativePath>\r
+ <groupId>org.onap.oparent</groupId>\r
+ <artifactId>version</artifactId>\r
+ <version>1.0.0-SNAPSHOT</version>\r
+ <relativePath>../../oparent</relativePath>\r
</parent>\r
\r
- <groupId>org.openo.holmes.actions</groupId>\r
+ <groupId>org.onap.holmes.actions</groupId>\r
<artifactId>holmes-actions-parent</artifactId>\r
<packaging>pom</packaging>\r
+ <version>1.0.0-SNAPSHOT</version>\r
<name>holmes-actions-parent</name>\r
<modules>\r
<module>holmes-actions</module>\r
<artifactId>stringtemplate</artifactId>\r
<version>${stringtemplate.version}</version>\r
</dependency>\r
-\r
- <dependency>\r
- <groupId>org.openo.common-services.common-utilities</groupId>\r
- <artifactId>dropwizard-ioc-container</artifactId>\r
- <version>${project.version}</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.openo.common-services.common-utilities</groupId>\r
- <artifactId>baseservice-i18n</artifactId>\r
- <version>${project.version}</version>\r
- </dependency>\r
<dependency>\r
<groupId>org.quartz-scheduler</groupId>\r
<artifactId>quartz</artifactId>\r