• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

aspectran / aspectran / #3986

15 Jan 2025 04:27AM CUT coverage: 35.056% (+0.05%) from 35.004%
#3986

push

github

topframe
Update

7 of 40 new or added lines in 6 files covered. (17.5%)

2 existing lines in 2 files now uncovered.

14194 of 40489 relevant lines covered (35.06%)

0.35 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/core/src/main/java/com/aspectran/core/context/builder/reload/ContextReloadingTimer.java
1
/*
2
 * Copyright (c) 2008-2025 The Aspectran Project
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 com.aspectran.core.context.builder.reload;
17

18
import com.aspectran.core.context.resource.SiblingClassLoader;
19
import com.aspectran.core.service.ServiceLifeCycle;
20
import com.aspectran.utils.logging.Logger;
21
import com.aspectran.utils.logging.LoggerFactory;
22

23
import java.util.Timer;
24

25
/**
26
 * Provides timer control to reload the ActivityContext.
27
 */
28
public class ContextReloadingTimer {
29

30
    private static final Logger logger = LoggerFactory.getLogger(ContextReloadingTimer.class);
×
31

32
    private final SiblingClassLoader classLoader;
33

34
    private final ServiceLifeCycle serviceLifeCycle;
35

36
    private volatile Timer timer;
37

38
    private ContextReloadingTask task;
39

NEW
40
    public ContextReloadingTimer(SiblingClassLoader classLoader, ServiceLifeCycle serviceLifeCycle) {
×
NEW
41
        this.classLoader = classLoader;
×
42
        this.serviceLifeCycle = serviceLifeCycle;
×
43
    }
×
44

45
    public void start(int scanIntervalInSeconds) {
46
        stop();
×
47

48
        if (logger.isDebugEnabled()) {
×
49
            logger.debug("Starting ContextReloadingTimer...");
×
50
        }
51

NEW
52
        task = new ContextReloadingTask(serviceLifeCycle);
×
NEW
53
        task.setResources(classLoader.getAllResources());
×
54

55
        timer = new Timer("ContextReloading");
×
NEW
56
        timer.schedule(task, 0, scanIntervalInSeconds * 1000L);
×
57
    }
×
58

59
    public void stop() {
60
        if (timer != null) {
×
61
            if (logger.isDebugEnabled()) {
×
62
                logger.debug("Stopping ContextReloadingTimer...");
×
63
            }
64

65
            timer.cancel();
×
66
            timer = null;
×
67

NEW
68
            task.cancel();
×
NEW
69
            task = null;
×
70
        }
71
    }
×
72

73
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc