• 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

43.75
/core/src/main/java/com/aspectran/core/context/builder/AbstractActivityContextBuilder.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;
17

18
import com.aspectran.core.adapter.ApplicationAdapter;
19
import com.aspectran.core.adapter.DefaultApplicationAdapter;
20
import com.aspectran.core.component.aspect.AspectAdviceRulePreRegister;
21
import com.aspectran.core.component.aspect.AspectRuleRegistry;
22
import com.aspectran.core.component.aspect.InvalidPointcutPatternException;
23
import com.aspectran.core.component.aspect.pointcut.Pointcut;
24
import com.aspectran.core.component.aspect.pointcut.PointcutPattern;
25
import com.aspectran.core.component.bean.BeanRuleRegistry;
26
import com.aspectran.core.component.bean.DefaultBeanRegistry;
27
import com.aspectran.core.component.schedule.ScheduleRuleRegistry;
28
import com.aspectran.core.component.template.DefaultTemplateRenderer;
29
import com.aspectran.core.component.template.TemplateRuleRegistry;
30
import com.aspectran.core.component.translet.TransletRuleRegistry;
31
import com.aspectran.core.context.ActivityContext;
32
import com.aspectran.core.context.DefaultActivityContext;
33
import com.aspectran.core.context.builder.reload.ContextReloadingTimer;
34
import com.aspectran.core.context.config.ContextAutoReloadConfig;
35
import com.aspectran.core.context.config.ContextConfig;
36
import com.aspectran.core.context.config.ContextProfilesConfig;
37
import com.aspectran.core.context.env.ActivityEnvironment;
38
import com.aspectran.core.context.env.ActivityEnvironmentBuilder;
39
import com.aspectran.core.context.env.EnvironmentProfiles;
40
import com.aspectran.core.context.resource.InvalidResourceException;
41
import com.aspectran.core.context.resource.ResourceManager;
42
import com.aspectran.core.context.resource.SiblingClassLoader;
43
import com.aspectran.core.context.rule.AspectRule;
44
import com.aspectran.core.context.rule.EnvironmentRule;
45
import com.aspectran.core.context.rule.IllegalRuleException;
46
import com.aspectran.core.context.rule.ItemRule;
47
import com.aspectran.core.context.rule.ItemRuleMap;
48
import com.aspectran.core.context.rule.PointcutPatternRule;
49
import com.aspectran.core.context.rule.assistant.ActivityRuleAssistant;
50
import com.aspectran.core.context.rule.assistant.BeanReferenceException;
51
import com.aspectran.core.context.rule.assistant.BeanReferenceInspector;
52
import com.aspectran.core.context.rule.params.AspectranParameters;
53
import com.aspectran.core.context.rule.type.AutoReloadType;
54
import com.aspectran.core.service.CoreService;
55
import com.aspectran.utils.StringUtils;
56
import com.aspectran.utils.SystemUtils;
57
import com.aspectran.utils.annotation.jsr305.NonNull;
58
import com.aspectran.utils.logging.Logger;
59
import com.aspectran.utils.logging.LoggerFactory;
60

61
import java.io.File;
62
import java.io.IOException;
63
import java.nio.file.Files;
64
import java.nio.file.Path;
65
import java.util.List;
66

67
import static com.aspectran.core.context.config.AspectranConfig.BASE_PATH_PROPERTY_NAME;
68
import static com.aspectran.core.context.config.AspectranConfig.TEMP_PATH_PROPERTY_NAME;
69
import static com.aspectran.core.context.config.AspectranConfig.WORK_PATH_PROPERTY_NAME;
70

71
public abstract class AbstractActivityContextBuilder implements ActivityContextBuilder {
72

73
    private static final Logger logger = LoggerFactory.getLogger(AbstractActivityContextBuilder.class);
1✔
74

75
    private static final String TMP_BASE_DIRNAME_PREFIX = "com.aspectran-";
76

77
    private String basePath;
78

79
    private boolean ownBasePath;
80

81
    private final CoreService masterService;
82

83
    private ContextConfig contextConfig;
84

85
    private AspectranParameters aspectranParameters;
86

87
    private String[] contextRules;
88

89
    private String encoding;
90

91
    private String[] resourceLocations;
92

93
    private String[] basePackages;
94

95
    private String[] activeProfiles;
96

97
    private String[] defaultProfiles;
98

99
    private ItemRuleMap propertyItemRuleMap;
100

101
    private boolean hardReload;
102

103
    private boolean autoReloadEnabled;
104

105
    private int scanIntervalSeconds;
106

107
    private ContextReloadingTimer contextReloadingTimer;
108

109
    private SiblingClassLoader siblingClassLoader;
110

111
    private boolean useAponToLoadXml;
112

113
    private boolean debugMode;
114

115
    public AbstractActivityContextBuilder(CoreService masterService) {
1✔
116
        this.masterService = masterService;
1✔
117
        this.useAponToLoadXml = Boolean.parseBoolean(SystemUtils.getProperty(USE_APON_TO_LOAD_XML_PROPERTY_NAME));
1✔
118
        this.debugMode = Boolean.parseBoolean(SystemUtils.getProperty(DEBUG_MODE_PROPERTY_NAME));
1✔
119
    }
1✔
120

121
    @Override
122
    public String getBasePath() {
123
        return basePath;
×
124
    }
125

126
    @Override
127
    public void setBasePath(String basePath) {
128
        if (StringUtils.hasText(basePath)) {
1✔
129
            this.basePath = basePath;
1✔
130
        } else {
131
            this.basePath = null;
×
132
        }
133
    }
1✔
134

135
    @Override
136
    public boolean hasOwnBasePath() {
137
        return ownBasePath;
×
138
    }
139

140
    protected void setOwnBasePath(boolean ownBasePath) {
141
        this.ownBasePath = ownBasePath;
×
142
    }
×
143

144
    @Override
145
    public CoreService getMasterService() {
146
        return masterService;
1✔
147
    }
148

149
    @Override
150
    public ContextConfig getContextConfig() {
151
        return contextConfig;
1✔
152
    }
153

154
    @Override
155
    public AspectranParameters getAspectranParameters() {
156
        return aspectranParameters;
1✔
157
    }
158

159
    @Override
160
    public void setAspectranParameters(AspectranParameters aspectranParameters) {
161
        this.aspectranParameters = aspectranParameters;
×
162
        this.contextRules = null;
×
163
    }
×
164

165
    @Override
166
    public String[] getContextRules() {
167
        return contextRules;
1✔
168
    }
169

170
    @Override
171
    public void setContextRules(String[] contextRules) {
172
        this.contextRules = contextRules;
1✔
173
        this.aspectranParameters = null;
1✔
174
    }
1✔
175

176
    @Override
177
    public String getEncoding() {
178
        return (encoding == null ? ActivityContext.DEFAULT_ENCODING : encoding);
1✔
179
    }
180

181
    @Override
182
    public void setEncoding(String encoding) {
183
        this.encoding = encoding;
×
184
    }
×
185

186
    @Override
187
    public String[] getResourceLocations() {
188
        return resourceLocations;
×
189
    }
190

191
    @Override
192
    public void setResourceLocations(String... resourceLocations) {
193
        this.resourceLocations = resourceLocations;
×
194
    }
×
195

196
    @Override
197
    public String[] getBasePackages() {
198
        return basePackages;
1✔
199
    }
200

201
    @Override
202
    public void setBasePackages(String... basePackages) {
203
        if (basePackages != null && basePackages.length > 0) {
1✔
204
            this.basePackages = basePackages;
1✔
205
        }
206
    }
1✔
207

208
    @Override
209
    public String[] getActiveProfiles() {
210
        return activeProfiles;
1✔
211
    }
212

213
    @Override
214
    public void setActiveProfiles(String... activeProfiles) {
215
        this.activeProfiles = activeProfiles;
1✔
216
    }
1✔
217

218
    @Override
219
    public String[] getDefaultProfiles() {
220
        return defaultProfiles;
1✔
221
    }
222

223
    @Override
224
    public void setDefaultProfiles(String... defaultProfiles) {
225
        this.defaultProfiles = defaultProfiles;
×
226
    }
×
227

228
    @Override
229
    public void putPropertyItemRule(ItemRule propertyItemRule) {
230
        if (this.propertyItemRuleMap == null) {
1✔
231
            this.propertyItemRuleMap = new ItemRuleMap();
1✔
232
        }
233
        this.propertyItemRuleMap.putItemRule(propertyItemRule);
1✔
234
    }
1✔
235

236
    @Override
237
    public boolean isHardReload() {
238
        return hardReload;
×
239
    }
240

241
    @Override
242
    public void setHardReload(boolean hardReload) {
243
        this.hardReload = hardReload;
×
244
    }
×
245

246
    @Override
247
    public ClassLoader getClassLoader() {
248
        return siblingClassLoader;
×
249
    }
250

251
    @Override
252
    public void configure(ContextConfig contextConfig) throws IOException, InvalidResourceException {
253
        if (this.basePath == null) {
×
254
            if (getMasterService() != null) {
×
255
                this.basePath = getMasterService().getBasePath();
×
256
            } else {
257
                this.basePath = contextConfig.getBasePath();
×
258
            }
259
        }
260

261
        if (getMasterService() == null || getMasterService().isRootService()) {
×
262
            checkDirectoryStructure();
×
263
        }
264

265
        if (contextConfig != null) {
×
266
            this.contextConfig = contextConfig;
×
267
            this.contextRules = contextConfig.getContextRules();
×
268

269
            AspectranParameters aspectranParameters = contextConfig.getAspectranParameters();
×
270
            if (aspectranParameters != null) {
×
271
                this.aspectranParameters = aspectranParameters;
×
272
            }
273

274
            this.encoding = contextConfig.getEncoding();
×
275

276
            String[] resourceLocations = contextConfig.getResourceLocations();
×
277
            this.resourceLocations = ResourceManager.checkResourceLocations(resourceLocations, getBasePath());
×
278

279
            this.basePackages = contextConfig.getBasePackages();
×
280

281
            ContextProfilesConfig profilesConfig = contextConfig.getProfilesConfig();
×
282
            if (profilesConfig != null) {
×
283
                setActiveProfiles(profilesConfig.getActiveProfiles());
×
284
                setDefaultProfiles(profilesConfig.getDefaultProfiles());
×
285
            }
286

287
            ContextAutoReloadConfig autoReloadConfig = contextConfig.getAutoReloadConfig();
×
288
            if (autoReloadConfig != null) {
×
289
                String reloadMode = autoReloadConfig.getReloadMode();
×
290
                int scanIntervalSeconds = autoReloadConfig.getScanIntervalSeconds();
×
291
                boolean autoReloadEnabled = autoReloadConfig.isEnabled();
×
292
                this.hardReload = AutoReloadType.HARD.toString().equals(reloadMode);
×
293
                this.autoReloadEnabled = autoReloadEnabled;
×
294
                this.scanIntervalSeconds = scanIntervalSeconds;
×
295
            }
296
            if (this.autoReloadEnabled && this.resourceLocations == null) {
×
297
                this.autoReloadEnabled = false;
×
298
            }
299
            if (this.autoReloadEnabled) {
×
300
                if (this.scanIntervalSeconds == -1) {
×
301
                    this.scanIntervalSeconds = 10;
×
302
                    if (logger.isDebugEnabled()) {
×
303
                        logger.debug("Context option 'autoReload' not specified, defaulting to 10 seconds");
×
304
                    }
305
                }
306
            }
307
        }
308
    }
×
309

310
    protected boolean isUseAponToLoadXml() {
311
        return useAponToLoadXml;
1✔
312
    }
313

314
    @Override
315
    public void setUseAponToLoadXml(boolean useAponToLoadXml) {
316
        this.useAponToLoadXml = useAponToLoadXml;
×
317
    }
×
318

319
    public boolean isDebugMode() {
320
        return debugMode;
1✔
321
    }
322

323
    @Override
324
    public void setDebugMode(boolean debugMode) {
325
        this.debugMode = debugMode;
1✔
326
    }
1✔
327

328
    protected SiblingClassLoader createSiblingClassLoader(String contextName, ClassLoader parentClassLoader)
329
        throws InvalidResourceException {
330
        if (siblingClassLoader == null || hardReload) {
1✔
331
            siblingClassLoader = new SiblingClassLoader(contextName, parentClassLoader, resourceLocations);
1✔
332
        } else {
333
            siblingClassLoader.reload();
×
334
        }
335
        return siblingClassLoader;
1✔
336
    }
337

338
    protected ApplicationAdapter createApplicationAdapter() {
339
        return new DefaultApplicationAdapter(basePath);
1✔
340
    }
341

342
    protected EnvironmentProfiles createEnvironmentProfiles() {
343
        EnvironmentProfiles environmentProfiles = new EnvironmentProfiles();
1✔
344
        if (getDefaultProfiles() != null) {
1✔
345
            environmentProfiles.setDefaultProfiles(getDefaultProfiles());
×
346
        }
347
        if (getActiveProfiles() != null) {
1✔
348
            environmentProfiles.setActiveProfiles(getActiveProfiles());
1✔
349
        } else {
350
            environmentProfiles.getActiveProfiles(); // just for logging
1✔
351
        }
352
        return environmentProfiles;
1✔
353
    }
354

355
    /**
356
     * Returns a new instance of ActivityContext.
357
     * @param assistant the activity rule assistant
358
     * @return the activity context
359
     * @throws BeanReferenceException will be thrown when cannot resolve reference to bean
360
     * @throws IllegalRuleException if an illegal rule is found
361
     */
362
    protected ActivityContext createActivityContext(@NonNull ActivityRuleAssistant assistant)
363
            throws BeanReferenceException, IllegalRuleException {
364
        DefaultActivityContext context = new DefaultActivityContext(
1✔
365
                assistant.getClassLoader(), assistant.getApplicationAdapter());
1✔
366
        if (getContextConfig() != null) {
1✔
367
            context.setName(getContextConfig().getName());
×
368
        }
369
        context.setDescriptionRule(assistant.getAssistantLocal().getDescriptionRule());
1✔
370

371
        ActivityEnvironment activityEnvironment = createActivityEnvironment(context, assistant);
1✔
372
        context.setActivityEnvironment(activityEnvironment);
1✔
373

374
        AspectRuleRegistry aspectRuleRegistry = assistant.getAspectRuleRegistry();
1✔
375

376
        BeanRuleRegistry beanRuleRegistry = assistant.getBeanRuleRegistry();
1✔
377
        beanRuleRegistry.postProcess(assistant);
1✔
378

379
        BeanReferenceInspector beanReferenceInspector = assistant.getBeanReferenceInspector();
1✔
380
        beanReferenceInspector.inspect(beanRuleRegistry);
1✔
381

382
        initAspectRuleRegistry(assistant);
1✔
383

384
        DefaultBeanRegistry defaultBeanRegistry = new DefaultBeanRegistry(context, beanRuleRegistry);
1✔
385

386
        TemplateRuleRegistry templateRuleRegistry = assistant.getTemplateRuleRegistry();
1✔
387
        DefaultTemplateRenderer defaultTemplateRenderer = new DefaultTemplateRenderer(
1✔
388
                context, templateRuleRegistry);
389

390
        ScheduleRuleRegistry scheduleRuleRegistry = assistant.getScheduleRuleRegistry();
1✔
391
        TransletRuleRegistry transletRuleRegistry = assistant.getTransletRuleRegistry();
1✔
392

393
        context.setAspectRuleRegistry(aspectRuleRegistry);
1✔
394
        context.setBeanRegistry(defaultBeanRegistry);
1✔
395
        context.setScheduleRuleRegistry(scheduleRuleRegistry);
1✔
396
        context.setTemplateRenderer(defaultTemplateRenderer);
1✔
397
        context.setTransletRuleRegistry(transletRuleRegistry);
1✔
398
        return context;
1✔
399
    }
400

401
    protected void startContextReloadingTimer() {
402
        if (autoReloadEnabled && masterService != null && siblingClassLoader != null) {
×
NEW
403
            contextReloadingTimer = new ContextReloadingTimer(siblingClassLoader, masterService.getServiceLifeCycle());
×
404
            contextReloadingTimer.start(scanIntervalSeconds);
×
405
        }
406
    }
×
407

408
    protected void stopContextReloadingTimer() {
409
        if (contextReloadingTimer != null) {
1✔
410
            contextReloadingTimer.stop();
×
411
            contextReloadingTimer = null;
×
412
        }
413
    }
1✔
414

415
    @NonNull
416
    private ActivityEnvironment createActivityEnvironment(
417
            ActivityContext context, @NonNull ActivityRuleAssistant assistant) {
418
        EnvironmentProfiles environmentProfiles = assistant.getEnvironmentProfiles();
1✔
419
        ActivityEnvironmentBuilder builder = new ActivityEnvironmentBuilder(context, environmentProfiles)
1✔
420
            .putPropertyItemRules(propertyItemRuleMap);
1✔
421
        for (EnvironmentRule environmentRule : assistant.getEnvironmentRules()) {
1✔
422
            if (environmentProfiles.acceptsProfiles(environmentRule.getProfiles())) {
1✔
423
                if (environmentRule.getPropertyItemRuleMapList() != null) {
1✔
424
                    for (ItemRuleMap propertyIrm : environmentRule.getPropertyItemRuleMapList()) {
1✔
425
                        if (environmentProfiles.acceptsProfiles(propertyIrm.getProfiles())) {
1✔
426
                            builder.putPropertyItemRules(propertyIrm);
1✔
427
                        }
428
                    }
1✔
429
                }
430
            }
431
        }
1✔
432
        return builder.build();
1✔
433
    }
434

435
    /**
436
     * Initialize the aspect rule registry.
437
     * @param assistant the activity rule assistant
438
     */
439
    private void initAspectRuleRegistry(@NonNull ActivityRuleAssistant assistant) {
440
        AspectRuleRegistry aspectRuleRegistry = assistant.getAspectRuleRegistry();
1✔
441
        BeanRuleRegistry beanRuleRegistry = assistant.getBeanRuleRegistry();
1✔
442
        TransletRuleRegistry transletRuleRegistry = assistant.getTransletRuleRegistry();
1✔
443

444
        boolean pointcutPatternVerifiable = assistant.isPointcutPatternVerifiable();
1✔
445

446
        AspectAdviceRulePreRegister preRegister = new AspectAdviceRulePreRegister(aspectRuleRegistry);
1✔
447
        preRegister.setPointcutPatternVerifiable(pointcutPatternVerifiable || logger.isDebugEnabled());
1✔
448
        preRegister.register(beanRuleRegistry);
1✔
449
        preRegister.register(transletRuleRegistry);
1✔
450

451
        // check invalid pointcut pattern
452
        if (pointcutPatternVerifiable || logger.isDebugEnabled()) {
1✔
453
            int invalidPointcutPatterns = 0;
1✔
454
            for (AspectRule aspectRule : aspectRuleRegistry.getAspectRules()) {
1✔
455
                Pointcut pointcut = aspectRule.getPointcut();
1✔
456
                if (pointcut != null) {
1✔
457
                    List<PointcutPatternRule> pointcutPatternRuleList = pointcut.getPointcutPatternRuleList();
1✔
458
                    if (pointcutPatternRuleList != null) {
1✔
459
                        for (PointcutPatternRule ppr : pointcutPatternRuleList) {
1✔
460
                            PointcutPattern pp = ppr.getPointcutPattern();
1✔
461
                            if (pp != null) {
1✔
462
                                if (pp.getBeanIdPattern() != null && ppr.getMatchedBeanIdCount() == 0) {
1✔
463
                                    invalidPointcutPatterns++;
×
464
                                    String msg = "No beans matching to '" + pp.getBeanIdPattern() +
×
465
                                            "'; aspectRule " + aspectRule;
466
                                    if (pointcutPatternVerifiable) {
×
467
                                        logger.error(msg);
×
468
                                    } else if (logger.isDebugEnabled()) {
×
469
                                        logger.debug(msg);
×
470
                                    }
471
                                }
472
                                if (pp.getClassNamePattern() != null && ppr.getMatchedClassNameCount() == 0) {
1✔
473
                                    invalidPointcutPatterns++;
×
474
                                    String msg = "No beans matching to '@class:" + pp.getClassNamePattern() +
×
475
                                            "'; aspectRule " + aspectRule;
476
                                    if (pointcutPatternVerifiable) {
×
477
                                        logger.error(msg);
×
478
                                    } else if (logger.isDebugEnabled()) {
×
479
                                        logger.debug(msg);
×
480
                                    }
481
                                }
482
                                if (pp.getMethodNamePattern() != null && ppr.getMatchedMethodNameCount() == 0) {
1✔
483
                                    invalidPointcutPatterns++;
×
484
                                    String msg = "No beans have methods matching to '^" + pp.getMethodNamePattern() +
×
485
                                            "'; aspectRule " + aspectRule;
486
                                    if (pointcutPatternVerifiable) {
×
487
                                        logger.error(msg);
×
488
                                    } else if (logger.isDebugEnabled()) {
×
489
                                        logger.debug(msg);
×
490
                                    }
491
                                }
492
                            }
493
                        }
1✔
494
                    }
495
                }
496
            }
1✔
497
            if (invalidPointcutPatterns > 0) {
1✔
498
                String msg = "Invalid pointcut detected: " + invalidPointcutPatterns +
×
499
                        "; Please check the logs for more information";
500
                if (pointcutPatternVerifiable) {
×
501
                    logger.error(msg);
×
502
                    throw new InvalidPointcutPatternException(msg);
×
503
                } else {
504
                    logger.debug(msg);
×
505
                }
506
            }
507
        }
508
    }
1✔
509

510
    public void clear() {
511
        SystemUtils.clearProperty(BASE_PATH_PROPERTY_NAME);
×
512
        SystemUtils.clearProperty(WORK_PATH_PROPERTY_NAME);
×
513
        SystemUtils.clearProperty(TEMP_PATH_PROPERTY_NAME);
×
514
    }
×
515

516
    private void checkDirectoryStructure() throws IOException {
517
        setOwnBasePath(true);
×
518

519
        // Determines the path of the base directory
520
        if (getBasePath() == null) {
×
521
            String basePath = SystemUtils.getProperty(BASE_PATH_PROPERTY_NAME);
×
522
            File baseDir;
523
            if (StringUtils.hasText(basePath)) {
×
524
                baseDir = new File(basePath);
×
525
                if (!baseDir.isDirectory()) {
×
526
                    throw new IOException("Make sure it is a valid base directory; " +
×
527
                        BASE_PATH_PROPERTY_NAME + "=" + basePath);
528
                }
529
            } else {
530
                setOwnBasePath(false);
×
531
                try {
532
                    String tmpDir = SystemUtils.getJavaIoTmpDir();
×
533
                    baseDir = Files.createTempDirectory(Path.of(tmpDir), TMP_BASE_DIRNAME_PREFIX).toFile();
×
534
                    baseDir.deleteOnExit();
×
535
                } catch (IOException e) {
×
536
                    throw new IOException("Could not verify the base directory", e);
×
537
                }
×
538
            }
539
            try {
540
                setBasePath(baseDir.getCanonicalPath());
×
541
                System.setProperty(BASE_PATH_PROPERTY_NAME, getBasePath());
×
542
            } catch (IOException e) {
×
543
                throw new IOException("Could not verify the base directory", e);
×
544
            }
×
545
        } else {
×
546
            System.setProperty(BASE_PATH_PROPERTY_NAME, getBasePath());
×
547
        }
548

549
        // Determines the path of the working directory.
550
        // If a 'work' directory exists under the base directory,
551
        // set it as the system property 'aspectran.workPath'.
552
        File workDir = null;
×
553
        String workPath = SystemUtils.getProperty(WORK_PATH_PROPERTY_NAME);
×
554
        if (StringUtils.hasText(workPath)) {
×
555
            workDir = new File(workPath);
×
556
        }
557
        if (workDir == null || !workDir.isDirectory()) {
×
558
            workDir = new File(getBasePath(), "work");
×
559
        }
560
        try {
561
            System.setProperty(WORK_PATH_PROPERTY_NAME, workDir.getCanonicalPath());
×
562
        } catch (Exception e) {
×
563
            logger.warn("Could not verify the working directory: " + workDir);
×
564
        }
×
565

566
        // Determines the path of the temporary directory.
567
        // If a 'temp' directory exists under the base directory,
568
        // set it as the system property 'aspectran.tempPath'.
569
        File tempDir = null;
×
570
        String tempPath = SystemUtils.getProperty(TEMP_PATH_PROPERTY_NAME);
×
571
        if (StringUtils.hasText(tempPath)) {
×
572
            tempDir = new File(tempPath);
×
573
        }
574
        if (tempDir == null || !tempDir.isDirectory()) {
×
575
            tempDir = new File(getBasePath(), "temp");
×
576
        }
577
        try {
578
            System.setProperty(TEMP_PATH_PROPERTY_NAME, tempDir.getCanonicalPath());
×
579
        } catch (Exception e) {
×
580
            logger.warn("Could not verify the temporary directory: " + tempDir);
×
581
        }
×
582
    }
×
583

584
}
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