Skip to content

Commit

Permalink
Merge pull request #122 from scottslewis/master
Browse files Browse the repository at this point in the history
Fix for xbill.dns version
  • Loading branch information
scottslewis authored Aug 8, 2024
2 parents d741f84 + 55003b3 commit 3ee34c7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ 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
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
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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<String>="DNSSD,ecf.discovery.dnssd.locator,ecf.discovery.dnssd.advertiser";version:Version=1.1
4 changes: 2 additions & 2 deletions providers/bundles/org.eclipse.ecf.provider.dnssd/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<version>1.0.0-SNAPSHOT</version>
<relativePath>../../../</relativePath>
</parent>
<groupId>org.eclipse.ecf</groupId>

<artifactId>org.eclipse.ecf.provider.dnssd</artifactId>
<version>1.3.0-SNAPSHOT</version>
<version>1.3.100-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand All @@ -45,13 +44,15 @@ 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;

/*
* (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;

Expand All @@ -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));
Expand All @@ -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();) {
Expand All @@ -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);

Expand All @@ -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;
}

Expand All @@ -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) {
Expand All @@ -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();
}

Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 3ee34c7

Please sign in to comment.