From: <pat...@us...> - 2011-02-18 03:21:27
|
Revision: 1217 http://cishell.svn.sourceforge.net/cishell/?rev=1217&view=rev Author: pataphil Date: 2011-02-18 03:21:21 +0000 (Fri, 18 Feb 2011) Log Message: ----------- * Improved Converter to have calculateLossiness method. * Trying to fix the build (ServiceReferenceDelegate.java) Modified Paths: -------------- trunk/core/org.cishell.framework/META-INF/MANIFEST.MF trunk/core/org.cishell.framework/src/org/cishell/framework/ServiceReferenceDelegate.java trunk/core/org.cishell.framework/src/org/cishell/service/conversion/Converter.java Modified: trunk/core/org.cishell.framework/META-INF/MANIFEST.MF =================================================================== --- trunk/core/org.cishell.framework/META-INF/MANIFEST.MF 2011-02-18 03:20:04 UTC (rev 1216) +++ trunk/core/org.cishell.framework/META-INF/MANIFEST.MF 2011-02-18 03:21:21 UTC (rev 1217) @@ -5,8 +5,7 @@ Bundle-Version: 1.0.0 Bundle-Vendor: Cyberinfrastructure for Network Science Center Bundle-RequiredExecutionEnvironment: J2SE-1.5 -Import-Package: org.eclipse.osgi.framework.internal.core, - org.osgi.framework, +Import-Package: org.osgi.framework, org.osgi.service.log, org.osgi.service.metatype, org.osgi.service.prefs Modified: trunk/core/org.cishell.framework/src/org/cishell/framework/ServiceReferenceDelegate.java =================================================================== --- trunk/core/org.cishell.framework/src/org/cishell/framework/ServiceReferenceDelegate.java 2011-02-18 03:20:04 UTC (rev 1216) +++ trunk/core/org.cishell.framework/src/org/cishell/framework/ServiceReferenceDelegate.java 2011-02-18 03:21:21 UTC (rev 1217) @@ -1,86 +1,96 @@ -package org.cishell.framework; +//package org.cishell.framework; +// +//import org.osgi.framework.ServiceReference; +// +// +//public class ServiceReferenceDelegate { +// public static ServiceReference createUniqueServiceReference( +// ServiceReference originalServiceReference) { +// originalServiceReference.getClass(). +// return null; +// } +//} -import java.lang.reflect.Field; - -import org.eclipse.osgi.framework.internal.core.ServiceReferenceImpl; -import org.eclipse.osgi.framework.internal.core.ServiceRegistrationImpl; -import org.osgi.framework.Bundle; -import org.osgi.framework.ServiceReference; - -public class ServiceReferenceDelegate extends ServiceReferenceImpl { - public static final String REGISTRATION_FIELD_NAME = - "org.eclipse.osgi.framework.internal.core.ServiceReferenceImpl.registration"; - - private static int nextUniqueID = 0; - - private ServiceReference actualServiceReference; - private int uniqueID; - - public ServiceReferenceDelegate(ServiceReference actualServiceReference) { - super(getServiceRegistration(actualServiceReference)); - this.actualServiceReference = actualServiceReference; - this.uniqueID = nextUniqueID; - nextUniqueID++; - - } - - public Object getProperty(String key) { - return this.actualServiceReference.getProperty(key); - } - - public String[] getPropertyKeys() { - return this.actualServiceReference.getPropertyKeys(); - } - - public Bundle getBundle() { - return this.actualServiceReference.getBundle(); - } - - public Bundle[] getUsingBundles() { - return this.actualServiceReference.getUsingBundles(); - } - - public boolean isAssignableTo(Bundle bundle, String className) { - return this.actualServiceReference.isAssignableTo(bundle, className); - } - - @Override - public int compareTo(Object reference) { - if (reference instanceof ServiceReferenceDelegate) { - ServiceReferenceDelegate otherDelegate = (ServiceReferenceDelegate) reference; - - return new Integer(this.uniqueID).compareTo(new Integer(otherDelegate.uniqueID)); - } else { - return this.actualServiceReference.compareTo(reference); - } - } - - @Override - public int hashCode() { - return this.actualServiceReference.hashCode() + new Integer(this.uniqueID).hashCode(); - } - - // TODO: Totally, disginstingly hacky. - private static ServiceRegistrationImpl getServiceRegistration( - ServiceReference actualServiceReference) { - try { - Field[] fields = actualServiceReference.getClass().getDeclaredFields(); - -// for (Field field : fields) { -// System.err.println(field); -// } - Field registrationField = fields[0]; -// actualServiceReference.getClass().getField(REGISTRATION_FIELD_NAME); - boolean isAccessible = registrationField.isAccessible(); - registrationField.setAccessible(true); - Object serviceRegistration = registrationField.get(actualServiceReference); - registrationField.setAccessible(isAccessible); - - return (ServiceRegistrationImpl) serviceRegistration; - } catch (IllegalAccessException e) { - throw new RuntimeException(e.getMessage(), e); - } /* catch (NoSuchFieldException e) { - throw new RuntimeException(e.getMessage(), e); - } */ - } -} \ No newline at end of file +// +//import org.eclipse.osgi.framework.internal.core.ServiceReferenceImpl; +//import org.eclipse.osgi.framework.internal.core.ServiceRegistrationImpl; +//import org.osgi.framework.Bundle; +//import org.osgi.framework.ServiceReference; +// +//public class ServiceReferenceDelegate extends ServiceReferenceImpl { +// public static final String REGISTRATION_FIELD_NAME = +// "org.eclipse.osgi.framework.internal.core.ServiceReferenceImpl.registration"; +// +// private static int nextUniqueID = 0; +// +// private ServiceReference actualServiceReference; +// private int uniqueID; +// +// public ServiceReferenceDelegate(ServiceReference actualServiceReference) { +// super(getServiceRegistration(actualServiceReference)); +// this.actualServiceReference = actualServiceReference; +// this.uniqueID = nextUniqueID; +// nextUniqueID++; +// +// } +// +// public Object getProperty(String key) { +// return this.actualServiceReference.getProperty(key); +// } +// +// public String[] getPropertyKeys() { +// return this.actualServiceReference.getPropertyKeys(); +// } +// +// public Bundle getBundle() { +// return this.actualServiceReference.getBundle(); +// } +// +// public Bundle[] getUsingBundles() { +// return this.actualServiceReference.getUsingBundles(); +// } +// +// public boolean isAssignableTo(Bundle bundle, String className) { +// return this.actualServiceReference.isAssignableTo(bundle, className); +// } +// +// @Override +// public int compareTo(Object reference) { +// if (reference instanceof ServiceReferenceDelegate) { +// ServiceReferenceDelegate otherDelegate = (ServiceReferenceDelegate) reference; +// +// return new Integer(this.uniqueID).compareTo(new Integer(otherDelegate.uniqueID)); +// } else { +// return this.actualServiceReference.compareTo(reference); +// } +// } +// +// @Override +// public int hashCode() { +// return this.actualServiceReference.hashCode() + new Integer(this.uniqueID).hashCode(); +// } +// +// // TODO: Totally, disginstingly hacky. +// private static ServiceRegistrationImpl getServiceRegistration( +// ServiceReference actualServiceReference) { +// try { +// Field[] fields = actualServiceReference.getClass().getDeclaredFields(); +// +//// for (Field field : fields) { +//// System.err.println(field); +//// } +// Field registrationField = fields[0]; +//// actualServiceReference.getClass().getField(REGISTRATION_FIELD_NAME); +// boolean isAccessible = registrationField.isAccessible(); +// registrationField.setAccessible(true); +// Object serviceRegistration = registrationField.get(actualServiceReference); +// registrationField.setAccessible(isAccessible); +// +// return (ServiceRegistrationImpl) serviceRegistration; +// } catch (IllegalAccessException e) { +// throw new RuntimeException(e.getMessage(), e); +// } /* catch (NoSuchFieldException e) { +// throw new RuntimeException(e.getMessage(), e); +// } */ +// } +//} \ No newline at end of file Modified: trunk/core/org.cishell.framework/src/org/cishell/service/conversion/Converter.java =================================================================== --- trunk/core/org.cishell.framework/src/org/cishell/service/conversion/Converter.java 2011-02-18 03:20:04 UTC (rev 1216) +++ trunk/core/org.cishell.framework/src/org/cishell/service/conversion/Converter.java 2011-02-18 03:21:21 UTC (rev 1217) @@ -65,4 +65,6 @@ * @throws ConversionException If the data conversion fails while converting */ public Data convert(Data data) throws ConversionException; + + public String calculateLossiness(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |