47
47
import org .eclipse .jetty .servlet .ServletHolder ;
48
48
import org .eclipse .jetty .util .ssl .SslContextFactory ;
49
49
import org .eclipse .jetty .util .thread .ThreadPool ;
50
- import org .eclipse .jetty .webapp .WebAppContext ;
51
50
52
51
import com .ibm .streams .operator .OperatorContext ;
53
52
import com .ibm .streams .operator .StreamingData ;
54
53
import com .ibm .streams .operator .management .OperatorManagement ;
55
54
import com .ibm .streamsx .inet .rest .ops .Functions ;
56
55
import com .ibm .streamsx .inet .rest .ops .PostTuple ;
57
56
import com .ibm .streamsx .inet .rest .ops .ServletOperator ;
57
+ import com .ibm .streamsx .inet .rest .servlets .ExposedContextInfo ;
58
58
import com .ibm .streamsx .inet .rest .servlets .ExposedPortsInfo ;
59
59
import com .ibm .streamsx .inet .rest .servlets .PortInfo ;
60
60
import com .ibm .streamsx .inet .rest .setup .ExposedPort ;
@@ -178,6 +178,10 @@ public void join() throws InterruptedException {
178
178
portsIntro .addServlet (new ServletHolder ( new ExposedPortsInfo (exposedPorts )), "/info" );
179
179
addHandler (portsIntro );
180
180
181
+ ServletContextHandler contextIntro = new ServletContextHandler (server , "/contexts" , ServletContextHandler .SESSIONS );
182
+ contextIntro .addServlet (new ServletHolder ( new ExposedContextInfo (staticContexts )), "/info" );
183
+ addHandler (contextIntro );
184
+
181
185
// making a abs path by combining toolkit directory with the opt/resources dir
182
186
URI baseToolkitDir = operatorContext .getToolkitDirectory ().toURI ();
183
187
addStaticContext ("streamsx.inet.resources" , PathConversionHelper .convertToAbsPath (baseToolkitDir , "opt/resources" ));
@@ -212,14 +216,18 @@ private void setHTTPSConnector(OperatorContext operatorContext, Server server, i
212
216
File keyStorePathFile = new File (keyStorePath );
213
217
if (!keyStorePathFile .isAbsolute ())
214
218
keyStorePathFile = new File (operatorContext .getPE ().getApplicationDirectory (), keyStorePath );
215
- sslContextFactory .setKeyStorePath (keyStorePathFile .getAbsolutePath ());
219
+ String keyStorePathToLoad = keyStorePathFile .getAbsolutePath ();
220
+ System .out .println ("keyStorePathToLoad=" + keyStorePathToLoad );
221
+ sslContextFactory .setKeyStorePath (keyStorePathToLoad );
216
222
//the key store password is optional
217
223
if (operatorContext .getParameterNames ().contains (SSL_KEYSTORE_PASSWORD_PARAM )) {
218
224
String keyStorePassword = operatorContext .getParameterValues (SSL_KEYSTORE_PASSWORD_PARAM ).get (0 );
225
+ System .out .println ("keyStorePassword=****" );
219
226
sslContextFactory .setKeyStorePassword (Functions .obfuscate (keyStorePassword ));
220
227
}
221
228
//Key password is required
222
229
String keyPassword = operatorContext .getParameterValues (SSL_KEY_PASSWORD_PARAM ).get (0 );
230
+ System .out .println ("keyPassword=****" );
223
231
sslContextFactory .setKeyManagerPassword (Functions .obfuscate (keyPassword ));
224
232
//Key alias
225
233
String alias = operatorContext .getParameterValues (SSL_CERT_ALIAS_PARAM ).get (0 );
@@ -230,10 +238,13 @@ private void setHTTPSConnector(OperatorContext operatorContext, Server server, i
230
238
File trustStorePathFile = new File (trustStorePath );
231
239
if (!trustStorePathFile .isAbsolute ())
232
240
trustStorePathFile = new File (operatorContext .getPE ().getApplicationDirectory (), trustStorePath );
233
- sslContextFactory .setTrustStorePath (trustStorePath );
241
+ String trustStorePathToLoad = trustStorePathFile .getAbsolutePath ();
242
+ System .out .println ("trustStorePathToLoad=" + trustStorePathToLoad );
243
+ sslContextFactory .setTrustStorePath (trustStorePathToLoad );
234
244
sslContextFactory .setNeedClientAuth (true );
235
245
if (operatorContext .getParameterNames ().contains (SSL_TRUSTSTORE_PASSWORD_PARAM )) {
236
246
String trustStorePassword = operatorContext .getParameterValues (SSL_TRUSTSTORE_PASSWORD_PARAM ).get (0 );
247
+ System .out .println ("trustStorePassword=****" );
237
248
sslContextFactory .setTrustStorePassword (Functions .obfuscate (trustStorePassword ));
238
249
}
239
250
}
@@ -421,12 +432,21 @@ public void registerOperator(ServletOperator operator, Object conduit) throws Ex
421
432
staticContext .setAttribute ("operator.conduit" , conduit );
422
433
}
423
434
424
- // For a static context just use the name of the
425
- // base operator (without the composite nesting qualifiers)
426
- // as the lead in for resources exposed by this operator.
427
- // Otherwise use the full name of the operator so that it is unique.
435
+ // If there is a context parameter in this operator
436
+ // just use the base name of the operator (without the composite nesting qualifiers)
437
+ // as the lead in for port resources exposed by this operator.
438
+ // Otherwise use the full operator name so that it is unique.
439
+ String ctxName = null ;
440
+ if (operatorContext .getParameterNames ().contains (CONTEXT_PARAM )) {
441
+ ctxName = operatorContext .getParameterValues (CONTEXT_PARAM ).get (0 );
442
+
443
+ if ("" .equals (ctxName ))
444
+ throw new IllegalArgumentException ("Parameter " + CONTEXT_PARAM + " cannot be empty" );
445
+
446
+ }
447
+
428
448
String leadIn = operatorContext .getName (); // .replace('.', '/');
429
- if (staticContext != null && leadIn .indexOf ('.' ) != -1 ) {
449
+ if (ctxName != null && leadIn .indexOf ('.' ) != -1 ) {
430
450
leadIn = leadIn .substring (leadIn .lastIndexOf ('.' ) + 1 );
431
451
}
432
452
@@ -436,10 +456,9 @@ public void registerOperator(ServletOperator operator, Object conduit) throws Ex
436
456
operatorContext .getNumberOfStreamingOutputs () != 0 ) {
437
457
438
458
String portsContextPath = "/" + leadIn + "/ports" ;
439
- if (staticContext != null )
440
- portsContextPath = staticContext .getContextPath () + portsContextPath ;
441
- ports = new ServletContextHandler (server , portsContextPath ,
442
- ServletContextHandler .SESSIONS );
459
+ if (ctxName != null )
460
+ portsContextPath = "/" + ctxName + portsContextPath ;
461
+ ports = new ServletContextHandler (server , portsContextPath , ServletContextHandler .SESSIONS );
443
462
444
463
ports .setAttribute ("operator.context" , operatorContext );
445
464
if (conduit != null )
@@ -480,10 +499,10 @@ public void registerOperator(ServletOperator operator, Object conduit) throws Ex
480
499
addHandler (ports );
481
500
}
482
501
483
- public static class OperatorWebAppContext extends WebAppContext {
502
+ /* public static class OperatorWebAppContext extends WebAppContext {
484
503
public OperatorWebAppContext() {
485
504
}
486
- }
505
+ }*/
487
506
488
507
@ Override
489
508
public void postDeregister () {
0 commit comments