You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directmemory.apache.org by ol...@apache.org on 2012/10/01 22:57:52 UTC
svn commit: r1392595 [9/15] - in /directmemory/lightning/trunk: ./
lightning-api/ lightning-api/src/ lightning-api/src/main/
lightning-api/src/main/java/ lightning-api/src/main/java/org/
lightning-api/src/main/java/org/apache/ lightning-api/src/main/ja...
Added: directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/marshaller/StringMarshaller.java
URL: http://svn.apache.org/viewvc/directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/marshaller/StringMarshaller.java?rev=1392595&view=auto
==============================================================================
--- directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/marshaller/StringMarshaller.java (added)
+++ directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/marshaller/StringMarshaller.java Mon Oct 1 20:57:42 2012
@@ -0,0 +1,66 @@
+/*
+ * 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 org.apache.directmemory.lightning.internal.marshaller;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.directmemory.lightning.SerializationContext;
+import org.apache.directmemory.lightning.base.AbstractMarshaller;
+import org.apache.directmemory.lightning.metadata.PropertyDescriptor;
+
+public class StringMarshaller
+ extends AbstractMarshaller
+{
+
+ @Override
+ public boolean acceptType( Class<?> type )
+ {
+ return String.class == type;
+ }
+
+ @Override
+ public void marshall( Object value, PropertyDescriptor propertyDescriptor, DataOutput dataOutput,
+ SerializationContext serializationContext )
+ throws IOException
+ {
+
+ if ( !writePossibleNull( value, dataOutput ) )
+ {
+ return;
+ }
+
+ dataOutput.writeUTF( (String) value );
+ }
+
+ @Override
+ @SuppressWarnings( "unchecked" )
+ public <V> V unmarshall( PropertyDescriptor propertyDescriptor, DataInput dataInput,
+ SerializationContext serializationContext )
+ throws IOException
+ {
+ if ( isNull( dataInput ) )
+ {
+ return null;
+ }
+
+ return (V) dataInput.readUTF();
+ }
+}
Propchange: directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/marshaller/StringMarshaller.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/marshaller/StringMarshaller.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/BeanUtil.java
URL: http://svn.apache.org/viewvc/directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/BeanUtil.java?rev=1392595&view=auto
==============================================================================
--- directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/BeanUtil.java (added)
+++ directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/BeanUtil.java Mon Oct 1 20:57:42 2012
@@ -0,0 +1,312 @@
+/*
+ * 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 org.apache.directmemory.lightning.internal.util;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.directmemory.lightning.exceptions.SerializerDefinitionException;
+import org.apache.directmemory.lightning.metadata.Attribute;
+import org.apache.directmemory.lightning.metadata.PropertyAccessor;
+import org.apache.directmemory.lightning.metadata.PropertyDescriptor;
+import org.objectweb.asm.Type;
+
+public final class BeanUtil
+{
+
+ private BeanUtil()
+ {
+ }
+
+ public static Set<Field> findPropertiesByClass( Class<?> type, Class<? extends Annotation> attributeAnnotation )
+ {
+ Set<Field> properties = new HashSet<Field>();
+ properties.addAll( findPropertiesByInstanceFields( type, attributeAnnotation ) );
+ properties.addAll( findPropertiesByMethods( type, type, attributeAnnotation ) );
+ properties.addAll( findPropertiesByInterfaces( type, attributeAnnotation ) );
+
+ if ( type.getSuperclass() != null && type.getSuperclass() != Object.class )
+ {
+ properties.addAll( findPropertiesByClass( type.getSuperclass(), attributeAnnotation ) );
+ }
+
+ return properties;
+ }
+
+ public static Set<Field> findPropertiesByInstanceFields( Class<?> type,
+ Class<? extends Annotation> attributeAnnotation )
+ {
+ Set<Field> attributes = new HashSet<Field>();
+ for ( Field field : type.getDeclaredFields() )
+ {
+ if ( field.isAnnotationPresent( attributeAnnotation ) )
+ {
+ attributes.add( field );
+ }
+ }
+
+ return attributes;
+ }
+
+ public static Set<Field> findPropertiesByMethods( Class<?> type, Class<?> searchType,
+ Class<? extends Annotation> attributeAnnotation )
+ {
+ Set<Field> attributes = new HashSet<Field>();
+ for ( Method method : searchType.getDeclaredMethods() )
+ {
+ if ( method.isAnnotationPresent( attributeAnnotation ) )
+ {
+ String propertyName = BeanUtil.buildPropertyName( method );
+ Field field = BeanUtil.getFieldByPropertyName( propertyName, type );
+ if ( field == null )
+ {
+ if ( attributeAnnotation == Attribute.class )
+ {
+ Attribute attribute = method.getAnnotation( Attribute.class );
+ field = BeanUtil.getFieldByPropertyName( attribute.property(), type );
+ }
+
+ if ( field == null )
+ {
+ throw new SerializerDefinitionException( "No property for method " + method + " was found" );
+ }
+ }
+
+ attributes.add( field );
+ }
+ }
+
+ return attributes;
+ }
+
+ public static Set<Field> findPropertiesByInterfaces( Class<?> type, Class<? extends Annotation> attributeAnnotation )
+ {
+ Set<Field> attributes = new HashSet<Field>();
+
+ for ( Class<?> interfaze : type.getInterfaces() )
+ {
+ // Add all annotated methods in interface
+ attributes.addAll( findInterfaceProperties0( type, interfaze, attributeAnnotation ) );
+ }
+
+ return attributes;
+ }
+
+ private static Set<Field> findInterfaceProperties0( Class<?> type, Class<?> interfaze,
+ Class<? extends Annotation> attributeAnnotation )
+ {
+ Set<Field> attributes = new HashSet<Field>();
+
+ // Add all annotated methods in interface
+ attributes.addAll( findPropertiesByMethods( type, interfaze, attributeAnnotation ) );
+
+ // Look up super-interface
+ if ( interfaze.getSuperclass() != null )
+ {
+ attributes.addAll( findInterfaceProperties0( type, interfaze.getSuperclass(), attributeAnnotation ) );
+ }
+
+ return attributes;
+ }
+
+ public static Field getFieldByPropertyName( String propertyName, Class<?> type )
+ {
+ try
+ {
+ return type.getDeclaredField( propertyName );
+ }
+ catch ( NoSuchFieldException e )
+ {
+ if ( type.getSuperclass() != null && type.getSuperclass() != Object.class )
+ {
+ return getFieldByPropertyName( propertyName, type.getSuperclass() );
+ }
+ return null;
+ }
+ }
+
+ public static Method findSetterMethod( Method method )
+ {
+ if ( method.getName().startsWith( "set" ) )
+ {
+ return method;
+ }
+
+ String propertyName = StringUtil.toUpperCamelCase( extractPropertyName( method.getName() ) );
+
+ Class<?> type = method.getReturnType();
+ Class<?> clazz = method.getDeclaringClass();
+ String setterName = "set" + propertyName;
+
+ try
+ {
+ return clazz.getDeclaredMethod( setterName, type );
+ }
+ catch ( Exception e )
+ {
+ // Seems there's no setter, so ignore all exceptions
+ return null;
+ }
+ }
+
+ public static Method findArraySetterMethod( Method method )
+ {
+ if ( method.getName().startsWith( "set" ) )
+ {
+ return method;
+ }
+
+ String propertyName = StringUtil.toUpperCamelCase( extractPropertyName( method.getName() ) );
+
+ Class<?> type = method.getReturnType();
+ Class<?> clazz = method.getDeclaringClass();
+ String setterName = "set" + propertyName;
+
+ try
+ {
+ return clazz.getDeclaredMethod( setterName, type, int.class );
+ }
+ catch ( Exception e )
+ {
+ // Seems there's no setter, so ignore all exceptions
+ return null;
+ }
+ }
+
+ public static Method findGetterMethod( Method method )
+ {
+ if ( method.getName().startsWith( "get" ) || method.getName().startsWith( "is" ) )
+ {
+ return method;
+ }
+
+ String propertyName = StringUtil.toUpperCamelCase( extractPropertyName( method.getName() ) );
+
+ Class<?> type = method.getParameterTypes()[0];
+ Class<?> clazz = method.getDeclaringClass();
+ String getterObjectName = "get" + propertyName;
+ String getterBooleanName = "is" + propertyName;
+
+ try
+ {
+ return clazz.getDeclaredMethod( getterObjectName, type );
+ }
+ catch ( Exception e )
+ {
+ if ( type == boolean.class )
+ {
+ try
+ {
+ return clazz.getDeclaredMethod( getterBooleanName, type );
+ }
+ catch ( Exception ex )
+ {
+ // Intentionally left blank - just fall through
+ }
+ }
+
+ // Seems there's no setter, so ignore all exceptions
+ return null;
+ }
+ }
+
+ public static Method findArrayGetterMethod( Method method )
+ {
+ if ( method.getName().startsWith( "get" ) || method.getName().startsWith( "is" ) )
+ {
+ return method;
+ }
+
+ String propertyName = StringUtil.toUpperCamelCase( extractPropertyName( method.getName() ) );
+
+ Class<?> type = method.getParameterTypes()[0];
+ Class<?> clazz = method.getDeclaringClass();
+ String getterObjectName = "get" + propertyName;
+ String getterBooleanName = "is" + propertyName;
+
+ try
+ {
+ return clazz.getDeclaredMethod( getterObjectName, type );
+ }
+ catch ( Exception e )
+ {
+ if ( type == boolean.class )
+ {
+ try
+ {
+ return clazz.getDeclaredMethod( getterBooleanName, type, int.class );
+ }
+ catch ( Exception ex )
+ {
+ // Intentionally left blank - just fall through
+ }
+ }
+
+ // Seems there's no setter, so ignore all exceptions
+ return null;
+ }
+ }
+
+ public static String buildPropertyName( Method method )
+ {
+ return buildPropertyName( method.getName() );
+ }
+
+ public static String buildPropertyName( String methodName )
+ {
+ return StringUtil.toLowerCamelCase( extractPropertyName( methodName ) );
+ }
+
+ public static String buildInternalSignature( Iterable<PropertyDescriptor> propertyDescriptors )
+ {
+ StringBuilder internalSignature = new StringBuilder();
+ for ( PropertyDescriptor propertyDescriptor : propertyDescriptors )
+ {
+ internalSignature.append( propertyDescriptor.getInternalSignature() );
+ }
+ return internalSignature.toString();
+ }
+
+ public static <T> String buildInternalSignature( String propertyName, PropertyAccessor propertyAccessor )
+ {
+ String type = Type.getDescriptor( propertyAccessor.getType() );
+ return new StringBuilder( "{" ).append( propertyName ).append( "}" ).append( type ).toString();
+ }
+
+ private static String extractPropertyName( String methodName )
+ {
+ if ( methodName.toUpperCase().startsWith( "GET" ) || methodName.toUpperCase().startsWith( "IS" )
+ || methodName.toUpperCase().startsWith( "SET" ) )
+ {
+
+ char[] characters = methodName.toCharArray();
+ for ( int i = 1; i < characters.length; i++ )
+ {
+ if ( Character.isUpperCase( characters[i] ) )
+ {
+ return StringUtil.toLowerCamelCase( methodName.substring( i ) );
+ }
+ }
+ }
+ return StringUtil.toLowerCamelCase( methodName );
+ }
+}
Propchange: directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/BeanUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/BeanUtil.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/ClassUtil.java
URL: http://svn.apache.org/viewvc/directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/ClassUtil.java?rev=1392595&view=auto
==============================================================================
--- directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/ClassUtil.java (added)
+++ directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/ClassUtil.java Mon Oct 1 20:57:42 2012
@@ -0,0 +1,509 @@
+/*
+ * 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 org.apache.directmemory.lightning.internal.util;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectStreamClass;
+import java.io.Serializable;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.directmemory.lightning.metadata.ClassDefinition;
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
+
+public final class ClassUtil
+{
+
+ public static final ClassDefinition[] CLASS_DESCRIPTORS = new ClassDefinition[] {
+ new JavaBuildInTypeClassDefinition( boolean.class, 1 ), new JavaBuildInTypeClassDefinition( Boolean.class, 2 ),
+ new JavaBuildInTypeClassDefinition( byte.class, 3 ), new JavaBuildInTypeClassDefinition( Byte.class, 4 ),
+ new JavaBuildInTypeClassDefinition( char.class, 5 ), new JavaBuildInTypeClassDefinition( Character.class, 6 ),
+ new JavaBuildInTypeClassDefinition( double.class, 7 ), new JavaBuildInTypeClassDefinition( Double.class, 8 ),
+ new JavaBuildInTypeClassDefinition( float.class, 9 ), new JavaBuildInTypeClassDefinition( Float.class, 10 ),
+ new JavaBuildInTypeClassDefinition( int.class, 11 ), new JavaBuildInTypeClassDefinition( Integer.class, 12 ),
+ new JavaBuildInTypeClassDefinition( long.class, 13 ), new JavaBuildInTypeClassDefinition( Long.class, 14 ),
+ new JavaBuildInTypeClassDefinition( short.class, 15 ), new JavaBuildInTypeClassDefinition( Short.class, 16 ),
+ new JavaBuildInTypeClassDefinition( String.class, 17 ), new JavaBuildInTypeClassDefinition( List.class, 18 ),
+ new JavaBuildInTypeClassDefinition( Set.class, 19 ), new JavaBuildInTypeClassDefinition( Map.class, 20 ),
+ new JavaBuildInTypeClassDefinition( BigInteger.class, 21 ),
+ new JavaBuildInTypeClassDefinition( BigDecimal.class, 22 ) };
+
+ private static final Map<Class<?>, Long> SERIAL_VERSION_UID_CACHE = new ConcurrentHashMap<Class<?>, Long>();
+
+ private ClassUtil()
+ {
+ }
+
+ public static boolean isReferenceCapable( Class<?> type )
+ {
+ return !type.isPrimitive() && Boolean.class != type && Byte.class != type && Short.class != type
+ && Integer.class != type && Long.class != type && Float.class != type && Double.class != type;
+ }
+
+ public static Class<?> loadClass( String canonicalName )
+ throws ClassNotFoundException
+ {
+ return loadClass( canonicalName, ClassUtil.class.getClassLoader() );
+ }
+
+ public static Class<?> loadClass( String canonicalName, ClassLoader classLoader )
+ throws ClassNotFoundException
+ {
+ Class<?> type = null;
+ try
+ {
+ type = classLoader.loadClass( canonicalName );
+ }
+ catch ( ClassNotFoundException e )
+ {
+ // Intentionally left blank
+ }
+
+ if ( type == null )
+ {
+ try
+ {
+ type = Class.forName( canonicalName );
+ }
+ catch ( ClassNotFoundException e )
+ {
+ // Intentionally left blank
+ }
+ }
+
+ if ( type == null )
+ {
+ try
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ type = tcl.loadClass( canonicalName );
+ }
+ catch ( ClassNotFoundException e )
+ {
+ // Intentionally left blank
+ }
+ }
+
+ if ( type == null )
+ {
+ try
+ {
+ ClassLoader ccl = ClassUtil.class.getClassLoader();
+ type = ccl.loadClass( canonicalName );
+ }
+ catch ( ClassNotFoundException e )
+ {
+ // Intentionally left blank
+ }
+ }
+
+ if ( type != null )
+ {
+ return type;
+ }
+
+ throw new ClassNotFoundException( "Class " + canonicalName + " not found on classpath" );
+ }
+
+ public static long calculateSerialVersionUID( Class<?> clazz )
+ {
+ Long serialVersionUID = SERIAL_VERSION_UID_CACHE.get( clazz );
+ if ( serialVersionUID != null )
+ {
+ return serialVersionUID;
+ }
+
+ if ( Serializable.class.isAssignableFrom( clazz ) )
+ {
+ serialVersionUID = ObjectStreamClass.lookup( clazz ).getSerialVersionUID();
+ SERIAL_VERSION_UID_CACHE.put( clazz, serialVersionUID );
+ return serialVersionUID;
+ }
+
+ serialVersionUID = getSerialVersionUIDFromField( clazz );
+ if ( serialVersionUID != null )
+ {
+ SERIAL_VERSION_UID_CACHE.put( clazz, serialVersionUID );
+ return serialVersionUID;
+ }
+
+ try
+ {
+ ClassReader reader = new ClassReader( Type.getInternalName( clazz ).replace( "/", "." ) );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ DataOutputStream out = new DataOutputStream( baos );
+
+ SerialVersionClassVisitor classVisitor = new SerialVersionClassVisitor();
+ reader.accept( classVisitor, 0 );
+
+ // Classname
+ out.writeUTF( toJavaName( classVisitor.name ) );
+
+ // Modifiers
+ out.writeInt( clazz.getModifiers()
+ & ( Modifier.PUBLIC | Modifier.FINAL | Modifier.INTERFACE | Modifier.ABSTRACT ) );
+
+ // Interfaces
+ Collections.sort( classVisitor.interfaces );
+ for ( int i = 0; i < classVisitor.interfaces.size(); i++ )
+ {
+ out.writeUTF( toJavaName( classVisitor.interfaces.get( i ) ) );
+ }
+
+ // Fields
+ Field[] fields = clazz.getDeclaredFields();
+ Arrays.sort( fields, new Comparator<Field>()
+ {
+
+ @Override
+ public int compare( Field o1, Field o2 )
+ {
+ return o1.getName().compareTo( o2.getName() );
+ }
+ } );
+
+ for ( Field field : fields )
+ {
+ int mods = field.getModifiers();
+ if ( ( ( mods & Modifier.PRIVATE ) == 0 || ( mods & ( Modifier.STATIC | Modifier.TRANSIENT ) ) == 0 ) )
+ {
+ out.writeUTF( field.getName() );
+ out.writeInt( mods );
+ out.writeUTF( Type.getDescriptor( field.getType() ) );
+ }
+ }
+
+ // Static Initializer
+ if ( classVisitor.staticInitializerFound )
+ {
+ out.writeUTF( "<clinit>" );
+ out.writeInt( Modifier.STATIC );
+ out.writeUTF( "()V" );
+ }
+
+ // Constructors
+ Constructor<?>[] constructors = clazz.getDeclaredConstructors();
+ Arrays.sort( constructors, new Comparator<Constructor<?>>()
+ {
+
+ @Override
+ public int compare( Constructor<?> o1, Constructor<?> o2 )
+ {
+ return Type.getConstructorDescriptor( o1 ).compareTo( Type.getConstructorDescriptor( o2 ) );
+ }
+ } );
+
+ for ( int i = 0; i < constructors.length; i++ )
+ {
+ Constructor<?> constructor = constructors[i];
+ int mods = constructor.getModifiers();
+ if ( ( mods & Modifier.PRIVATE ) == 0 )
+ {
+ out.writeUTF( "<init>" );
+ out.writeInt( mods );
+ out.writeUTF( toJavaName( Type.getConstructorDescriptor( constructor ) ) );
+ }
+ }
+
+ // Methods
+ Method[] methods = clazz.getDeclaredMethods();
+ Arrays.sort( methods, new Comparator<Method>()
+ {
+
+ @Override
+ public int compare( Method o1, Method o2 )
+ {
+ return Type.getMethodDescriptor( o1 ).compareTo( Type.getMethodDescriptor( o2 ) );
+ }
+ } );
+
+ for ( int i = 0; i < methods.length; i++ )
+ {
+ Method method = methods[i];
+ int mods = method.getModifiers();
+ if ( ( mods & Modifier.PRIVATE ) == 0 )
+ {
+ out.writeUTF( "<init>" );
+ out.writeInt( mods );
+ out.writeUTF( toJavaName( Type.getMethodDescriptor( method ) ) );
+ }
+ }
+
+ // Final calculation
+ out.flush();
+ MessageDigest digest = MessageDigest.getInstance( "SHA" );
+ byte[] checksum = digest.digest( baos.toByteArray() );
+
+ long hash = 0;
+ for ( int i = Math.min( checksum.length, 8 ) - 1; i >= 0; i-- )
+ {
+ hash = ( hash << 8 ) | ( checksum[i] & 0xFF );
+ }
+
+ SERIAL_VERSION_UID_CACHE.put( clazz, hash );
+ return hash;
+ }
+ catch ( IOException e )
+ {
+ }
+ catch ( NoSuchAlgorithmException e )
+ {
+ }
+
+ return -1L;
+ }
+
+ public static byte[] getClassBytes( Class<?> clazz )
+ {
+ try
+ {
+ ClassLoader classLoader = clazz.getClassLoader();
+ if ( classLoader == null )
+ {
+ classLoader = Thread.currentThread().getContextClassLoader();
+ }
+
+ String internalName = Type.getInternalName( clazz );
+ InputStream stream = classLoader.getResourceAsStream( internalName + ".class" );
+ byte[] data = new byte[stream.available()];
+ stream.read( data );
+ stream.close();
+ return data;
+ }
+ catch ( IOException e )
+ {
+ throw new RuntimeException( "Class bytes could not be read", e );
+ }
+ }
+
+ private static String toJavaName( String classname )
+ {
+ return classname.replace( "/", "." );
+ }
+
+ private static Long getSerialVersionUIDFromField( Class<?> clazz )
+ {
+ try
+ {
+ Field f = clazz.getDeclaredField( "serialVersionUID" );
+ int mask = Modifier.STATIC | Modifier.FINAL;
+ if ( ( f.getModifiers() & mask ) == mask )
+ {
+ f.setAccessible( true );
+ return Long.valueOf( f.getLong( null ) );
+ }
+ }
+ catch ( Exception ex )
+ {
+ }
+ return null;
+ }
+
+ private static class JavaBuildInTypeClassDefinition
+ implements ClassDefinition
+ {
+
+ private final long id;
+
+ private final Class<?> type;
+
+ private final String canonicalName;
+
+ private final byte[] checksum = new byte[20];
+
+ private final long serialVersionUID = -1L;
+
+ JavaBuildInTypeClassDefinition( Class<?> type, long id )
+ {
+ this.id = id;
+ this.type = type;
+ this.canonicalName = type.getCanonicalName();
+ }
+
+ @Override
+ public String getCanonicalName()
+ {
+ return canonicalName;
+ }
+
+ @Override
+ public Class<?> getType()
+ {
+ return type;
+ }
+
+ @Override
+ public byte[] getChecksum()
+ {
+ return checksum;
+ }
+
+ @Override
+ public long getId()
+ {
+ return id;
+ }
+
+ @Override
+ public long getSerialVersionUID()
+ {
+ return serialVersionUID;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ( ( canonicalName == null ) ? 0 : canonicalName.hashCode() );
+ result = prime * result + Arrays.hashCode( checksum );
+ result = prime * result + (int) ( id ^ ( id >>> 32 ) );
+ result = prime * result + (int) ( serialVersionUID ^ ( serialVersionUID >>> 32 ) );
+ return result;
+ }
+
+ @Override
+ public boolean equals( Object obj )
+ {
+ if ( this == obj )
+ return true;
+ if ( obj == null )
+ return false;
+ if ( getClass() != obj.getClass() )
+ return false;
+ JavaBuildInTypeClassDefinition other = (JavaBuildInTypeClassDefinition) obj;
+ if ( canonicalName == null )
+ {
+ if ( other.canonicalName != null )
+ return false;
+ }
+ else if ( !canonicalName.equals( other.canonicalName ) )
+ return false;
+ if ( !Arrays.equals( checksum, other.checksum ) )
+ return false;
+ if ( id != other.id )
+ return false;
+ if ( serialVersionUID != other.serialVersionUID )
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "JavaBuildInTypeClassDefinition [id=" + id + ", type=" + type + ", canonicalName=" + canonicalName
+ + ", checksum=" + Arrays.toString( checksum ) + ", serialVersionUID=" + serialVersionUID + "]";
+ }
+ }
+
+ private static class SerialVersionClassVisitor
+ extends ClassVisitor
+ {
+
+ public SerialVersionClassVisitor()
+ {
+ super( Opcodes.ASM4 );
+ }
+
+ private List<String> interfaces = new ArrayList<String>();
+
+ private boolean staticInitializerFound = false;
+
+ private String name;
+
+ @Override
+ public void visit( int version, int access, String name, String signature, String superName, String[] interfaces )
+ {
+ this.name = name;
+ this.interfaces = Arrays.asList( interfaces );
+ }
+
+ @Override
+ public AnnotationVisitor visitAnnotation( String desc, boolean visible )
+ {
+ return null;
+ }
+
+ @Override
+ public void visitAttribute( Attribute attr )
+ {
+ }
+
+ @Override
+ public void visitEnd()
+ {
+ }
+
+ @Override
+ public FieldVisitor visitField( int access, String name, String desc, String signature, Object value )
+ {
+ return null;
+ }
+
+ @Override
+ public void visitInnerClass( String name, String outerName, String innerName, int access )
+ {
+ }
+
+ @Override
+ public MethodVisitor visitMethod( int access, String name, String desc, String signature, String[] exceptions )
+ {
+ if ( "<clinit>".equals( name ) && ( access & Opcodes.ACC_STATIC ) != 0 )
+ {
+ staticInitializerFound = true;
+ }
+ return null;
+ }
+
+ @Override
+ public void visitOuterClass( String owner, String name, String desc )
+ {
+ }
+
+ @Override
+ public void visitSource( String source, String debug )
+ {
+ }
+ }
+}
Propchange: directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/ClassUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/ClassUtil.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/Crc64Util.java
URL: http://svn.apache.org/viewvc/directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/Crc64Util.java?rev=1392595&view=auto
==============================================================================
--- directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/Crc64Util.java (added)
+++ directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/Crc64Util.java Mon Oct 1 20:57:42 2012
@@ -0,0 +1,96 @@
+/*
+ * 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 org.apache.directmemory.lightning.internal.util;
+
+/**
+ * Crc64 checksum computation. This classes basic content was copied from original position:
+ * http://intact.googlecode.com/ It was changed to use byte data instead of strings
+ *
+ * @author The European Bioinformatics Institute, and others.
+ * @author Uniparc
+ * @version $Id$
+ */
+public final class Crc64Util
+{
+
+ private static long _crc64Array[] = new long[256];
+
+ /**
+ * Initialization of _crc64Array.
+ */
+ static
+ {
+
+ for ( int i = 0; i <= 255; ++i )
+ {
+ long k = i;
+ for ( int j = 0; j < 8; ++j )
+ {
+ if ( ( k & 1 ) != 0 )
+ {
+ k = ( k >>> 1 ) ^ 0xd800000000000000l;
+ }
+ else
+ {
+ k = k >>> 1;
+ }
+ }
+ _crc64Array[i] = k;
+ }
+ }
+
+ private Crc64Util()
+ {
+ }
+
+ /**
+ * Returns a hex string representation of the checksum
+ *
+ * @param checksum
+ * @return
+ */
+ public static String toString( long checksum )
+ {
+ String crc64String = Long.toHexString( checksum ).toUpperCase();
+ StringBuffer crc64 = new StringBuffer( "0000000000000000" );
+ crc64.replace( crc64.length() - crc64String.length(), crc64.length(), crc64String );
+
+ return crc64.toString();
+ }
+
+ /**
+ * Calculated the checksum of the given data array as a long value.
+ *
+ * @param data the data to checksum
+ * @return the calculated checksum
+ */
+ public static long checksum( byte[] data )
+ {
+ long crc64Number = 0;
+ for ( int i = 0; i < data.length; ++i )
+ {
+ int symbol = data[i];
+ long a = ( crc64Number >>> 8 );
+ long b = ( crc64Number ^ symbol ) & 0xff;
+ crc64Number = a ^ _crc64Array[(int) b];
+ }
+
+ return crc64Number;
+ }
+}
Propchange: directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/Crc64Util.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/Crc64Util.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/InternalUtil.java
URL: http://svn.apache.org/viewvc/directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/InternalUtil.java?rev=1392595&view=auto
==============================================================================
--- directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/InternalUtil.java (added)
+++ directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/InternalUtil.java Mon Oct 1 20:57:42 2012
@@ -0,0 +1,131 @@
+/*
+ * 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 org.apache.directmemory.lightning.internal.util;
+
+import java.lang.reflect.Constructor;
+import java.nio.charset.Charset;
+import java.security.MessageDigest;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.directmemory.lightning.instantiator.ObjectInstantiator;
+import org.apache.directmemory.lightning.internal.beans.PropertyAccessorFactory;
+import org.apache.directmemory.lightning.logging.Logger;
+import org.apache.directmemory.lightning.metadata.PropertyDescriptor;
+
+public final class InternalUtil
+{
+
+ public static final Charset CHARSET = Charset.forName( "UTF-8" );
+
+ public static final boolean UNSAFE_AVAILABLE;
+
+ static
+ {
+ boolean unsafeAvailable = false;
+ try
+ {
+ Class.forName( "sun.misc.Unsafe" );
+ unsafeAvailable = true;
+ }
+ catch ( Exception e )
+ {
+ // Intentionally left blank
+ }
+
+ UNSAFE_AVAILABLE = unsafeAvailable;
+ }
+
+ private InternalUtil()
+ {
+ }
+
+ public static byte[] getChecksum( byte[] data, Logger logger )
+ {
+ try
+ {
+ MessageDigest digest = MessageDigest.getInstance( "SHA-1" );
+ digest.update( data, 0, data.length );
+ return digest.digest();
+ }
+ catch ( Exception e )
+ {
+ throw new RuntimeException( "Could not build checksum of data" );
+ }
+ }
+
+ public static byte[] getChecksum( Collection<PropertyDescriptor> propertyDescriptors, Logger logger )
+ {
+ final StringBuilder builder = new StringBuilder();
+
+ // Clone and sort list of PropertyDescriptors
+ List<PropertyDescriptor> temp = new ArrayList<PropertyDescriptor>( propertyDescriptors );
+ Collections.sort( temp );
+
+ for ( PropertyDescriptor propertyDescriptor : temp )
+ {
+ logger.trace( "Adding property " + propertyDescriptor.getName() + " to checksum" );
+ builder.append( propertyDescriptor.getInternalSignature() );
+ }
+
+ return getChecksum( builder.toString().getBytes( CHARSET ), logger );
+ }
+
+ public static boolean isUnsafeAvailable()
+ {
+ return UNSAFE_AVAILABLE;
+ }
+
+ @SuppressWarnings( "unchecked" )
+ public static ObjectInstantiator buildSunUnsafeInstantiator( Class<?> type )
+ {
+ try
+ {
+ Class<? extends ObjectInstantiator> clazz =
+ (Class<? extends ObjectInstantiator>) ClassUtil.loadClass( "org.apache.directmemory.lightning.internal.instantiator.sun.SunUnsafeAllocateInstanceInstantiator" );
+
+ Constructor<? extends ObjectInstantiator> constructor = clazz.getDeclaredConstructor( Class.class );
+ return constructor.newInstance( type );
+ }
+ catch ( Exception e )
+ {
+ return null;
+ }
+ }
+
+ @SuppressWarnings( "unchecked" )
+ public static PropertyAccessorFactory buildSunUnsafePropertyAccessor()
+ {
+ try
+ {
+ Class<? extends PropertyAccessorFactory> clazz =
+ (Class<? extends PropertyAccessorFactory>) ClassUtil.loadClass( "org.apache.directmemory.lightning.internal.beans.SunUnsafePropertyAccessorFactory" );
+
+ Constructor<? extends PropertyAccessorFactory> constructor = clazz.getDeclaredConstructor();
+ constructor.setAccessible( true );
+ return constructor.newInstance();
+ }
+ catch ( Exception e )
+ {
+ return null;
+ }
+ }
+}
Propchange: directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/InternalUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/InternalUtil.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/StringUtil.java
URL: http://svn.apache.org/viewvc/directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/StringUtil.java?rev=1392595&view=auto
==============================================================================
--- directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/StringUtil.java (added)
+++ directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/StringUtil.java Mon Oct 1 20:57:42 2012
@@ -0,0 +1,95 @@
+/*
+ * 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 org.apache.directmemory.lightning.internal.util;
+
+public final class StringUtil
+{
+
+ private StringUtil()
+ {
+ }
+
+ public static String toLowerCamelCase( String value )
+ {
+ if ( value == null )
+ return null;
+
+ if ( value.length() == 0 )
+ return value;
+
+ return toCamelCase( value );
+ }
+
+ public static String toUpperCamelCase( String value )
+ {
+ String lowerCamelCase = toLowerCamelCase( value );
+ return String.valueOf( Character.toUpperCase( lowerCamelCase.toCharArray()[0] ) )
+ + lowerCamelCase.substring( 1 );
+ }
+
+ private static String toCamelCase( String value )
+ {
+ StringBuilder camelCase = new StringBuilder();
+ char[] characters = value.toCharArray();
+
+ for ( int i = 0; i < characters.length; i++ )
+ {
+ i = ignoreWhitespace( characters, i );
+ if ( i == -1 )
+ break;
+
+ if ( camelCase.length() == 0 )
+ camelCase.append( Character.toLowerCase( characters[i] ) );
+ else
+ camelCase.append( Character.toUpperCase( characters[i] ) );
+
+ int nextWhitespace = nextWhitespace( characters, i );
+ if ( nextWhitespace == -1 )
+ nextWhitespace = characters.length;
+
+ camelCase.append( value.substring( i + 1, nextWhitespace ) );
+ i = nextWhitespace;
+ }
+
+ return camelCase.toString();
+ }
+
+ private static int ignoreWhitespace( char[] characters, int offset )
+ {
+ for ( int i = offset; i < characters.length; i++ )
+ {
+ char c = characters[i];
+ if ( !Character.isWhitespace( c ) && '-' != c && '_' != c )
+ return i;
+ }
+ return -1;
+ }
+
+ private static int nextWhitespace( char[] characters, int offset )
+ {
+ for ( int i = offset + 1; i < characters.length; i++ )
+ {
+ char c = characters[i];
+ if ( Character.isWhitespace( c ) || '-' == c || '_' == c )
+ return i;
+ }
+ return -1;
+ }
+
+}
Propchange: directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/StringUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/StringUtil.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/TypeUtil.java
URL: http://svn.apache.org/viewvc/directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/TypeUtil.java?rev=1392595&view=auto
==============================================================================
--- directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/TypeUtil.java (added)
+++ directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/TypeUtil.java Mon Oct 1 20:57:42 2012
@@ -0,0 +1,61 @@
+/*
+ * 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 org.apache.directmemory.lightning.internal.util;
+
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+
+public final class TypeUtil
+{
+
+ private TypeUtil()
+ {
+ }
+
+ public static Class<?> getBaseType( Type type )
+ {
+ if ( type instanceof Class )
+ {
+ return (Class<?>) type;
+ }
+
+ if ( type instanceof ParameterizedType )
+ {
+ return (Class<?>) ( (ParameterizedType) type ).getRawType();
+ }
+
+ throw new IllegalStateException( "The requested type is an generic array or wildcard which is not supported" );
+ }
+
+ public static Type[] getTypeArgument( Type type )
+ {
+ if ( type instanceof Class )
+ {
+ return null;
+ }
+
+ if ( type instanceof ParameterizedType )
+ {
+ return ( (ParameterizedType) type ).getActualTypeArguments();
+ }
+
+ throw new IllegalStateException( "The requested type is an generic array or wildcard which is not supported" );
+ }
+
+}
Propchange: directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/TypeUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/TypeUtil.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/UnsafeUtil.java
URL: http://svn.apache.org/viewvc/directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/UnsafeUtil.java?rev=1392595&view=auto
==============================================================================
--- directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/UnsafeUtil.java (added)
+++ directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/UnsafeUtil.java Mon Oct 1 20:57:42 2012
@@ -0,0 +1,54 @@
+/*
+ * 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 org.apache.directmemory.lightning.internal.util;
+
+import java.lang.reflect.Field;
+
+@SuppressWarnings( "restriction" )
+public final class UnsafeUtil
+{
+
+ private static final sun.misc.Unsafe UNSAFE;
+
+ static
+ {
+ sun.misc.Unsafe unsafe;
+ try
+ {
+ Field unsafeField = sun.misc.Unsafe.class.getDeclaredField( "theUnsafe" );
+ unsafeField.setAccessible( true );
+ unsafe = (sun.misc.Unsafe) unsafeField.get( null );
+ }
+ catch ( Exception e )
+ {
+ unsafe = null;
+ }
+
+ UNSAFE = unsafe;
+ }
+
+ private UnsafeUtil()
+ {
+ }
+
+ public static sun.misc.Unsafe getUnsafe()
+ {
+ return UNSAFE;
+ }
+}
Propchange: directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/UnsafeUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directmemory/lightning/trunk/lightning-core/src/main/java/org/apache/directmemory/lightning/internal/util/UnsafeUtil.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directmemory/lightning/trunk/lightning-core/src/test/java/org/apache/directmemory/lightning/Benchmark.java
URL: http://svn.apache.org/viewvc/directmemory/lightning/trunk/lightning-core/src/test/java/org/apache/directmemory/lightning/Benchmark.java?rev=1392595&view=auto
==============================================================================
--- directmemory/lightning/trunk/lightning-core/src/test/java/org/apache/directmemory/lightning/Benchmark.java (added)
+++ directmemory/lightning/trunk/lightning-core/src/test/java/org/apache/directmemory/lightning/Benchmark.java Mon Oct 1 20:57:42 2012
@@ -0,0 +1,526 @@
+/*
+ * 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 org.apache.directmemory.lightning;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.File;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.directmemory.lightning.Lightning;
+import org.apache.directmemory.lightning.SerializationContext;
+import org.apache.directmemory.lightning.Serializer;
+import org.apache.directmemory.lightning.base.AbstractObjectMarshaller;
+import org.apache.directmemory.lightning.base.AbstractSerializerDefinition;
+import org.apache.directmemory.lightning.io.SerializerInputStream;
+import org.apache.directmemory.lightning.io.SerializerOutputStream;
+import org.apache.directmemory.lightning.metadata.Attribute;
+import org.apache.directmemory.lightning.metadata.PropertyDescriptor;
+import org.junit.Ignore;
+import org.junit.Test;
+
+@Ignore
+public class Benchmark
+{
+
+ private static final int WARMUP_ROUNDS = 100000;
+
+ private static final int BENCHMARK_ROUNDS = 800000;
+
+ @Test
+ public void benchmarkLightningSerialization()
+ throws Exception
+ {
+ long buildStartTime = System.nanoTime();
+ Serializer serializer =
+ Lightning.newBuilder().debugCacheDirectory( new File( "target" ) ).serializerDefinitions( new BenchmarkSerializerDefinition() ).build();
+ long nanos = TimeUnit.NANOSECONDS.toMillis( System.nanoTime() - buildStartTime );
+ System.out.println( "Lightning Serializer build time: " + nanos + " ms" );
+
+ long size = 0;
+ for ( int i = 0; i < WARMUP_ROUNDS; i++ )
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ SerializerOutputStream out = new SerializerOutputStream( baos, serializer );
+ Foo foo = buildRandomFoo();
+ out.writeObject( foo );
+
+ assertNotNull( baos );
+ assertNotNull( out );
+ assertNotNull( baos.toByteArray() );
+ size = baos.toByteArray().length;
+ }
+
+ try
+ {
+ Thread.sleep( 5000 );
+ }
+ catch ( Exception e )
+ {
+ }
+
+ long time = 0;
+ for ( int i = 0; i < BENCHMARK_ROUNDS; i++ )
+ {
+ Foo foo = buildRandomFoo();
+
+ long startTime = System.nanoTime();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ SerializerOutputStream out = new SerializerOutputStream( baos, serializer );
+ out.writeObject( foo );
+
+ time += System.nanoTime() - startTime;
+ assertNotNull( baos.toByteArray() );
+ }
+
+ double avg = time / (double) BENCHMARK_ROUNDS;
+ System.out.println( "Lightning Serialization Avg: " + String.format( "%5.2f", avg ) + " ns, runs: "
+ + BENCHMARK_ROUNDS + ", size: " + size + " bytes" );
+
+ System.runFinalization();
+ System.gc();
+
+ try
+ {
+ Thread.sleep( 5000 );
+ }
+ catch ( Exception e )
+ {
+ }
+ }
+
+ @Test
+ public void benchmarkLightningDeserialization()
+ throws Exception
+ {
+ Serializer serializer =
+ Lightning.newBuilder().serializerDefinitions( new BenchmarkSerializerDefinition() ).build();
+
+ long size = 0;
+ for ( int i = 0; i < WARMUP_ROUNDS; i++ )
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ SerializerOutputStream out = new SerializerOutputStream( baos, serializer );
+ Foo foo = buildRandomFoo();
+ out.writeObject( foo );
+
+ assertNotNull( baos );
+ assertNotNull( out );
+ assertNotNull( baos.toByteArray() );
+ size = baos.toByteArray().length;
+
+ ByteArrayInputStream bais = new ByteArrayInputStream( baos.toByteArray() );
+ SerializerInputStream in = new SerializerInputStream( bais, serializer );
+ Object value = in.readObject();
+ assertNotNull( value );
+ assertEquals( foo, value );
+ }
+
+ try
+ {
+ Thread.sleep( 5000 );
+ }
+ catch ( Exception e )
+ {
+ }
+
+ long time = 0;
+ for ( int i = 0; i < BENCHMARK_ROUNDS; i++ )
+ {
+ Foo foo = buildRandomFoo();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ SerializerOutputStream out = new SerializerOutputStream( baos, serializer );
+ out.writeObject( foo );
+
+ long startTime = System.nanoTime();
+ ByteArrayInputStream bais = new ByteArrayInputStream( baos.toByteArray() );
+ SerializerInputStream in = new SerializerInputStream( bais, serializer );
+ Object value = in.readObject();
+ time += System.nanoTime() - startTime;
+ assertNotNull( value );
+ assertEquals( foo, value );
+ }
+
+ double avg = time / (double) BENCHMARK_ROUNDS;
+ System.out.println( "Lightning Deserialization Avg: " + String.format( "%5.2f", avg ) + " ns, runs: "
+ + BENCHMARK_ROUNDS + ", size: " + size + " bytes" );
+
+ System.runFinalization();
+ System.gc();
+
+ try
+ {
+ Thread.sleep( 5000 );
+ }
+ catch ( Exception e )
+ {
+ }
+ }
+
+ @Test
+ public void benchmarkJavaSerialization()
+ throws Exception
+ {
+ long size = 0;
+ for ( int i = 0; i < WARMUP_ROUNDS; i++ )
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+ Foo foo = buildRandomFoo();
+ out.writeObject( foo );
+
+ assertNotNull( baos );
+ assertNotNull( out );
+ assertNotNull( baos.toByteArray() );
+ size = baos.toByteArray().length;
+ }
+
+ try
+ {
+ Thread.sleep( 5000 );
+ }
+ catch ( Exception e )
+ {
+ }
+
+ long time = 0;
+ for ( int i = 0; i < BENCHMARK_ROUNDS; i++ )
+ {
+ Foo foo = buildRandomFoo();
+
+ long startTime = System.nanoTime();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+ out.writeObject( foo );
+
+ time += System.nanoTime() - startTime;
+ assertNotNull( baos.toByteArray() );
+ }
+
+ double avg = time / (double) BENCHMARK_ROUNDS;
+ System.out.println( "Java Serialization Avg: " + String.format( "%5.2f", avg ) + " ns, runs: "
+ + BENCHMARK_ROUNDS + ", size: " + size + " bytes" );
+
+ System.runFinalization();
+ System.gc();
+
+ try
+ {
+ Thread.sleep( 5000 );
+ }
+ catch ( Exception e )
+ {
+ }
+ }
+
+ @Test
+ public void benchmarkJavaDeserialization()
+ throws Exception
+ {
+ long size = 0;
+ for ( int i = 0; i < WARMUP_ROUNDS; i++ )
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+ Foo foo = buildRandomFoo();
+ out.writeObject( foo );
+
+ assertNotNull( baos );
+ assertNotNull( out );
+ assertNotNull( baos.toByteArray() );
+ size = baos.toByteArray().length;
+
+ ByteArrayInputStream bais = new ByteArrayInputStream( baos.toByteArray() );
+ ObjectInputStream in = new ObjectInputStream( bais );
+ Object value = in.readObject();
+ assertNotNull( value );
+ assertEquals( foo, value );
+ }
+
+ try
+ {
+ Thread.sleep( 5000 );
+ }
+ catch ( Exception e )
+ {
+ }
+
+ long time = 0;
+ for ( int i = 0; i < BENCHMARK_ROUNDS; i++ )
+ {
+ Foo foo = buildRandomFoo();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+ out.writeObject( foo );
+
+ long startTime = System.nanoTime();
+ ByteArrayInputStream bais = new ByteArrayInputStream( baos.toByteArray() );
+ ObjectInputStream in = new ObjectInputStream( bais );
+ Object value = in.readObject();
+
+ time += System.nanoTime() - startTime;
+ assertNotNull( value );
+ assertEquals( foo, value );
+ }
+
+ double avg = time / (double) BENCHMARK_ROUNDS;
+ System.out.println( "Java Deserialization Avg: " + String.format( "%5.2f", avg ) + " ns, runs: "
+ + BENCHMARK_ROUNDS + ", size: " + size + " bytes" );
+
+ System.runFinalization();
+ System.gc();
+
+ try
+ {
+ Thread.sleep( 5000 );
+ }
+ catch ( Exception e )
+ {
+ }
+ }
+
+ private static final Random RANDOM = new Random( System.nanoTime() );
+
+ private static final String[] STRING_VALUES = { "HGHO", "jldu", "oösd", "JKGH", "HGFG", "JLHL", "GJJK", "JKGH" };
+
+ private static Foo buildRandomFoo()
+ {
+ Foo foo = new Foo();
+ foo.enumValue = RANDOM.nextInt( 100 ) < 50 ? Bar.Value1 : Bar.Value2;
+ foo.someOther = RANDOM.nextInt();
+ foo.value = RANDOM.nextInt( 100 ) < 50 ? null : RANDOM.nextInt();
+ foo.first = STRING_VALUES[RANDOM.nextInt( STRING_VALUES.length )];
+ foo.second = STRING_VALUES[RANDOM.nextInt( STRING_VALUES.length )];
+
+ return foo;
+ }
+
+ public static class BenchmarkSerializerDefinition
+ extends AbstractSerializerDefinition
+ {
+
+ @Override
+ protected void configure()
+ {
+ serialize( Foo.class ).attributes();
+ }
+ }
+
+ @SuppressWarnings( "serial" )
+ public static class Foo
+ implements Serializable
+ {
+
+ private String first;
+
+ private String second;
+
+ private Integer value;
+
+ private int someOther;
+
+ @Attribute
+ private Bar enumValue;
+
+ @Attribute
+ public String getFirst()
+ {
+ return first;
+ }
+
+ public void setFirst( String first )
+ {
+ this.first = first;
+ }
+
+ @Attribute
+ public String getSecond()
+ {
+ return second;
+ }
+
+ public void setSecond( String second )
+ {
+ this.second = second;
+ }
+
+ @Attribute
+ public Integer getValue()
+ {
+ return value;
+ }
+
+ public void setValue( Integer value )
+ {
+ this.value = value;
+ }
+
+ @Attribute
+ // Implicitly required
+ public int getSomeOther()
+ {
+ return someOther;
+ }
+
+ public void setSomeOther( int someOther )
+ {
+ this.someOther = someOther;
+ }
+
+ public Bar getEnumValue()
+ {
+ return enumValue;
+ }
+
+ public void setEnumValue( Bar enumValue )
+ {
+ this.enumValue = enumValue;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Foo [hash=@" + hashCode() + ", first=" + first + ", second=" + second + ", value=" + value
+ + ", someOther=" + someOther + ", enumValue=" + enumValue + "]";
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ( ( enumValue == null ) ? 0 : enumValue.hashCode() );
+ result = prime * result + ( ( first == null ) ? 0 : first.hashCode() );
+ result = prime * result + ( ( second == null ) ? 0 : second.hashCode() );
+ result = prime * result + someOther;
+ result = prime * result + ( ( value == null ) ? 0 : value.hashCode() );
+ return result;
+ }
+
+ @Override
+ public boolean equals( Object obj )
+ {
+ if ( this == obj )
+ return true;
+ if ( obj == null )
+ return false;
+ if ( getClass() != obj.getClass() )
+ return false;
+ Foo other = (Foo) obj;
+ if ( enumValue != other.enumValue )
+ return false;
+ if ( first == null )
+ {
+ if ( other.first != null )
+ return false;
+ }
+ else if ( !first.equals( other.first ) )
+ return false;
+ if ( second == null )
+ {
+ if ( other.second != null )
+ return false;
+ }
+ else if ( !second.equals( other.second ) )
+ return false;
+ if ( someOther != other.someOther )
+ return false;
+ if ( value == null )
+ {
+ if ( other.value != null )
+ return false;
+ }
+ else if ( !value.equals( other.value ) )
+ return false;
+ return true;
+ }
+ }
+
+ public static enum Bar
+ {
+ Value1, Value2
+ }
+
+ public static class BarMarshaller
+ extends AbstractObjectMarshaller
+ {
+
+ @Override
+ public boolean acceptType( Class<?> type )
+ {
+ return type == Bar.class;
+ }
+
+ @Override
+ public void marshall( Object value, PropertyDescriptor propertyDescriptor, DataOutput dataOutput,
+ SerializationContext serializationContext )
+ throws IOException
+ {
+ }
+
+ @Override
+ public <V> V unmarshall( V value, PropertyDescriptor propertyDescriptor, DataInput dataInput,
+ SerializationContext serializationContext )
+ throws IOException
+ {
+
+ return null;
+ }
+ }
+
+ public static class SomeSpecialIntegerMarshaller
+ extends AbstractObjectMarshaller
+ {
+
+ @Override
+ public boolean acceptType( Class<?> type )
+ {
+ return type == Integer.class;
+ }
+
+ @Override
+ public void marshall( Object value, PropertyDescriptor propertyDescriptor, DataOutput dataOutput,
+ SerializationContext serializationContext )
+ throws IOException
+ {
+ }
+
+ @Override
+ public <V> V unmarshall( V value, PropertyDescriptor propertyDescriptor, DataInput dataInput,
+ SerializationContext serializationContext )
+ throws IOException
+ {
+
+ return value;
+ }
+
+ }
+}
Propchange: directmemory/lightning/trunk/lightning-core/src/test/java/org/apache/directmemory/lightning/Benchmark.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directmemory/lightning/trunk/lightning-core/src/test/java/org/apache/directmemory/lightning/Benchmark.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directmemory/lightning/trunk/lightning-core/src/test/java/org/apache/directmemory/lightning/ClassDefinitionContainerTestCase.java
URL: http://svn.apache.org/viewvc/directmemory/lightning/trunk/lightning-core/src/test/java/org/apache/directmemory/lightning/ClassDefinitionContainerTestCase.java?rev=1392595&view=auto
==============================================================================
--- directmemory/lightning/trunk/lightning-core/src/test/java/org/apache/directmemory/lightning/ClassDefinitionContainerTestCase.java (added)
+++ directmemory/lightning/trunk/lightning-core/src/test/java/org/apache/directmemory/lightning/ClassDefinitionContainerTestCase.java Mon Oct 1 20:57:42 2012
@@ -0,0 +1,221 @@
+/*
+ * 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 org.apache.directmemory.lightning;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import org.apache.directmemory.lightning.ClassComparisonStrategy;
+import org.apache.directmemory.lightning.Lightning;
+import org.apache.directmemory.lightning.Serializer;
+import org.apache.directmemory.lightning.base.AbstractSerializerDefinition;
+import org.apache.directmemory.lightning.exceptions.ClassDefinitionInconsistentException;
+import org.apache.directmemory.lightning.internal.util.DebugLogger;
+import org.apache.directmemory.lightning.metadata.Attribute;
+import org.apache.directmemory.lightning.metadata.ClassDefinitionContainer;
+import org.junit.Test;
+
+public class ClassDefinitionContainerTestCase
+{
+
+ @Test
+ public void testLightningChecksum()
+ throws Exception
+ {
+ Serializer serializer =
+ Lightning.newBuilder().logger( new DebugLogger() ).debugCacheDirectory( new File( "target" ) ).serializerDefinitions( new SerializerDefinition() ).build();
+
+ ClassDefinitionContainer container = serializer.getClassDefinitionContainer();
+
+ Serializer remoteSerializer =
+ Lightning.newBuilder().logger( new DebugLogger() ).serializerDefinitions( new SerializerDefinition() ).build();
+
+ remoteSerializer.setClassDefinitionContainer( container );
+ }
+
+ @Test( expected = ClassDefinitionInconsistentException.class )
+ public void testLightningChecksumFailing()
+ throws Exception
+ {
+ Serializer serializer =
+ Lightning.newBuilder().logger( new DebugLogger() ).serializerDefinitions( new SerializerDefinition() ).build();
+
+ ClassDefinitionContainer container = serializer.getClassDefinitionContainer();
+
+ Serializer remoteSerializer = Lightning.newBuilder().logger( new DebugLogger() ).build();
+
+ remoteSerializer.setClassDefinitionContainer( container );
+ }
+
+ @Test
+ public void testSerialVersionUID()
+ throws Exception
+ {
+ Serializer serializer =
+ Lightning.newBuilder().logger( new DebugLogger() ).classComparisonStrategy( ClassComparisonStrategy.SerialVersionUID ).serializerDefinitions( new SerializerDefinition() ).build();
+
+ ClassDefinitionContainer container = serializer.getClassDefinitionContainer();
+
+ Serializer remoteSerializer =
+ Lightning.newBuilder().logger( new DebugLogger() ).serializerDefinitions( new SerializerDefinition() ).build();
+
+ remoteSerializer.setClassDefinitionContainer( container );
+ }
+
+ @Test( expected = ClassDefinitionInconsistentException.class )
+ public void testSerialVersionUIDFailing()
+ throws Exception
+ {
+ Serializer serializer =
+ Lightning.newBuilder().logger( new DebugLogger() ).classComparisonStrategy( ClassComparisonStrategy.SerialVersionUID ).serializerDefinitions( new SerializerDefinition() ).build();
+
+ ClassDefinitionContainer container = serializer.getClassDefinitionContainer();
+
+ Serializer remoteSerializer = Lightning.newBuilder().logger( new DebugLogger() ).build();
+
+ remoteSerializer.setClassDefinitionContainer( container );
+ }
+
+ @Test
+ public void testClassDefinitionContainerTransportLightningChecksum()
+ throws Exception
+ {
+ Serializer serializer =
+ Lightning.newBuilder().logger( new DebugLogger() ).serializerDefinitions( new SerializerDefinition() ).build();
+
+ ClassDefinitionContainer container = serializer.getClassDefinitionContainer();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ out.writeObject( container );
+ byte[] data = baos.toByteArray();
+
+ ByteArrayInputStream bais = new ByteArrayInputStream( data );
+ ObjectInputStream in = new ObjectInputStream( bais );
+
+ ClassDefinitionContainer remoteContainer = (ClassDefinitionContainer) in.readObject();
+
+ Serializer remoteSerializer =
+ Lightning.newBuilder().logger( new DebugLogger() ).serializerDefinitions( new SerializerDefinition() ).build();
+
+ remoteSerializer.setClassDefinitionContainer( remoteContainer );
+ }
+
+ @Test
+ public void testClassDefinitionContainerTransportSerialVersionUID()
+ throws Exception
+ {
+ Serializer serializer =
+ Lightning.newBuilder().logger( new DebugLogger() ).classComparisonStrategy( ClassComparisonStrategy.SerialVersionUID ).serializerDefinitions( new SerializerDefinition() ).build();
+
+ ClassDefinitionContainer container = serializer.getClassDefinitionContainer();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ out.writeObject( container );
+ byte[] data = baos.toByteArray();
+
+ ByteArrayInputStream bais = new ByteArrayInputStream( data );
+ ObjectInputStream in = new ObjectInputStream( bais );
+
+ ClassDefinitionContainer remoteContainer = (ClassDefinitionContainer) in.readObject();
+
+ Serializer remoteSerializer =
+ Lightning.newBuilder().logger( new DebugLogger() ).classComparisonStrategy( ClassComparisonStrategy.SerialVersionUID ).serializerDefinitions( new SerializerDefinition() ).build();
+
+ remoteSerializer.setClassDefinitionContainer( remoteContainer );
+ }
+
+ public static class SerializerDefinition
+ extends AbstractSerializerDefinition
+ {
+
+ @Override
+ protected void configure()
+ {
+ serialize( Foo.class ).attributes();
+ serialize( Bar.class ).attributes();
+ }
+ }
+
+ public static class Foo
+ {
+
+ @Attribute
+ private int id;
+
+ @Attribute
+ private String name;
+
+ public int getId()
+ {
+ return id;
+ }
+
+ public void setId( int id )
+ {
+ this.id = id;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+ }
+
+ public static class Bar
+ {
+
+ @Attribute
+ private int id;
+
+ @Attribute
+ private String name;
+
+ public int getId()
+ {
+ return id;
+ }
+
+ public void setId( int id )
+ {
+ this.id = id;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+ }
+}
Propchange: directmemory/lightning/trunk/lightning-core/src/test/java/org/apache/directmemory/lightning/ClassDefinitionContainerTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directmemory/lightning/trunk/lightning-core/src/test/java/org/apache/directmemory/lightning/ClassDefinitionContainerTestCase.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision