You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by pc...@apache.org on 2004/08/10 01:23:17 UTC
cvs commit: xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/annogen/internal AnnotationServiceParamsImpl.java
pcal 2004/08/09 16:23:16
Modified: v2/jam/src/org/apache/xmlbeans/impl/jam
JAnnotationValue.java
v2/jam/src/org/apache/xmlbeans/impl/jam/annogen
AnnotationServiceFactory.java
v2/jam/src/org/apache/xmlbeans/impl/jam/annogen/internal
AnnotationServiceParamsImpl.java
Log:
jam: few updates
Revision Changes Path
1.4 +17 -0 xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/JAnnotationValue.java
Index: JAnnotationValue.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/JAnnotationValue.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- JAnnotationValue.java 5 Apr 2004 00:06:12 -0000 1.3
+++ JAnnotationValue.java 9 Aug 2004 23:23:16 -0000 1.4
@@ -18,6 +18,23 @@
/**
* <p>Represents a member value of a JAnnotation.</p>
*
+ * <p><b>A note regarding enums</b></p>
+ *
+ * <p>The presence of metadata of 'enum' types poses a bit of a challenge
+ * in the untyped view of metadata that is presented by JAnnotationValue.
+ * Because JAM cannot assume that the enum definitions have been compiled,
+ * it is not possible for JAM to return an instance of an enumuerated type.
+ * In other words, it is not possible for JAnnotationValue to provide an
+ * asEnum() method.</p>
+ *
+ * <p>If JAM encounters an annotation value of an enumerated type, it will
+ * represent it with a JAnnotationValue such that calling <code>
+ * myAnnotationValue.getType().isEnumType()</code> will return true.
+ * Moreover, calling <code>myAnnotationValue.asString()</code> will return
+ * the name of the enumeration field, exactly as it appears in the
+ * type declaration.
+ * </p>
+ *
* @author Patrick Calahan <pc...@bea.com>
*/
public interface JAnnotationValue {
1.2 +52 -7 xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/annogen/AnnotationServiceFactory.java
Index: AnnotationServiceFactory.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/annogen/AnnotationServiceFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AnnotationServiceFactory.java 4 Aug 2004 16:31:40 -0000 1.1
+++ AnnotationServiceFactory.java 9 Aug 2004 23:23:16 -0000 1.2
@@ -15,6 +15,9 @@
package org.apache.xmlbeans.impl.jam.annogen;
import org.apache.xmlbeans.impl.jam.annogen.internal.AnnotationServiceParamsImpl;
+import org.apache.xmlbeans.impl.jam.annogen.internal.BaseAnnotationService;
+import org.apache.xmlbeans.impl.jam.annogen.provider.ProxyPopulator;
+import org.apache.xmlbeans.impl.jam.annogen.provider.CompositeProxyPopulator;
/**
@@ -23,11 +26,6 @@
public class AnnotationServiceFactory {
// ========================================================================
- // Constants
-
- private static final AnnotationServiceFactory DEFAULT = new AnnotationServiceFactory();
-
- // ========================================================================
// Singleton
/**
@@ -36,6 +34,20 @@
public static AnnotationServiceFactory getInstance() { return DEFAULT; }
// ========================================================================
+ // Constants
+
+ private static final AnnotationServiceFactory DEFAULT = new AnnotationServiceFactory();
+
+
+ private static final String REFLECTING_POPULATOR =
+ "org.apache.xmlbeans.impl.jam.annogen.internal.reflect175";
+
+ // ========================================================================
+ // Variables
+
+ private ProxyPopulator mReflectingPopulator = null;
+
+ // ========================================================================
// Constructors
protected AnnotationServiceFactory() {}
@@ -55,8 +67,10 @@
/**
* <p>Create a new AnnoService using the given parameters.</p>
*/
- public AnnotationService createService(AnnotationService params) {
- return null;
+ public AnnotationService createService(AnnotationServiceParams params) {
+ ProxyPopulator[] pps = ((AnnotationServiceParamsImpl)params).getPopulators();
+ ProxyPopulator cp = new CompositeProxyPopulator((pps));
+ return new BaseAnnotationService(cp);
}
@@ -66,6 +80,37 @@
* annotation APIs in java.lang.reflect).</p>
*/
public AnnotationService createDefaultService() {
+ return new BaseAnnotationService(getReflectingPopulator());
+ }
+
+
+ // ========================================================================
+ // Private methods
+
+
+ public ProxyPopulator getReflectingPopulator() {
+ if (mReflectingPopulator != null) return mReflectingPopulator;
+
+ try {
+ // class for name this because it's 1.5-specific. if it fails, we
+ // don't want to use the extractor
+ Class.forName("java.lang.annotation.Annotation");
+ } catch (ClassNotFoundException e) {
+ //issue14RuntimeWarning(e);
+ return null;
+ }
+ // ok, if we could load that, let's new up the extractor delegate
+ try {
+ mReflectingPopulator = (ProxyPopulator)
+ Class.forName(REFLECTING_POPULATOR).newInstance();
+ // if this fails for any reason, things are in a bad state
+ } catch (ClassNotFoundException e) {
+// issue14BuildWarning(e);
+ } catch (IllegalAccessException e) {
+// issue14BuildWarning(e);
+ } catch (InstantiationException e) {
+// issue14BuildWarning(e);
+ }
return null;
}
}
1.3 +8 -3 xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/annogen/internal/AnnotationServiceParamsImpl.java
Index: AnnotationServiceParamsImpl.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/annogen/internal/AnnotationServiceParamsImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AnnotationServiceParamsImpl.java 5 Aug 2004 16:29:12 -0000 1.2
+++ AnnotationServiceParamsImpl.java 9 Aug 2004 23:23:16 -0000 1.3
@@ -16,6 +16,7 @@
import org.apache.xmlbeans.impl.jam.annogen.provider.ProxyPopulator;
import org.apache.xmlbeans.impl.jam.annogen.AnnotationServiceParams;
+import org.apache.xmlbeans.impl.jam.annogen.AnnotationServiceFactory;
import java.io.Reader;
import java.io.File;
@@ -36,7 +37,11 @@
// ========================================================================
// Constructors
- public AnnotationServiceParamsImpl() {}
+ public AnnotationServiceParamsImpl() {
+ ProxyPopulator reflectProxy =
+ AnnotationServiceFactory.getInstance().getReflectingPopulator();
+ if (reflectProxy != null) mPopulators.add(reflectProxy);
+ }
// ========================================================================
// Public methods
@@ -60,9 +65,9 @@
}
// ========================================================================
- // Pacakge methods
+ // Internal use only
- /*package*/ ProxyPopulator[] getPopulators() {
+ public ProxyPopulator[] getPopulators() {
ProxyPopulator[] out = new ProxyPopulator[mPopulators.size()];
mPopulators.toArray(out);
return out;
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org