From 8fba0fdabb6a056c87927cafb4dbc8a488fe6b70 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Fri, 27 Oct 2017 23:48:39 +0800 Subject: [PATCH] Define UI module. --- .../apm/collector/core/module/Module.java | 2 +- .../collector/core/module/ModuleProvider.java | 2 +- .../collector-ui-define/pom.xml | 33 ++++++++ .../skywalking/apm/collector/ui/UIModule.java | 37 +++++++++ ...kywalking.apm.collector.core.module.Module | 19 +++++ .../collector-ui-jetty-provider/pom.xml | 50 ++++++++++++ .../ui/jetty/UIModuleJettyProvider.java | 78 +++++++++++++++++++ ...g.apm.collector.core.module.ModuleProvider | 19 +++++ apm-collector/apm-collector-ui/pom.xml | 13 +++- 9 files changed, 250 insertions(+), 3 deletions(-) create mode 100644 apm-collector/apm-collector-ui/collector-ui-define/pom.xml create mode 100644 apm-collector/apm-collector-ui/collector-ui-define/src/main/java/org/skywalking/apm/collector/ui/UIModule.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-define/src/main/resources/META-INF/services/org.skywalking.apm.collector.core.module.Module create mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/pom.xml create mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/resources/META-INF/services/org.skywalking.apm.collector.core.module.ModuleProvider diff --git a/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/Module.java b/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/Module.java index 0a8855cc0c..9fb70de587 100644 --- a/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/Module.java +++ b/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/Module.java @@ -121,7 +121,7 @@ public abstract class Module { return loadedProviders.getFirst(); } - public T getService(Class serviceType) throws ServiceNotProvidedException { + public final T getService(Class serviceType) throws ServiceNotProvidedException { try { return provider().getService(serviceType); } catch (ProviderNotFoundException | DuplicateProviderException e) { diff --git a/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/ModuleProvider.java b/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/ModuleProvider.java index c49e1bde61..43e52ef805 100644 --- a/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/ModuleProvider.java +++ b/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/module/ModuleProvider.java @@ -46,7 +46,7 @@ public abstract class ModuleProvider { this.module = module; } - protected ModuleManager getManager() { + protected final ModuleManager getManager() { return manager; } diff --git a/apm-collector/apm-collector-ui/collector-ui-define/pom.xml b/apm-collector/apm-collector-ui/collector-ui-define/pom.xml new file mode 100644 index 0000000000..d454246e53 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-define/pom.xml @@ -0,0 +1,33 @@ + + + + + + apm-collector-ui + org.skywalking + 3.2.3-2017 + + 4.0.0 + + collector-ui-define + jar + + \ No newline at end of file diff --git a/apm-collector/apm-collector-ui/collector-ui-define/src/main/java/org/skywalking/apm/collector/ui/UIModule.java b/apm-collector/apm-collector-ui/collector-ui-define/src/main/java/org/skywalking/apm/collector/ui/UIModule.java new file mode 100644 index 0000000000..7ce129a9fc --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-define/src/main/java/org/skywalking/apm/collector/ui/UIModule.java @@ -0,0 +1,37 @@ +/* + * Copyright 2017, OpenSkywalking Organization All rights reserved. + * + * 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. + * + * Project repository: https://github.com/OpenSkywalking/skywalking + */ + +package org.skywalking.apm.collector.ui; + +import org.skywalking.apm.collector.core.module.Module; + +/** + * @author peng-yongsheng + */ +public class UIModule extends Module { + + public static final String NAME = "Naming"; + + @Override public String name() { + return NAME; + } + + @Override public Class[] services() { + return new Class[0]; + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-define/src/main/resources/META-INF/services/org.skywalking.apm.collector.core.module.Module b/apm-collector/apm-collector-ui/collector-ui-define/src/main/resources/META-INF/services/org.skywalking.apm.collector.core.module.Module new file mode 100644 index 0000000000..26b274ec71 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-define/src/main/resources/META-INF/services/org.skywalking.apm.collector.core.module.Module @@ -0,0 +1,19 @@ +# +# Copyright 2017, OpenSkywalking Organization All rights reserved. +# +# 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. +# +# Project repository: https://github.com/OpenSkywalking/skywalking +# + +org.skywalking.apm.collector.ui.UIModule \ No newline at end of file diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/pom.xml b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/pom.xml new file mode 100644 index 0000000000..45269ccec3 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/pom.xml @@ -0,0 +1,50 @@ + + + + + + apm-collector-ui + org.skywalking + 3.2.3-2017 + + 4.0.0 + + collector-ui-jetty-provider + jar + + + + org.skywalking + collector-ui-define + ${project.version} + + + org.skywalking + collector-cluster-define + ${project.version} + + + org.skywalking + collector-server-manager-define + ${project.version} + + + \ No newline at end of file diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java new file mode 100644 index 0000000000..dbcf3158a3 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java @@ -0,0 +1,78 @@ +/* + * Copyright 2017, OpenSkywalking Organization All rights reserved. + * + * 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. + * + * Project repository: https://github.com/OpenSkywalking/skywalking + */ + +package org.skywalking.apm.collector.ui.jetty; + +import java.util.Properties; +import org.skywalking.apm.collector.cluster.ClusterModule; +import org.skywalking.apm.collector.cluster.service.ModuleRegisterService; +import org.skywalking.apm.collector.core.module.Module; +import org.skywalking.apm.collector.core.module.ModuleNotFoundException; +import org.skywalking.apm.collector.core.module.ModuleProvider; +import org.skywalking.apm.collector.core.module.ServiceNotProvidedException; +import org.skywalking.apm.collector.server.Server; +import org.skywalking.apm.collector.server.manager.ServerManagerModule; +import org.skywalking.apm.collector.server.manager.service.JettyServerConfig; +import org.skywalking.apm.collector.server.manager.service.JettyServerManagerService; +import org.skywalking.apm.collector.ui.UIModule; + +/** + * @author peng-yongsheng + */ +public class UIModuleJettyProvider extends ModuleProvider { + + private static final String HOST = "host"; + private static final String PORT = "port"; + private static final String CONTEXT_PATH = "context_path"; + + @Override public String name() { + return "Jetty"; + } + + @Override public Class module() { + return UIModule.class; + } + + @Override public void prepare(Properties config) throws ServiceNotProvidedException { + String host = config.getProperty(HOST); + String port = config.getProperty(PORT); + String contextPath = config.getProperty(CONTEXT_PATH); + JettyServerConfig serverConfig = new JettyServerConfig(host, Integer.valueOf(port), contextPath); + + try { + JettyServerManagerService managerService = getManager().find(ServerManagerModule.NAME).getService(JettyServerManagerService.class); + Server jettyServer = managerService.getElseCreateServer(serverConfig); + + ModuleRegisterService moduleRegisterService = getManager().find(ClusterModule.NAME).getService(ModuleRegisterService.class); + } catch (ModuleNotFoundException e) { + throw new ServiceNotProvidedException(e.getMessage()); + } + } + + @Override public void start(Properties config) throws ServiceNotProvidedException { + + } + + @Override public void notifyAfterCompleted() throws ServiceNotProvidedException { + + } + + @Override public String[] requiredModules() { + return new String[] {ClusterModule.NAME, ServerManagerModule.NAME}; + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/resources/META-INF/services/org.skywalking.apm.collector.core.module.ModuleProvider b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/resources/META-INF/services/org.skywalking.apm.collector.core.module.ModuleProvider new file mode 100644 index 0000000000..c045a167a7 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/resources/META-INF/services/org.skywalking.apm.collector.core.module.ModuleProvider @@ -0,0 +1,19 @@ +# +# Copyright 2017, OpenSkywalking Organization All rights reserved. +# +# 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. +# +# Project repository: https://github.com/OpenSkywalking/skywalking +# + +org.skywalking.apm.collector.ui.jetty.UIModuleJettyProvider \ No newline at end of file diff --git a/apm-collector/apm-collector-ui/pom.xml b/apm-collector/apm-collector-ui/pom.xml index e6f94973b4..c239fe7e20 100644 --- a/apm-collector/apm-collector-ui/pom.xml +++ b/apm-collector/apm-collector-ui/pom.xml @@ -10,6 +10,17 @@ 4.0.0 apm-collector-ui - jar + pom + + collector-ui-define + collector-ui-jetty-provider + + + + org.skywalking + apm-collector-core + ${project.version} + + \ No newline at end of file