diff options
author | slewis | 2018-04-02 20:15:49 +0000 |
---|---|---|
committer | slewis | 2018-04-02 20:15:49 +0000 |
commit | 4a57e441dc58fb13dd1ed03fbf564d2fb72e3b20 (patch) | |
tree | 3907300cae1f2135cb399e672c5761c5d4e948b0 /framework/bundles | |
parent | 26609be7053ab3524e383a75e11e2b0a25dfca2c (diff) | |
download | org.eclipse.ecf-4a57e441dc58fb13dd1ed03fbf564d2fb72e3b20.tar.gz org.eclipse.ecf-4a57e441dc58fb13dd1ed03fbf564d2fb72e3b20.tar.xz org.eclipse.ecf-4a57e441dc58fb13dd1ed03fbf564d2fb72e3b20.zip |
Additional fixes for bug
https://bugs.eclipse.org/bugs/show_bug.cgi?id=532205
Added support for osgi.basic serialization specification in the form of
org.eclipse.ecf.util.OSGIObjectOutputStream and OSGIObjectInputStream
Change-Id: Ic82780c6f4179a27928fb95261ad766be7ad4526
Diffstat (limited to 'framework/bundles')
34 files changed, 1299 insertions, 129 deletions
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/BaseID.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/BaseID.java index aa5e1cb25..1630a79b3 100644 --- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/BaseID.java +++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/BaseID.java @@ -26,7 +26,10 @@ public abstract class BaseID implements ID { protected Namespace namespace; - protected BaseID() { + /** + * @since 3.9 + */ + public BaseID() { // } @@ -125,16 +128,15 @@ public abstract class BaseID implements ID { /** * Called by {@link Namespace#getHashCodeForID(BaseID)}. * - * @return int hashCode for this ID. Returned value must be unique within - * this process. + * @return int hashCode for this ID. Returned value must be unique within this + * process. */ protected abstract int namespaceHashCode(); /** * Called by {@link Namespace#toExternalForm(BaseID)}. * - * @return String that represents this ID. Default implementation is to - * return + * @return String that represents this ID. Default implementation is to return * * <pre> * namespace.getScheme() + Namespace.SCHEME_SEPARATOR + namespaceGetName(); diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/GUID.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/GUID.java index c084da12d..666ea7239 100644 --- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/GUID.java +++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/GUID.java @@ -71,6 +71,13 @@ public class GUID extends StringID { protected static transient SecureRandom random; /** + * @since 3.9 + */ + public GUID() { + + } + + /** * Protected constructor for factory-based construction * * @param n diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/LongID.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/LongID.java index 9e3b94be8..52271c18e 100644 --- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/LongID.java +++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/LongID.java @@ -57,6 +57,13 @@ public class LongID extends BaseID { } } + /** + * @since 3.9 + */ + public LongID() { + + } + protected LongID(Namespace n, Long v) { super(n); value = v; diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/Namespace.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/Namespace.java index ad3c8ce99..f13ba0e97 100644 --- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/Namespace.java +++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/Namespace.java @@ -49,9 +49,9 @@ public abstract class Namespace implements Serializable, IAdaptable { private String description; - private int hashCode; + private transient int hashCode; - private boolean isInitialized = false; + private transient boolean isInitialized = false; public Namespace() { // public null constructor @@ -74,9 +74,9 @@ public abstract class Namespace implements Serializable, IAdaptable { } /** - * Override of Object.equals. This equals method returns true if the - * provided Object is also a Namespace instance, and the names of the two - * instances match. + * Override of Object.equals. This equals method returns true if the provided + * Object is also a Namespace instance, and the names of the two instances + * match. * * @param other * the Object to test for equality @@ -115,8 +115,8 @@ public abstract class Namespace implements Serializable, IAdaptable { } /** - * The default implementation of this method is to call - * id.namespaceGetName(). Subclasses may override. + * The default implementation of this method is to call id.namespaceGetName(). + * Subclasses may override. * * @param id * the ID to get the name for. Must not be <code>null</code>. @@ -142,14 +142,14 @@ public abstract class Namespace implements Serializable, IAdaptable { } /** - * The default implementation of this method is to call - * id.namespaceHashCode(). Subclasses may override. + * The default implementation of this method is to call id.namespaceHashCode(). + * Subclasses may override. * * @param id * the id in this Namespace to get the hashcode for. Must not be * <code>null</code>. - * @return the hashcode for the given id. Returned value must be unique - * within this process. + * @return the hashcode for the given id. Returned value must be unique within + * this process. */ protected int getHashCodeForID(BaseID id) { return id.namespaceHashCode(); @@ -161,11 +161,10 @@ public abstract class Namespace implements Serializable, IAdaptable { * * @param id * the id in this Namespace to convert to external form. - * @return String that represents the given id in an external form. Note - * that this external form may at some later time be passed to - * {@link #createInstance(Object[])} as a single String parameter, - * and should result in a valid ID instance of the appropriate - * Namespace. + * @return String that represents the given id in an external form. Note that + * this external form may at some later time be passed to + * {@link #createInstance(Object[])} as a single String parameter, and + * should result in a valid ID instance of the appropriate Namespace. */ protected String toExternalForm(BaseID id) { return id.namespaceToExternalForm(); @@ -174,9 +173,9 @@ public abstract class Namespace implements Serializable, IAdaptable { /** * Get the name of this namespace. Must not return <code>null</code>. * - * @return String name of Namespace instance. Must not return - * <code>null</code>, and the returned value should be a globally - * unique name for this Namespace subclass. + * @return String name of Namespace instance. Must not return <code>null</code>, + * and the returned value should be a globally unique name for this + * Namespace subclass. * */ public String getName() { @@ -184,8 +183,8 @@ public abstract class Namespace implements Serializable, IAdaptable { } /** - * Get the description, associated with this Namespace. The returned value - * may be <code>null</code>. + * Get the description, associated with this Namespace. The returned value may + * be <code>null</code>. * * @return the description associated with this Namespace. May be * <code>null</code>. @@ -195,9 +194,8 @@ public abstract class Namespace implements Serializable, IAdaptable { } /** - * Make an instance of this namespace. Namespace subclasses, provided by - * plugins must implement this method to construct ID instances for the - * given namespace. + * Make an instance of this namespace. Namespace subclasses, provided by plugins + * must implement this method to construct ID instances for the given namespace. * <p> * </p> * See {@link #getSupportedParameterTypes()} to get information relevant to @@ -206,8 +204,7 @@ public abstract class Namespace implements Serializable, IAdaptable { * </p> * * @param parameters - * an Object[] of parameters for creating ID instances. May be - * null. + * an Object[] of parameters for creating ID instances. May be null. * * @return a non-null ID instance. The class used may extend BaseID or may * implement the ID interface directly @@ -227,8 +224,8 @@ public abstract class Namespace implements Serializable, IAdaptable { public abstract String getScheme(); /** - * Get an array of schemes supported by this Namespace instance. Subclasses - * may override to support multiple schemes. + * Get an array of schemes supported by this Namespace instance. Subclasses may + * override to support multiple schemes. * * @return String[] of schemes supported by this Namespace. Will not be * <code>null</code>, but returned array may be of length 0. @@ -239,20 +236,20 @@ public abstract class Namespace implements Serializable, IAdaptable { /** * Get the supported parameter types for IDs created via subsequent calls to - * {@link #createInstance(Object[])}. Callers may use this method to - * determine the available parameter types, and then create and pass in - * conforming Object arrays to to {@link #createInstance(Object[])}. + * {@link #createInstance(Object[])}. Callers may use this method to determine + * the available parameter types, and then create and pass in conforming Object + * arrays to to {@link #createInstance(Object[])}. * <p> * </p> - * An empty two-dimensional array (new Class[0][0]) is the default returned - * by this abstract superclass. This means that the Object [] passed to + * An empty two-dimensional array (new Class[0][0]) is the default returned by + * this abstract superclass. This means that the Object [] passed to * {@link #createInstance(Object[])} will be ignored. * <p> * </p> - * Subsclasses should override this method to specify the parameters that - * they will accept in calls to {@link #createInstance(Object[])}. The rows - * of the returned Class array are the acceptable types for a given - * invocation of createInstance. + * Subsclasses should override this method to specify the parameters that they + * will accept in calls to {@link #createInstance(Object[])}. The rows of the + * returned Class array are the acceptable types for a given invocation of + * createInstance. * <p> * </p> * Consider the following example: @@ -265,10 +262,9 @@ public abstract class Namespace implements Serializable, IAdaptable { * } * </pre> * - * The above means that there are two acceptable values for the Object [] - * passed into {@link #createInstance(Object[])}: 1) a single String, and 2) - * two Strings. These would therefore be acceptable as input to - * createInstance: + * The above means that there are two acceptable values for the Object [] passed + * into {@link #createInstance(Object[])}: 1) a single String, and 2) two + * Strings. These would therefore be acceptable as input to createInstance: * * <pre> * ID newID1 = namespace.createInstance(new Object[] { "Hello" }); diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/NamespacePermission.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/NamespacePermission.java index 2053d1e14..b93dcacac 100644 --- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/NamespacePermission.java +++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/NamespacePermission.java @@ -26,6 +26,13 @@ public class NamespacePermission extends BasicPermission { protected String actions; + /** + * @since 3.9 + */ + public NamespacePermission() { + super("", ""); + } + public NamespacePermission(String s) { super(s); } diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/StringID.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/StringID.java index a11401e18..e5e1d8220 100644 --- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/StringID.java +++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/StringID.java @@ -33,8 +33,7 @@ public class StringID extends BaseID { return new StringID(this, init); return new StringID(this, (String) parameters[0]); } catch (Exception e) { - throw new IDCreateException(StringIDNamespace.this.getName() - + " createInstance()", e); //$NON-NLS-1$ + throw new IDCreateException(StringIDNamespace.this.getName() + " createInstance()", e); //$NON-NLS-1$ } } @@ -56,6 +55,13 @@ public class StringID extends BaseID { protected String value; /** + * @since 3.9 + */ + public StringID() { + + } + + /** * Protected constructor for factory-based construction * * @param n @@ -128,8 +134,7 @@ public class StringID extends BaseID { protected synchronized void setEmptyNamespace() { if (namespace == null) { - namespace = IDFactory.getDefault().getNamespaceByName( - StringID.class.getName()); + namespace = IDFactory.getDefault().getNamespaceByName(StringID.class.getName()); } } diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/URIID.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/URIID.java index 36454db99..a449926b5 100644 --- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/URIID.java +++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/URIID.java @@ -78,7 +78,14 @@ public class URIID extends BaseID implements IResourceID { } private static final long serialVersionUID = 7328962407044918278L; - private final URI uri; + private URI uri; + + /** + * @since 3.9 + */ + public URIID() { + + } public URIID(Namespace namespace, URI uri) { super(namespace); diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/UuID.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/UuID.java index 8e8675e90..8ce1b6559 100644 --- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/UuID.java +++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/UuID.java @@ -41,20 +41,16 @@ public class UuID extends BaseID { return new UuID(this, UUID.fromString(init)); if (parameters != null && parameters.length > 0) { if (parameters[0] instanceof String) - return new UuID(this, - UUID.fromString((String) parameters[0])); + return new UuID(this, UUID.fromString((String) parameters[0])); else if (parameters[0] instanceof URI) - return new UuID(this, - UUID.fromString(((URI) parameters[0]) - .getSchemeSpecificPart())); + return new UuID(this, UUID.fromString(((URI) parameters[0]).getSchemeSpecificPart())); else if (parameters[0] instanceof UUID) return new UuID(this, (UUID) parameters[0]); } // If we get here, then use random return new UuID(this, UUID.randomUUID()); } catch (Exception e) { - throw new IDCreateException(UuIDNamespace.this.getName() - + " createInstance()", e); //$NON-NLS-1$ + throw new IDCreateException(UuIDNamespace.this.getName() + " createInstance()", e); //$NON-NLS-1$ } } @@ -65,12 +61,18 @@ public class UuID extends BaseID { @Override public Class<?>[][] getSupportedParameterTypes() { - return new Class[][] { { String.class }, { UUID.class }, - { URI.class } }; + return new Class[][] { { String.class }, { UUID.class }, { URI.class } }; } } - protected final UUID uuid; + protected UUID uuid; + + /** + * @since 3.9 + */ + public UuID() { + + } protected UuID(UuIDNamespace ns, UUID uuid) { super(ns); diff --git a/framework/bundles/org.eclipse.ecf.provider/META-INF/MANIFEST.MF b/framework/bundles/org.eclipse.ecf.provider/META-INF/MANIFEST.MF index 63bee1165..c4282322a 100644 --- a/framework/bundles/org.eclipse.ecf.provider/META-INF/MANIFEST.MF +++ b/framework/bundles/org.eclipse.ecf.provider/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-SymbolicName: org.eclipse.ecf.provider;singleton:=true Automatic-Module-Name: org.eclipse.ecf.provider -Bundle-Version: 4.7.500.qualifier +Bundle-Version: 4.8.0.qualifier Bundle-Name: %plugin.name Bundle-Vendor: %plugin.provider Bundle-Activator: org.eclipse.ecf.internal.provider.ProviderPlugin @@ -12,7 +12,7 @@ Export-Package: org.eclipse.ecf.internal.provider;x-internal:=true, org.eclipse.ecf.provider.comm.tcp;version="4.3.0", org.eclipse.ecf.provider.generic;version="4.3.0", org.eclipse.ecf.provider.generic.gmm;version="4.3.0", - org.eclipse.ecf.provider.util;version="4.3.0" + org.eclipse.ecf.provider.util;version="4.4.0" Eclipse-BuddyPolicy: global Bundle-ManifestVersion: 2 Require-Bundle: org.eclipse.equinox.common;bundle-version="[3.0.0,4.0.0)", diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SOContainer.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SOContainer.java index a91051e64..a9acd3776 100644 --- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SOContainer.java +++ b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/SOContainer.java @@ -30,7 +30,6 @@ import org.eclipse.ecf.internal.provider.ProviderPlugin; import org.eclipse.ecf.provider.comm.*; import org.eclipse.ecf.provider.generic.ContainerMessage.SharedObjectMessage; import org.eclipse.ecf.provider.generic.gmm.Member; -import org.eclipse.ecf.provider.util.*; public abstract class SOContainer extends AbstractContainer implements ISharedObjectContainer { class LoadingSharedObject implements ISharedObject { @@ -484,6 +483,7 @@ public abstract class SOContainer extends AbstractContainer implements ISharedOb final ByteArrayOutputStream bos = new ByteArrayOutputStream(); final ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(obj); + oos.close(); return bos.toByteArray(); } @@ -991,6 +991,9 @@ public abstract class SOContainer extends AbstractContainer implements ISharedOb return getSharedObjectMessageSerializer().serializeMessage(sharedObjectID, message); } + private static final String SO_SERIALIZATION_OSGI = "osgi.basic"; //$NON-NLS-1$ + private static final String SO_SERIALIZATION_DEFAULT = System.getProperty("org.eclipse.ecf.provider.soserialization", SO_SERIALIZATION_OSGI); //$NON-NLS-1$ + /** * @param sharedObjectID shared object ID * @param message message @@ -1002,9 +1005,11 @@ public abstract class SOContainer extends AbstractContainer implements ISharedOb if (!(message instanceof Serializable)) throw new NotSerializableException("shared object=" + sharedObjectID + " message=" + message + " not serializable"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ final ByteArrayOutputStream bouts = new ByteArrayOutputStream(); - final IdentifiableObjectOutputStream ioos = new IdentifiableObjectOutputStream(sharedObjectID.getName(), bouts); - ioos.writeObject(message); - ioos.close(); + // If system property set to osgi.basic then use OSGIObjectOutputStream, if not then + // use ObjectOutputStream + final ObjectOutputStream oos = SO_SERIALIZATION_DEFAULT.equals(SO_SERIALIZATION_OSGI) ? new OSGIObjectOutputStream(bouts) : new ObjectOutputStream(bouts); + oos.writeObject(message); + oos.close(); return bouts.toByteArray(); } @@ -1017,38 +1022,12 @@ public abstract class SOContainer extends AbstractContainer implements ISharedOb */ protected Object defaultDeserializeSharedObjectMessage(byte[] bytes) throws IOException, ClassNotFoundException { final ByteArrayInputStream bins = new ByteArrayInputStream(bytes); - Object obj = null; - try { - final ObjectInputStream oins = ProviderPlugin.getDefault().createObjectInputStream(bins); - obj = oins.readObject(); - } catch (final ClassNotFoundException e) { - // first reset stream - bins.reset(); - // Now try with shared object classloader - final IdentifiableObjectInputStream iins = new IdentifiableObjectInputStream(new IClassLoaderMapper() { - public ClassLoader mapNameToClassLoader(String name) { - ISharedObjectManager manager = getSharedObjectManager(); - ID[] ids = manager.getSharedObjectIDs(); - ID found = null; - for (int i = 0; i < ids.length; i++) { - ID id = ids[i]; - if (name.equals(id.getName())) { - found = id; - break; - } - } - if (found == null) - return null; - ISharedObject obj1 = manager.getSharedObject(found); - if (obj1 == null) - return null; - return obj1.getClass().getClassLoader(); - } - }, bins); - obj = iins.readObject(); - iins.close(); - } - return obj; + // If system property set to osgi.basic then use OSGIObjectOutputStream, if not then + // use ObjectOutputStream + final ObjectInputStream oins = SO_SERIALIZATION_DEFAULT.equals(SO_SERIALIZATION_OSGI) ? new OSGIObjectInputStream(ProviderPlugin.getDefault().getContext().getBundle(), bins) : new ObjectInputStream(bins); + Object result = oins.readObject(); + oins.close(); + return result; } protected Object deserializeSharedObjectMessage(byte[] bytes) throws IOException, ClassNotFoundException { diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/util/IdentifiableObjectInputStream.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/util/IdentifiableObjectInputStream.java index a2bcf77e4..e48886169 100644 --- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/util/IdentifiableObjectInputStream.java +++ b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/util/IdentifiableObjectInputStream.java @@ -11,6 +11,8 @@ package org.eclipse.ecf.provider.util; import java.io.*; +import org.eclipse.ecf.core.util.OSGIObjectInputStream; +import org.osgi.framework.Bundle; /** * Restores Java objects from the underlying stream by using the classloader @@ -18,19 +20,27 @@ import java.io.*; * specified by the associated IdentifiableObjectOutputStream. * */ -public class IdentifiableObjectInputStream extends ObjectInputStream { +public class IdentifiableObjectInputStream extends OSGIObjectInputStream { IClassLoaderMapper mapper; public IdentifiableObjectInputStream(IClassLoaderMapper map, InputStream ins) throws IOException { - super(ins); + super(null, ins); this.mapper = map; } + /** + * @since 4.8 + */ + public IdentifiableObjectInputStream(Bundle b, InputStream ins) throws IOException { + super(b, ins); + } + /* * (non-Javadoc) * * @see java.io.ObjectInputStream#resolveClass(java.io.ObjectStreamClass) */ + @SuppressWarnings("unchecked") protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { String name = readUTF(); if (name == null || mapper == null) { diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/util/IdentifiableObjectOutputStream.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/util/IdentifiableObjectOutputStream.java index 135d5ddec..c32202107 100644 --- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/util/IdentifiableObjectOutputStream.java +++ b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/util/IdentifiableObjectOutputStream.java @@ -10,7 +10,9 @@ *******************************************************************************/ package org.eclipse.ecf.provider.util; -import java.io.*; +import java.io.IOException; +import java.io.OutputStream; +import org.eclipse.ecf.core.util.OSGIObjectOutputStream; /** * Stores Java objects in the underlying stream in an manner that allows @@ -18,7 +20,7 @@ import java.io.*; * classloader (via IClassLoaderMapper). * */ -public class IdentifiableObjectOutputStream extends ObjectOutputStream { +public class IdentifiableObjectOutputStream extends OSGIObjectOutputStream { String name = null; public IdentifiableObjectOutputStream(String name, OutputStream outs) throws IOException { diff --git a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/RemoteServiceRegistrationImpl.java b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/RemoteServiceRegistrationImpl.java index 63e196e81..61e64ac96 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/RemoteServiceRegistrationImpl.java +++ b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/RemoteServiceRegistrationImpl.java @@ -160,14 +160,16 @@ public class RemoteServiceRegistrationImpl implements IRemoteServiceRegistration */ private static final long serialVersionUID = -3684607010228779249L; + Map storedProps; + /** * Create a properties object for the service. * * @param props - * The properties for this service. + * Theproperties for this service. */ private Properties(int size, Dictionary props) { - super((size << 1) + 1); + this.storedProps = new HashMap(size); if (props != null) { synchronized (props) { @@ -186,8 +188,11 @@ public class RemoteServiceRegistrationImpl implements IRemoteServiceRegistration } } - protected Properties() { - super(); + /** + * @since 4.3 + */ + public Properties() { + this(null); } /** @@ -209,7 +214,7 @@ public class RemoteServiceRegistrationImpl implements IRemoteServiceRegistration * there is no property by that name. */ protected Object getProperty(String key) { - return (cloneValue(get(key))); + return this.storedProps.get(key); } /** @@ -218,14 +223,14 @@ public class RemoteServiceRegistrationImpl implements IRemoteServiceRegistration * @return The list of property key names. */ protected synchronized String[] getPropertyKeys() { - final int size = size(); + final int size = this.storedProps.size(); final String[] keynames = new String[size]; - final Enumeration keysEnum = keys(); + final Iterator iter = this.storedProps.keySet().iterator(); for (int i = 0; i < size; i++) { - keynames[i] = (String) keysEnum.nextElement(); + keynames[i] = (String) iter.next(); } return (keynames); @@ -240,8 +245,9 @@ public class RemoteServiceRegistrationImpl implements IRemoteServiceRegistration * Value of property. * @return previous property value. */ + @SuppressWarnings("unchecked") protected synchronized Object setProperty(String key, Object value) { - return (put(key, cloneValue(value))); + return this.storedProps.put(key, value); } /** @@ -255,6 +261,7 @@ public class RemoteServiceRegistrationImpl implements IRemoteServiceRegistration * object to be cloned. * @return cloned object or original object if we didn't clone it. */ + @SuppressWarnings("unchecked") protected static Object cloneValue(Object value) { if (value == null) { return null; @@ -308,7 +315,7 @@ public class RemoteServiceRegistrationImpl implements IRemoteServiceRegistration sb.append(key); sb.append('='); - final Object value = get(key); + final Object value = this.storedProps.get(key); if (value.getClass().isArray()) { sb.append('['); final int length = Array.getLength(value); @@ -330,6 +337,62 @@ public class RemoteServiceRegistrationImpl implements IRemoteServiceRegistration return (sb.toString()); } + + @Override + public int size() { + return this.storedProps.size(); + } + + @Override + public boolean isEmpty() { + return this.storedProps.isEmpty(); + } + + @Override + public Enumeration keys() { + final Iterator i = this.storedProps.keySet().iterator(); + return new Enumeration() { + + public boolean hasMoreElements() { + return i.hasNext(); + } + + public Object nextElement() { + return i.next(); + } + }; + } + + @Override + public Enumeration elements() { + final Iterator i = this.storedProps.values().iterator(); + return new Enumeration() { + + public boolean hasMoreElements() { + return i.hasNext(); + } + + public Object nextElement() { + return i.next(); + } + }; + } + + @Override + public Object get(Object key) { + return this.storedProps.get(key); + } + + @Override + public Object put(Object key, Object value) { + return this.storedProps.put(key, value); + } + + @Override + public Object remove(Object key) { + return this.storedProps.remove(key); + } + } public Object getProperty(String key) { diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/META-INF/MANIFEST.MF b/framework/bundles/org.eclipse.ecf.sharedobject/META-INF/MANIFEST.MF index 3663242e1..f67070605 100644 --- a/framework/bundles/org.eclipse.ecf.sharedobject/META-INF/MANIFEST.MF +++ b/framework/bundles/org.eclipse.ecf.sharedobject/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-Name: %plugin.name Bundle-SymbolicName: org.eclipse.ecf.sharedobject;singleton:=true Automatic-Module-Name: org.eclipse.ecf.sharedobject -Bundle-Version: 2.5.200.qualifier +Bundle-Version: 2.6.0.qualifier Bundle-Activator: org.eclipse.ecf.internal.core.sharedobject.Activator Bundle-Localization: plugin Bundle-Vendor: %plugin.provider diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ReplicaSharedObjectDescription.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ReplicaSharedObjectDescription.java index e144c00cd..082ed3d5c 100644 --- a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ReplicaSharedObjectDescription.java +++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/ReplicaSharedObjectDescription.java @@ -30,6 +30,13 @@ public class ReplicaSharedObjectDescription extends SharedObjectDescription impl protected long identifier; /** + * @since 2.6 + */ + public ReplicaSharedObjectDescription() { + + } + + /** * @since 2.3 */ public ReplicaSharedObjectDescription(SharedObjectTypeDescription type, ID soID, ID homeID) { diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectDescription.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectDescription.java index 0c8738feb..f935deb24 100644 --- a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectDescription.java +++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectDescription.java @@ -27,6 +27,13 @@ public class SharedObjectDescription implements Serializable { protected Map<String, ?> properties = null; /** + * @since 2.6 + */ + public SharedObjectDescription() { + + } + + /** * @since 2.3 */ public SharedObjectDescription(SharedObjectTypeDescription typeDescription, ID id, Map<String, ?> properties) { diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectMsgEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectMsgEvent.java index 4b4d30a37..a7f066159 100644 --- a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectMsgEvent.java +++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectMsgEvent.java @@ -22,6 +22,10 @@ public class SharedObjectMsgEvent extends RemoteSharedObjectEvent { private static final long serialVersionUID = -8674874265514762123L; + public SharedObjectMsgEvent() { + super(); + } + /** * @param senderObj * @param remoteCont diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectTypeDescription.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectTypeDescription.java index 2bf5a1d67..5ddf84192 100644 --- a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectTypeDescription.java +++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/SharedObjectTypeDescription.java @@ -34,6 +34,13 @@ public class SharedObjectTypeDescription implements Serializable { protected String className; + /** + * @since 2.6 + */ + public SharedObjectTypeDescription() { + + } + public SharedObjectTypeDescription(String name, ISharedObjectInstantiator instantiator, String desc, Map props) { this.name = name; this.instantiator = instantiator; diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/RemoteSharedObjectCreateResponseEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/RemoteSharedObjectCreateResponseEvent.java index 4bdd6965f..5691bdf4c 100644 --- a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/RemoteSharedObjectCreateResponseEvent.java +++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/RemoteSharedObjectCreateResponseEvent.java @@ -10,14 +10,19 @@ package org.eclipse.ecf.core.sharedobject.events; import org.eclipse.ecf.core.identity.ID; -public class RemoteSharedObjectCreateResponseEvent extends - RemoteSharedObjectEvent implements ISharedObjectCreateResponseEvent { +public class RemoteSharedObjectCreateResponseEvent extends RemoteSharedObjectEvent implements ISharedObjectCreateResponseEvent { private static final long serialVersionUID = 3618421544527738673L; long sequence = 0; - public RemoteSharedObjectCreateResponseEvent(ID senderObj, ID remoteCont, - long seq, Throwable exception) { + /** + * @since 2.6 + */ + public RemoteSharedObjectCreateResponseEvent() { + + } + + public RemoteSharedObjectCreateResponseEvent(ID senderObj, ID remoteCont, long seq, Throwable exception) { super(senderObj, remoteCont, exception); this.sequence = seq; } @@ -41,8 +46,7 @@ public class RemoteSharedObjectCreateResponseEvent extends } public String toString() { - StringBuffer sb = new StringBuffer( - "RemoteSharedObjectCreateResponseEvent["); //$NON-NLS-1$ + StringBuffer sb = new StringBuffer("RemoteSharedObjectCreateResponseEvent["); //$NON-NLS-1$ sb.append(getSenderSharedObjectID()).append(";"); //$NON-NLS-1$ sb.append(getRemoteContainerID()).append(";"); //$NON-NLS-1$ sb.append(getSequence()).append(";"); //$NON-NLS-1$ diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/RemoteSharedObjectEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/RemoteSharedObjectEvent.java index 65f2764b2..7cd537b7d 100644 --- a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/RemoteSharedObjectEvent.java +++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/RemoteSharedObjectEvent.java @@ -12,15 +12,20 @@ import java.io.Serializable; import org.eclipse.ecf.core.identity.ID; import org.eclipse.ecf.core.util.Event; -public class RemoteSharedObjectEvent implements ISharedObjectMessageEvent, - Serializable { +public class RemoteSharedObjectEvent implements ISharedObjectMessageEvent, Serializable { private static final long serialVersionUID = 3257572797621680182L; - private final ID senderSharedObjectID; + private ID senderSharedObjectID; - private final ID remoteContainerID; + private ID remoteContainerID; - private final Object data; + private Object data; + + /** + * @since 2.6 + */ + public RemoteSharedObjectEvent() { + } public RemoteSharedObjectEvent(ID senderObj, ID remoteCont, Object data) { super(); diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectActivatedEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectActivatedEvent.java index 99e9edff7..32cd41637 100644 --- a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectActivatedEvent.java +++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectActivatedEvent.java @@ -11,9 +11,16 @@ package org.eclipse.ecf.core.sharedobject.events; import org.eclipse.ecf.core.identity.ID; public class SharedObjectActivatedEvent implements ISharedObjectActivatedEvent { - private final ID activatedID; + private ID activatedID; - private final ID localContainerID; + private ID localContainerID; + + /** + * @since 2.6 + */ + public SharedObjectActivatedEvent() { + + } public SharedObjectActivatedEvent(ID container, ID act) { super(); diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectCallEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectCallEvent.java index 6b7379e9c..3eddb835e 100644 --- a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectCallEvent.java +++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectCallEvent.java @@ -23,6 +23,13 @@ public class SharedObjectCallEvent implements ISharedObjectCallEvent { IFuture result; /** + * @since 2.6 + */ + public SharedObjectCallEvent() { + + } + + /** * @since 2.0 */ public SharedObjectCallEvent(ID sender, Event evt, IFuture res) { diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectCommitEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectCommitEvent.java index 438b7deb5..55c22faa8 100644 --- a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectCommitEvent.java +++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectCommitEvent.java @@ -19,6 +19,13 @@ public class SharedObjectCommitEvent implements ISharedObjectCommitEvent, Serial Event event = null; + /** + * @since 2.6 + */ + public SharedObjectCommitEvent() { + + } + public SharedObjectCommitEvent(ID senderSharedObjectID, Event event) { super(); this.senderSharedObjectID = senderSharedObjectID; diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectDeactivatedEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectDeactivatedEvent.java index 40da70e02..e36873b62 100644 --- a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectDeactivatedEvent.java +++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectDeactivatedEvent.java @@ -11,9 +11,16 @@ package org.eclipse.ecf.core.sharedobject.events; import org.eclipse.ecf.core.identity.ID; public class SharedObjectDeactivatedEvent implements ISharedObjectDeactivatedEvent { - private final ID deactivatedID; + private ID deactivatedID; - private final ID localContainerID; + private ID localContainerID; + + /** + * @since 2.6 + */ + public SharedObjectDeactivatedEvent() { + + } public SharedObjectDeactivatedEvent(ID container, ID deact) { super(); diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerAddEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerAddEvent.java index e270b0fcb..452a83410 100644 --- a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerAddEvent.java +++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerAddEvent.java @@ -22,6 +22,13 @@ public class SharedObjectManagerAddEvent implements ISharedObjectManagerEvent { ID sharedObjectID = null; + /** + * @since 2.6 + */ + public SharedObjectManagerAddEvent() { + + } + public SharedObjectManagerAddEvent(ID localContainerID, ID sharedObjectID) { this.localContainerID = localContainerID; this.sharedObjectID = sharedObjectID; diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerConnectEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerConnectEvent.java index ab6e1a5e3..95de775c2 100644 --- a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerConnectEvent.java +++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerConnectEvent.java @@ -24,6 +24,13 @@ public class SharedObjectManagerConnectEvent implements ISharedObjectManagerConn ISharedObjectConnector connector = null; + /** + * @since 2.6 + */ + public SharedObjectManagerConnectEvent() { + + } + public SharedObjectManagerConnectEvent(ID localContainerID, ISharedObjectConnector connector) { this.localContainerID = localContainerID; this.connector = connector; diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerCreateEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerCreateEvent.java index ba8d88905..46e4dd17c 100644 --- a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerCreateEvent.java +++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerCreateEvent.java @@ -21,6 +21,13 @@ public class SharedObjectManagerCreateEvent implements ISharedObjectManagerEvent ID sharedObjectID = null; + /** + * @since 2.6 + */ + public SharedObjectManagerCreateEvent() { + + } + public SharedObjectManagerCreateEvent(ID localContainerID, ID sharedObjectID) { this.localContainerID = localContainerID; this.sharedObjectID = sharedObjectID; diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerDisconnectEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerDisconnectEvent.java index b94f5a952..44ad51347 100644 --- a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerDisconnectEvent.java +++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerDisconnectEvent.java @@ -24,6 +24,13 @@ public class SharedObjectManagerDisconnectEvent implements ISharedObjectManagerC ISharedObjectConnector connector = null; + /** + * @since 2.6 + */ + public SharedObjectManagerDisconnectEvent() { + + } + public SharedObjectManagerDisconnectEvent(ID localContainerID, ISharedObjectConnector connector) { this.localContainerID = localContainerID; this.connector = connector; diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerRemoveEvent.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerRemoveEvent.java index 9e2f8c260..1a6be7dfc 100644 --- a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerRemoveEvent.java +++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/events/SharedObjectManagerRemoveEvent.java @@ -21,6 +21,13 @@ public class SharedObjectManagerRemoveEvent implements ISharedObjectManagerEvent ID localContainerID = null; + /** + * @since 2.6 + */ + public SharedObjectManagerRemoveEvent() { + + } + public SharedObjectManagerRemoveEvent(ID localContainerID, ID sharedObjectID) { this.localContainerID = localContainerID; this.sharedObjectID = sharedObjectID; diff --git a/framework/bundles/org.eclipse.ecf/META-INF/MANIFEST.MF b/framework/bundles/org.eclipse.ecf/META-INF/MANIFEST.MF index 5412a9f3b..4e56599a0 100644 --- a/framework/bundles/org.eclipse.ecf/META-INF/MANIFEST.MF +++ b/framework/bundles/org.eclipse.ecf/META-INF/MANIFEST.MF @@ -22,6 +22,7 @@ Export-Package: org.eclipse.ecf.core;version="3.0.0", org.eclipse.ecf.internal.core;x-internal:=true Import-Package: org.eclipse.core.runtime.jobs, org.eclipse.equinox.concurrent.future;version="[1.0.0,2.0.0)";x-installation:=greedy, + org.osgi.dto;version="1.0.0", org.osgi.framework;version="[1.3.0,2.0.0)", org.osgi.service.log;version="[1.3.0,2.0.0)", org.osgi.util.tracker;version="[1.3.2,2.0.0)" @@ -30,3 +31,4 @@ Require-Bundle: org.eclipse.equinox.common;bundle-version="[3.0.0,4.0.0)", org.eclipse.ecf.identity;visibility:=reexport Bundle-ActivationPolicy: lazy Provide-Capability: ecf.containertype;names:List<String>="ecf.base"; version:Version=3.3 +DynamicImport-Package: * diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/util/OSGIObjectInputStream.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/util/OSGIObjectInputStream.java new file mode 100644 index 000000000..c29b6ac01 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/util/OSGIObjectInputStream.java @@ -0,0 +1,449 @@ +/******************************************************************************* + * Copyright (c) 2018 Composent, Inc. 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 + * + * Contributors: Composent, Inc. - initial API and implementation + ******************************************************************************/ +package org.eclipse.ecf.core.util; + +import java.io.*; +import java.lang.reflect.*; +import java.util.*; +import org.osgi.framework.Bundle; +import org.osgi.framework.Version; +import org.osgi.service.log.LogService; + +/** + * @since 3.9 + */ +public class OSGIObjectInputStream extends ObjectInputStream implements OSGIObjectStreamConstants { + + protected final ObjectInputStream in; + protected final Bundle b; + protected LogService logger; + + public OSGIObjectInputStream(Bundle b, InputStream in, LogService logger) throws IOException { + super(); + this.b = b; + this.in = new ObjectInputStream(in); + this.logger = logger; + } + + public OSGIObjectInputStream(Bundle b, InputStream in) throws IOException { + this(b, in, null); + } + + public void setLogService(LogService log) { + this.logger = log; + } + + protected void trace(String message) { + LogService ls = this.logger; + if (ls != null) { + ls.log(LogService.LOG_DEBUG, message); + } + } + + protected Class loadClass(String classname) throws ClassNotFoundException { + Bundle bundle = b; + return (bundle == null) ? Class.forName(classname) : bundle.loadClass(classname); + } + + protected Class<?> getClassForType(String type) throws ClassNotFoundException { + if (type.equals(byte.class.getName())) + return byte.class; + else if (type.equals(long.class.getName())) + return long.class; + else if (type.equals(int.class.getName())) + return int.class; + else if (type.equals(short.class.getName())) + return short.class; + else if (type.equals(char.class.getName())) + return char.class; + else if (type.equals(boolean.class.getName())) + return boolean.class; + else if (type.equals(float.class.getName())) + return float.class; + else if (type.equals(double.class.getName())) + return double.class; + else + return loadClass(type); + } + + protected final Object readObjectOverride() throws IOException, ClassNotFoundException { + final byte type = in.readByte(); + switch (type) { + case C_NULL : // null + trace("null"); //$NON-NLS-1$ + return null; + case C_SER : // Serializable + trace("readSerializedObject"); //$NON-NLS-1$ + return readSerializedObject(); + case C_VER : // Version + trace("readVersion"); //$NON-NLS-1$ + return Version.parseVersion(in.readUTF()); + case C_ARRAY : // Object[] + // read array length + trace("readArray"); //$NON-NLS-1$ + int ol = in.readInt(); + // read component type and create array for that component type + Class<?> clazz = getClassForType(in.readUTF()); + Object oresult = Array.newInstance(clazz, ol); + for (int i = 0; i < ol; i++) + Array.set(oresult, i, readObjectOverride()); + return oresult; + case C_DTO : // DTO + trace("readDTO"); //$NON-NLS-1$ + return readDTO(); + case C_DICT : // Dictionary + trace("readDictionary"); //$NON-NLS-1$ + Class<?> dictClazz = loadClass(in.readUTF()); + Dictionary dict = null; + Constructor cons; + try { + cons = dictClazz.getDeclaredConstructor((Class[]) null); + cons.setAccessible(true); + dict = (Dictionary) cons.newInstance((Object[]) null); + } catch (Exception e) { + throw new IOException("Could not create dictionary instance of clazz=" + dictClazz.getName()); //$NON-NLS-1$ + } + int dsize = in.readInt(); + for (int i = 0; i < dsize; i++) { + Object key = readObjectOverride(); + Object val = readObjectOverride(); + dict.put(key, val); + } + return dict; + case C_MAP : // Map + // read map length + int ms = in.readInt(); + trace("readMap=" + ms); //$NON-NLS-1$ + Map mr = new HashMap(); + for (int i = 0; i < ms; i++) { + Object key = readObjectOverride(); + Object val = readObjectOverride(); + mr.put(key, val); + } + return mr; + case C_LIST : // List + int lsize = in.readInt(); + trace("readList=" + lsize); //$NON-NLS-1$ + List l = new ArrayList(lsize); + for (int i = 0; i < lsize; i++) + l.add(readObjectOverride()); + return l; + case C_SET : // Set + int ssize = in.readInt(); + trace("readSet=" + ssize); //$NON-NLS-1$ + Set s = new HashSet(ssize); + for (int i = 0; i < ssize; i++) + s.add(readObjectOverride()); + return s; + case C_COLL : // Collection + int csize = in.readInt(); + trace("readCol=" + csize); //$NON-NLS-1$ + Collection c = new ArrayList(csize); + for (int i = 0; i < csize; i++) + c.add(readObjectOverride()); + return c; + case C_ITER : // Iterable + int isize = in.readInt(); + trace("readIter=" + isize); //$NON-NLS-1$ + List itr = new ArrayList(isize); + for (int i = 0; i < isize; i++) + itr.add(readObjectOverride()); + return itr; + case C_EXTER : // Externalizable + return readExternalizable(); + case C_STRING : // String + trace("readString"); //$NON-NLS-1$ + return in.readUTF(); + case C_LONG : + case C_OLONG : + trace("readLong"); //$NON-NLS-1$ + return in.readLong(); + case C_INT : + case C_OINT : + trace("readInt"); //$NON-NLS-1$ + return in.readInt(); + case C_SHORT : + case C_OSHORT : + trace("readShort"); //$NON-NLS-1$ + return in.readShort(); + case C_BOOL : + case C_OBOOL : + trace("readBool"); //$NON-NLS-1$ + return in.readBoolean(); + case C_BYTE : + case C_OBYTE : + trace("readByte"); //$NON-NLS-1$ + return in.readByte(); + case C_CHAR : + case C_OCHAR : + trace("readChar"); //$NON-NLS-1$ + return in.readChar(); + case C_DOUBLE : + case C_ODOUBLE : + trace("readDouble"); //$NON-NLS-1$ + return in.readDouble(); + case C_FLOAT : + case C_OFLOAT : + trace("readFloat"); //$NON-NLS-1$ + return in.readFloat(); + case C_ENUM : + trace("readEnum"); //$NON-NLS-1$ + return in.readObject(); + case C_OBJECT : + return readNonSerializedObject(); + default : + throw new IOException("Cannot deserialize object with type=" + type); //$NON-NLS-1$ + } + } + + private Object readDTO() throws IOException, ClassNotFoundException { + Class<?> clazz = loadClass(in.readUTF()); + Object result = null; + try { + result = clazz.newInstance(); + for (Field f : clazz.getFields()) { + final int mod = f.getModifiers(); + // If it's static or transient then ignore + if (Modifier.isStatic(mod) || Modifier.isTransient(mod)) + continue; + // Else read and set value of field + f.set(result, readObjectOverride()); + } + } catch (Exception e) { + throw new IOException("Cannot deserialize DTO because of exception: " + e.getMessage()); //$NON-NLS-1$ + } + return result; + } + + private Object createInstance(ObjectStreamClass osc) throws IOException { + try { + Method m = osc.getClass().getDeclaredMethod("newInstance", (Class<?>[]) null); //$NON-NLS-1$ + m.setAccessible(true); + return m.invoke(osc, (Object[]) null); + } catch (Exception e) { + throw new IOException("Exception creating newInstance of class=" + osc.getName()); //$NON-NLS-1$ + } + } + + protected Object readExternalizable() throws ClassNotFoundException, IOException { + final String clazzName = in.readUTF(); + trace("readExternalizable " + clazzName); //$NON-NLS-1$ + Class<?> clazz = loadClass(clazzName); + Object inst = createInstance(clazz); + Externalizable ex = (Externalizable) inst; + ex.readExternal(this); + return inst; + } + + protected Object readFields(Class<?> clazz, Object inst) throws IOException { + try { + int fieldCount = in.readInt(); + while (fieldCount > -1) { + for (int i = 0; i < fieldCount; i++) { + final String fieldName = in.readUTF(); + final Field field = clazz.getDeclaredField(fieldName); + final int mod = field.getModifiers(); + if (!Modifier.isPublic(mod)) + field.setAccessible(true); + + // + final Object value = readObjectOverride(); + field.set(inst, value); + } + clazz = clazz.getSuperclass(); + fieldCount = in.readInt(); + } + return inst; + } catch (final Exception e) { + throw new IOException("Error while deserializing class=" + clazz.getName() + ": " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + + protected Object createInstance(Class<?> clazz) throws IOException { + try { + return clazz.newInstance(); + } catch (Exception e) { + throw new IOException("Could create new instance of class=" + clazz.getName() + ". Class must have public no-arg constructor"); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + + protected Object readNonSerializedObject() throws IOException, ClassNotFoundException { + // read object stream class + String className = in.readUTF(); + trace("readNonSerializedObject " + className); //$NON-NLS-1$ + Class<?> clazz = loadClass(className); + // create instance + Object instance = createInstance(clazz); + return readFields(clazz, instance); + } + + protected Object readSerializedObject() throws IOException, ClassNotFoundException { + // read object stream class + ObjectStreamClass osc = (ObjectStreamClass) in.readObject(); + trace("readSerializedObject " + osc.getName()); //$NON-NLS-1$ + Class<?> clazz = osc.forClass(); + // create instance + final Object instance = createInstance(osc); + return readFields(clazz, instance); + } + + /** + * + * @see java.io.ObjectInputStream#read() + */ + public final int read() throws IOException { + return in.read(); + } + + /** + * + * @see java.io.ObjectInputStream#read(byte[], int, int) + */ + public final int read(final byte[] buf, final int off, final int len) throws IOException { + return in.read(buf, off, len); + } + + /** + * + * @see java.io.ObjectInputStream#available() + */ + public final int available() throws IOException { + return in.available(); + } + + /** + * + * @see java.io.ObjectInputStream#close() + */ + public final void close() throws IOException { + in.close(); + } + + /** + * + * @see java.io.ObjectInputStream#readBoolean() + */ + public final boolean readBoolean() throws IOException { + return in.readBoolean(); + } + + /** + * + * @see java.io.ObjectInputStream#readByte() + */ + public final byte readByte() throws IOException { + return in.readByte(); + } + + /** + * + * @see java.io.ObjectInputStream#readUnsignedByte() + */ + public final int readUnsignedByte() throws IOException { + return in.readUnsignedByte(); + } + + /** + * + * @see java.io.ObjectInputStream#readChar() + */ + public final char readChar() throws IOException { + return in.readChar(); + } + + /** + * + * @see java.io.ObjectInputStream#readShort() + */ + public final short readShort() throws IOException { + return in.readShort(); + } + + /** + * + * @see java.io.ObjectInputStream#readUnsignedShort() + */ + public final int readUnsignedShort() throws IOException { + return in.readUnsignedShort(); + } + + /** + * + * @see java.io.ObjectInputStream#readInt() + */ + public final int readInt() throws IOException { + return in.readInt(); + } + + /** + * + * @see java.io.ObjectInputStream#readLong() + */ + public final long readLong() throws IOException { + return in.readLong(); + } + + /** + * + * @see java.io.ObjectInputStream#readFloat() + */ + public final float readFloat() throws IOException { + return in.readFloat(); + } + + /** + * + * @see java.io.ObjectInputStream#readDouble() + */ + public final double readDouble() throws IOException { + return in.readDouble(); + } + + /** + * + * @see java.io.ObjectInputStream#readFully(byte[]) + */ + public final void readFully(final byte[] buf) throws IOException { + in.readFully(buf); + } + + /** + * + * @see java.io.ObjectInputStream#readFully(byte[], int, int) + */ + public final void readFully(final byte[] buf, final int off, final int len) throws IOException { + in.readFully(buf, off, len); + } + + /** + * + * @see java.io.ObjectInputStream#skipBytes(int) + */ + public final int skipBytes(final int len) throws IOException { + return in.skipBytes(len); + } + + /** + * @return String + * @throws IOException + * @deprecated + */ + public final String readLine() throws IOException { + return in.readLine(); + } + + /** + * + * @see java.io.ObjectInputStream#readUTF() + */ + public final String readUTF() throws IOException { + return in.readUTF(); + } + +} diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/util/OSGIObjectOutputStream.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/util/OSGIObjectOutputStream.java new file mode 100644 index 000000000..fb207aa48 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/util/OSGIObjectOutputStream.java @@ -0,0 +1,479 @@ +/******************************************************************************* + * Copyright (c) 2018 Composent, Inc. 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 + * + * Contributors: Composent, Inc. - initial API and implementation + ******************************************************************************/ +package org.eclipse.ecf.core.util; + +import java.io.*; +import java.lang.reflect.*; +import java.util.*; +import org.osgi.dto.DTO; +import org.osgi.framework.Version; +import org.osgi.service.log.LogService; + +/** + * @since 3.9 + */ +public class OSGIObjectOutputStream extends ObjectOutputStream implements OSGIObjectStreamConstants { + + protected final ObjectOutputStream out; + protected LogService logger; + protected boolean allowNonSerializable = false; + + public OSGIObjectOutputStream(OutputStream out, boolean allowNonSerializable, LogService log) throws IOException { + super(); + this.out = new ObjectOutputStream(out); + this.allowNonSerializable = allowNonSerializable; + this.logger = log; + } + + public OSGIObjectOutputStream(OutputStream out, boolean allowNonSerializable) throws IOException { + this(out, allowNonSerializable, null); + } + + public OSGIObjectOutputStream(OutputStream out) throws IOException { + this(out, false, null); + } + + public void setAllowNonSerializable(boolean value) { + this.allowNonSerializable = value; + } + + public void setLogService(LogService log) { + this.logger = log; + } + + protected void writeExternalizable(Externalizable obj, Class<?> clazz) throws IOException { + trace("writeExternalizable " + clazz.getName()); //$NON-NLS-1$ + obj.writeExternal(this); + } + + protected void trace(String message) { + LogService ls = this.logger; + if (ls != null) { + ls.log(LogService.LOG_DEBUG, message); + } + } + + protected void writeFields(Object obj, Class<?> clazz) throws IOException { + while (clazz != Object.class) { + try { + final Field[] allFields = clazz.getDeclaredFields(); + final int allFieldCount = allFields.length; + int actualFieldCount = 0; + for (int i = 0; i < allFieldCount; i++) { + final int mod = allFields[i].getModifiers(); + if (!(Modifier.isStatic(mod) || Modifier.isTransient(mod))) + actualFieldCount++; + } + // write field count + out.writeInt(actualFieldCount); + for (int i = 0; i < allFieldCount; i++) { + final int mod = allFields[i].getModifiers(); + if (Modifier.isStatic(mod) || Modifier.isTransient(mod)) + continue; + else if (!Modifier.isPublic(mod)) + allFields[i].setAccessible(true); + // write field name + out.writeUTF(allFields[i].getName()); + // field value + writeObjectOverride(allFields[i].get(obj)); + } + } catch (final Exception e) { + throw new NotSerializableException("Exception while serializing " + obj.toString() //$NON-NLS-1$ + + ":\n" + e.getMessage()); //$NON-NLS-1$ + } + clazz = clazz.getSuperclass(); + } + // Write out a terminator so reader can detect end of object + out.writeInt(-1); + } + + protected void writeNonSerializable(Object obj, Class<?> clazz) throws IOException { + // lookup object stream class + trace("writeNonSerializable " + clazz.getName()); //$NON-NLS-1$ + // write class name + out.writeObject(clazz.getName()); + writeFields(obj, clazz); + } + + protected void writeSerializable(Object obj, Class<?> clazz) throws IOException { + // lookup object stream class + trace("writeSerializable " + clazz.getName()); //$NON-NLS-1$ + // write the osc + out.writeObject(ObjectStreamClass.lookup(clazz)); + writeFields(obj, clazz); + } + + @Override + protected void writeObjectOverride(Object obj) throws IOException { + if (obj == null) { + out.writeByte(C_NULL); + return; + } + Class<?> clazz = obj.getClass(); + if (clazz.isArray()) { + trace("writing array"); //$NON-NLS-1$ + out.writeByte(C_ARRAY); + int len = Array.getLength(obj); + // write length + out.writeInt(len); + // write component type + out.writeUTF(clazz.getComponentType().getName()); + // write out each array entry + for (int i = 0; i < len; i++) + writeObjectOverride(Array.get(obj, i)); + return; + } else if (obj instanceof Long) { + trace("writing Long"); //$NON-NLS-1$ + if (clazz.isPrimitive()) { + trace("writing long"); //$NON-NLS-1$ + out.writeByte(C_LONG); + } else { + trace("writing Long"); //$NON-NLS-1$ + out.writeByte(C_OLONG); + } + out.writeLong((Long) obj); + return; + } else if (obj instanceof Integer) { + if (clazz.isPrimitive()) { + trace("writing int"); //$NON-NLS-1$ + out.writeByte(C_INT); + } else { + trace("writing Integer"); //$NON-NLS-1$ + out.writeByte(C_OINT); + } + out.writeInt((Integer) obj); + return; + } else if (obj instanceof Short) { + if (clazz.isPrimitive()) { + trace("writing short"); //$NON-NLS-1$ + out.writeByte(C_SHORT); + } else { + trace("writing Short"); //$NON-NLS-1$ + out.writeByte(C_OSHORT); + } + out.writeShort((Short) obj); + return; + } else if (obj instanceof Boolean) { + if (clazz.isPrimitive()) { + trace("writing bool"); //$NON-NLS-1$ + out.writeByte(C_BOOL); + } else { + trace("writing Boolean"); //$NON-NLS-1$ + out.writeByte(C_OBOOL); + } + out.writeBoolean((Boolean) obj); + return; + } else if (obj instanceof Byte) { + if (clazz.isPrimitive()) { + trace("writing byte"); //$NON-NLS-1$ + out.writeByte(C_BYTE); + } else { + trace("writing Byte"); //$NON-NLS-1$ + out.writeByte(C_OBYTE); + } + out.writeByte((Byte) obj); + return; + } else if (obj instanceof Character) { + if (clazz.isPrimitive()) { + trace("writing char"); //$NON-NLS-1$ + out.writeByte(C_CHAR); + } else { + trace("writing Character"); //$NON-NLS-1$ + out.writeByte(C_OCHAR); + } + out.writeChar((Character) obj); + return; + } else if (obj instanceof Float) { + if (clazz.isPrimitive()) { + trace("writing float"); //$NON-NLS-1$ + out.writeByte(C_FLOAT); + } else { + trace("writing Float"); //$NON-NLS-1$ + out.writeByte(C_OFLOAT); + } + out.writeFloat((Float) obj); + return; + } else if (obj instanceof Double) { + if (clazz.isPrimitive()) { + trace("writing double"); //$NON-NLS-1$ + out.writeByte(C_DOUBLE); + } else { + trace("writing Double"); //$NON-NLS-1$ + out.writeByte(C_ODOUBLE); + } + out.writeDouble((Double) obj); + return; + } else if (obj instanceof String) { + trace("writing String"); //$NON-NLS-1$ + out.writeByte(C_STRING); + out.writeUTF((String) obj); + return; + } else if (obj instanceof Dictionary) { + trace("writing dictionary"); //$NON-NLS-1$ + out.writeByte(C_DICT); + out.writeUTF(clazz.getName()); + Dictionary dict = (Dictionary) obj; + // write size + int ds = dict.size(); + trace("writing Dictionary=" + ds); //$NON-NLS-1$ + out.writeInt(ds); + // for each element in Map + for (Enumeration e = dict.keys(); e.hasMoreElements();) { + Object key = e.nextElement(); + writeObjectOverride(key); + writeObjectOverride(dict.get(key)); + } + return; + } else if (obj instanceof Map) { + out.writeByte(C_MAP); + Map map = (Map) obj; + // write size + int size = map.size(); + trace("writing Map=" + size); //$NON-NLS-1$ + out.writeInt(size); + // for each element in Map + for (Object key : map.keySet()) { + // Write key + writeObjectOverride(key); + // Write value + writeObjectOverride(map.get(key)); + } + return; + } else if (obj instanceof List) { + out.writeByte(C_LIST); + List list = (List) obj; + // write size + int size = list.size(); + trace("writing List=" + size); //$NON-NLS-1$ + out.writeInt(size); + // write each element + for (Object item : list) + writeObjectOverride(item); + return; + } else if (obj instanceof Set) { + out.writeByte(C_SET); + Set set = (Set) obj; + // write size + int size = set.size(); + trace("writing Set=" + size); //$NON-NLS-1$ + out.writeInt(size); + // then elements + for (Object item : set) + writeObjectOverride(item); + return; + } else if (obj instanceof Collection) { + out.writeByte(C_COLL); + Collection col = (Collection) obj; + // write size + int size = col.size(); + trace("writing col=" + size); //$NON-NLS-1$ + out.writeInt(size); + // then elements + for (Object item : col) + writeObjectOverride(item); + return; + } else if (obj instanceof Iterable) { + out.writeByte(C_ITER); + Iterable itr = (Iterable) obj; + int size = 0; + // Get size + for (@SuppressWarnings("unused") + Object v : itr) + size++; + // write size + trace("writing Iterable=" + size); //$NON-NLS-1$ + out.writeInt(size); + // write elements + for (Object item : itr) + writeObjectOverride(item); + return; + } else if (obj instanceof Externalizable) { + out.writeByte(C_EXTER); + writeExternalizable((Externalizable) obj, clazz); + } else if (obj instanceof Serializable) { + out.writeByte(C_SER); + writeSerializable(obj, clazz); + return; + } else if (obj instanceof Version) { + trace("writing Version"); //$NON-NLS-1$ + out.writeByte(C_VER); + out.writeUTF(((Version) obj).toString()); + return; + } else if (obj instanceof DTO) { + out.writeByte(C_DTO); + writeDTO(obj, clazz); + return; + } else if (obj instanceof Enum) { + out.writeByte(C_ENUM); + out.writeObject(obj); + return; + } else { + if (allowNonSerializable) { + out.writeByte(C_OBJECT); + writeNonSerializable(obj, clazz); + return; + } + throw new NotSerializableException("Cannot serialize instance of class=" + clazz.getName()); //$NON-NLS-1$ + } + } + + private void writeDTO(Object obj, Class<?> clazz) throws IOException { + trace("writing DTO"); //$NON-NLS-1$ + // Write out class name + out.writeUTF(clazz.getName()); + for (Field f : clazz.getFields()) { + final int mod = f.getModifiers(); + if (Modifier.isStatic(mod) || Modifier.isTransient(mod)) + continue; + try { + writeObjectOverride(f.get(obj)); + } catch (Exception e) { + // Should not happen for DTO + throw new NotSerializableException(clazz.getName()); + } + } + } + + /** + * + * @see java.io.ObjectOutputStream#write(int) + */ + public final void write(final int val) throws IOException { + out.write(val); + } + + /** + * + * @see java.io.ObjectOutputStream#write(byte[]) + */ + public final void write(final byte[] buf) throws IOException { + out.write(buf); + } + + /** + * + * @see java.io.ObjectOutputStream#write(byte[], int, int) + */ + public final void write(final byte[] buf, final int off, final int len) throws IOException { + out.write(buf, off, len); + } + + /** + * + * @see java.io.ObjectOutputStream#flush() + */ + public final void flush() throws IOException { + out.flush(); + } + + /** + * + * @see java.io.ObjectOutputStream#reset() + */ + public final void reset() throws IOException { + out.reset(); + } + + /** + * + * @see java.io.ObjectOutputStream#close() + */ + public final void close() throws IOException { + out.close(); + } + + /** + * + * @see java.io.ObjectOutputStream#writeBoolean(boolean) + */ + public final void writeBoolean(final boolean val) throws IOException { + out.writeBoolean(val); + } + + /** + * + * @see java.io.ObjectOutputStream#writeByte(int) + */ + public final void writeByte(final int val) throws IOException { + out.writeByte(val); + } + + /** + * + * @see java.io.ObjectOutputStream#writeShort(int) + */ + public final void writeShort(final int val) throws IOException { + out.writeShort(val); + } + + /** + * + * @see java.io.ObjectOutputStream#writeChar(int) + */ + public final void writeChar(final int val) throws IOException { + out.writeChar(val); + } + + /** + * + * @see java.io.ObjectOutputStream#writeInt(int) + */ + public final void writeInt(final int val) throws IOException { + out.writeInt(val); + } + + /** + * + * @see java.io.ObjectOutputStream#writeLong(long) + */ + public final void writeLong(final long val) throws IOException { + out.writeLong(val); + } + + /** + * + * @see java.io.ObjectOutputStream#writeFloat(float) + */ + public final void writeFloat(final float val) throws IOException { + out.writeFloat(val); + } + + /** + * + * @see java.io.ObjectOutputStream#writeDouble(double) + */ + public final void writeDouble(final double val) throws IOException { + out.writeDouble(val); + } + + /** + * + * @see java.io.ObjectOutputStream#writeBytes(java.lang.String) + */ + public final void writeBytes(final String str) throws IOException { + out.writeBytes(str); + } + + /** + * + * @see java.io.ObjectOutputStream#writeChars(java.lang.String) + */ + public final void writeChars(final String str) throws IOException { + out.writeChars(str); + } + + /** + * + * @see java.io.ObjectOutputStream#writeUTF(java.lang.String) + */ + public final void writeUTF(final String str) throws IOException { + out.writeUTF(str); + } + +} diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/util/OSGIObjectStreamConstants.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/util/OSGIObjectStreamConstants.java new file mode 100644 index 000000000..b1cfaaa77 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/util/OSGIObjectStreamConstants.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2018 Composent, Inc. 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 + * + * Contributors: Composent, Inc. - initial API and implementation + ******************************************************************************/ +package org.eclipse.ecf.core.util; + +/** + * @since 3.9 + */ +public interface OSGIObjectStreamConstants { + + public static final byte C_NULL = 0; // null + public static final byte C_SER = 1; // Serializable + public static final byte C_VER = 2; // Version + public static final byte C_ARRAY = 3; // array + public static final byte C_DTO = 4; // DTO + public static final byte C_MAP = 5; // Map + public static final byte C_LIST = 6; // List + public static final byte C_SET = 7; // Set + public static final byte C_COLL = 8; // Collection + public static final byte C_ITER = 9; // Iterable + public static final byte C_EXTER = 10; // Externalizable + public static final byte C_STRING = 11; // String + public static final byte C_ENUM = 12; // Enum + public static final byte C_OBJECT = 13; // Everything else + public static final byte C_DICT = 14; // Dictionary + + // primitive types + public static final byte C_LONG = 20; // primitive long + public static final byte C_INT = 21; // primitive int + public static final byte C_SHORT = 22; // prim short + public static final byte C_BOOL = 23; // prim boolean + public static final byte C_BYTE = 24; // prim byte + public static final byte C_CHAR = 25; // primp character + public static final byte C_DOUBLE = 26; // prim double + public static final byte C_FLOAT = 27; // prim float + + // simple object types + public static final byte C_OLONG = 30; // Long + public static final byte C_OINT = 31; // Integer + public static final byte C_OSHORT = 32; // Short + public static final byte C_OBOOL = 33; // Boolean + public static final byte C_OBYTE = 34; // Byte + public static final byte C_OCHAR = 35; // Character + public static final byte C_ODOUBLE = 36; // Double + public static final byte C_OFLOAT = 37; // Float + +} diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/ECFPlugin.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/ECFPlugin.java index b74ca9ac1..3ebb5efdc 100644 --- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/ECFPlugin.java +++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/ECFPlugin.java @@ -98,6 +98,10 @@ public class ECFPlugin implements BundleActivator { return plugin; } + public BundleContext getContext() { + return context; + } + public ECFPlugin() { // null constructor } |