From 276e328530173218015e14236b77a634c4ea5246 Mon Sep 17 00:00:00 2001 From: Scott Lewis Date: Thu, 8 Aug 2024 14:02:04 -0700 Subject: [PATCH] Fix for xbill version -> 3.6.0 --- .../org.eclipse.ecf.provider.dnssd/.classpath | 2 +- .../.settings/org.eclipse.jdt.core.prefs | 8 +-- .../META-INF/MANIFEST.MF | 6 +-- .../org.eclipse.ecf.provider.dnssd/pom.xml | 4 +- .../eclipse/ecf/provider/dnssd/Activator.java | 54 +++++++++---------- 5 files changed, 34 insertions(+), 40 deletions(-) diff --git a/providers/bundles/org.eclipse.ecf.provider.dnssd/.classpath b/providers/bundles/org.eclipse.ecf.provider.dnssd/.classpath index 2fbb7a23e1..81fe078c20 100644 --- a/providers/bundles/org.eclipse.ecf.provider.dnssd/.classpath +++ b/providers/bundles/org.eclipse.ecf.provider.dnssd/.classpath @@ -1,6 +1,6 @@ - + diff --git a/providers/bundles/org.eclipse.ecf.provider.dnssd/.settings/org.eclipse.jdt.core.prefs b/providers/bundles/org.eclipse.ecf.provider.dnssd/.settings/org.eclipse.jdt.core.prefs index 1b33a49184..0cc4cd7da6 100644 --- a/providers/bundles/org.eclipse.ecf.provider.dnssd/.settings/org.eclipse.jdt.core.prefs +++ b/providers/bundles/org.eclipse.ecf.provider.dnssd/.settings/org.eclipse.jdt.core.prefs @@ -11,9 +11,9 @@ org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.4 +org.eclipse.jdt.core.compiler.compliance=17 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -21,5 +21,5 @@ org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning -org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.3 +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/providers/bundles/org.eclipse.ecf.provider.dnssd/META-INF/MANIFEST.MF b/providers/bundles/org.eclipse.ecf.provider.dnssd/META-INF/MANIFEST.MF index 6b0cab235a..c2b1bc0339 100644 --- a/providers/bundles/org.eclipse.ecf.provider.dnssd/META-INF/MANIFEST.MF +++ b/providers/bundles/org.eclipse.ecf.provider.dnssd/META-INF/MANIFEST.MF @@ -3,10 +3,10 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.ecf.provider.dnssd;singleton:=true Automatic-Module-Name: org.eclipse.ecf.provider.dnssd -Bundle-Version: 1.3.0.qualifier +Bundle-Version: 1.3.100.qualifier Bundle-Activator: org.eclipse.ecf.provider.dnssd.Activator Bundle-Vendor: %pluginProvider -Bundle-RequiredExecutionEnvironment: J2SE-1.4 +Bundle-RequiredExecutionEnvironment: JavaSE-17 Import-Package: org.eclipse.ecf.core;version="3.0.0", org.eclipse.ecf.core.events, org.eclipse.ecf.core.identity;version="3.0.0", @@ -22,7 +22,7 @@ Import-Package: org.eclipse.ecf.core;version="3.0.0", org.osgi.util.tracker;version="1.3.1" Bundle-ActivationPolicy: lazy Export-Package: org.eclipse.ecf.provider.dnssd;version="1.0.0" -Require-Bundle: org.xbill.dns;bundle-version="2.0.8", +Require-Bundle: org.xbill.dns;bundle-version="3.6.0", org.eclipse.equinox.common Bundle-Localization: plugin Provide-Capability: osgi.remoteserviceadmin.discovery;protocols:List="DNSSD,ecf.discovery.dnssd.locator,ecf.discovery.dnssd.advertiser";version:Version=1.1 diff --git a/providers/bundles/org.eclipse.ecf.provider.dnssd/pom.xml b/providers/bundles/org.eclipse.ecf.provider.dnssd/pom.xml index aa063f08a5..845ebd8d45 100644 --- a/providers/bundles/org.eclipse.ecf.provider.dnssd/pom.xml +++ b/providers/bundles/org.eclipse.ecf.provider.dnssd/pom.xml @@ -8,8 +8,8 @@ 1.0.0-SNAPSHOT ../../../ - org.eclipse.ecf + org.eclipse.ecf.provider.dnssd - 1.3.0-SNAPSHOT + 1.3.100-SNAPSHOT eclipse-plugin diff --git a/providers/bundles/org.eclipse.ecf.provider.dnssd/src/org/eclipse/ecf/provider/dnssd/Activator.java b/providers/bundles/org.eclipse.ecf.provider.dnssd/src/org/eclipse/ecf/provider/dnssd/Activator.java index b298b202fc..d0fa9b6705 100644 --- a/providers/bundles/org.eclipse.ecf.provider.dnssd/src/org/eclipse/ecf/provider/dnssd/Activator.java +++ b/providers/bundles/org.eclipse.ecf.provider.dnssd/src/org/eclipse/ecf/provider/dnssd/Activator.java @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2009 Markus Alexander Kuppe. +- * Copyright (c) 2009 Markus Alexander Kuppe. * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -14,12 +14,11 @@ import java.util.Dictionary; import java.util.HashMap; +import java.util.Hashtable; import java.util.Iterator; import java.util.Map; -import java.util.Properties; import org.eclipse.core.runtime.SafeRunner; -import org.eclipse.ecf.core.ContainerConnectException; import org.eclipse.ecf.core.ContainerTypeDescription; import org.eclipse.ecf.core.IContainer; import org.eclipse.ecf.core.identity.Namespace; @@ -45,6 +44,7 @@ public class Activator implements BundleActivator { private static final String DISCOVERY_CONTAINER_NAME_KEY = "org.eclipse.ecf.discovery.containerName"; //$NON-NLS-1$ + @SuppressWarnings("rawtypes") private final Map serviceRegistrations = new HashMap(); private volatile BundleContext context; @@ -52,6 +52,7 @@ public class Activator implements BundleActivator { * (non-Javadoc) * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) */ + @SuppressWarnings({ "rawtypes", "unchecked" }) public void start(final BundleContext context) throws Exception { this.context = context; @@ -64,23 +65,23 @@ protected void runWithoutRegistry() throws Exception { }); // register a managed factory for the locator service - final Properties locCmProps = new Properties(); + final Hashtable locCmProps = new Hashtable(); locCmProps.put(Constants.SERVICE_PID, DISCOVERY_CONTAINER_NAME_VALUE + LOCATOR); context.registerService(ManagedServiceFactory.class.getName(), new DnsSdManagedServiceFactory(DnsSdDiscoveryLocator.class), locCmProps); // register the locator service - final Properties locProps = new Properties(); + final Hashtable locProps = new Hashtable(); locProps.put(DISCOVERY_CONTAINER_NAME_KEY, DISCOVERY_CONTAINER_NAME_VALUE + LOCATOR); locProps.put(Constants.SERVICE_RANKING, Integer.valueOf(750)); serviceRegistrations.put(null, context.registerService(IDiscoveryLocator.class.getName(), new DnsSdServiceFactory(DnsSdDiscoveryLocator.class), locProps)); // register a managed factory for the advertiser service - final Properties advCmProps = new Properties(); + final Hashtable advCmProps = new Hashtable(); advCmProps.put(Constants.SERVICE_PID, DISCOVERY_CONTAINER_NAME_VALUE + ADVERTISER); context.registerService(ManagedServiceFactory.class.getName(), new DnsSdManagedServiceFactory(DnsSdDiscoveryAdvertiser.class), advCmProps); // register the advertiser service - final Properties advProps = new Properties(); + final Hashtable advProps = new Hashtable(); advProps.put(DISCOVERY_CONTAINER_NAME_KEY, DISCOVERY_CONTAINER_NAME_VALUE + ADVERTISER); advProps.put(Constants.SERVICE_RANKING, Integer.valueOf(750)); serviceRegistrations.put(null, context.registerService(IDiscoveryAdvertiser.class.getName(), new DnsSdServiceFactory(DnsSdDiscoveryAdvertiser.class), advProps)); @@ -90,6 +91,7 @@ protected void runWithoutRegistry() throws Exception { * (non-Javadoc) * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) */ + @SuppressWarnings("rawtypes") public void stop(BundleContext context) throws Exception { if (serviceRegistrations != null) { for (final Iterator itr = serviceRegistrations.values().iterator(); itr.hasNext();) { @@ -103,7 +105,9 @@ public void stop(BundleContext context) throws Exception { /** * @param serviceRegistration disconnects the underlying IContainer and unregisters the service */ - private void disposeServiceRegistration(ServiceRegistration serviceRegistration) { + @SuppressWarnings("unchecked") + private void disposeServiceRegistration(@SuppressWarnings("rawtypes") ServiceRegistration serviceRegistration) { + @SuppressWarnings("rawtypes") final ServiceReference reference = serviceRegistration.getReference(); final IContainer aContainer = (DnsSdDiscoveryContainerAdapter) context.getService(reference); @@ -117,9 +121,10 @@ private void disposeServiceRegistration(ServiceRegistration serviceRegistration) * A ManagedServiceFactory capable to handle DnsSdDiscoveryContainerAdapters */ private class DnsSdManagedServiceFactory implements ManagedServiceFactory { + @SuppressWarnings("rawtypes") private final Class containerClass; - public DnsSdManagedServiceFactory(Class aContainerClass) { + public DnsSdManagedServiceFactory(@SuppressWarnings("rawtypes") Class aContainerClass) { containerClass = aContainerClass; } @@ -133,6 +138,7 @@ public String getName() { /* (non-Javadoc) * @see org.osgi.service.cm.ManagedServiceFactory#updated(java.lang.String, java.util.Dictionary) */ + @SuppressWarnings({ "unchecked", "rawtypes" }) public void updated(String pid, Dictionary properties) throws ConfigurationException { if(properties != null) { @@ -145,7 +151,7 @@ public void updated(String pid, Dictionary properties) adapter = (DnsSdDiscoveryContainerAdapter) context.getService(serviceRegistration.getReference()); targetID = (DnsSdServiceTypeID) adapter.getConnectedID(); } else { - adapter = (DnsSdDiscoveryContainerAdapter) containerClass.newInstance(); + adapter = (DnsSdDiscoveryContainerAdapter) containerClass.getDeclaredConstructor().newInstance(); targetID = new DnsSdServiceTypeID(); } @@ -168,28 +174,22 @@ public void updated(String pid, Dictionary properties) // finally connect container and keep ser reg for later updates/deletes if(serviceRegistration == null) { - final Properties props = new Properties(); + final Hashtable props = new Hashtable(); props.put(Constants.SERVICE_PID, pid); adapter.connect(targetID, null); serviceRegistrations.put(pid, context.registerService(IDiscoveryLocator.class.getName(), adapter, props)); } - } catch (ContainerConnectException e) { + } catch (Exception e) { throw new ConfigurationException("IDnsSdDiscoveryConstants properties", e.getLocalizedMessage(), e); //$NON-NLS-1$ - } catch (ClassCastException cce) { - throw new ConfigurationException("IDnsSdDiscoveryConstants properties", cce.getLocalizedMessage(), cce); //$NON-NLS-1$ - } catch (InstantiationException e) { - // may never happen - throw new ConfigurationException("InstantiationException", e.getLocalizedMessage(), e); //$NON-NLS-1$ - } catch (IllegalAccessException e) { - // may never happen - throw new ConfigurationException("IllegalAccessException", e.getLocalizedMessage(), e); //$NON-NLS-1$ } + } } /* (non-Javadoc) * @see org.osgi.service.cm.ManagedServiceFactory#deleted(java.lang.String) */ + @SuppressWarnings("rawtypes") public void deleted(String pid) { final ServiceRegistration serviceRegistration = (ServiceRegistration) serviceRegistrations.get(pid); disposeServiceRegistration(serviceRegistration); @@ -199,6 +199,7 @@ public void deleted(String pid) { /** * A ServiceFactory capable to handle DnsSdDiscoveryContainerAdapters */ + @SuppressWarnings("rawtypes") public class DnsSdServiceFactory implements ServiceFactory { private volatile DnsSdDiscoveryContainerAdapter container; private final Class containerClass; @@ -210,20 +211,13 @@ public DnsSdServiceFactory(Class aDiscoveryContainerClass) { /* (non-Javadoc) * @see org.osgi.framework.ServiceFactory#getService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration) */ + @SuppressWarnings("unchecked") public Object getService(Bundle bundle, ServiceRegistration registration) { if (container == null) { try { - container = (DnsSdDiscoveryContainerAdapter) containerClass.newInstance(); + container = (DnsSdDiscoveryContainerAdapter) containerClass.getDeclaredConstructor().newInstance(); container.connect(null, null); - } catch (final ContainerConnectException e) { - // may never happen - e.printStackTrace(); - container = null; - } catch (InstantiationException e) { - // may never happen - e.printStackTrace(); - container = null; - } catch (IllegalAccessException e) { + } catch (Exception e) { // may never happen e.printStackTrace(); container = null;