Skip to content

Commit 4366d7b

Browse files
Add temp wrapper class for deprecated properties logic while we refactor
1 parent 4b6488b commit 4366d7b

File tree

4 files changed

+92
-97
lines changed

4 files changed

+92
-97
lines changed

ng-appserver/src/main/java/ng/appserver/NGApplication.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ public static <E extends NGApplication> E runAndReturn( final String[] args, fin
119119
properties.addAndReadSourceHighestPriority( new PropertiesSourceArguments( args ) );
120120

121121
// We need to start out with initializing logging to ensure we're seeing everything the application does during the init phase.
122-
redirectOutputToFilesIfOutputPathSet( properties.propWOOutputPath() );
122+
redirectOutputToFilesIfOutputPathSet( properties.d().propWOOutputPath() );
123123

124124
// Determine the mode we're currently running in. CHECKME: This should be configured using an explicit parameter // Hugi 2025-03-16
125-
final boolean isDevelopmentMode = !properties.propWOMonitorEnabled();
125+
final boolean isDevelopmentMode = !properties.d().propWOMonitorEnabled();
126126

127127
if( isDevelopmentMode ) {
128128
logger.info( "========================================" );
@@ -158,7 +158,7 @@ public static <E extends NGApplication> E runAndReturn( final String[] args, fin
158158

159159
// What we're doing here is allowing for the WO URL structure, which is required for us to work with the WO Apache Adaptor.
160160
// Ideally, we don't want to prefix URLs at all, instead just handling requests at root level.
161-
application._urlRewritePatterns.add( Pattern.compile( "^/(cgi-bin|Apps)/WebObjects/" + properties.propWOApplicationName() + ".woa(/[0-9])?" ) );
161+
application._urlRewritePatterns.add( Pattern.compile( "^/(cgi-bin|Apps)/WebObjects/" + properties.d().propWOApplicationName() + ".woa(/[0-9])?" ) );
162162

163163
// FIXME: This is probably not the place to load plugins. Probably need more extension points for plugin initialization (pre-constructor, post-constructor etc.) // Hugi 2023-07-28
164164
// We should also allow users to manually register plugins they're going to use for each NGApplication instance, as an alternative to greedily autoloading every provided plugin on the classpath
@@ -177,7 +177,7 @@ public static <E extends NGApplication> E runAndReturn( final String[] args, fin
177177
// FIXME: Eventually the adaptor startup should probably be done by the user
178178
application.createAdaptor().start( application );
179179

180-
if( properties.propWOLifebeatEnabled() ) {
180+
if( properties.d().propWOLifebeatEnabled() ) {
181181
NGDefaultLifeBeatThread.start( application._properties );
182182
}
183183

ng-appserver/src/main/java/ng/appserver/properties/NGProperties.java

Lines changed: 8 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -284,97 +284,17 @@ public String _propertiesMapAsString() {
284284
return String.join( "\n", stringKeyPairs );
285285
}
286286

287-
/**
288-
* Defines a property
289-
*
290-
* FIXME: Finish this concept up (for defined, typesafe properties) // Hugi 2023-08-05
291-
*/
292-
public static class Property<E> {
293-
private String _key;
294-
private E _value;
295-
private E _defaultValue;
296-
297-
public Property( final String key, E value, E defaultValue ) {
298-
_key = key;
299-
_value = value;
300-
_defaultValue = defaultValue;
301-
}
302-
303-
public String key() {
304-
return _key;
305-
}
306-
307-
public E value() {
308-
return _value;
309-
}
310-
311-
public E defaultValue() {
312-
return _defaultValue;
313-
}
314-
}
287+
private NGPropertiesDeprecated _d;
315288

316289
/**
317-
* FIXME: We're creating cover methods for some of the more used properties for now. // Hugi 2021-12-29
318-
* This is not the way we it'll be going forward, but it will help with refactoring later (rather than using property name strings)
290+
* FIXME: TEmporary bridge to old properties
319291
*/
320-
public Integer propWOPort() {
321-
return getInteger( WOProperties.WOPort.name() );
322-
}
323-
324-
public String propWOHost() {
325-
return get( WOProperties.WOHost.name() );
326-
}
327-
328-
public Integer propWOLifebeatDestinationPort() {
329-
return getInteger( WOProperties.WOLifebeatDestinationPort.name() );
330-
}
331-
332-
public Integer propWOLifebeatIntervalInSeconds() {
333-
return getInteger( WOProperties.WOLifebeatInterval.name() );
334-
}
335-
336-
public boolean propWOLifebeatEnabled() {
337-
return "YES".equals( get( WOProperties.WOLifebeatEnabled.name() ) );
338-
}
339-
340-
public boolean propWOMonitorEnabled() {
341-
return "YES".equals( get( WOProperties.WOMonitorEnabled.name() ) );
342-
}
343-
344-
public String propWOApplicationName() {
345-
return get( WOProperties.WOApplicationName.name() );
346-
}
347-
348-
public String propWOOutputPath() {
349-
return get( WOProperties.WOOutputPath.name() );
350-
}
292+
@Deprecated
293+
public NGPropertiesDeprecated d() {
294+
if( _d == null ) {
295+
_d = new NGPropertiesDeprecated( this );
296+
}
351297

352-
/**
353-
* Container for all the old properties from WO
354-
*/
355-
public static enum WOProperties {
356-
// Properties in use
357-
WOOutputPath,
358-
WOApplicationName,
359-
WOMonitorEnabled,
360-
WOLifebeatEnabled,
361-
WOLifebeatInterval,
362-
WOLifebeatDestinationPort,
363-
WOHost,
364-
WOPort,
365-
366-
// Properties currently NOT in use
367-
NSProjectSearchPath,
368-
WOAdaptor,
369-
WOAutoOpenClientApplication,
370-
WOAutoOpenInBrowser,
371-
WOCachingEnabled,
372-
WODebuggingEnabled,
373-
WOListenQueueSize,
374-
WONoPause,
375-
WOSessionTimeOut,
376-
WOWorkerThreadCount,
377-
WOWorkerThreadCountMax,
378-
WOWorkerThreadCountMin
298+
return _d;
379299
}
380300
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package ng.appserver.properties;
2+
3+
/**
4+
* FIXME: Temp class for holding deprecated logic while we migrate our properties to a nice new model // Hugi 2025-03-25
5+
*/
6+
7+
public class NGPropertiesDeprecated {
8+
9+
private final NGProperties _p;
10+
11+
public NGPropertiesDeprecated( final NGProperties properties ) {
12+
_p = properties;
13+
}
14+
15+
/**
16+
* Container for all the old properties from WO
17+
*/
18+
private enum WOProperties {
19+
// Properties in use
20+
WOOutputPath,
21+
WOApplicationName,
22+
WOMonitorEnabled,
23+
WOLifebeatEnabled,
24+
WOLifebeatInterval,
25+
WOLifebeatDestinationPort,
26+
WOHost,
27+
WOPort,
28+
29+
// Properties currently NOT in use
30+
NSProjectSearchPath,
31+
WOAdaptor,
32+
WOAutoOpenClientApplication,
33+
WOAutoOpenInBrowser,
34+
WOCachingEnabled,
35+
WODebuggingEnabled,
36+
WOListenQueueSize,
37+
WONoPause,
38+
WOSessionTimeOut,
39+
WOWorkerThreadCount,
40+
WOWorkerThreadCountMax,
41+
WOWorkerThreadCountMin
42+
}
43+
44+
public Integer propWOPort() {
45+
return _p.getInteger( WOProperties.WOPort.name() );
46+
}
47+
48+
public String propWOHost() {
49+
return _p.get( WOProperties.WOHost.name() );
50+
}
51+
52+
public Integer propWOLifebeatDestinationPort() {
53+
return _p.getInteger( WOProperties.WOLifebeatDestinationPort.name() );
54+
}
55+
56+
public Integer propWOLifebeatIntervalInSeconds() {
57+
return _p.getInteger( WOProperties.WOLifebeatInterval.name() );
58+
}
59+
60+
public boolean propWOLifebeatEnabled() {
61+
return "YES".equals( _p.get( WOProperties.WOLifebeatEnabled.name() ) );
62+
}
63+
64+
public boolean propWOMonitorEnabled() {
65+
return "YES".equals( _p.get( WOProperties.WOMonitorEnabled.name() ) );
66+
}
67+
68+
public String propWOApplicationName() {
69+
return _p.get( WOProperties.WOApplicationName.name() );
70+
}
71+
72+
public String propWOOutputPath() {
73+
return _p.get( WOProperties.WOOutputPath.name() );
74+
}
75+
}

ng-appserver/src/main/java/ng/appserver/wointegration/NGDefaultLifeBeatThread.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ public class NGDefaultLifeBeatThread {
2121
* Starts a lifebeat thread for communicating with wotaskd.
2222
*/
2323
public static void start( final NGProperties properties ) {
24-
final String hostName = properties.propWOHost();
25-
final String appName = properties.propWOApplicationName();
26-
final Integer appPort = properties.propWOPort();
27-
final Integer lifeBeatDestinationPort = properties.propWOLifebeatDestinationPort();
28-
final Integer lifeBeatIntervalInSeconds = properties.propWOLifebeatIntervalInSeconds();
24+
final String hostName = properties.d().propWOHost();
25+
final String appName = properties.d().propWOApplicationName();
26+
final Integer appPort = properties.d().propWOPort();
27+
final Integer lifeBeatDestinationPort = properties.d().propWOLifebeatDestinationPort();
28+
final Integer lifeBeatIntervalInSeconds = properties.d().propWOLifebeatIntervalInSeconds();
2929
final long lifeBeatIntervalInMilliseconds = TimeUnit.MILLISECONDS.convert( lifeBeatIntervalInSeconds, TimeUnit.SECONDS );
3030

3131
InetAddress hostAddress = null;

0 commit comments

Comments
 (0)