Skip to content

Commit d96a7e9

Browse files
committed
initial commit
0 parents  commit d96a7e9

File tree

8 files changed

+173
-0
lines changed

8 files changed

+173
-0
lines changed

LICENSE

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2022, Automatic Controls Equipment Systems, Inc.
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
3. Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# GarbageCollector
2+
3+
WebCTRL is a trademark of Automated Logic Corporation. Any other trademarks mentioned herein are the property of their respective owners.
4+
5+
## About
6+
7+
This WebCTRL add-on invokes `System.gc()` every 5 minutes. Essentially, this hints that the JVM should run its garbage collector, freeing any excess memory. In some cases, this should improve performance of a WebCTRL server.

config/BUILD_DETAILS

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
JDK Version:
2+
openjdk 18.0.2.1 2022-08-18
3+
OpenJDK Runtime Environment (build 18.0.2.1+1-1)
4+
OpenJDK 64-Bit Server VM (build 18.0.2.1+1-1, mixed mode, sharing)
5+
6+
Compilation Flags:
7+
--release 8
8+
9+
Runtime Dependencies:
10+
addonsupport-api-addon-1.7.0
11+
alarmmanager-api-addon-1.7.0
12+
bacnet-api-addon-1.8.007-20220318.0837r
13+
directaccess-api-addon-1.7.0
14+
tomcat-embed-core-9.0.37
15+
webaccess-api-addon-1.7.0
16+
xdatabase-api-addon-1.7.0
17+
18+
Packaged Dependencies:

config/COMPILE_FLAGS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--release 8

ext/deploy.bat

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
@echo off
2+
if "%WebCTRL%" EQU "" goto :bad
3+
if "%addonFile%" EQU "" goto :bad
4+
if "%certFile%" EQU "" goto :bad
5+
if /i "%*" EQU "--help" (
6+
echo DEPLOY Copies the .addon archive and certificate file to the bound WebCTRL installation.
7+
exit /b 0
8+
)
9+
if "%*" NEQ "" (
10+
echo Unexpected parameter.
11+
exit /b 1
12+
)
13+
if not exist "%addonFile%" (
14+
echo Cannot deploy because !name!.addon does not exist.
15+
exit /b 1
16+
)
17+
echo Deploying...
18+
if "!name!" EQU "AddonDevRefresher" (
19+
echo Cannot be used to self-deploy.
20+
echo Deployment unsuccessful.
21+
exit /b 1
22+
)
23+
if not exist "%WebCTRL%\addons" mkdir "%WebCTRL%\addons" >nul 2>nul
24+
copy /y "%certFile%" "%WebCTRL%\addons\%certFileName%" >nul
25+
copy /y "%addonFile%" "%WebCTRL%\addons\!name!.update" >nul
26+
if %ErrorLevel% NEQ 0 (
27+
echo Deployment unsuccessful.
28+
exit /b 1
29+
)
30+
set /a count=0
31+
:waitUpdate
32+
timeout 1 /nobreak >nul
33+
set /a count+=1
34+
if exist "%WebCTRL%\addons\!name!.update" (
35+
if "%count%" EQU "60" (
36+
echo Timeout occurred.
37+
echo Deployment unsuccessful.
38+
exit /b 1
39+
) else (
40+
goto :waitUpdate
41+
)
42+
)
43+
if exist "%WebCTRL%\addons\!name!.addon" (
44+
echo Deployment successful.
45+
exit /b 0
46+
) else (
47+
echo Deployment unsuccessful.
48+
exit /b 1
49+
)
50+
51+
:bad
52+
echo This script should not be invoked as a stand-alone application.
53+
echo You must use this file as an extension to addon-dev-script.
54+
echo https://github.com/automatic-controls/addon-dev-script
55+
echo Press any key to exit.
56+
pause >nul
57+
exit /b 1

root/info.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<extension version="1">
2+
<name>GarbageCollector</name>
3+
<description>A simple WebCTRL add-on which invoked System.gc() every 5 minutes.</description>
4+
<version>1.0.0</version>
5+
<vendor>Automatic Controls Equipment Systems, Inc.</vendor>
6+
</extension>

root/webapp/WEB-INF/web.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<web-app>
4+
5+
<listener>
6+
<listener-class>aces.webctrl.garbage.Initializer</listener-class>
7+
</listener>
8+
9+
<security-constraint>
10+
<web-resource-collection>
11+
<web-resource-name>WEB</web-resource-name>
12+
<url-pattern>/*</url-pattern>
13+
</web-resource-collection>
14+
</security-constraint>
15+
16+
<filter>
17+
<filter-name>RoleFilterAJAX</filter-name>
18+
<filter-class>com.controlj.green.addonsupport.web.RoleFilter</filter-class>
19+
<init-param>
20+
<param-name>roles</param-name>
21+
<param-value>view_administrator_only</param-value>
22+
</init-param>
23+
</filter>
24+
<filter-mapping>
25+
<filter-name>RoleFilterAJAX</filter-name>
26+
<url-pattern>/*</url-pattern>
27+
</filter-mapping>
28+
29+
</web-app>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package aces.webctrl.garbage;
2+
import javax.servlet.*;
3+
public class Initializer implements ServletContextListener {
4+
private volatile Thread thread;
5+
private volatile boolean go = true;
6+
@Override public void contextInitialized(ServletContextEvent sce){
7+
thread = new Thread(){
8+
@Override public void run(){
9+
while (go){
10+
try{
11+
System.gc();
12+
Thread.sleep(300000);
13+
}catch(InterruptedException e){}
14+
}
15+
}
16+
};
17+
thread.start();
18+
}
19+
@Override public void contextDestroyed(ServletContextEvent sce){
20+
try{
21+
go = false;
22+
thread.interrupt();
23+
thread.join();
24+
}catch(InterruptedException e){}
25+
}
26+
}

0 commit comments

Comments
 (0)