Skip to content

Commit fe7fc95

Browse files
committed
renamed Context life cycle management method as "register"
1 parent b644dbb commit fe7fc95

File tree

7 files changed

+19
-19
lines changed

7 files changed

+19
-19
lines changed

logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,8 @@ public Object getConfigurationLock() {
305305
return configurationLock;
306306
}
307307

308-
public void addLifeCycleComponent(LifeCycle component) {
309-
lifeCycleManager.addComponent(component);
308+
public void register(LifeCycle component) {
309+
lifeCycleManager.register(component);
310310
}
311311

312312
// ====== Methods from catalina Lifecycle =====

logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ReceiverAction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ public void end(InterpretationContext ic, String name)
6666

6767
if (inError) return;
6868

69-
ic.getContext().addLifeCycleComponent(receiver);
69+
ic.getContext().register(receiver);
70+
receiver.start();
7071

7172
Object o = ic.peekObject();
7273
if (o != receiver) {

logback-core/src/main/java/ch/qos/logback/core/Context.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ public interface Context extends PropertyContainer {
116116
ExecutorService getExecutorService();
117117

118118
/**
119-
* Adds a component that participates in the context's life cycle.
119+
* Register a component that participates in the context's life cycle.
120120
* <p>
121-
* A component that is passed to this method, will be started if necessary,
122-
* and will be stopped when the context is reset.
121+
* All components registered via this method will be stopped and removed
122+
* from the context when the context is reset.
123123
*
124-
* @param component the subject componet
124+
* @param component the subject component
125125
*/
126-
void addLifeCycleComponent(LifeCycle component);
126+
void register(LifeCycle component);
127127

128128
}

logback-core/src/main/java/ch/qos/logback/core/ContextBase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ public ExecutorService getExecutorService() {
153153
return executorService;
154154
}
155155

156-
public void addLifeCycleComponent(LifeCycle component) {
157-
getLifeCycleManager().addComponent(component);
156+
public void register(LifeCycle component) {
157+
getLifeCycleManager().register(component);
158158
}
159159

160160
protected synchronized LifeCycleManager getLifeCycleManager() {

logback-core/src/main/java/ch/qos/logback/core/LifeCycleManager.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
/**
2323
* An object that manages a collection of components that implement the
2424
* {@link LifeCycle} interface. Each component that is added to the manager
25-
* is started if necessary, and is stopped when the manager is reset.
25+
* will be stopped and removed from the manager when the manager is reset.
2626
*
2727
* @author Carl Harris
2828
*/
@@ -31,12 +31,11 @@ public class LifeCycleManager {
3131
private final Set<LifeCycle> components = new HashSet<LifeCycle>();
3232

3333
/**
34-
* Adds a component to this manager.
34+
* Registers a component with this manager.
3535
* <p>
36-
* The component is started if necessary.
3736
* @param component the component whose life cycle is to be managed
3837
*/
39-
public void addComponent(LifeCycle component) {
38+
public void register(LifeCycle component) {
4039
if (!component.isStarted()) {
4140
component.start();
4241
}

logback-core/src/test/java/ch/qos/logback/core/ContextBaseTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void resetTest() {
6262
assertEquals("valA", context.getProperty("keyA"));
6363
assertEquals("valA", context.getObject("keyA"));
6464
MockLifeCycleComponent component = new MockLifeCycleComponent();
65-
context.addLifeCycleComponent(component);
65+
context.register(component);
6666
assertSame(component, lifeCycleManager.getLastComponent());
6767
context.reset();
6868
assertNull(context.getProperty("keyA"));
@@ -102,9 +102,9 @@ private static class InstrumentedLifeCycleManager extends LifeCycleManager {
102102
private boolean reset;
103103

104104
@Override
105-
public void addComponent(LifeCycle component) {
105+
public void register(LifeCycle component) {
106106
lastComponent = component;
107-
super.addComponent(component);
107+
super.register(component);
108108
}
109109

110110
@Override

logback-core/src/test/java/ch/qos/logback/core/LifeCycleManagerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ public class LifeCycleManagerTest {
3030
private LifeCycleManager manager = new LifeCycleManager();
3131

3232
@Test
33-
public void testAddComponentAndReset() {
33+
public void testRegisterAndReset() {
3434
MockLifeCycleComponent component = new MockLifeCycleComponent();
35-
manager.addComponent(component);
35+
manager.register(component);
3636
assertTrue(component.isStarted());
3737
manager.reset();
3838
assertFalse(component.isStarted());

0 commit comments

Comments
 (0)