geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aba...@apache.org
Subject [26/51] [partial] incubator-geode git commit: GEODE-917: rename gemfire subprojects to geode
Date Wed, 17 Feb 2016 18:23:30 GMT
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/gemfire-core/src/main/java/com/gemstone/gemfire/CanonicalInstantiator.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/CanonicalInstantiator.java b/gemfire-core/src/main/java/com/gemstone/gemfire/CanonicalInstantiator.java
deleted file mode 100644
index e4a9182..0000000
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/CanonicalInstantiator.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire;
-
-import java.io.*;
-
-/**
- * <code>CanonicalInstantiator</code> is much like its parent
- * <code>Instantiator</code> except that instead of
- * needing to implement <code>newInstance()</code>
- * you now must implement <code>newInstance(DataInput)</code>.
- * The addition of the <code>DataInput</code> parameter allows the instance
- * creator to optionally read data from the data input stream and use it to
- * decide the instance to create. This allows a value that represents a
- * canonical instance to be written by a class's {@link DataSerializer#toData}
- * and then be read by <code>newInstance(DataInput)</code>
- * and map it back to a canonical instance.
- * <p>
- * Note that {@link DataSerializer#fromData} is always called on the instance
- * returned from <code>newInstance(DataInput)</code>.
- *
- * @author darrel
- * @since 5.1
- */
-public abstract class CanonicalInstantiator extends Instantiator {
-  /**
-   * Creates a new <code>CanonicalInstantiator</code> that instantiates a given
-   * class.
-   *
-   * @param c
-   *        The <code>DataSerializable</code> class to register.  This
-   *        class must have a static initializer that registers this
-   *        <code>Instantiator</code>. 
-   * @param classId
-   *        A unique id for class <code>c</code>.  The
-   *        <code>classId</code> must not be zero.
-   *        This has been an <code>int</code> since dsPhase1.
-   *
-   * @throws IllegalArgumentException
-   *         If <code>c</code> does not implement
-   *         <code>DataSerializable</code>, <code>classId</code>
is
-   *         less than or equal to zero.
-   * @throws NullPointerException
-   *         If <code>c</code> is <code>null</code>
-   */
-  public CanonicalInstantiator(Class<? extends DataSerializable> c, int classId) {
-    super(c, classId);
-  }
-  
-  /**
-   * This method is not supported and if called will
-   * throw UnsupportedOperationException.
-   * Use {@link #newInstance(DataInput)} instead.
-   * 
-   * @throws UnsupportedOperationException in all cases
-   */
-  @Override
-  public final DataSerializable newInstance() {
-    throw new UnsupportedOperationException();
-  }
-  /**
-   * Creates a new "empty" instance of a <Code>DataSerializable</code>
-   * class whose state will be filled in by invoking its 
-   * {@link DataSerializable#fromData fromData} method.
-   * @param in the data input that can be read to decide what instance to create.
-   * @return the new "empty" instance.
-   * @throws IOException if a read from <code>in</code> fails.
-   * @since 5.1
-   */
-  public abstract DataSerializable newInstance(DataInput in)
-    throws IOException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/gemfire-core/src/main/java/com/gemstone/gemfire/CopyException.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/CopyException.java b/gemfire-core/src/main/java/com/gemstone/gemfire/CopyException.java
deleted file mode 100644
index e7387c1..0000000
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/CopyException.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire;
-
-/**
- * Indicates a failure to copy an object.
- *
- * @author Darrel Schneider
- *
- *
- * @see CopyHelper#copy
- * @since 4.0
- */
-public class CopyException extends GemFireException {
-private static final long serialVersionUID = -1143711608610323585L;
-  
-  /**
-   * Constructs a new <code>CopyException</code>.
-   */
-  public CopyException() {
-    super();
-  }
-  
-  /**
-   * Constructs a new <code>CopyException</code> with a message string.
-   *
-   * @param msg a message string
-   */
-  public CopyException(String msg) {
-    super(msg);
-  }
-  
-  /**
-   * Constructs a new <code>CopyException</code> with a message string
-   * and a cause.
-   *
-   * @param msg the message string
-   * @param cause a causal Throwable
-   */
-  public CopyException(String msg, Throwable cause) {
-    super(msg, cause);
-  }
-  
-  /**
-   * Constructs a new <code>CopyException</code> with a cause.
-   *
-   * @param cause a causal Throwable
-   */
-  public CopyException(Throwable cause) {
-    super(cause);
-  }
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/gemfire-core/src/main/java/com/gemstone/gemfire/CopyHelper.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/CopyHelper.java b/gemfire-core/src/main/java/com/gemstone/gemfire/CopyHelper.java
deleted file mode 100644
index a34414f..0000000
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/CopyHelper.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire;
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.io.Serializable;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.Arrays;
-import java.util.UUID;
-
-import com.gemstone.gemfire.internal.HeapDataOutputStream;
-import com.gemstone.gemfire.internal.Version;
-import com.gemstone.gemfire.internal.cache.CachedDeserializable;
-import com.gemstone.gemfire.internal.cache.Token;
-import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
-import com.gemstone.gemfire.pdx.PdxInstance;
-import com.gemstone.gemfire.pdx.WritablePdxInstance;
-import com.gemstone.gemfire.pdx.internal.PdxUnreadData;
-
-/**
- * A static helper for optimally creating copies.  Creating copies
- * of cache values provides improved concurrency as well as isolation.
- * For transactions, creating a copy is the guaranteed way to enforce
- * "Read Committed" isolation on changes to cache
- * <code>Entries</code>.
-
- * <p>Here is a simple example of how to use <code>CopyHelper.copy</code>
- *  <pre>
- *    Object o = r.get("stringBuf");
- *    StringBuffer s = (StringBuffer) CopyHelper.copy(o);
- *    s.append("... and they lived happily ever after.  The End.");
- *    r.put("stringBuf", s);
- *  </pre>
- *
- * @see Cloneable
- * @see Serializable
- * @see DataSerializer
- * @see com.gemstone.gemfire.cache.Cache#setCopyOnRead
- * @see com.gemstone.gemfire.cache.CacheTransactionManager
- *
- * @author Mitch Thomas
- * @since 4.0
- */
-
-public final class CopyHelper {
-
-  // no instances allowed
-  private CopyHelper() {
-  }
-
-  /**
-   * Return true if the given object is an instance of a well known
-   * immutable class.
-   * The well known classes are:
-   * <ul>
-   * <li>String
-   * <li>Byte
-   * <li>Character
-   * <li>Short
-   * <li>Integer
-   * <li>Long
-   * <li>Float
-   * <li>Double
-   * <li>BigInteger
-   * <li>BigDecimal
-   * <li>UUID
-   * <li>PdxInstance but not WritablePdxInstance
-   * </ul>
-   * @param o the object to check
-   * @return true if o is an instance of a well known immutable class.
-   * @since 6.6.2
-   */
-  public static boolean isWellKnownImmutableInstance(Object o) {
-    if (o instanceof String) {
-      return true;
-    }
-    if (o instanceof Number) {
-      if (o instanceof Integer) return true;
-      if (o instanceof Long) return true;
-      if (o instanceof Byte) return true;
-      if (o instanceof Short) return true;
-      if (o instanceof Float) return true;
-      if (o instanceof Double) return true;
-      // subclasses of non-final classes may be mutable
-      if (o.getClass().equals(BigInteger.class)) return true;
-      if (o.getClass().equals(BigDecimal.class)) return true;
-    }
-    if (o instanceof PdxInstance && !(o instanceof WritablePdxInstance)) {
-      // no need to copy since it is immutable
-      return true;
-    }
-    if (o instanceof Character) return true;
-    if (o instanceof UUID) return true;
-    return false;
-  }
-  /**
-   * <p>Makes a copy of the specified object. The object returned is not guaranteed
-   * to be a deep copy of the original object, as explained below.
-   * 
-   * <p>Copies can only be made if the original is a <tt>Cloneable</tt>
or serializable by 
-   * GemFire.
-   * If o is a {@link #isWellKnownImmutableInstance(Object) well known immutable instance}
-   * then it will be returned without copying it.
-   * 
-   * <p>If the argument o is an instance of {@link java.lang.Cloneable}, a copy is
-   * made by invoking <tt>clone</tt> on it. Note that not all implementations
of <tt>clone</tt> 
-   * make deep copies (e.g. {@link java.util.HashMap#clone HashMap.clone}). Otherwise, if
the
-   * argument is not an instance of <tt>Cloneable</tt>, a copy is made using
serialization: if 
-   * GemFire serialization is implemented, it is used; otherwise, java serialization is used.
-   * 
-   * <p> The difference between this method and {@link #deepCopy(Object) deepCopy},
is that
-   * this method uses <tt>clone</tt> if available, whereas <tt>deepCopy</tt>
does not. As a
-   * result, for <tt>Cloneable</tt> objects copied using this method, how deep
a copy the 
-   * returned object is depends on its implementation of <tt>clone</tt>. 
-   * 
-   * @param o the original object that a copy is needed of
-   * @return the new instance that is a copy of of the original
-   * @throws CopyException if copying fails because a class could not
-   * be found or could not be serialized.
-   * @see #deepCopy(Object)
-   * @since 4.0
-   */
-  @SuppressWarnings("unchecked")
-  public static <T> T copy(T o) {
-    T copy = null;
-    try {
-      if (o == null) {
-        return null;
-      } else if (o instanceof Token) {
-        return o;
-      } else {
-        if (isWellKnownImmutableInstance(o)) return o;
-        if (o instanceof Cloneable) {
-          try {
-            // Note that Object.clone is protected so we need to use reflection
-            // to call clone even though this guy implements Cloneable
-            Class<?> c = o.getClass();
-            // By convention, the user should make the clone method public.
-            // But even if they don't, let's go ahead and use it.
-            // The other problem is that if the class is private, we still
-            // need to make the method accessible even if the method is public,
-            // because Object.clone is protected.
-            Method m = c.getDeclaredMethod("clone", new Class[0]);
-            m.setAccessible(true);
-            copy = (T)m.invoke(o, new Object[0]);
-            return copy;
-          } catch (NoSuchMethodException ignore) {
-            // try using Serialization
-          } catch (IllegalAccessException ignore) {
-            // try using Serialization
-          } catch (SecurityException ignore) {
-            // try using Serialization
-          } catch (InvocationTargetException ex) {
-            Throwable cause = ex.getTargetException();
-            if (cause instanceof CloneNotSupportedException) {
-              // try using Serialization
-            } else {
-              throw new CopyException(LocalizedStrings.CopyHelper_CLONE_FAILED.toLocalizedString(),
cause != null ? cause : ex);
-            }
-          }
-        } else if (o instanceof CachedDeserializable) {
-          copy = (T) ((CachedDeserializable) o).getDeserializedWritableCopy(null, null);
-          return copy;
-        } else if (o.getClass().isArray() && o.getClass().getComponentType().isPrimitive())
{
-          if (o instanceof byte[]) {
-            byte[] a = (byte[])o;
-            copy = (T) Arrays.copyOf(a, a.length);
-          } else if (o instanceof boolean[]) {
-            boolean[] a = (boolean[])o;
-            copy = (T) Arrays.copyOf(a, a.length);
-          } else if (o instanceof char[]) {
-            char[] a = (char[])o;
-            copy = (T) Arrays.copyOf(a, a.length);
-          } else if (o instanceof int[]) {
-            int[] a = (int[])o;
-            copy = (T) Arrays.copyOf(a, a.length);
-          } else if (o instanceof long[]) {
-            long[] a = (long[])o;
-            copy = (T) Arrays.copyOf(a, a.length);
-          } else if (o instanceof short[]) {
-            short[] a = (short[])o;
-            copy = (T) Arrays.copyOf(a, a.length);
-          } else if (o instanceof float[]) {
-            float[] a = (float[])o;
-            copy = (T) Arrays.copyOf(a, a.length);
-          } else if (o instanceof double[]) {
-            double[] a = (double[])o;
-            copy = (T) Arrays.copyOf(a, a.length);
-          }
-          return copy;
-        }
-        // Copy using serialization
-        copy = doDeepCopy(o);
-        return copy;
-      }
-    } finally {
-      if (copy != null) {
-        PdxUnreadData.copy(o, copy);
-      }
-    }
-  }
-
-  /**
-   * Makes a deep copy of the specified object o using serialization, so the object
-   * has to be serializable by GemFire. 
-   * 
-   * <p>If o is a {@link #isWellKnownImmutableInstance(Object) well known immutable

-   * instance} then it will be returned without copying it.
-   * 
-   * <p>The passed in object is serialized in memory, and then deserialized into 
-   * a new instance, which is returned. If GemFire serialization is implemented 
-   * for the object, it is used; otherwise, java serialization is used.  
-   * 
-   * @param o the original object to be copied
-   * @return the new instance that is a copy of the original
-   * @throws CopyException if copying fails because a class could not
-   * be found or could not be serialized
-   * @see #copy(Object)
-   */
-  public static <T> T deepCopy(T o) {
-    T copy = null;
-    try {
-      if (o == null) {
-        return null;
-      } else if (o instanceof Token || isWellKnownImmutableInstance(o)) {
-        return o;
-      } else {
-        copy = doDeepCopy(o);
-        return copy;
-      }
-    } finally {
-      if (copy != null) {
-        PdxUnreadData.copy(o, copy);
-      }
-    }
-  }
-
-  @SuppressWarnings("unchecked")
-  private static<T> T doDeepCopy(T o) {
-    try {
-      HeapDataOutputStream hdos = new HeapDataOutputStream(Version.CURRENT);
-      DataSerializer.writeObject(o, hdos);
-      return (T)DataSerializer.readObject(new DataInputStream(hdos.getInputStream()));
-    } catch (ClassNotFoundException ex) {
-      throw new CopyException(LocalizedStrings.CopyHelper_COPY_FAILED_ON_INSTANCE_OF_0.toLocalizedString(o.getClass()),
ex);
-    } catch (IOException ex) {
-      throw new CopyException(LocalizedStrings.CopyHelper_COPY_FAILED_ON_INSTANCE_OF_0.toLocalizedString(o.getClass()),
ex);
-    }
-
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f6c4c2f9/gemfire-core/src/main/java/com/gemstone/gemfire/DataSerializable.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/DataSerializable.java b/gemfire-core/src/main/java/com/gemstone/gemfire/DataSerializable.java
deleted file mode 100644
index 4bacef4..0000000
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/DataSerializable.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire;
-
-import java.io.*;
-
-/**
- * An interface for objects whose state can be written/read as
- * primitive types and strings ("data").  That is, instead of
- * serializing itself to an {@link java.io.ObjectOutputStream}, a
- * <code>DataSerializable</code> can serialize itself to a {@link
- * DataOutput}.  By implementing this interface, objects can be
- * serialized faster and in a more compact format than standard Java
- * serialization.  The {@link DataSerializer} class contains a number
- * of static methods that may be helpful to implementations of
- * <code>DataSerializable</code>.
- *
- * <P>
- *
- * When possible, GemFire respects the <code>DataSerializable</code>
- * contract to provide optimal object serialization.  For instance, if
- * a <code>DataSerializable</code> object is 
- * {@linkplain com.gemstone.gemfire.cache.Region#put(Object, Object) placed} into a distributed
- * cache region, its <code>toData</code> method will be used to
- * serialize it when it is sent to another member of the distributed
- * system.
- *
- * <P>
- *
- * To avoid the overhead of Java reflection,
- * <code>DataSerializable</code> classes may register an {@link
- * Instantiator} to be used during deserialization.  Alternatively,
- * classes that implement <code>DataSerializable</code> can provide a
- * zero-argument constructor that will be invoked when they are read
- * with {@link DataSerializer#readObject}.
- *
- * <P>
- *
- * Some classes (especially third-party classes that you may not have
- * the source code to) cannot be modified to implement
- * <code>DataSerializable</code>.  These classes can be data
- * serialized by an instance of {@link DataSerializer}.
- *
- * <P>
- *
- * <code>DataSerializable</code> offers improved performance over
- * standard Java serialization, but does not offer all of the features
- * of standard Java serialization.  In particular, data serialization
- * does not attempt to maintain referential integrity among the
- * objects it is writing or reading.  As a result, data serialization
- * should not be used with complex object graphs.  Attempting to data
- * serialize graphs that contain object cycles will result in infinite
- * recursion and a {@link StackOverflowError}.  Attempting to
- * deserialize an object graph that contains multiple reference
- * paths to the same object will result in multiple copies of the
- * objects that are referred to through multiple paths.
- *
- * <P>
- *
- * <CENTER>
- * <IMG src="doc-files/data-serialization-exceptions.gif" 
- *      HEIGHT="219" WIDTH="698">
- * </CENTER>
- *
- * @see java.io.Serializable
- * @see DataSerializer
- * @see Instantiator
- *
- * @author David Whitlock
- * @since 3.5 */
-public interface DataSerializable extends Serializable {
-
-  /**
-   * Writes the state of this object as primitive data to the given
-   * <code>DataOutput</code>.
-   * <p>
-   * Since 5.7 it is possible for any method call to the specified
-   * <code>DataOutput</code> to throw {@link GemFireRethrowable}.
-   * It should <em>not</em> be caught by user code.
-   * If it is it <em>must</em> be rethrown.
-   *
-   * @throws IOException
-   *         A problem occurs while writing to <code>out</code>
-   */
-  public void toData(DataOutput out) throws IOException;
-
-  /**
-   * Reads the state of this object as primitive data from the given
-   * <code>DataInput</code>. 
-   *
-   * @throws IOException
-   *         A problem occurs while reading from <code>in</code>
-   * @throws ClassNotFoundException
-   *         A class could not be loaded while reading from
-   *         <code>in</code> 
-   */
-  public void fromData(DataInput in)
-    throws IOException, ClassNotFoundException;
-
-  ////////////////////////  Inner Classes  ////////////////////////
-
-  /**
-   * <code>Replaceable</code> allows an object to write an alternative
-   * version of itself to a <code>DataOutput</code>.  It is similar to
-   * the <code>writeReplace</code> method of standard Java
-   * {@linkplain java.io.Serializable serialization}.  
-   *
-   * <P>
-   *
-   * Note that if a <code>Replaceable</code> is also
-   * <code>DataSerializable</code>, its <code>toData</code> method
-   * will <B>not</B> be invoked.  Instead, its replacement object will
-   * be written to the stream using {@link DataSerializer#writeObject(Object, DataOutput)}.

-   *
-   * @see DataSerializer#writeObject(Object, DataOutput)
-   */
-  public interface Replaceable {
-
-    /**
-     * Replaces this object with another in the "output stream"
-     * written by {@link DataSerializer#writeObject(Object, DataOutput)}.
-     */
-    public Object replace() throws IOException;
-  }
-
-}


Mime
View raw message