Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
cvogt729 committed Sep 2, 2022
0 parents commit d96a7e9
Show file tree
Hide file tree
Showing 8 changed files with 173 additions and 0 deletions.
29 changes: 29 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2022, Automatic Controls Equipment Systems, Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# GarbageCollector

WebCTRL is a trademark of Automated Logic Corporation. Any other trademarks mentioned herein are the property of their respective owners.

## About

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.
18 changes: 18 additions & 0 deletions config/BUILD_DETAILS
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
JDK Version:
openjdk 18.0.2.1 2022-08-18
OpenJDK Runtime Environment (build 18.0.2.1+1-1)
OpenJDK 64-Bit Server VM (build 18.0.2.1+1-1, mixed mode, sharing)

Compilation Flags:
--release 8

Runtime Dependencies:
addonsupport-api-addon-1.7.0
alarmmanager-api-addon-1.7.0
bacnet-api-addon-1.8.007-20220318.0837r
directaccess-api-addon-1.7.0
tomcat-embed-core-9.0.37
webaccess-api-addon-1.7.0
xdatabase-api-addon-1.7.0

Packaged Dependencies:
1 change: 1 addition & 0 deletions config/COMPILE_FLAGS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--release 8
57 changes: 57 additions & 0 deletions ext/deploy.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
@echo off
if "%WebCTRL%" EQU "" goto :bad
if "%addonFile%" EQU "" goto :bad
if "%certFile%" EQU "" goto :bad
if /i "%*" EQU "--help" (
echo DEPLOY Copies the .addon archive and certificate file to the bound WebCTRL installation.
exit /b 0
)
if "%*" NEQ "" (
echo Unexpected parameter.
exit /b 1
)
if not exist "%addonFile%" (
echo Cannot deploy because !name!.addon does not exist.
exit /b 1
)
echo Deploying...
if "!name!" EQU "AddonDevRefresher" (
echo Cannot be used to self-deploy.
echo Deployment unsuccessful.
exit /b 1
)
if not exist "%WebCTRL%\addons" mkdir "%WebCTRL%\addons" >nul 2>nul
copy /y "%certFile%" "%WebCTRL%\addons\%certFileName%" >nul
copy /y "%addonFile%" "%WebCTRL%\addons\!name!.update" >nul
if %ErrorLevel% NEQ 0 (
echo Deployment unsuccessful.
exit /b 1
)
set /a count=0
:waitUpdate
timeout 1 /nobreak >nul
set /a count+=1
if exist "%WebCTRL%\addons\!name!.update" (
if "%count%" EQU "60" (
echo Timeout occurred.
echo Deployment unsuccessful.
exit /b 1
) else (
goto :waitUpdate
)
)
if exist "%WebCTRL%\addons\!name!.addon" (
echo Deployment successful.
exit /b 0
) else (
echo Deployment unsuccessful.
exit /b 1
)

:bad
echo This script should not be invoked as a stand-alone application.
echo You must use this file as an extension to addon-dev-script.
echo https://github.com/automatic-controls/addon-dev-script
echo Press any key to exit.
pause >nul
exit /b 1
6 changes: 6 additions & 0 deletions root/info.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<extension version="1">
<name>GarbageCollector</name>
<description>A simple WebCTRL add-on which invoked System.gc() every 5 minutes.</description>
<version>1.0.0</version>
<vendor>Automatic Controls Equipment Systems, Inc.</vendor>
</extension>
29 changes: 29 additions & 0 deletions root/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>

<web-app>

<listener>
<listener-class>aces.webctrl.garbage.Initializer</listener-class>
</listener>

<security-constraint>
<web-resource-collection>
<web-resource-name>WEB</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
</security-constraint>

<filter>
<filter-name>RoleFilterAJAX</filter-name>
<filter-class>com.controlj.green.addonsupport.web.RoleFilter</filter-class>
<init-param>
<param-name>roles</param-name>
<param-value>view_administrator_only</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>RoleFilterAJAX</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

</web-app>
26 changes: 26 additions & 0 deletions src/aces/webctrl/garbage/Initializer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package aces.webctrl.garbage;
import javax.servlet.*;
public class Initializer implements ServletContextListener {
private volatile Thread thread;
private volatile boolean go = true;
@Override public void contextInitialized(ServletContextEvent sce){
thread = new Thread(){
@Override public void run(){
while (go){
try{
System.gc();
Thread.sleep(300000);
}catch(InterruptedException e){}
}
}
};
thread.start();
}
@Override public void contextDestroyed(ServletContextEvent sce){
try{
go = false;
thread.interrupt();
thread.join();
}catch(InterruptedException e){}
}
}

0 comments on commit d96a7e9

Please sign in to comment.