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

mybatis / ibatis-2 / #341

08 Sep 2023 11:16PM UTC coverage: 64.938% (+0.03%) from 64.913%
#341

push

github

web-flow
Merge pull request #183 from hazendaz/master

fixes #174, update GHA, maven wrapper, fix EOL markers, do not use star imports

5047 of 7772 relevant lines covered (64.94%)

0.65 hits per line

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

89.19
/src/main/java/com/ibatis/sqlmap/engine/config/CacheModelConfig.java
1
/*
2
 * Copyright 2004-2023 the original author or authors.
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
 *    https://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.ibatis.sqlmap.engine.config;
17

18
import com.ibatis.sqlmap.engine.cache.CacheController;
19
import com.ibatis.sqlmap.engine.cache.CacheModel;
20
import com.ibatis.sqlmap.engine.impl.SqlMapClientImpl;
21
import com.ibatis.sqlmap.engine.scope.ErrorContext;
22

23
import java.util.Properties;
24

25
/**
26
 * The Class CacheModelConfig.
27
 */
28
public class CacheModelConfig {
29

30
  /** The error context. */
31
  private ErrorContext errorContext;
32

33
  /** The cache model. */
34
  private CacheModel cacheModel;
35

36
  /**
37
   * Instantiates a new cache model config.
38
   *
39
   * @param config
40
   *          the config
41
   * @param id
42
   *          the id
43
   * @param controller
44
   *          the controller
45
   * @param readOnly
46
   *          the read only
47
   * @param serialize
48
   *          the serialize
49
   */
50
  CacheModelConfig(SqlMapConfiguration config, String id, CacheController controller, boolean readOnly,
51
      boolean serialize) {
1✔
52
    this.errorContext = config.getErrorContext();
1✔
53
    this.cacheModel = new CacheModel();
1✔
54
    SqlMapClientImpl client = config.getClient();
1✔
55
    errorContext.setActivity("building a cache model");
1✔
56
    cacheModel.setReadOnly(readOnly);
1✔
57
    cacheModel.setSerialize(serialize);
1✔
58
    errorContext.setObjectId(id + " cache model");
1✔
59
    errorContext.setMoreInfo("Check the cache model type.");
1✔
60
    cacheModel.setId(id);
1✔
61
    cacheModel.setResource(errorContext.getResource());
1✔
62
    try {
63
      cacheModel.setCacheController(controller);
1✔
64
    } catch (Exception e) {
×
65
      throw new RuntimeException("Error setting Cache Controller Class.  Cause: " + e, e);
×
66
    }
1✔
67
    errorContext.setMoreInfo("Check the cache model configuration.");
1✔
68
    if (client.getDelegate().isCacheModelsEnabled()) {
1✔
69
      client.getDelegate().addCacheModel(cacheModel);
1✔
70
    }
71
    errorContext.setMoreInfo(null);
1✔
72
    errorContext.setObjectId(null);
1✔
73
  }
1✔
74

75
  /**
76
   * Sets the flush interval.
77
   *
78
   * @param hours
79
   *          the hours
80
   * @param minutes
81
   *          the minutes
82
   * @param seconds
83
   *          the seconds
84
   * @param milliseconds
85
   *          the milliseconds
86
   */
87
  public void setFlushInterval(long hours, long minutes, long seconds, long milliseconds) {
88
    errorContext.setMoreInfo("Check the cache model flush interval.");
1✔
89
    long t = 0L;
1✔
90
    t += milliseconds;
1✔
91
    t += seconds * 1000L;
1✔
92
    t += minutes * 60L * 1000L;
1✔
93
    t += hours * 60L * 60L * 1000L;
1✔
94
    if (t < 1L)
1✔
95
      throw new RuntimeException(
×
96
          "A flush interval must specify one or more of milliseconds, seconds, minutes or hours.");
97
    cacheModel.setFlushInterval(t);
1✔
98
  }
1✔
99

100
  /**
101
   * Adds the flush trigger statement.
102
   *
103
   * @param statement
104
   *          the statement
105
   */
106
  public void addFlushTriggerStatement(String statement) {
107
    errorContext.setMoreInfo("Check the cache model flush on statement elements.");
1✔
108
    cacheModel.addFlushTriggerStatement(statement);
1✔
109
  }
1✔
110

111
  /**
112
   * Gets the cache model.
113
   *
114
   * @return the cache model
115
   */
116
  public CacheModel getCacheModel() {
117
    return cacheModel;
×
118
  }
119

120
  /**
121
   * Sets the controller properties.
122
   *
123
   * @param cacheProps
124
   *          the new controller properties
125
   */
126
  public void setControllerProperties(Properties cacheProps) {
127
    cacheModel.setControllerProperties(cacheProps);
1✔
128
  }
1✔
129
}
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