Search in sources :

Example 1 with OldClientSupportService

use of org.apache.geode.internal.cache.tier.sockets.OldClientSupportService in project geode by apache.

the class InternalDataSerializer method processIncomingClassName.

/**
   * For backward compatibility we must swizzle the package of some classes that had to be moved
   * when GemFire was open- sourced. This preserves backward-compatibility.
   * 
   * @param name the fully qualified class name
   * @return the name of the class in this implementation
   */
public static String processIncomingClassName(String name) {
    // TCPServer classes are used before a cache exists and support for old clients has been
    // initialized
    String oldPackage = "com.gemstone.org.jgroups.stack.tcpserver";
    String newPackage = "org.apache.geode.distributed.internal.tcpserver";
    if (name.startsWith(oldPackage)) {
        return newPackage + name.substring(oldPackage.length());
    }
    OldClientSupportService svc = getOldClientSupportService();
    if (svc != null) {
        return svc.processIncomingClassName(name);
    }
    return name;
}
Also used : OldClientSupportService(org.apache.geode.internal.cache.tier.sockets.OldClientSupportService)

Example 2 with OldClientSupportService

use of org.apache.geode.internal.cache.tier.sockets.OldClientSupportService in project geode by apache.

the class InternalDataSerializer method processOutgoingClassName.

/**
   * For backward compatibility we must swizzle the package of some classes that had to be moved
   * when GemFire was open- sourced. This preserves backward-compatibility.
   * 
   * @param name the fully qualified class name
   * @param out the consumer of the serialized object
   * @return the name of the class in this implementation
   */
public static String processOutgoingClassName(String name, DataOutput out) {
    // TCPServer classes are used before a cache exists and support for old clients has been
    // initialized
    String oldPackage = "com.gemstone.org.jgroups.stack.tcpserver";
    String newPackage = "org.apache.geode.distributed.internal.tcpserver";
    if (name.startsWith(newPackage)) {
        return oldPackage + name.substring(newPackage.length());
    }
    OldClientSupportService svc = getOldClientSupportService();
    if (svc != null) {
        return svc.processOutgoingClassName(name, out);
    }
    return name;
}
Also used : OldClientSupportService(org.apache.geode.internal.cache.tier.sockets.OldClientSupportService)

Example 3 with OldClientSupportService

use of org.apache.geode.internal.cache.tier.sockets.OldClientSupportService in project geode by apache.

the class OldClientSupportDUnitTest method testConversionOfArrayTypes.

@Test
public void testConversionOfArrayTypes() throws Exception {
    OldClientSupportService oldClientSupport = OldClientSupportProvider.getService(myCache);
    Version oldClientVersion = Version.GFE_82;
    VersionedDataOutputStream dout = new VersionedDataOutputStream(new HeapDataOutputStream(10, oldClientVersion), oldClientVersion);
    for (String geodeClassName : newArrayClassNames) {
        String newName = oldClientSupport.processOutgoingClassName(geodeClassName, dout);
        Assert.assertNotEquals(geodeClassName, newName);
    }
    for (String className : allNonconformingArrayClassNames) {
        String newName = oldClientSupport.processOutgoingClassName(className, dout);
        Assert.assertEquals(className, newName);
    }
    VersionedDataInputStream din = new VersionedDataInputStream(new DataInputStream(new ByteArrayInputStream(new byte[10])), oldClientVersion);
    for (String oldClassName : oldArrayClassNames) {
        String newName = oldClientSupport.processIncomingClassName(oldClassName, din);
        Assert.assertNotEquals(oldClassName, newName);
    }
}
Also used : Version(org.apache.geode.internal.Version) ByteArrayInputStream(java.io.ByteArrayInputStream) HeapDataOutputStream(org.apache.geode.internal.HeapDataOutputStream) VersionedDataOutputStream(org.apache.geode.internal.VersionedDataOutputStream) OldClientSupportService(org.apache.geode.internal.cache.tier.sockets.OldClientSupportService) DataInputStream(java.io.DataInputStream) VersionedDataInputStream(org.apache.geode.internal.VersionedDataInputStream) VersionedDataInputStream(org.apache.geode.internal.VersionedDataInputStream) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 4 with OldClientSupportService

use of org.apache.geode.internal.cache.tier.sockets.OldClientSupportService in project geode by apache.

the class OldClientSupportDUnitTest method convertThrowable.

private void convertThrowable(String geodeClassName) throws Exception {
    Version oldClientVersion = Version.GFE_82;
    final String comGemstoneGemFire = "com.gemstone.gemfire";
    final int comGemstoneGemFireLength = comGemstoneGemFire.length();
    OldClientSupportService oldClientSupport = OldClientSupportProvider.getService(myCache);
    System.out.println("checking " + geodeClassName);
    Class geodeClass = Class.forName(geodeClassName);
    Object geodeObject = instantiate(geodeClass);
    if (geodeObject instanceof Throwable) {
        Throwable geodeThrowable = (Throwable) instantiate(geodeClass);
        Throwable gemfireThrowable = oldClientSupport.getThrowable(geodeThrowable, oldClientVersion);
        Assert.assertEquals("Failed to convert " + geodeClassName + ". Throwable class is " + gemfireThrowable.getClass().getName(), comGemstoneGemFire, gemfireThrowable.getClass().getName().substring(0, comGemstoneGemFireLength));
    }
}
Also used : Version(org.apache.geode.internal.Version) OldClientSupportService(org.apache.geode.internal.cache.tier.sockets.OldClientSupportService)

Aggregations

OldClientSupportService (org.apache.geode.internal.cache.tier.sockets.OldClientSupportService)4 Version (org.apache.geode.internal.Version)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInputStream (java.io.DataInputStream)1 HeapDataOutputStream (org.apache.geode.internal.HeapDataOutputStream)1 VersionedDataInputStream (org.apache.geode.internal.VersionedDataInputStream)1 VersionedDataOutputStream (org.apache.geode.internal.VersionedDataOutputStream)1 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)1 Test (org.junit.Test)1