Remove AAAWebEnvironment.create() 33/104333/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 8 Feb 2023 21:59:53 +0000 (22:59 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 8 Feb 2023 22:00:49 +0000 (23:00 +0100)
There is really no need to go through a factory method, just perform
all the initialization in constructor.

JIRA: AAA-205
Change-Id: I09fdef159ddd8f5437ac652bfe65f0ad48d7aa12
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/web/env/AAAWebEnvironment.java
aaa-shiro/impl/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml

index ed853f1dc8315ab216fd008336e091f40c51b1ef..b113e9bdc554b00de26cf69ffbcdeac0300d4fc3 100644 (file)
@@ -35,11 +35,7 @@ import org.slf4j.LoggerFactory;
 public final class AAAWebEnvironment extends IniWebEnvironment implements AAAShiroWebEnvironment {
     private static final Logger LOG = LoggerFactory.getLogger(AAAWebEnvironment.class);
 
-    private AAAWebEnvironment(final Ini ini) {
-        setIni(ini);
-    }
-
-    public static AAAWebEnvironment create(final ShiroIni shiroConfiguration, final DataBroker dataBroker,
+    public AAAWebEnvironment(final ShiroIni shiroConfiguration, final DataBroker dataBroker,
             final ICertificateManager certificateManager, final AuthenticationService authenticationService,
             final TokenAuthenticators tokenAuthenticators, final TokenStore tokenStore,
             final PasswordHashService passwordHashService, final ServletSupport servletSupport) {
@@ -56,8 +52,8 @@ public final class AAAWebEnvironment extends IniWebEnvironment implements AAAShi
             urlsSection.put(url.getPairKey(), url.getPairValue());
         }
 
-        // Create an instance
-        final var ret = new AAAWebEnvironment(ini);
+        // Set the configuration
+        setIni(ini);
 
         // Configure the instance with all known custom components prepared for loading via their thread locals and
         // clean up afterwards. This needs to happen on our class loader so Shiro's ReflectionBuilder use of
@@ -69,11 +65,10 @@ public final class AAAWebEnvironment extends IniWebEnvironment implements AAAShi
                  var moonLoad = MoonRealm.prepareForLoad(servletSupport);
                  var tokenAuthLoad = TokenAuthRealm.prepareForLoad(authenticationService, tokenAuthenticators,
                      tokenStore)) {
-                ret.configure();
+                configure();
             }
         });
 
         LOG.debug("AAAWebEnvironment created");
-        return ret;
     }
 }
index 0c6e0d7b47edb5eda9fa2de36515042e5b24eda7..0140ec49036fd74908db836f258e5533209ef823 100644 (file)
@@ -33,7 +33,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <argument ref="idmStore"/>
   </bean>
 
-  <bean id="webEnvironment" class="org.opendaylight.aaa.shiro.web.env.AAAWebEnvironment" factory-method="create">
+  <bean id="webEnvironment" class="org.opendaylight.aaa.shiro.web.env.AAAWebEnvironment">
     <argument ref="shiroConfiguration"/>
     <argument ref="dataBroker"/>
     <argument ref="certManager"/>