--- /dev/null
+/*
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.akka.osgi.impl;
+
+import akka.actor.ActorSystem;
+import com.typesafe.config.Config;
+import java.util.concurrent.TimeoutException;
+import org.opendaylight.controller.cluster.ActorSystemProvider;
+import org.opendaylight.controller.cluster.ActorSystemProviderListener;
+import org.opendaylight.controller.cluster.akka.impl.ActorSystemProviderImpl;
+import org.opendaylight.controller.cluster.akka.impl.AkkaConfigFactory;
+import org.opendaylight.controller.cluster.common.actor.AkkaConfigurationReader;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import scala.concurrent.Await;
+import scala.concurrent.duration.Duration;
+
+@Component(immediate = true)
+public final class OSGiActorSystemProvider implements ActorSystemProvider {
+ private static final Logger LOG = LoggerFactory.getLogger(OSGiActorSystemProvider.class);
+
+ @Reference
+ AkkaConfigurationReader reader = null;
+
+ private ActorSystemProviderImpl delegate;
+
+ @Override
+ public ActorSystem getActorSystem() {
+ return delegate.getActorSystem();
+ }
+
+ @Override
+ public ListenerRegistration<ActorSystemProviderListener> registerActorSystemProviderListener(
+ final ActorSystemProviderListener listener) {
+ return delegate.registerActorSystemProviderListener(listener);
+ }
+
+ @Activate
+ void activate(final BundleContext bundleContext) {
+ LOG.info("Actor System provider starting");
+ final Config akkaConfig = AkkaConfigFactory.createAkkaConfig(reader);
+ delegate = new ActorSystemProviderImpl(BundleClassLoaderFactory.createClassLoader(bundleContext),
+ QuarantinedMonitorActorPropsFactory.createProps(bundleContext, akkaConfig), akkaConfig);
+ LOG.info("Actor System provider started");
+ }
+
+ @Deactivate
+ void deactivate() throws TimeoutException, InterruptedException {
+ LOG.info("Actor System provider stopping");
+ Await.result(delegate.asyncClose(), Duration.Inf());
+ delegate = null;
+ LOG.info("Actor System provider stopped");
+ }
+}
+
<argument ref="bindingSerializer"/>
</bean>
- <!-- ActorSystemProvider -->
-
- <bean id="bundleClassLoader" class="org.opendaylight.controller.cluster.akka.osgi.impl.BundleClassLoaderFactory"
- factory-method="createClassLoader">
- <argument ref="blueprintBundleContext" />
- </bean>
-
- <reference id="akkaReader" interface="org.opendaylight.controller.cluster.common.actor.AkkaConfigurationReader"/>
-
- <bean id="akkaConfig" class="org.opendaylight.controller.cluster.akka.impl.AkkaConfigFactory"
- factory-method="createAkkaConfig">
- <argument ref="akkaReader" />
- </bean>
-
- <bean id="actorSystemProps" class="org.opendaylight.controller.cluster.akka.osgi.impl.QuarantinedMonitorActorPropsFactory"
- factory-method="createProps">
- <argument ref="blueprintBundleContext" />
- <argument ref="akkaConfig"/>
- </bean>
-
- <bean id="actorSystemProvider" class="org.opendaylight.controller.cluster.akka.impl.ActorSystemProviderImpl"
- destroy-method="close">
- <argument ref="bundleClassLoader" />
- <argument ref="actorSystemProps"/>
- <argument ref="akkaConfig"/>
- </bean>
-
- <service ref="actorSystemProvider" interface="org.opendaylight.controller.cluster.ActorSystemProvider"/>
-
<!-- Datastore properties -->
+ <reference id="actorSystemProvider" interface="org.opendaylight.controller.cluster.ActorSystemProvider"/>
+
<cm:cm-properties id="datastoreProps" persistent-id="org.opendaylight.controller.cluster.datastore"/>
<!-- Distributed Config Datastore -->