Author: hardy.ferentschik
Date: 2009-01-20 12:05:49 -0500 (Tue, 20 Jan 2009)
New Revision: 13152
Added:
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/IMetaEntity.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/IMetaMember.java
Modified:
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity.java
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMember.java
Log:
Added interfaced for some of the MetaXXX classes. The idea being to be able to create
second set of MetaXXX implementation backed by xml conmfiguration
Added: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/IMetaEntity.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/IMetaEntity.java
(rev 0)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/IMetaEntity.java 2009-01-20
17:05:49 UTC (rev 13152)
@@ -0,0 +1,43 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed 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.jboss.jpa.metamodel.ap;
+
+import javax.lang.model.element.Name;
+import javax.lang.model.element.Element;
+import java.util.List;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface IMetaEntity extends ImportContext {
+ String getSimpleName();
+
+ String getQualifiedName();
+
+ String getPackageName();
+
+ List<IMetaMember> getMembers();
+
+ String generateImports();
+
+ String importType(String fqcn);
+
+ String staticImport(String fqcn, String member);
+
+ String importType(Name qualifiedName);
+}
Added: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/IMetaMember.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/IMetaMember.java
(rev 0)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/IMetaMember.java 2009-01-20
17:05:49 UTC (rev 13152)
@@ -0,0 +1,25 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed 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.jboss.jpa.metamodel.ap;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface IMetaMember {
+ String getDeclarationString();
+}
Modified:
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java
===================================================================
---
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java 2009-01-20
16:41:50 UTC (rev 13151)
+++
workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java 2009-01-20
17:05:49 UTC (rev 13152)
@@ -27,7 +27,7 @@
private static final String ORM_XML_LOCATION = "/META-INF/orm.xml";
- private static final Map<String, MetaEntity> metaEntities = new
HashMap<String, MetaEntity>();
+ private static final Map<String, IMetaEntity> metaEntities = new
HashMap<String, IMetaEntity>();
public JPAMetaModelEntityProcessor() {
}
@@ -118,17 +118,15 @@
}
}
- private void writeFile(MetaEntity entity) {
+ private void writeFile(IMetaEntity entity) {
try {
- Name metaModelPackage = entity.getPackageName();
+ String metaModelPackage = entity.getPackageName();
-
StringBuffer body = generateBody(entity);
FileObject fo = processingEnv.getFiler().createSourceFile(
- metaModelPackage + "." + entity.getSimpleName() +
"_",
- entity.getOriginalElement());
+ metaModelPackage + "." + entity.getSimpleName() +
"_");
OutputStream os = fo.openOutputStream();
PrintWriter pw = new PrintWriter(os);
@@ -161,7 +159,7 @@
*
* @return body content
*/
- private StringBuffer generateBody(MetaEntity entity) {
+ private StringBuffer generateBody(IMetaEntity entity) {
StringWriter sw = new StringWriter();
PrintWriter pw = null;
@@ -177,9 +175,9 @@
pw.println();
- List<MetaMember> members = entity.getMembers();
+ List<IMetaMember> members = entity.getMembers();
- for (MetaMember metaMember : members) {
+ for (IMetaMember metaMember : members) {
pw.println(" " + metaMember.getDeclarationString());
}
pw.println();
Modified: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity.java 2009-01-20
16:41:50 UTC (rev 13151)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaEntity.java 2009-01-20
17:05:49 UTC (rev 13152)
@@ -21,7 +21,7 @@
import javax.lang.model.util.SimpleTypeVisitor6;
import javax.tools.Diagnostic.Kind;
-public class MetaEntity implements ImportContext {
+public class MetaEntity implements IMetaEntity {
final TypeElement element;
final protected ProcessingEnvironment pe;
@@ -34,26 +34,26 @@
importContext = new ImportContextImpl(getPackageName().toString());
}
- public Name getSimpleName() {
- return element.getSimpleName();
+ public String getSimpleName() {
+ return element.getSimpleName().toString();
}
public Element getOriginalElement() {
return element;
}
- public Name getQualifiedName() {
- return element.getQualifiedName();
+ public String getQualifiedName() {
+ return element.getQualifiedName().toString();
}
- public Name getPackageName() {
+ public String getPackageName() {
PackageElement packageOf = pe.getElementUtils().getPackageOf(element);
- return pe.getElementUtils().getName(packageOf.getQualifiedName() +
".metamodel");
+ return pe.getElementUtils().getName(packageOf.getQualifiedName() +
".metamodel").toString();
}
- public List<MetaMember> getMembers() {
+ public List<IMetaMember> getMembers() {
- List<MetaMember> members = new ArrayList<MetaMember>();
+ List<IMetaMember> members = new ArrayList<IMetaMember>();
if (useFields()) {
Modified: workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMember.java
===================================================================
--- workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMember.java 2009-01-20
16:41:50 UTC (rev 13151)
+++ workspace/max/jpaap/jpaap/src/org/jboss/jpa/metamodel/ap/MetaMember.java 2009-01-20
17:05:49 UTC (rev 13152)
@@ -7,7 +7,7 @@
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.Name;
-public abstract class MetaMember {
+public abstract class MetaMember implements IMetaMember {
final protected Element element;
final protected MetaEntity parent;