1 /*
2  * Copyright (c) 2018 Google Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you
5  * may not use this file except in compliance with the License. You may
6  * 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
13  * implied. See the License for the specific language governing
14  * permissions and limitations under the License.
15  */
16 
17 package com.android.vts.job;
18 
19 
20 import javax.servlet.ServletConfig;
21 import javax.servlet.ServletException;
22 import javax.servlet.http.HttpServlet;
23 import java.util.Properties;
24 
25 /**
26  * An abstract class to be subclassed to create Job Servlet
27  */
28 public abstract class BaseJobServlet extends HttpServlet {
29 
30     /**
31      * System Configuration Property class
32      */
33     protected static Properties systemConfigProp = new Properties();
34 
35     /**
36      * This variable is for maximum number of entities per transaction You can find the detail here
37      * (https://cloud.google.com/datastore/docs/concepts/limits)
38      */
39     protected int MAX_ENTITY_SIZE_PER_TRANSACTION = 300;
40 
41     @Override
init(ServletConfig cfg)42     public void init(ServletConfig cfg) throws ServletException {
43         super.init(cfg);
44 
45         systemConfigProp =
46                 Properties.class.cast(cfg.getServletContext().getAttribute("systemConfigProp"));
47 
48         this.MAX_ENTITY_SIZE_PER_TRANSACTION =
49                 Integer.parseInt(systemConfigProp.getProperty("datastore.maxEntitySize"));
50     }
51 }
52