/*
* Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2021 PANTHEON.tech, s.r.o.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import com.google.common.annotations.VisibleForTesting;
import java.util.Arrays;
+import java.util.List;
import java.util.ServiceLoader;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.eclipse.jdt.annotation.NonNull;
import org.kohsuke.MetaInfServices;
+import org.opendaylight.protocol.rsvp.parser.spi.EROSubobjectRegistry;
+import org.opendaylight.protocol.rsvp.parser.spi.LabelRegistry;
+import org.opendaylight.protocol.rsvp.parser.spi.RROSubobjectRegistry;
import org.opendaylight.protocol.rsvp.parser.spi.RSVPExtensionConsumerContext;
import org.opendaylight.protocol.rsvp.parser.spi.RSVPExtensionProviderActivator;
+import org.opendaylight.protocol.rsvp.parser.spi.RSVPExtensionProviderContext;
+import org.opendaylight.protocol.rsvp.parser.spi.RSVPTeObjectRegistry;
+import org.opendaylight.protocol.rsvp.parser.spi.XROSubobjectRegistry;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferencePolicyOption;
/**
- * Starts and stops RSVPExtensionProviderActivator instances for a RSVPExtensionProviderContext.
- *
- * @author Thomas Pantelis
+ * Starts and stops {@link RSVPExtensionProviderActivator} instances for an {@link RSVPExtensionProviderContext}.
*/
@Singleton
-@MetaInfServices(value = RSVPExtensionConsumerContext.class)
-public class DefaultRSVPExtensionConsumerContext extends ForwardingRSVPExtensionConsumerContext {
+@Component(immediate = true, service = RSVPExtensionConsumerContext.class)
+@MetaInfServices
+public final class DefaultRSVPExtensionConsumerContext implements RSVPExtensionConsumerContext {
private final @NonNull SimpleRSVPExtensionProviderContext delegate = new SimpleRSVPExtensionProviderContext();
public DefaultRSVPExtensionConsumerContext() {
extensionActivators.forEach(activator -> activator.start(delegate));
}
+ @Activate
+ public DefaultRSVPExtensionConsumerContext(final @Reference(policyOption = ReferencePolicyOption.GREEDY)
+ List<RSVPExtensionProviderActivator> extensionActivators) {
+ extensionActivators.forEach(activator -> activator.start(delegate));
+ }
+
+ @Override
+ public RSVPTeObjectRegistry getRsvpRegistry() {
+ return delegate.getRsvpRegistry();
+ }
+
+ @Override
+ public XROSubobjectRegistry getXROSubobjectHandlerRegistry() {
+ return delegate.getXROSubobjectHandlerRegistry();
+ }
+
+ @Override
+ public EROSubobjectRegistry getEROSubobjectHandlerRegistry() {
+ return delegate.getEROSubobjectHandlerRegistry();
+ }
+
+ @Override
+ public RROSubobjectRegistry getRROSubobjectHandlerRegistry() {
+ return delegate.getRROSubobjectHandlerRegistry();
+ }
+
@Override
- RSVPExtensionConsumerContext delegate() {
- return delegate;
+ public LabelRegistry getLabelHandlerRegistry() {
+ return delegate.getLabelHandlerRegistry();
}
}
+++ /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.protocol.rsvp.parser.spi.pojo;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.protocol.rsvp.parser.spi.EROSubobjectRegistry;
-import org.opendaylight.protocol.rsvp.parser.spi.LabelRegistry;
-import org.opendaylight.protocol.rsvp.parser.spi.RROSubobjectRegistry;
-import org.opendaylight.protocol.rsvp.parser.spi.RSVPExtensionConsumerContext;
-import org.opendaylight.protocol.rsvp.parser.spi.RSVPTeObjectRegistry;
-import org.opendaylight.protocol.rsvp.parser.spi.XROSubobjectRegistry;
-
-abstract class ForwardingRSVPExtensionConsumerContext implements RSVPExtensionConsumerContext {
-
- abstract @NonNull RSVPExtensionConsumerContext delegate();
-
- @Override
- public final RSVPTeObjectRegistry getRsvpRegistry() {
- return delegate().getRsvpRegistry();
- }
-
- @Override
- public final XROSubobjectRegistry getXROSubobjectHandlerRegistry() {
- return delegate().getXROSubobjectHandlerRegistry();
- }
-
- @Override
- public final EROSubobjectRegistry getEROSubobjectHandlerRegistry() {
- return delegate().getEROSubobjectHandlerRegistry();
- }
-
- @Override
- public final RROSubobjectRegistry getRROSubobjectHandlerRegistry() {
- return delegate().getRROSubobjectHandlerRegistry();
- }
-
- @Override
- public final LabelRegistry getLabelHandlerRegistry() {
- return delegate().getLabelHandlerRegistry();
- }
-}
+++ /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.protocol.rsvp.parser.spi.pojo;
-
-import static com.google.common.base.Verify.verifyNotNull;
-
-import java.util.List;
-import org.opendaylight.protocol.rsvp.parser.spi.RSVPExtensionConsumerContext;
-import org.opendaylight.protocol.rsvp.parser.spi.RSVPExtensionProviderActivator;
-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.osgi.service.component.annotations.ReferencePolicyOption;
-
-@Component(immediate = true, service = RSVPExtensionConsumerContext.class)
-// FIXME: merge with DefaultRSVPExtensionConsumerContext once we have OSGi R7
-public final class OSGiRSVPExtensionConsumerContext extends ForwardingRSVPExtensionConsumerContext {
- @Reference(policyOption = ReferencePolicyOption.GREEDY)
- List<RSVPExtensionProviderActivator> extensionActivators;
-
- private SimpleRSVPExtensionProviderContext delegate;
-
- @Activate
- void activate() {
- final SimpleRSVPExtensionProviderContext local = new SimpleRSVPExtensionProviderContext();
- extensionActivators.forEach(activator -> activator.start(local));
- delegate = local;
- }
-
- @Deactivate
- void deactivate() {
- delegate = null;
- }
-
- @Override
- RSVPExtensionConsumerContext delegate() {
- return verifyNotNull(delegate);
- }
-}
* 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.protocol.rsvp.parser.spi.pojo;
import org.opendaylight.protocol.rsvp.parser.spi.RSVPExtensionConsumerContext;