[jboss-cvs] JBossAS SVN: r72888 - in projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature: javassist and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Apr 30 05:24:13 EDT 2008
Author: alesj
Date: 2008-04-30 05:24:13 -0400 (Wed, 30 Apr 2008)
New Revision: 72888
Added:
projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/javassist/
projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/javassist/JavassistConstructorSignature.java
projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/javassist/JavassistFieldSignature.java
projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/javassist/JavassistMethodParametersSignature.java
projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/javassist/JavassistMethodSignature.java
projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/javassist/JavassistSignatureFactory.java
Modified:
projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/ConstructorSignature.java
projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/FieldSignature.java
projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/MethodParametersSignature.java
projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/MethodSignature.java
projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/Signature.java
Log:
Javassist Signatures.
Moving them into separate package, out of plain Signature - removing dependency on javassist.
TODO on tests.
Modified: projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/ConstructorSignature.java
===================================================================
--- projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/ConstructorSignature.java 2008-04-30 07:52:05 UTC (rev 72887)
+++ projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/ConstructorSignature.java 2008-04-30 09:24:13 UTC (rev 72888)
@@ -23,8 +23,6 @@
import java.lang.reflect.Constructor;
-import javassist.CtConstructor;
-import javassist.NotFoundException;
import org.jboss.reflect.spi.ConstructorInfo;
/**
@@ -67,17 +65,6 @@
/**
* Create a new Signature.
- *
- * @param constructor the constructor
- * @throws NotFoundException for any errors
- */
- public ConstructorSignature(CtConstructor constructor) throws NotFoundException
- {
- super(convertParameters(constructor.getParameterTypes()));
- }
-
- /**
- * Create a new Signature.
*
* @param constructor the constructor
*/
Modified: projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/FieldSignature.java
===================================================================
--- projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/FieldSignature.java 2008-04-30 07:52:05 UTC (rev 72887)
+++ projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/FieldSignature.java 2008-04-30 09:24:13 UTC (rev 72888)
@@ -23,7 +23,6 @@
import java.lang.reflect.Field;
-import javassist.CtField;
import org.jboss.reflect.spi.FieldInfo;
/**
@@ -56,16 +55,6 @@
/**
* Create a new Signature.
- *
- * @param field the field
- */
- public FieldSignature(CtField field)
- {
- super(field.getName());
- }
-
- /**
- * Create a new Signature.
*
* @param field the field
*/
Modified: projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/MethodParametersSignature.java
===================================================================
--- projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/MethodParametersSignature.java 2008-04-30 07:52:05 UTC (rev 72887)
+++ projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/MethodParametersSignature.java 2008-04-30 09:24:13 UTC (rev 72888)
@@ -23,8 +23,6 @@
import java.lang.reflect.Method;
-import javassist.CtMethod;
-import javassist.NotFoundException;
import org.jboss.reflect.spi.MethodInfo;
/**
@@ -78,20 +76,6 @@
this.param = param;
checkParam();
}
-
- /**
- * Create a new Signature.
- *
- * @param method the method
- * @param param the parameter number
- * @throws NotFoundException for any error
- */
- public MethodParametersSignature(CtMethod method, int param) throws NotFoundException
- {
- super(method.getName(), convertParameters(method.getParameterTypes()));
- this.param = param;
- checkParam();
- }
/**
* Create a new Signature.
Modified: projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/MethodSignature.java
===================================================================
--- projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/MethodSignature.java 2008-04-30 07:52:05 UTC (rev 72887)
+++ projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/MethodSignature.java 2008-04-30 09:24:13 UTC (rev 72888)
@@ -24,8 +24,6 @@
import java.lang.reflect.Method;
import org.jboss.reflect.spi.MethodInfo;
-import javassist.CtMethod;
-import javassist.NotFoundException;
/**
* Method Signature.
@@ -69,17 +67,6 @@
/**
* Create a new Signature.
- *
- * @param method the method
- * @throws NotFoundException for any error
- */
- public MethodSignature(CtMethod method) throws NotFoundException
- {
- super(method.getName(), convertParameters(method.getParameterTypes()));
- }
-
- /**
- * Create a new Signature.
*
* @param method the method
*/
Modified: projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/Signature.java
===================================================================
--- projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/Signature.java 2008-04-30 07:52:05 UTC (rev 72887)
+++ projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/Signature.java 2008-04-30 09:24:13 UTC (rev 72888)
@@ -28,13 +28,6 @@
import java.lang.reflect.Method;
import java.util.Arrays;
-import javassist.CtClass;
-import javassist.CtConstructor;
-import javassist.CtField;
-import javassist.CtMember;
-import javassist.CtMethod;
-import javassist.NotFoundException;
-import javassist.CtPrimitiveType;
import org.jboss.reflect.spi.ConstructorInfo;
import org.jboss.reflect.spi.FieldInfo;
import org.jboss.reflect.spi.MemberInfo;
@@ -101,36 +94,6 @@
}
/**
- * Get a signature for a member
- *
- * @param member the member
- * @return the result
- * @throws NotFoundException for any error
- */
- public static Signature getSignature(CtMember member) throws NotFoundException
- {
- if (member == null)
- throw new IllegalArgumentException("Null member");
-
- if (member instanceof CtMethod)
- {
- CtMethod method = CtMethod.class.cast(member);
- return new MethodSignature(method);
- }
- if (member instanceof CtField)
- {
- CtField field = CtField.class.cast(member);
- return new FieldSignature(field);
- }
- if (member instanceof CtConstructor)
- {
- CtConstructor constructor = CtConstructor.class.cast(member);
- return new ConstructorSignature(constructor);
- }
- throw new IllegalArgumentException("Unknown member: " + member);
- }
-
- /**
* Get a signature for a member info
*
* @param member the member
@@ -176,76 +139,6 @@
return paramTypes;
}
- public static String[] convertParameters(CtClass[] classes)
- {
- if (classes == null || classes.length == 0)
- return NO_PARAMETERS;
-
- String[] paramTypes = new String[classes.length];
- for (int i = 0; i < classes.length; ++i)
- paramTypes[i] = convertName(classes[i]);
- return paramTypes;
- }
-
- /**
- * Convert ct class to full classname.
- *
- * @param clazz the ct class
- * @return class name
- */
- protected static String convertName(CtClass clazz)
- {
- if (clazz == null)
- throw new IllegalArgumentException("Null CtClass");
-
- CtClass temp = clazz;
- if (temp.isArray())
- {
- StringBuilder buffer = new StringBuilder();
- try
- {
- while (temp.isArray())
- {
- buffer.append('[');
- temp = temp.getComponentType();
- }
- if (temp.isPrimitive())
- {
- CtPrimitiveType primitive = (CtPrimitiveType) temp;
- buffer.append(Character.toString(primitive.getDescriptor()));
- }
- else
- {
- buffer.append('L');
- buffer.append(temp.getName());
- buffer.append(';');
- }
- return buffer.toString();
- }
- catch (NotFoundException e)
- {
- throw raiseClassNotFound(clazz.getName(), e);
- }
- }
- return clazz.getName();
- }
-
- /**
- * Raise NCDFE exception.
- *
- * @param name the classname
- * @param e javassist exception
- * @return NCDFE instance
- * @throws NoClassDefFoundError transform e param into NCDFE
- */
- protected static NoClassDefFoundError raiseClassNotFound(String name, NotFoundException e) throws NoClassDefFoundError
- {
- NoClassDefFoundError ex = new NoClassDefFoundError("Unable to find class " + name);
- if (e.getCause() != null)
- ex.initCause(e.getCause()); // Hide the javassist error
- throw ex;
- }
-
@SuppressWarnings("deprecation")
public static Class<?>[] convertParameterTypes(TypeInfo[] typeInfos)
{
Copied: projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/javassist/JavassistConstructorSignature.java (from rev 72880, projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/ConstructorSignature.java)
===================================================================
--- projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/javassist/JavassistConstructorSignature.java (rev 0)
+++ projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/javassist/JavassistConstructorSignature.java 2008-04-30 09:24:13 UTC (rev 72888)
@@ -0,0 +1,45 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.metadata.spi.signature.javassist;
+
+import javassist.CtConstructor;
+import javassist.NotFoundException;
+import org.jboss.metadata.spi.signature.ConstructorSignature;
+
+/**
+ * Javassist Constructor Signature.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class JavassistConstructorSignature extends ConstructorSignature
+{
+ /**
+ * Create a new Signature.
+ *
+ * @param constructor the constructor
+ * @throws javassist.NotFoundException for any errors
+ */
+ public JavassistConstructorSignature(CtConstructor constructor) throws NotFoundException
+ {
+ super(JavassistSignatureFactory.convertParameters(constructor.getParameterTypes()));
+ }
+}
\ No newline at end of file
Copied: projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/javassist/JavassistFieldSignature.java (from rev 72880, projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/FieldSignature.java)
===================================================================
--- projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/javassist/JavassistFieldSignature.java (rev 0)
+++ projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/javassist/JavassistFieldSignature.java 2008-04-30 09:24:13 UTC (rev 72888)
@@ -0,0 +1,43 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.metadata.spi.signature.javassist;
+
+import javassist.CtField;
+import org.jboss.metadata.spi.signature.FieldSignature;
+
+/**
+ * Javassist Field Signature.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class JavassistFieldSignature extends FieldSignature
+{
+ /**
+ * Create a new Signature.
+ *
+ * @param field the field
+ */
+ public JavassistFieldSignature(CtField field)
+ {
+ super(field.getName());
+ }
+}
\ No newline at end of file
Copied: projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/javassist/JavassistMethodParametersSignature.java (from rev 72880, projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/MethodParametersSignature.java)
===================================================================
--- projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/javassist/JavassistMethodParametersSignature.java (rev 0)
+++ projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/javassist/JavassistMethodParametersSignature.java 2008-04-30 09:24:13 UTC (rev 72888)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.metadata.spi.signature.javassist;
+
+import javassist.CtMethod;
+import javassist.NotFoundException;
+import org.jboss.metadata.spi.signature.MethodParametersSignature;
+
+/**
+ * Javassist Method parameters Signature.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class JavassistMethodParametersSignature extends MethodParametersSignature
+{
+ /**
+ * Create a new Signature.
+ *
+ * @param method the method
+ * @param param the parameter number
+ * @throws javassist.NotFoundException for any error
+ */
+ public JavassistMethodParametersSignature(CtMethod method, int param) throws NotFoundException
+ {
+ super(method.getName(), JavassistSignatureFactory.convertParameters(method.getParameterTypes()), param);
+ }
+}
\ No newline at end of file
Added: projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/javassist/JavassistMethodSignature.java
===================================================================
--- projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/javassist/JavassistMethodSignature.java (rev 0)
+++ projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/javassist/JavassistMethodSignature.java 2008-04-30 09:24:13 UTC (rev 72888)
@@ -0,0 +1,45 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.metadata.spi.signature.javassist;
+
+import javassist.CtMethod;
+import javassist.NotFoundException;
+import org.jboss.metadata.spi.signature.MethodSignature;
+
+/**
+ * Javassist Method Signature.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class JavassistMethodSignature extends MethodSignature
+{
+ /**
+ * Create a new Signature.
+ *
+ * @param method the method
+ * @throws javassist.NotFoundException for any error
+ */
+ public JavassistMethodSignature(CtMethod method) throws NotFoundException
+ {
+ super(method.getName(), JavassistSignatureFactory.convertParameters(method.getParameterTypes()));
+ }
+}
\ No newline at end of file
Copied: projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/javassist/JavassistSignatureFactory.java (from rev 72880, projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/Signature.java)
===================================================================
--- projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/javassist/JavassistSignatureFactory.java (rev 0)
+++ projects/jboss-mdr/trunk/src/main/org/jboss/metadata/spi/signature/javassist/JavassistSignatureFactory.java 2008-04-30 09:24:13 UTC (rev 72888)
@@ -0,0 +1,145 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.metadata.spi.signature.javassist;
+
+import javassist.CtConstructor;
+import javassist.CtField;
+import javassist.CtMember;
+import javassist.CtMethod;
+import javassist.NotFoundException;
+import javassist.CtClass;
+import javassist.CtPrimitiveType;
+import org.jboss.metadata.spi.signature.Signature;
+
+/**
+ * Javassist Signature factory.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class JavassistSignatureFactory
+{
+ /**
+ * Get a signature for a member
+ *
+ * @param member the member
+ * @return the result
+ * @throws javassist.NotFoundException for any error
+ */
+ public static Signature getSignature(CtMember member) throws NotFoundException
+ {
+ if (member == null)
+ throw new IllegalArgumentException("Null member");
+
+ if (member instanceof CtMethod)
+ {
+ CtMethod method = CtMethod.class.cast(member);
+ return new JavassistMethodSignature(method);
+ }
+ if (member instanceof CtField)
+ {
+ CtField field = CtField.class.cast(member);
+ return new JavassistFieldSignature(field);
+ }
+ if (member instanceof CtConstructor)
+ {
+ CtConstructor constructor = CtConstructor.class.cast(member);
+ return new JavassistConstructorSignature(constructor);
+ }
+ throw new IllegalArgumentException("Unknown member: " + member);
+ }
+
+ /**
+ * Convert ct classes to string class names.
+ *
+ * @param classes the classes
+ * @return class names
+ */
+ public static String[] convertParameters(CtClass[] classes)
+ {
+ if (classes == null || classes.length == 0)
+ return Signature.NO_PARAMETERS;
+
+ String[] paramTypes = new String[classes.length];
+ for (int i = 0; i < classes.length; ++i)
+ paramTypes[i] = convertName(classes[i]);
+ return paramTypes;
+ }
+
+ /**
+ * Convert ct class to full classname.
+ *
+ * @param clazz the ct class
+ * @return class name
+ */
+ protected static String convertName(CtClass clazz)
+ {
+ if (clazz == null)
+ throw new IllegalArgumentException("Null CtClass");
+
+ CtClass temp = clazz;
+ if (temp.isArray())
+ {
+ StringBuilder buffer = new StringBuilder();
+ try
+ {
+ while (temp.isArray())
+ {
+ buffer.append('[');
+ temp = temp.getComponentType();
+ }
+ if (temp.isPrimitive())
+ {
+ CtPrimitiveType primitive = (CtPrimitiveType) temp;
+ buffer.append(Character.toString(primitive.getDescriptor()));
+ }
+ else
+ {
+ buffer.append('L');
+ buffer.append(temp.getName());
+ buffer.append(';');
+ }
+ return buffer.toString();
+ }
+ catch (NotFoundException e)
+ {
+ throw raiseClassNotFound(clazz.getName(), e);
+ }
+ }
+ return clazz.getName();
+ }
+
+ /**
+ * Raise NCDFE exception.
+ *
+ * @param name the classname
+ * @param e javassist exception
+ * @return NCDFE instance
+ * @throws NoClassDefFoundError transform e param into NCDFE
+ */
+ protected static NoClassDefFoundError raiseClassNotFound(String name, NotFoundException e) throws NoClassDefFoundError
+ {
+ NoClassDefFoundError ex = new NoClassDefFoundError("Unable to find class " + name);
+ if (e.getCause() != null)
+ ex.initCause(e.getCause()); // Hide the javassist error
+ throw ex;
+ }
+}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list