<groupId>org.kohsuke.metainf-services</groupId>
<artifactId>metainf-services</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.guicedee.services</groupId>
+ <artifactId>javax.inject</artifactId>
+ <optional>true</optional>
+ </dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<dependency>
<configuration>
<instructions>
<Automatic-Module-Name>org.opendaylight.yangtools.yang.data.jaxen</Automatic-Module-Name>
- <Bundle-Activator>org.opendaylight.yangtools.yang.data.jaxen.osgi.Activator</Bundle-Activator>
</instructions>
</configuration>
</plugin>
*/
package org.opendaylight.yangtools.yang.data.jaxen;
+import javax.inject.Inject;
+import javax.inject.Singleton;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.kohsuke.MetaInfServices;
import org.opendaylight.yangtools.yang.data.jaxen.api.XPathSchemaContext;
import org.opendaylight.yangtools.yang.data.jaxen.api.XPathSchemaContextFactory;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@MetaInfServices
+@Singleton
+@Component
@NonNullByDefault
public final class JaxenSchemaContextFactory implements XPathSchemaContextFactory {
+ private static final Logger LOG = LoggerFactory.getLogger(JaxenSchemaContextFactory.class);
+
+ @Inject
+ public JaxenSchemaContextFactory() {
+ // For DI
+ }
+
@Override
public XPathSchemaContext createContext(final EffectiveModelContext context) {
return new JaxenSchemaContext(context);
}
+
+ @Activate
+ @SuppressWarnings("static-method")
+ void activate() {
+ LOG.info("Jaxen XPathSchemaContextFactory enabled");
+ }
+
+ @Deactivate
+ @SuppressWarnings("static-method")
+ void deactivate() {
+ LOG.info("Jaxen XPathSchemaContextFactory disabled");
+ }
}
+++ /dev/null
-/*
- * Copyright (c) 2018 Pantheon Technologies, 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.yangtools.yang.data.jaxen.osgi;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.yang.data.jaxen.JaxenSchemaContextFactory;
-import org.opendaylight.yangtools.yang.data.jaxen.api.XPathSchemaContextFactory;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-
-/**
- * YANG Jaxen XPath implementation activator. Publishes a {@link XPathSchemaContextFactory} implementation on bundle
- * start.
- *
- * @author Robert Varga
- */
-public final class Activator implements BundleActivator {
- private ServiceRegistration<@NonNull XPathSchemaContextFactory> registration;
-
- @Override
- public void start(final BundleContext context) throws Exception {
- registration = context.registerService(XPathSchemaContextFactory.class, new JaxenSchemaContextFactory(), null);
- }
-
- @Override
- public void stop(final BundleContext context) throws Exception {
- if (registration != null) {
- registration.unregister();
- registration = null;
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2018 Pantheon Technologies, 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
- */
-/**
- * OSGi-specific Jaxen XPath implementation code. Contains activators and similar.
- */
-package org.opendaylight.yangtools.yang.data.jaxen.osgi;
\ No newline at end of file
<artifactId>org.osgi.service.component.annotations</artifactId>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
<dependency>
<groupId>org.immutables</groupId>
<artifactId>value</artifactId>