-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Repackage policy & config center api to governance-api
- Loading branch information
1 parent
222da27
commit 852cec4
Showing
55 changed files
with
238 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...joylive-core-api/src/main/java/com/jd/live/agent/core/service/ServiceSupervisorAware.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright © ${year} ${owner} (${email}) | ||
* | ||
* 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 com.jd.live.agent.core.service; | ||
|
||
/** | ||
* An interface that allows a service to be aware of and interact with its supervisor. | ||
*/ | ||
public interface ServiceSupervisorAware { | ||
|
||
/** | ||
* Sets the service supervisor for this service. | ||
* | ||
* @param serviceSupervisor The service supervisor to be set. | ||
*/ | ||
void setup(ServiceSupervisor serviceSupervisor); | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...overnance-api/src/main/java/com/jd/live/agent/governance/bootstrap/ConfigPreparation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright © ${year} ${owner} (${email}) | ||
* | ||
* 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 com.jd.live.agent.governance.bootstrap; | ||
|
||
import com.jd.live.agent.core.bootstrap.ApplicationBootstrapContext; | ||
import com.jd.live.agent.core.bootstrap.ApplicationEnvironment; | ||
import com.jd.live.agent.core.bootstrap.ApplicationListener; | ||
import com.jd.live.agent.core.bootstrap.ApplicationListener.ApplicationListenerAdapter; | ||
import com.jd.live.agent.core.bootstrap.ApplicationPropertySource; | ||
import com.jd.live.agent.core.extension.annotation.Extension; | ||
import com.jd.live.agent.core.inject.annotation.Inject; | ||
import com.jd.live.agent.core.inject.annotation.Injectable; | ||
import com.jd.live.agent.governance.subscription.config.ConfigCenter; | ||
import com.jd.live.agent.governance.subscription.config.Configurator; | ||
|
||
/** | ||
* An extension that prepares config for the application. | ||
* | ||
* @since 1.6.0 | ||
*/ | ||
@Injectable | ||
@Extension(value = "ConfigPreparation", order = ApplicationListener.ORDER_BOOTSTRAP) | ||
public class ConfigPreparation extends ApplicationListenerAdapter { | ||
|
||
@Inject(value = ConfigCenter.COMPONENT_CONFIG_CENTER, component = true, nullable = true) | ||
private ConfigCenter configCenter; | ||
|
||
@Override | ||
public void onEnvironmentPrepared(ApplicationBootstrapContext context, ApplicationEnvironment environment) { | ||
if (configCenter != null) { | ||
Configurator configurator = configCenter.getConfigurator(); | ||
if (configurator != null) { | ||
environment.addFirst(new LivePropertySource(configurator)); | ||
} | ||
} | ||
} | ||
|
||
private static class LivePropertySource implements ApplicationPropertySource { | ||
|
||
private final Configurator configurator; | ||
|
||
LivePropertySource(Configurator configurator) { | ||
this.configurator = configurator; | ||
} | ||
|
||
@Override | ||
public String getProperty(String name) { | ||
Object property = configurator.getProperty(name); | ||
return property == null ? null : property.toString(); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return configurator.getName(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.