22 * Copyright (c) 2005-2020 The OPC Foundation, Inc. All rights reserved.
33 *
44 * OPC Foundation MIT License 1.00
5- *
5+ *
66 * Permission is hereby granted, free of charge, to any person
77 * obtaining a copy of this software and associated documentation
88 * files (the "Software"), to deal in the Software without
1111 * copies of the Software, and to permit persons to whom the
1212 * Software is furnished to do so, subject to the following
1313 * conditions:
14- *
14+ *
1515 * The above copyright notice and this permission notice shall be
1616 * included in all copies or substantial portions of the Software.
1717 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
3232using System . Linq ;
3333using System . Security . Cryptography . X509Certificates ;
3434using Opc . Ua ;
35+ using Opc . Ua . Configuration ;
3536using Opc . Ua . Server ;
37+ using Opc . Ua . Server . NodeManager ;
3638
3739namespace Quickstarts . ReferenceServer
3840{
@@ -43,12 +45,23 @@ namespace Quickstarts.ReferenceServer
4345 /// Each server instance must have one instance of a StandardServer object which is
4446 /// responsible for reading the configuration file, creating the endpoints and dispatching
4547 /// incoming requests to the appropriate handler.
46- ///
48+ ///
4749 /// This sub-class specifies non-configurable metadata such as Product Name and initializes
4850 /// the EmptyNodeManager which provides access to the data exposed by the Server.
4951 /// </remarks>
50- public partial class ReferenceServer : ReverseConnectServer
52+ public partial class ReferenceServer : ReverseConnectServer , IReferenceServer
5153 {
54+ public ReferenceServer (
55+ IApplicationInstance applicationInstance ,
56+ IServerInternal serverInternal ,
57+ IMainNodeManagerFactory mainNodeManagerFactory )
58+ : base ( applicationInstance , serverInternal , mainNodeManagerFactory )
59+ {
60+ m_applicationInstance = applicationInstance ;
61+ m_serverInternal = serverInternal ;
62+ m_mainNodeManagerFactory = mainNodeManagerFactory ;
63+ }
64+
5265 #region Properties
5366 public ITokenValidator TokenValidator { get ; set ; }
5467
@@ -63,7 +76,9 @@ public partial class ReferenceServer : ReverseConnectServer
6376 /// always creates a CoreNodeManager which handles the built-in nodes defined by the specification.
6477 /// Any additional NodeManagers are expected to handle application specific nodes.
6578 /// </remarks>
66- protected override MasterNodeManager CreateMasterNodeManager ( IServerInternal server , ApplicationConfiguration configuration )
79+ protected override IMasterNodeManager CreateMasterNodeManager (
80+ IServerInternal server ,
81+ ApplicationConfiguration configuration )
6782 {
6883 Utils . LogInfo ( Utils . TraceMasks . StartStop , "Creating the Reference Server Node Manager." ) ;
6984
@@ -78,7 +93,7 @@ protected override MasterNodeManager CreateMasterNodeManager(IServerInternal ser
7893 }
7994
8095 // create master node manager.
81- return new MasterNodeManager ( server , configuration , null , nodeManagers . ToArray ( ) ) ;
96+ return m_mainNodeManagerFactory . CreateMasterNodeManager ( null , nodeManagers . ToArray ( ) ) ;
8297 }
8398
8499 protected override IMonitoredItemQueueFactory CreateMonitoredItemQueueFactory ( IServerInternal server , ApplicationConfiguration configuration )
@@ -136,7 +151,7 @@ protected override ResourceManager CreateResourceManager(IServerInternal server,
136151 /// Initializes the server before it starts up.
137152 /// </summary>
138153 /// <remarks>
139- /// This method is called before any startup processing occurs. The sub-class may update the
154+ /// This method is called before any startup processing occurs. The sub-class may update the
140155 /// configuration object or do any other application specific startup tasks.
141156 /// </remarks>
142157 protected override void OnServerStarting ( ApplicationConfiguration configuration )
@@ -162,11 +177,10 @@ protected override void OnServerStarted(IServerInternal server)
162177
163178 try
164179 {
165- lock ( ServerInternal . Status . Lock )
166- {
167- // allow a faster sampling interval for CurrentTime node.
168- ServerInternal . Status . Variable . CurrentTime . MinimumSamplingInterval = 250 ;
169- }
180+ ServerInternal . UpdateServerStatus (
181+ ( serverStatus ) => {
182+ serverStatus . Variable . CurrentTime . MinimumSamplingInterval = 250 ;
183+ } ) ;
170184 }
171185 catch
172186 { }
@@ -416,7 +430,7 @@ private IUserIdentity VerifyIssuedToken(IssuedIdentityToken issuedToken)
416430 info = new TranslationInfo ( "IssuedTokenInvalid" , "en-US" , "token is an invalid issued token." ) ;
417431 result = StatusCodes . BadIdentityTokenInvalid ;
418432 }
419- else // Rejected
433+ else // Rejected
420434 {
421435 // construct translation object with default text.
422436 info = new TranslationInfo ( "IssuedTokenRejected" , "en-US" , "token is rejected." ) ;
@@ -434,6 +448,10 @@ private IUserIdentity VerifyIssuedToken(IssuedIdentityToken issuedToken)
434448
435449 #region Private Fields
436450 private ICertificateValidator m_userCertificateValidator ;
451+ private readonly IMainNodeManagerFactory m_mainNodeManagerFactory ;
452+ private readonly IServerInternal m_serverInternal ;
453+ private readonly IApplicationInstance m_applicationInstance ;
454+
437455 #endregion
438456 }
439457}
0 commit comments