import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
-*
-*/
public final class SchemaServiceImplSingletonModule extends
- org.opendaylight.controller.config.yang.md.sal.dom.impl.AbstractSchemaServiceImplSingletonModule {
+org.opendaylight.controller.config.yang.md.sal.dom.impl.AbstractSchemaServiceImplSingletonModule {
private static final Logger LOG = LoggerFactory.getLogger(SchemaServiceImplSingletonModule.class);
BundleContext bundleContext;
- public SchemaServiceImplSingletonModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
- org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ public SchemaServiceImplSingletonModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+ final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
super(identifier, dependencyResolver);
}
- public SchemaServiceImplSingletonModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
- org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
- SchemaServiceImplSingletonModule oldModule, java.lang.AutoCloseable oldInstance) {
+ public SchemaServiceImplSingletonModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+ final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+ final SchemaServiceImplSingletonModule oldModule, final java.lang.AutoCloseable oldInstance) {
super(identifier, dependencyResolver, oldModule, oldInstance);
}
@Override
- public boolean canReuseInstance(AbstractSchemaServiceImplSingletonModule oldModule) {
+ public boolean canReuseInstance(final AbstractSchemaServiceImplSingletonModule oldModule) {
return true;
}
return bundleContext;
}
- public void setBundleContext(BundleContext bundleContext) {
+ public void setBundleContext(final BundleContext bundleContext) {
this.bundleContext = bundleContext;
}
return new GlobalSchemaServiceProxy(getBundleContext(), ref);
}
- GlobalBundleScanningSchemaServiceImpl newInstance = new GlobalBundleScanningSchemaServiceImpl();
- newInstance.setContext(getBundleContext());
+ GlobalBundleScanningSchemaServiceImpl newInstance = new GlobalBundleScanningSchemaServiceImpl(getBundleContext());
newInstance.start();
return newInstance;
}
private ServiceReference<SchemaService> reference;
private SchemaService delegate;
- public GlobalSchemaServiceProxy(BundleContext bundleContext, ServiceReference<SchemaService> ref) {
+ public GlobalSchemaServiceProxy(final BundleContext bundleContext, final ServiceReference<SchemaService> ref) {
this.bundleContext = bundleContext;
this.reference = ref;
this.delegate = bundleContext.getService(reference);
}
@Override
- public void addModule(Module arg0) {
+ public void addModule(final Module arg0) {
delegate.addModule(arg0);
}
}
@Override
- public ListenerRegistration<SchemaServiceListener> registerSchemaServiceListener(SchemaServiceListener arg0) {
+ public ListenerRegistration<SchemaServiceListener> registerSchemaServiceListener(final SchemaServiceListener arg0) {
return delegate.registerSchemaServiceListener(arg0);
}
@Override
- public void removeModule(Module arg0) {
+ public void removeModule(final Module arg0) {
delegate.removeModule(arg0);
}
import org.slf4j.LoggerFactory;
import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
-public class GlobalBundleScanningSchemaServiceImpl implements //
-SchemaContextProvider, //
-SchemaService, //
-ServiceTrackerCustomizer<SchemaServiceListener, SchemaServiceListener>, //
-AutoCloseable {
+public class GlobalBundleScanningSchemaServiceImpl implements SchemaContextProvider, SchemaService, ServiceTrackerCustomizer<SchemaServiceListener, SchemaServiceListener>, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(GlobalBundleScanningSchemaServiceImpl.class);
+ private final ListenerRegistry<SchemaServiceListener> listeners = new ListenerRegistry<>();
private final URLSchemaContextResolver contextResolver = new URLSchemaContextResolver();
private final BundleScanner scanner = new BundleScanner();
+ private final BundleContext context;
+
private ServiceTracker<SchemaServiceListener, SchemaServiceListener> listenerTracker;
private BundleTracker<Iterable<Registration<URL>>> bundleTracker;
- private ListenerRegistry<SchemaServiceListener> listeners;
private boolean starting = true;
- private BundleContext context;
-
- public ListenerRegistry<SchemaServiceListener> getListeners() {
- return listeners;
- }
- public void setListeners(final ListenerRegistry<SchemaServiceListener> listeners) {
- this.listeners = listeners;
+ public GlobalBundleScanningSchemaServiceImpl(final BundleContext context) {
+ this.context = Preconditions.checkNotNull(context);
}
public BundleContext getContext() {
return context;
}
- public void setContext(final BundleContext context) {
- this.context = context;
- }
-
public void start() {
checkState(context != null);
- if (listeners == null) {
- listeners = new ListenerRegistry<>();
- }
listenerTracker = new ServiceTracker<>(context, SchemaServiceListener.class, GlobalBundleScanningSchemaServiceImpl.this);
- bundleTracker = new BundleTracker<Iterable<Registration<URL>>>(context, BundleEvent.RESOLVED
- | BundleEvent.UNRESOLVED, scanner);
+ bundleTracker = new BundleTracker<>(context, BundleEvent.RESOLVED | BundleEvent.UNRESOLVED, scanner);
bundleTracker.open();
listenerTracker.open();
starting = false;
}
public synchronized void tryToUpdateSchemaContext() {
- if(starting ) {
+ if (starting) {
return;
}
Optional<SchemaContext> schema = contextResolver.tryToUpdateSchemaContext();
public class SchemaServiceActivator implements BundleActivator {
-
+
private ServiceRegistration<SchemaService> schemaServiceReg;
private GlobalBundleScanningSchemaServiceImpl schemaService;
@Override
- public void start(BundleContext context) throws Exception {
- schemaService = new GlobalBundleScanningSchemaServiceImpl();
- schemaService.setContext(context);
+ public void start(final BundleContext context) {
+ schemaService = new GlobalBundleScanningSchemaServiceImpl(context);
schemaService.start();
schemaServiceReg = context.registerService(SchemaService.class, schemaService, new Hashtable<String,String>());
}
-
+
@Override
- public void stop(BundleContext context) throws Exception {
+ public void stop(final BundleContext context) throws Exception {
schemaServiceReg.unregister();
schemaService.close();
}