You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2008/07/20 13:37:32 UTC

svn commit: r678269 [1/2] - in /openejb/trunk/sandbox/openejb-eclipse-plugin: common/ common/src/main/java/org/apache/openejb/plugins/common/ common/src/main/resources/org/apache/openejb/plugins/common/ common/src/test/ common/src/test/java/ common/src...

Author: jgallimore
Date: Sun Jul 20 04:37:31 2008
New Revision: 678269

URL: http://svn.apache.org/viewvc?rev=678269&view=rev
Log:
Added very basic test to common conversion code, some exception handling, and some bug fixes.

Added:
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/java/
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/java/org/
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/java/org/apache/
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/java/org/apache/openejb/
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/java/org/apache/openejb/plugins/
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/java/org/apache/openejb/plugins/common/
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/java/org/apache/openejb/plugins/common/ConverterTest.java
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/java/org/apache/openejb/plugins/common/JDTFacadeStub.java
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/resources/
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/resources/org/
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/resources/org/apache/
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/resources/org/apache/openejb/
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/resources/org/apache/openejb/plugins/
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/resources/org/apache/openejb/plugins/common/
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/resources/org/apache/openejb/plugins/common/ejb-jar1.xml
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/resources/org/apache/openejb/plugins/common/ejb-jar2.xml
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/resources/org/apache/openejb/plugins/common/ejb-jar3.xml
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/resources/org/apache/openejb/plugins/common/openejb-jar1.xml
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/resources/org/apache/openejb/plugins/common/openejb-jar2.xml
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/resources/org/apache/openejb/plugins/common/openejb-jar3.xml
Modified:
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/pom.xml
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/EjbReferencesConverter.java
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/EntityBeanConverter.java
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/EntityBeanPojoConverter.java
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/IJDTFacade.java
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/OpenEjbXmlConverter.java
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/SessionBeanConverter.java
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/resources/org/apache/openejb/plugins/common/messages.properties
    openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/JDTFacade.java
    openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/wizards/EJBMigrationRefactoring.java

Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/common/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/common/pom.xml?rev=678269&r1=678268&r2=678269&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/common/pom.xml (original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/common/pom.xml Sun Jul 20 04:37:31 2008
@@ -1,126 +1,126 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
-  ~ 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.
-  -->
+	~ 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.
+-->
 <project>
-  <parent>
-    <artifactId>eclipse-plugins</artifactId>
-    <groupId>org.apache.openejb</groupId>
-    <version>1.0.0</version>
-  </parent>
-  <modelVersion>4.0.0</modelVersion>
-  <groupId>org.apache.openejb</groupId>
-  <artifactId>plugins-common</artifactId>
-  <name>${artifactId}</name>
-  <version>1.0.0</version>
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.geronimo.specs</groupId>
-      <artifactId>geronimo-ejb_3.0_spec</artifactId>
-      <version>1.0</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.xbean</groupId>
-      <artifactId>xbean-finder</artifactId>
-      <version>3.2-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <groupId>javax.activation</groupId>
-      <artifactId>activation</artifactId>
-      <version>1.1</version>
-    </dependency>
-    <dependency>
-      <groupId>javax.xml</groupId>
-      <artifactId>jsr173</artifactId>
-      <version>1.0</version>
-    </dependency>
-    <dependency>
-      <groupId>javax.xml.bind</groupId>
-      <artifactId>jsr173_api</artifactId>
-      <version>1.0</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.geronimo.specs</groupId>
-      <artifactId>geronimo-activation_1.1_spec</artifactId>
-      <version>1.0</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.geronimo.specs</groupId>
-      <artifactId>geronimo-stax-api_1.0_spec</artifactId>
-      <version>1.0</version>
-    </dependency>
-    <dependency>
-      <groupId>javax.xml.bind</groupId>
-      <artifactId>jaxb-api</artifactId>
-      <version>2.0</version>
-    </dependency>
-    <dependency>
-      <groupId>com.sun.xml.bind</groupId>
-      <artifactId>jaxb-impl</artifactId>
-      <version>2.0.3</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.openejb</groupId>
-      <artifactId>openejb-jee</artifactId>
-      <version>3.1-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.openejb</groupId>
-      <artifactId>openejb-core</artifactId>
-      <version>3.1-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.openejb</groupId>
-      <artifactId>openejb-loader</artifactId>
-      <version>3.1-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <groupId>javax.xml</groupId>
-      <artifactId>jsr173</artifactId>
-      <version>1.0</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.geronimo.specs</groupId>
-      <artifactId>geronimo-annotation_1.0_spec</artifactId>
-      <version>1.1</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.geronimo.specs</groupId>
-      <artifactId>geronimo-interceptor_3.0_spec</artifactId>
-      <version>1.0</version>
-    </dependency>
-    <dependency>
-      <groupId>wsdl4j</groupId>
-      <artifactId>wsdl4j</artifactId>
-      <version>1.6.1</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.geronimo.specs</groupId>
-      <artifactId>geronimo-jpa_3.0_spec</artifactId>
-      <version>1.1</version>
-    </dependency>
-    <dependency>
-      <groupId>log4j</groupId>
-      <artifactId>log4j</artifactId>
-      <version>1.2.12</version>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.swizzle</groupId>
-      <artifactId>swizzle-stream</artifactId>
-      <version>1.0.1</version>
-    </dependency>
-  </dependencies>
+	<parent>
+		<artifactId>eclipse-plugins</artifactId>
+		<groupId>org.apache.openejb</groupId>
+		<version>1.0.0</version>
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.apache.openejb</groupId>
+	<artifactId>plugins-common</artifactId>
+	<name>${artifactId}</name>
+	<version>1.0.0</version>
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.geronimo.specs</groupId>
+			<artifactId>geronimo-ejb_3.0_spec</artifactId>
+			<version>1.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.xbean</groupId>
+			<artifactId>xbean-finder</artifactId>
+			<version>3.2-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>javax.activation</groupId>
+			<artifactId>activation</artifactId>
+			<version>1.1</version>
+		</dependency>
+		<dependency>
+			<groupId>javax.xml</groupId>
+			<artifactId>jsr173</artifactId>
+			<version>1.0</version>
+		</dependency>
+		<dependency>
+			<groupId>javax.xml.bind</groupId>
+			<artifactId>jsr173_api</artifactId>
+			<version>1.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.geronimo.specs</groupId>
+			<artifactId>geronimo-activation_1.1_spec</artifactId>
+			<version>1.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.geronimo.specs</groupId>
+			<artifactId>geronimo-stax-api_1.0_spec</artifactId>
+			<version>1.0</version>
+		</dependency>
+		<dependency>
+			<groupId>javax.xml.bind</groupId>
+			<artifactId>jaxb-api</artifactId>
+			<version>2.0</version>
+		</dependency>
+		<dependency>
+			<groupId>com.sun.xml.bind</groupId>
+			<artifactId>jaxb-impl</artifactId>
+			<version>2.0.3</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.openejb</groupId>
+			<artifactId>openejb-jee</artifactId>
+			<version>3.1-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.openejb</groupId>
+			<artifactId>openejb-core</artifactId>
+			<version>3.1-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.openejb</groupId>
+			<artifactId>openejb-loader</artifactId>
+			<version>3.1-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>javax.xml</groupId>
+			<artifactId>jsr173</artifactId>
+			<version>1.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.geronimo.specs</groupId>
+			<artifactId>geronimo-annotation_1.0_spec</artifactId>
+			<version>1.1</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.geronimo.specs</groupId>
+			<artifactId>geronimo-interceptor_3.0_spec</artifactId>
+			<version>1.0</version>
+		</dependency>
+		<dependency>
+			<groupId>wsdl4j</groupId>
+			<artifactId>wsdl4j</artifactId>
+			<version>1.6.1</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.geronimo.specs</groupId>
+			<artifactId>geronimo-jpa_3.0_spec</artifactId>
+			<version>1.1</version>
+		</dependency>
+		<dependency>
+			<groupId>log4j</groupId>
+			<artifactId>log4j</artifactId>
+			<version>1.2.12</version>
+		</dependency>
+		<dependency>
+			<groupId>org.codehaus.swizzle</groupId>
+			<artifactId>swizzle-stream</artifactId>
+			<version>1.0.1</version>
+		</dependency>
+	</dependencies>
 </project>

Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/EjbReferencesConverter.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/EjbReferencesConverter.java?rev=678269&r1=678268&r2=678269&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/EjbReferencesConverter.java (original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/EjbReferencesConverter.java Sun Jul 20 04:37:31 2008
@@ -46,16 +46,19 @@
 					continue;
 				}
 
-				SessionBean sessionBean = (SessionBean) enterpriseBean;
-				String remoteClass = sessionBean.getRemote();
-				String localClass = sessionBean.getLocal();
-
-				if (remoteClass != null && remoteClass.length() > 0) {
-					facade.addAnnotationToFieldsOfType(remoteClass, EJB.class, null);
-				}
-
-				if (localClass != null && localClass.length() > 0) {
-					facade.addAnnotationToFieldsOfType(localClass, EJB.class, null);
+				try {
+					SessionBean sessionBean = (SessionBean) enterpriseBean;
+					String remoteClass = sessionBean.getRemote();
+					String localClass = sessionBean.getLocal();
+					if (remoteClass != null && remoteClass.length() > 0) {
+						facade.addAnnotationToFieldsOfType(remoteClass, EJB.class, null);
+					}
+					if (localClass != null && localClass.length() > 0) {
+						facade.addAnnotationToFieldsOfType(localClass, EJB.class, null);
+					}
+				} catch (Exception e) {
+					String warning = String.format(Messages.getString("org.apache.openejb.helper.annotation.warnings.12"), "@javax.ejb.EJB", enterpriseBean.getEjbClass());
+					facade.addWarning(warning);
 				}
 			}
 		}

Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/EntityBeanConverter.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/EntityBeanConverter.java?rev=678269&r1=678268&r2=678269&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/EntityBeanConverter.java (original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/EntityBeanConverter.java Sun Jul 20 04:37:31 2008
@@ -29,8 +29,13 @@
 
 import org.apache.openejb.config.AppModule;
 import org.apache.openejb.config.EjbModule;
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.EjbRelation;
+import org.apache.openejb.jee.EjbRelationshipRole;
 import org.apache.openejb.jee.EnterpriseBean;
 import org.apache.openejb.jee.EntityBean;
+import org.apache.openejb.jee.Multiplicity;
+import org.apache.openejb.jee.Relationships;
 import org.apache.openejb.jee.jpa.Attributes;
 import org.apache.openejb.jee.jpa.Basic;
 import org.apache.openejb.jee.jpa.CascadeType;
@@ -64,54 +69,61 @@
 	@SuppressWarnings("unchecked") //$NON-NLS-1$
 	private void addOneToManyRelationshipAnnotations(EntityBean entityBean, org.apache.openejb.jee.jpa.Entity entity) {
 
-		List<OneToMany> relationships = entity.getAttributes().getOneToMany();
-		for (OneToMany relationship : relationships) {
+		try {
+			List<OneToMany> relationships = entity.getAttributes().getOneToMany();
+			for (OneToMany relationship : relationships) {
 
-			Map oneToManyProperties = getPropertiesForRelationship(relationship);
+				Map oneToManyProperties = getPropertiesForRelationship(relationship);
 
-			String name = relationship.getName();
-			String nameGetter = "get" + name.substring(0, 1).toUpperCase() + name.substring(1); //$NON-NLS-1$
+				String name = relationship.getName();
+				String nameGetter = "get" + name.substring(0, 1).toUpperCase() + name.substring(1); //$NON-NLS-1$
 
-			facade.addMethodAnnotation(entityBean.getEjbClass(), nameGetter, new String[] {}, javax.persistence.OneToMany.class, oneToManyProperties);
+				facade.addMethodAnnotation(entityBean.getEjbClass(), nameGetter, new String[] {}, javax.persistence.OneToMany.class, oneToManyProperties);
+			}
+		} catch (Exception e) {
+			String warning = String.format(Messages.getString("org.apache.openejb.helper.annotation.warnings.12"), "@javax.persistence.OneToMany", entityBean.getEjbClass());
+			facade.addWarning(warning);
 		}
 	}
 
 	@SuppressWarnings("unchecked") //$NON-NLS-1$
 	private void addNamedQueriesAnnotations(EntityBean entityBean, org.apache.openejb.jee.jpa.Entity entity) {
 
-		List<NamedQuery> namedQueries = entity.getNamedQuery();
-		List namedQueriesValues = new ArrayList();
-
-		for (NamedQuery namedQuery : namedQueries) {
-			String name = namedQuery.getName();
-			String query = namedQuery.getQuery();
-
-			List<QueryHint> hints = namedQuery.getHint();
-
-			List hintProperties = new ArrayList();
+		try {
+			List<NamedQuery> namedQueries = entity.getNamedQuery();
+			List namedQueriesValues = new ArrayList();
+			for (NamedQuery namedQuery : namedQueries) {
+				String name = namedQuery.getName();
+				String query = namedQuery.getQuery();
+
+				List<QueryHint> hints = namedQuery.getHint();
+
+				List hintProperties = new ArrayList();
+
+				for (QueryHint hint : hints) {
+					String hintName = hint.getName();
+					String hintValue = hint.getValue();
+
+					Map hintProperty = new HashMap();
+					hintProperty.put("name", hintName); //$NON-NLS-1$
+					hintProperty.put("value", hintValue); //$NON-NLS-1$
+					hintProperties.add(hintProperty);
+				}
 
-			for (QueryHint hint : hints) {
-				String hintName = hint.getName();
-				String hintValue = hint.getValue();
+				Map namedQueryProperties = new HashMap();
+				namedQueryProperties.put("name", name); //$NON-NLS-1$
+				namedQueryProperties.put("query", query); //$NON-NLS-1$
+				namedQueryProperties.put("hints", hintProperties.toArray(new Object[0])); //$NON-NLS-1$
 
-				Map hintProperty = new HashMap();
-				hintProperty.put("name", hintName); //$NON-NLS-1$
-				hintProperty.put("value", hintValue); //$NON-NLS-1$
-				hintProperties.add(hintProperty);
+				namedQueriesValues.add(namedQueryProperties);
 			}
-
-			Map namedQueryProperties = new HashMap();
-			namedQueryProperties.put("name", name); //$NON-NLS-1$
-			namedQueryProperties.put("query", query); //$NON-NLS-1$
-			namedQueryProperties.put("hints", hintProperties.toArray(new Object[0])); //$NON-NLS-1$
-
-			namedQueriesValues.add(namedQueryProperties);
+			Map namedQueriesProperties = new HashMap();
+			namedQueriesProperties.put("value", namedQueriesValues.toArray(new Object[0])); //$NON-NLS-1$
+			facade.addClassAnnotation(entityBean.getEjbClass(), NamedQueries.class, namedQueriesProperties);
+		} catch (Exception e) {
+			String warning = String.format(Messages.getString("org.apache.openejb.helper.annotation.warnings.12"), "@javax.persistence.NamedQueries", entityBean.getEjbClass());
+			facade.addWarning(warning);
 		}
-
-		Map namedQueriesProperties = new HashMap();
-		namedQueriesProperties.put("value", namedQueriesValues.toArray(new Object[0])); //$NON-NLS-1$
-
-		facade.addClassAnnotation(entityBean.getEjbClass(), NamedQueries.class, namedQueriesProperties);
 	}
 
 	private void addBasicAnnotations(EntityBean entityBean, List<Basic> basicAttributes) {
@@ -119,26 +131,30 @@
 			String fieldName = basic.getName();
 			Column column = basic.getColumn();
 
+			if (fieldName == null || column == null) {
+				return;
+			}
+			
 			addBasicAnnotation(entityBean, fieldName, basic, column);
 		}
 	}
 
 	private void addBasicAnnotation(EntityBean entityBean, String fieldName, Basic basic, Column column) {
-		addColumnAnnotation(entityBean, fieldName, column);
-		Boolean optional = basic.isOptional();
-		FetchType fetchType = basic.getFetch();
-
-		Map<String, Object> basicProps = new HashMap<String, Object>();
-		if (optional != null)
-			basicProps.put("optional", optional.booleanValue()); //$NON-NLS-1$
-		if (fetchType != null)
-			basicProps.put("fetch", fetchType.value()); //$NON-NLS-1$
-
-		// annotationHelper.addFieldAnnotation(entityBean.getEjbClass(),
-		// fieldName, javax.persistence.Basic.class, basicProps);
-
-		String methodName = convertFieldNameToGetterName(fieldName);
-		facade.addMethodAnnotation(entityBean.getEjbClass(), methodName, new String[0], javax.persistence.Basic.class, basicProps);
+		try {
+			addColumnAnnotation(entityBean, fieldName, column);
+			Boolean optional = basic.isOptional();
+			FetchType fetchType = basic.getFetch();
+			Map<String, Object> basicProps = new HashMap<String, Object>();
+			if (optional != null)
+				basicProps.put("optional", optional.booleanValue()); //$NON-NLS-1$
+			if (fetchType != null)
+				basicProps.put("fetch", fetchType.value()); //$NON-NLS-1$
+			String methodName = convertFieldNameToGetterName(fieldName);
+			facade.addMethodAnnotation(entityBean.getEjbClass(), methodName, new String[0], javax.persistence.Basic.class, basicProps);
+		} catch (Exception e) {
+			String warning = String.format(Messages.getString("org.apache.openejb.helper.annotation.warnings.12"), "@javax.persistence.Basic", entityBean.getEjbClass());
+			facade.addWarning(warning);
+		}
 	}
 
 	private String convertFieldNameToGetterName(String fieldName) {
@@ -166,62 +182,67 @@
 	}
 
 	private void addColumnAnnotation(EntityBean entityBean, String fieldName, Column column) {
-		Map<String, Object> columnProps = new HashMap<String, Object>();
-		if (column.getName() != null)
-			columnProps.put("name", column.getName()); //$NON-NLS-1$
-		if (column.isUnique() != null)
-			columnProps.put("unique", column.isUnique().booleanValue()); //$NON-NLS-1$
-		if (column.isNullable() != null)
-			columnProps.put("nullable", column.isNullable().booleanValue()); //$NON-NLS-1$
-		if (column.isInsertable() != null)
-			columnProps.put("insertable", column.isInsertable().booleanValue()); //$NON-NLS-1$
-		if (column.isUpdatable() != null)
-			columnProps.put("updatable", column.isUpdatable().booleanValue()); //$NON-NLS-1$
-		if (column.getColumnDefinition() != null)
-			columnProps.put("columnDefinition", column.getColumnDefinition()); //$NON-NLS-1$
-		if (column.getTable() != null)
-			columnProps.put("table", column.getTable()); //$NON-NLS-1$
-		if (column.getLength() != null)
-			columnProps.put("length", column.getLength().intValue()); //$NON-NLS-1$
-		if (column.getPrecision() != null)
-			columnProps.put("precision", column.getPrecision().intValue()); //$NON-NLS-1$
-		if (column.getScale() != null)
-			columnProps.put("scale", column.getScale().intValue()); //$NON-NLS-1$
-
-		// annotationHelper.addFieldAnnotation(entityBean.getEjbClass(),
-		// fieldName, javax.persistence.Column.class, columnProps);
-
-		String methodName = convertFieldNameToGetterName(fieldName);
-		facade.addMethodAnnotation(entityBean.getEjbClass(), methodName, new String[0], javax.persistence.Column.class, columnProps);
-
+		try {
+			Map<String, Object> columnProps = new HashMap<String, Object>();
+			if (column.getName() != null)
+				columnProps.put("name", column.getName()); //$NON-NLS-1$
+			if (column.isUnique() != null)
+				columnProps.put("unique", column.isUnique().booleanValue()); //$NON-NLS-1$
+			if (column.isNullable() != null)
+				columnProps.put("nullable", column.isNullable().booleanValue()); //$NON-NLS-1$
+			if (column.isInsertable() != null)
+				columnProps.put("insertable", column.isInsertable().booleanValue()); //$NON-NLS-1$
+			if (column.isUpdatable() != null)
+				columnProps.put("updatable", column.isUpdatable().booleanValue()); //$NON-NLS-1$
+			if (column.getColumnDefinition() != null)
+				columnProps.put("columnDefinition", column.getColumnDefinition()); //$NON-NLS-1$
+			if (column.getTable() != null)
+				columnProps.put("table", column.getTable()); //$NON-NLS-1$
+			if (column.getLength() != null)
+				columnProps.put("length", column.getLength().intValue()); //$NON-NLS-1$
+			if (column.getPrecision() != null)
+				columnProps.put("precision", column.getPrecision().intValue()); //$NON-NLS-1$
+			if (column.getScale() != null)
+				columnProps.put("scale", column.getScale().intValue()); //$NON-NLS-1$
+			String methodName = convertFieldNameToGetterName(fieldName);
+			facade.addMethodAnnotation(entityBean.getEjbClass(), methodName, new String[0], javax.persistence.Column.class, columnProps);
+		} catch (Exception e) {
+			String warning = String.format(Messages.getString("org.apache.openejb.helper.annotation.warnings.12"), "@javax.persistence.Column", entityBean.getEjbClass());
+			facade.addWarning(warning);
+		}
 	}
 
 	private void addTableAnnotation(EntityBean entityBean, org.apache.openejb.jee.jpa.Entity entity) {
-		String tableName = entity.getTable().getName();
-		String schemaName = entity.getTable().getSchema();
-		String catalogName = entity.getTable().getCatalog();
+		try {
+			String tableName = entity.getTable().getName();
+			String schemaName = entity.getTable().getSchema();
+			String catalogName = entity.getTable().getCatalog();
 
-		Map<String, Object> tableProperties = new HashMap<String, Object>();
-		if (tableName != null && tableName.length() > 0) {
-			tableProperties.put("name", tableName); //$NON-NLS-1$
-		}
+			Map<String, Object> tableProperties = new HashMap<String, Object>();
+			if (tableName != null && tableName.length() > 0) {
+				tableProperties.put("name", tableName); //$NON-NLS-1$
+			}
 
-		if (schemaName != null && schemaName.length() > 0) {
-			tableProperties.put("schema", schemaName); //$NON-NLS-1$
-		}
+			if (schemaName != null && schemaName.length() > 0) {
+				tableProperties.put("schema", schemaName); //$NON-NLS-1$
+			}
 
-		if (catalogName != null && catalogName.length() > 0) {
-			tableProperties.put("catalog", catalogName); //$NON-NLS-1$
-		}
+			if (catalogName != null && catalogName.length() > 0) {
+				tableProperties.put("catalog", catalogName); //$NON-NLS-1$
+			}
 
-		facade.addClassAnnotation(entityBean.getEjbClass(), Table.class, tableProperties);
+			facade.addClassAnnotation(entityBean.getEjbClass(), Table.class, tableProperties);
+		} catch (Exception e) {
+			String warning = String.format(Messages.getString("org.apache.openejb.helper.annotation.warnings.12"), "@javax.persistence.Table", entityBean.getEjbClass());
+			facade.addWarning(warning);
+		}
 	}
 
 	private org.apache.openejb.jee.jpa.Entity getEntity(EntityMappings entityMappings, String ejbName) {
 		Collection<org.apache.openejb.jee.jpa.Entity> entities = entityMappings.getEntity();
 
 		for (org.apache.openejb.jee.jpa.Entity entity : entities) {
-			if (entity.getName().equals(ejbName)) {
+			if (entity.getEjbName().equals(ejbName)) {
 				return entity;
 			}
 		}
@@ -251,6 +272,8 @@
 		EntityMappings entityMappings = appModule.getCmpMappings();
 		List<EntityBean> entityBeans = getEntityBeans(appModule);
 
+		addRelationshipAnnotations(appModule);
+		
 		for (EntityBean entityBean : entityBeans) {
 
 			checkEjbClassName(entityBean);
@@ -268,24 +291,113 @@
 				addBasicAnnotations(entityBean, attributes.getBasic());
 				addNamedQueriesAnnotations(entityBean, entity);
 				addNamedNativeQueriesAnnotations(entityBean, entity);
-				addOneToManyRelationshipAnnotations(entityBean, entity);
-				addManyToOneRelationshipAnnotations(entityBean, entity);
-				addOneToOneRelationshipAnnotations(entityBean, entity);
+//				addOneToManyRelationshipAnnotations(entityBean, entity);
+//				addManyToOneRelationshipAnnotations(entityBean, entity);
+//				addOneToOneRelationshipAnnotations(entityBean, entity);
+			}
+		}
+	}
+
+	private void addRelationshipAnnotations(AppModule appModule) {
+		List<EjbModule> ejbModules = appModule.getEjbModules();
+		for (EjbModule ejbModule : ejbModules) {
+			EjbJar ejbJar = ejbModule.getEjbJar();
+			Relationships relationships = ejbJar.getRelationships();
+			List<EjbRelation> relations = relationships.getEjbRelation();
+			
+			for (EjbRelation relation : relations) {
+				List<EjbRelationshipRole> roles = relation.getEjbRelationshipRole();
+				if (roles == null || roles.size() != 2) {
+					// dunno what to do with this
+					continue;
+				}
+				
+				EjbRelationshipRole left = roles.get(0);
+				EjbRelationshipRole right = roles.get(1);
+				
+				String leftClass = getEjbClass(ejbJar, left.getRelationshipRoleSource().getEjbName());
+				String rightClass = getEjbClass(ejbJar, right.getRelationshipRoleSource().getEjbName());
+				String leftMethod = null;
+				try {
+					leftMethod = "get" + capitaliseFirstLetter(left.getCmrField().getCmrFieldName());
+				} catch (Exception e) {
+				}
+		
+				String rightMethod = null;
+				try {
+					rightMethod = "get" + capitaliseFirstLetter(right.getCmrField().getCmrFieldName());
+				} catch (Exception e) {
+				}
+				
+				boolean leftCascade = left.getCascadeDelete();
+				boolean rightCascade = right.getCascadeDelete();
+				
+				Map<String, Object> leftProps = new HashMap<String, Object>();
+				leftProps.put("targetEntity", rightClass);
+				
+				if (leftCascade) {
+					leftProps.put("cascade", new Object[] { javax.persistence.CascadeType.REMOVE }); //$NON-NLS-1$
+				}
+				
+
+				Map<String, Object> rightProps = new HashMap<String, Object>();
+				rightProps.put("targetEntity", leftClass);
+				
+				if (rightCascade) {
+					rightProps.put("cascade", new Object[] { javax.persistence.CascadeType.REMOVE }); //$NON-NLS-1$
+				}
+				
+				if (Multiplicity.MANY.equals(left.getMultiplicity()) && Multiplicity.MANY.equals(right.getMultiplicity())) {
+					if (leftMethod != null)
+						facade.addMethodAnnotation(leftClass, leftMethod, new String[0], javax.persistence.ManyToMany.class, leftProps);
+					if (rightMethod != null)
+						facade.addMethodAnnotation(rightClass, rightMethod, new String[0], javax.persistence.ManyToMany.class, rightProps);
+				} else if (Multiplicity.MANY.equals(left.getMultiplicity()) && Multiplicity.ONE.equals(right.getMultiplicity())) {
+					if (leftMethod != null)
+						facade.addMethodAnnotation(leftClass, leftMethod, new String[0], javax.persistence.ManyToOne.class, leftProps);
+					if (rightMethod != null)
+						facade.addMethodAnnotation(rightClass, rightMethod, new String[0], javax.persistence.OneToMany.class, rightProps);
+				} else if (Multiplicity.ONE.equals(left.getMultiplicity()) && Multiplicity.MANY.equals(right.getMultiplicity())) {
+					if (leftMethod != null)
+						facade.addMethodAnnotation(leftClass, leftMethod, new String[0], javax.persistence.OneToMany.class, leftProps);
+					if (rightMethod != null)
+						facade.addMethodAnnotation(rightClass, rightMethod, new String[0], javax.persistence.ManyToOne.class, rightProps);
+				} else if (Multiplicity.ONE.equals(left.getMultiplicity()) && Multiplicity.ONE.equals(right.getMultiplicity())) {
+					if (leftMethod != null)
+						facade.addMethodAnnotation(leftClass, leftMethod, new String[0], javax.persistence.OneToOne.class, leftProps);
+					if (rightMethod != null)
+						facade.addMethodAnnotation(rightClass, rightMethod, new String[0], javax.persistence.OneToOne.class, rightProps);
+				}
 			}
+			
 		}
 	}
 
+	private String getEjbClass(EjbJar ejbJar, String ejbName) {
+		EnterpriseBean enterpriseBean = ejbJar.getEnterpriseBean(ejbName);
+		if (enterpriseBean instanceof EntityBean) {
+			return enterpriseBean.getEjbClass();
+		}
+		
+		return null;
+	}
+
 	@SuppressWarnings("unchecked") //$NON-NLS-1$
 	private void addOneToOneRelationshipAnnotations(EntityBean entityBean, org.apache.openejb.jee.jpa.Entity entity) {
-		List<OneToOne> relationships = entity.getAttributes().getOneToOne();
-		for (OneToOne relationship : relationships) {
+		try {
+			List<OneToOne> relationships = entity.getAttributes().getOneToOne();
+			for (OneToOne relationship : relationships) {
 
-			String name = relationship.getName();
-			String nameGetter = "get" + name.substring(0, 1).toUpperCase() + name.substring(1); //$NON-NLS-1$
+				String name = relationship.getName();
+				String nameGetter = "get" + name.substring(0, 1).toUpperCase() + name.substring(1); //$NON-NLS-1$
 
-			Map<String, Object> oneToOneProperties = getPropertiesForRelationship(relationship);
+				Map<String, Object> oneToOneProperties = getPropertiesForRelationship(relationship);
 
-			facade.addMethodAnnotation(entityBean.getEjbClass(), nameGetter, new String[] {}, javax.persistence.OneToOne.class, oneToOneProperties);
+				facade.addMethodAnnotation(entityBean.getEjbClass(), nameGetter, new String[] {}, javax.persistence.OneToOne.class, oneToOneProperties);
+			}
+		} catch (Exception e) {
+			String warning = String.format(Messages.getString("org.apache.openejb.helper.annotation.warnings.12"), "@javax.persistence.OneToOne", entityBean.getEjbClass());
+			facade.addWarning(warning);
 		}
 	}
 
@@ -294,18 +406,19 @@
 		List<ManyToOne> relationships = entity.getAttributes().getManyToOne();
 		for (ManyToOne relationship : relationships) {
 
-			String name = relationship.getName();
-			String nameGetter = "get" + name.substring(0, 1).toUpperCase() + name.substring(1); //$NON-NLS-1$
-
-			Map manyToOneProperties = getPropertiesForRelationship(relationship);
-
-			Boolean optional = relationship.isOptional();
-			if (optional != null) {
-				manyToOneProperties.put("optional", optional.booleanValue()); //$NON-NLS-1$
+			try {
+				String name = relationship.getName();
+				String nameGetter = "get" + name.substring(0, 1).toUpperCase() + name.substring(1); //$NON-NLS-1$
+				Map manyToOneProperties = getPropertiesForRelationship(relationship);
+				Boolean optional = relationship.isOptional();
+				if (optional != null) {
+					manyToOneProperties.put("optional", optional.booleanValue()); //$NON-NLS-1$
+				}
+				facade.addMethodAnnotation(entityBean.getEjbClass(), nameGetter, new String[] {}, javax.persistence.OneToOne.class, manyToOneProperties);
+			} catch (Exception e) {
+				String warning = String.format(Messages.getString("org.apache.openejb.helper.annotation.warnings.12"), "@javax.persistence.OneToOone", entityBean.getEjbClass());
+				facade.addWarning(warning);
 			}
-
-
-			facade.addMethodAnnotation(entityBean.getEjbClass(), nameGetter, new String[] {}, javax.persistence.OneToOne.class, manyToOneProperties);
 		}
 	}
 
@@ -354,56 +467,60 @@
 
 	@SuppressWarnings("unchecked") //$NON-NLS-1$
 	private void addIdClassAnnotation(EntityBean entityBean, org.apache.openejb.jee.jpa.Entity entity) {
-		IdClass idClass = entity.getIdClass();
-
-		if (idClass == null) {
-			return;
+		try {
+			IdClass idClass = entity.getIdClass();
+			if (idClass == null) {
+				return;
+			}
+			String cls = idClass.getClazz();
+			Map props = new HashMap();
+			props.put("value", cls); //$NON-NLS-1$
+			facade.addClassAnnotation(entityBean.getEjbClass(), javax.persistence.IdClass.class, props);
+		} catch (Exception e) {
+			String warning = String.format(Messages.getString("org.apache.openejb.helper.annotation.warnings.12"), "@javax.persistence.IdClass", entityBean.getEjbClass());
+			facade.addWarning(warning);
 		}
-
-		String cls = idClass.getClazz();
-
-		Map props = new HashMap();
-		props.put("value", cls); //$NON-NLS-1$
-
-		facade.addClassAnnotation(entityBean.getEjbClass(), javax.persistence.IdClass.class, props);
 	}
 
 	@SuppressWarnings("unchecked") //$NON-NLS-1$
 	private void addNamedNativeQueriesAnnotations(EntityBean entityBean, org.apache.openejb.jee.jpa.Entity entity) {
-		List<NamedNativeQuery> namedQueries = entity.getNamedNativeQuery();
-		List namedQueriesValues = new ArrayList();
-
-		for (NamedNativeQuery namedQuery : namedQueries) {
-			String name = namedQuery.getName();
-			String query = namedQuery.getQuery();
-
-			List<QueryHint> hints = namedQuery.getHint();
-
-			List hintProperties = new ArrayList();
-
-			for (QueryHint hint : hints) {
-				String hintName = hint.getName();
-				String hintValue = hint.getValue();
-
-				Map hintProperty = new HashMap();
-				hintProperty.put("name", hintName); //$NON-NLS-1$
-				hintProperty.put("value", hintValue); //$NON-NLS-1$
-				hintProperties.add(hintProperty);
-			}
-
-			Map namedQueryProperties = new HashMap();
-			namedQueryProperties.put("name", name); //$NON-NLS-1$
-			namedQueryProperties.put("query", query); //$NON-NLS-1$
-			namedQueryProperties.put("hints", hintProperties.toArray(new Object[0])); //$NON-NLS-1$
-
-			namedQueriesValues.add(namedQueryProperties);
-		}
-
-		if (namedQueriesValues.size() > 0) {
-			Map namedQueriesProperties = new HashMap();
-			namedQueriesProperties.put("value", namedQueriesValues.toArray(new Object[0])); //$NON-NLS-1$
+		try {
+			List<NamedNativeQuery> namedQueries = entity.getNamedNativeQuery();
+			List namedQueriesValues = new ArrayList();
+			for (NamedNativeQuery namedQuery : namedQueries) {
+				String name = namedQuery.getName();
+				String query = namedQuery.getQuery();
+
+				List<QueryHint> hints = namedQuery.getHint();
+
+				List hintProperties = new ArrayList();
+
+				for (QueryHint hint : hints) {
+					String hintName = hint.getName();
+					String hintValue = hint.getValue();
+
+					Map hintProperty = new HashMap();
+					hintProperty.put("name", hintName); //$NON-NLS-1$
+					hintProperty.put("value", hintValue); //$NON-NLS-1$
+					hintProperties.add(hintProperty);
+				}
 
-			facade.addClassAnnotation(entityBean.getEjbClass(), NamedNativeQueries.class, namedQueriesProperties);
+				Map namedQueryProperties = new HashMap();
+				namedQueryProperties.put("name", name); //$NON-NLS-1$
+				namedQueryProperties.put("query", query); //$NON-NLS-1$
+				namedQueryProperties.put("hints", hintProperties.toArray(new Object[0])); //$NON-NLS-1$
+
+				namedQueriesValues.add(namedQueryProperties);
+			}
+			if (namedQueriesValues.size() > 0) {
+				Map namedQueriesProperties = new HashMap();
+				namedQueriesProperties.put("value", namedQueriesValues.toArray(new Object[0])); //$NON-NLS-1$
+
+				facade.addClassAnnotation(entityBean.getEjbClass(), NamedNativeQueries.class, namedQueriesProperties);
+			}
+		} catch (Exception e) {
+			String warning = String.format(Messages.getString("org.apache.openejb.helper.annotation.warnings.12"), "@javax.persistence.NamedNativeQueries", entityBean.getEjbClass());
+			facade.addWarning(warning);
 		}
 	}
 
@@ -414,26 +531,25 @@
 			String fieldName = id.getName();
 			Column column = id.getColumn();
 
-			addColumnAnnotation(entityBean, fieldName, column);
+			if (fieldName != null && column != null)
+				addColumnAnnotation(entityBean, fieldName, column);
 		}
 	}
 
 	@SuppressWarnings("unchecked") //$NON-NLS-1$
 	private void addIdAnnotation(EntityBean entityBean, Id id) {
-		String fieldName = id.getName();
-
-		String methodName = convertFieldNameToGetterName(fieldName);
-		String[] emptySignature = new String[0];
-		facade.addMethodAnnotation(entityBean.getEjbClass(), methodName, emptySignature , javax.persistence.Id.class, null);
-
-
-		GeneratedValue generatedValue = id.getGeneratedValue();
-		if (generatedValue != null) {
-			Map<String, Object> generatedValueProps = new HashMap<String, Object>();
-			generatedValueProps.put("generator", generatedValue.getGenerator()); //$NON-NLS-1$
+		try {
+			String fieldName = id.getName();
+			String methodName = convertFieldNameToGetterName(fieldName);
+			String[] emptySignature = new String[0];
+			facade.addMethodAnnotation(entityBean.getEjbClass(), methodName, emptySignature, javax.persistence.Id.class, null);
+			GeneratedValue generatedValue = id.getGeneratedValue();
+			if (generatedValue != null) {
+				Map<String, Object> generatedValueProps = new HashMap<String, Object>();
+				generatedValueProps.put("generator", generatedValue.getGenerator()); //$NON-NLS-1$
 
-			GenerationType strategy = generatedValue.getStrategy();
-			switch (strategy) {
+				GenerationType strategy = generatedValue.getStrategy();
+				switch (strategy) {
 				case AUTO:
 					generatedValueProps.put("strategy", javax.persistence.GenerationType.AUTO); //$NON-NLS-1$
 					break;
@@ -446,47 +562,49 @@
 				case TABLE:
 					generatedValueProps.put("strategy", javax.persistence.GenerationType.TABLE); //$NON-NLS-1$
 					break;
-			}
-
-			facade.addMethodAnnotation(entityBean.getEjbClass(), methodName, emptySignature, javax.persistence.GeneratedValue.class, generatedValueProps);
-		}
+				}
 
-		SequenceGenerator sequenceGenerator = id.getSequenceGenerator();
-		if (sequenceGenerator != null) {
-			Map<String, Object> sequenceGeneratorProps = new HashMap<String, Object>();
-			sequenceGeneratorProps.put("name", sequenceGenerator.getName()); //$NON-NLS-1$
-			sequenceGeneratorProps.put("sequenceName", sequenceGenerator.getSequenceName()); //$NON-NLS-1$
-			sequenceGeneratorProps.put("initialValue", sequenceGenerator.getInitialValue().intValue()); //$NON-NLS-1$
-			sequenceGeneratorProps.put("allocationSize", sequenceGenerator.getAllocationSize().intValue()); //$NON-NLS-1$
-
-			facade.addMethodAnnotation(entityBean.getEjbClass(), methodName, emptySignature, javax.persistence.SequenceGenerator.class, sequenceGeneratorProps);
-		}
-
-		TableGenerator tableGenerator = id.getTableGenerator();
-		if (tableGenerator != null) {
-			Map<String, Object> tableGeneratorProps = new HashMap<String, Object>();
-			tableGeneratorProps.put("name", tableGenerator.getName()); //$NON-NLS-1$
-			tableGeneratorProps.put("table", tableGenerator.getTable()); //$NON-NLS-1$
-			tableGeneratorProps.put("catalog", tableGenerator.getCatalog()); //$NON-NLS-1$
-			tableGeneratorProps.put("schema", tableGenerator.getSchema()); //$NON-NLS-1$
-			tableGeneratorProps.put("pkColumnName", tableGenerator.getPkColumnName()); //$NON-NLS-1$
-			tableGeneratorProps.put("valueColumnName", tableGenerator.getValueColumnName()); //$NON-NLS-1$
-			tableGeneratorProps.put("pkColumnValue", tableGenerator.getPkColumnValue()); //$NON-NLS-1$
-			tableGeneratorProps.put("initialValue", tableGenerator.getInitialValue().intValue()); //$NON-NLS-1$
-			tableGeneratorProps.put("allocationSize", tableGenerator.getAllocationSize().intValue()); //$NON-NLS-1$
-
-			List uniqueConstraintPropsList = new ArrayList();
-
-			List<UniqueConstraint> uniqueConstraints = tableGenerator.getUniqueConstraint();
-			for (UniqueConstraint uniqueConstriant : uniqueConstraints) {
-				Map<String, Object> uniqueConstraintProps = new HashMap<String, Object>();
-				List<String> columns = uniqueConstriant.getColumnName();
-				uniqueConstraintProps.put("columnNames", columns.toArray(new String[0])); //$NON-NLS-1$
-				uniqueConstraintPropsList.add(uniqueConstraintProps);
+				facade.addMethodAnnotation(entityBean.getEjbClass(), methodName, emptySignature, javax.persistence.GeneratedValue.class, generatedValueProps);
 			}
+			SequenceGenerator sequenceGenerator = id.getSequenceGenerator();
+			if (sequenceGenerator != null) {
+				Map<String, Object> sequenceGeneratorProps = new HashMap<String, Object>();
+				sequenceGeneratorProps.put("name", sequenceGenerator.getName()); //$NON-NLS-1$
+				sequenceGeneratorProps.put("sequenceName", sequenceGenerator.getSequenceName()); //$NON-NLS-1$
+				sequenceGeneratorProps.put("initialValue", sequenceGenerator.getInitialValue().intValue()); //$NON-NLS-1$
+				sequenceGeneratorProps.put("allocationSize", sequenceGenerator.getAllocationSize().intValue()); //$NON-NLS-1$
+
+				facade.addMethodAnnotation(entityBean.getEjbClass(), methodName, emptySignature, javax.persistence.SequenceGenerator.class, sequenceGeneratorProps);
+			}
+			TableGenerator tableGenerator = id.getTableGenerator();
+			if (tableGenerator != null) {
+				Map<String, Object> tableGeneratorProps = new HashMap<String, Object>();
+				tableGeneratorProps.put("name", tableGenerator.getName()); //$NON-NLS-1$
+				tableGeneratorProps.put("table", tableGenerator.getTable()); //$NON-NLS-1$
+				tableGeneratorProps.put("catalog", tableGenerator.getCatalog()); //$NON-NLS-1$
+				tableGeneratorProps.put("schema", tableGenerator.getSchema()); //$NON-NLS-1$
+				tableGeneratorProps.put("pkColumnName", tableGenerator.getPkColumnName()); //$NON-NLS-1$
+				tableGeneratorProps.put("valueColumnName", tableGenerator.getValueColumnName()); //$NON-NLS-1$
+				tableGeneratorProps.put("pkColumnValue", tableGenerator.getPkColumnValue()); //$NON-NLS-1$
+				tableGeneratorProps.put("initialValue", tableGenerator.getInitialValue().intValue()); //$NON-NLS-1$
+				tableGeneratorProps.put("allocationSize", tableGenerator.getAllocationSize().intValue()); //$NON-NLS-1$
+
+				List uniqueConstraintPropsList = new ArrayList();
+
+				List<UniqueConstraint> uniqueConstraints = tableGenerator.getUniqueConstraint();
+				for (UniqueConstraint uniqueConstriant : uniqueConstraints) {
+					Map<String, Object> uniqueConstraintProps = new HashMap<String, Object>();
+					List<String> columns = uniqueConstriant.getColumnName();
+					uniqueConstraintProps.put("columnNames", columns.toArray(new String[0])); //$NON-NLS-1$
+					uniqueConstraintPropsList.add(uniqueConstraintProps);
+				}
 
-			tableGeneratorProps.put("uniqueConstraints", uniqueConstraintPropsList.toArray(new Object[0])); //$NON-NLS-1$
-			facade.addMethodAnnotation(entityBean.getEjbClass(), methodName, emptySignature, javax.persistence.TableGenerator.class, tableGeneratorProps);
+				tableGeneratorProps.put("uniqueConstraints", uniqueConstraintPropsList.toArray(new Object[0])); //$NON-NLS-1$
+				facade.addMethodAnnotation(entityBean.getEjbClass(), methodName, emptySignature, javax.persistence.TableGenerator.class, tableGeneratorProps);
+			}
+		} catch (Exception e) {
+			String warning = String.format(Messages.getString("org.apache.openejb.helper.annotation.warnings.12"), "@javax.persistence.Id", entityBean.getEjbClass());
+			facade.addWarning(warning);
 		}
 	}
 

Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/EntityBeanPojoConverter.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/EntityBeanPojoConverter.java?rev=678269&r1=678268&r2=678269&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/EntityBeanPojoConverter.java (original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/EntityBeanPojoConverter.java Sun Jul 20 04:37:31 2008
@@ -17,21 +17,21 @@
 package org.apache.openejb.plugins.common;
 
 import java.util.Collection;
+import java.util.Iterator;
 import java.util.List;
 
 import org.apache.openejb.config.AppModule;
 import org.apache.openejb.config.EjbModule;
 import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.EjbRelation;
+import org.apache.openejb.jee.EjbRelationshipRole;
 import org.apache.openejb.jee.EnterpriseBean;
 import org.apache.openejb.jee.EntityBean;
+import org.apache.openejb.jee.Relationships;
 import org.apache.openejb.jee.jpa.Basic;
 import org.apache.openejb.jee.jpa.Entity;
 import org.apache.openejb.jee.jpa.EntityMappings;
 import org.apache.openejb.jee.jpa.Id;
-import org.apache.openejb.jee.jpa.ManyToMany;
-import org.apache.openejb.jee.jpa.ManyToOne;
-import org.apache.openejb.jee.jpa.OneToMany;
-import org.apache.openejb.jee.jpa.OneToOne;
 
 public class EntityBeanPojoConverter implements Converter {
 
@@ -49,6 +49,7 @@
 		for (EjbModule ejbModule : ejbModules) {
 			EjbJar ejbJar = ejbModule.getEjbJar();
 			EnterpriseBean[] enterpriseBeans = ejbJar.getEnterpriseBeans();
+			Relationships relationships = ejbJar.getRelationships();
 
 			for (EnterpriseBean enterpriseBean : enterpriseBeans) {
 				if (!(enterpriseBean instanceof EntityBean)) {
@@ -62,14 +63,42 @@
 					convertBeanToPojo(entityBean, entity);
 				}
 			}
+			
+			List<EjbRelation> ejbRelations = relationships.getEjbRelation();
+			for (Iterator<EjbRelation> relationIterator = ejbRelations.iterator(); relationIterator.hasNext();) {
+				EjbRelation ejbRelation = relationIterator.next();
+				List<EjbRelationshipRole> ejbRelationshipRoles = ejbRelation.getEjbRelationshipRole();
+				for (Iterator<EjbRelationshipRole> roleIteratore = ejbRelationshipRoles.iterator(); roleIteratore.hasNext();) {
+					EjbRelationshipRole ejbRelationshipRole = roleIteratore.next();
+					
+					String ejbName = ejbRelationshipRole.getRelationshipRoleSource().getEjbName();
+					EntityBean bean = getEntityBean(enterpriseBeans, ejbName);
+					if (bean == null) {
+						continue;
+					}
+					
+					if (ejbRelationshipRole.getCmrField() != null)
+						convertGetterAndSetterToNonAbstract(bean.getEjbClass(), ejbRelationshipRole.getCmrField().getCmrFieldName());
+				}
+			}
 		}
 	}
 
+	private EntityBean getEntityBean(EnterpriseBean[] enterpriseBeans, String ejbName) {
+		for (EnterpriseBean enterpriseBean : enterpriseBeans) {
+			if (enterpriseBean instanceof EntityBean && ejbName.equals(enterpriseBean.getEjbName())) {
+				return (EntityBean) enterpriseBean;
+			}
+		}
+		
+		return null;
+	}
+
 	private Entity getMapping(EntityMappings entityMappings, String ejbName) {
 			Collection<Entity> entities = entityMappings.getEntity();
 
 			for (Entity entity : entities) {
-				if (entity.getName().equals(ejbName)) {
+				if (entity.getEjbName().equals(ejbName)) {
 					return entity;
 				}
 			}
@@ -90,41 +119,26 @@
 		for (Id id : ids) {
 			convertGetterAndSetterToNonAbstract(entityBean.getEjbClass(), id.getName());
 		}
-
-		List<ManyToMany> manyToMany = entity.getAttributes().getManyToMany();
-		for (ManyToMany relationship : manyToMany) {
-			convertGetterAndSetterToNonAbstract(entityBean.getEjbClass(), relationship.getName());
-		}
-
-		List<OneToMany> oneToMany = entity.getAttributes().getOneToMany();
-		for (OneToMany relationship : oneToMany) {
-			convertGetterAndSetterToNonAbstract(entityBean.getEjbClass(), relationship.getName());
-		}
-
-		List<ManyToOne> manyToOne = entity.getAttributes().getManyToOne();
-		for (ManyToOne relationship : manyToOne) {
-			convertGetterAndSetterToNonAbstract(entityBean.getEjbClass(), relationship.getName());
-		}
-
-		List<OneToOne> oneToOne = entity.getAttributes().getOneToOne();
-		for (OneToOne relationship : oneToOne) {
-			convertGetterAndSetterToNonAbstract(entityBean.getEjbClass(), relationship.getName());
-		}
 	}
 
 	private void convertGetterAndSetterToNonAbstract(String cls, String fieldName) {
-		String[] emptySignature = new String[0];
-		String getterMethodName = convertFieldNameToGetterName(fieldName);
-		String setterMethodName = convertFieldNameToSetterName(fieldName);
-
-		String fieldType = facade.getMethodReturnType(cls, getterMethodName, emptySignature);
-		facade.addField(cls, fieldName, fieldType);
-
-		String getterMethodBody = "return " + fieldName + ";"; //$NON-NLS-1$ //$NON-NLS-2$
-		String setterMethodBody = "this." + fieldName + " = ${0};"; //$NON-NLS-1$ //$NON-NLS-2$
-
-		facade.removeAbstractModifierFromMethod(cls, getterMethodName, emptySignature, getterMethodBody);
-		facade.removeAbstractModifierFromMethod(cls, setterMethodName, new String[] { fieldType }, setterMethodBody);
+		try {
+			String[] emptySignature = new String[0];
+			String getterMethodName = convertFieldNameToGetterName(fieldName);
+			String setterMethodName = convertFieldNameToSetterName(fieldName);
+			String fieldType = facade.getMethodReturnType(cls,
+					getterMethodName, emptySignature);
+			facade.addField(cls, fieldName, fieldType);
+			String getterMethodBody = "return " + fieldName + ";"; //$NON-NLS-1$ //$NON-NLS-2$
+			String setterMethodBody = "this." + fieldName + " = ${0};"; //$NON-NLS-1$ //$NON-NLS-2$
+			facade.removeAbstractModifierFromMethod(cls, getterMethodName,
+					emptySignature, getterMethodBody);
+			facade.removeAbstractModifierFromMethod(cls, setterMethodName,
+					new String[] { fieldType }, setterMethodBody);
+		} catch (Exception e) {
+			String warning = String.format(Messages.getString("org.apache.openejb.helper.annotation.warnings.7"), cls, fieldName);
+			facade.addWarning(warning);
+		}
 	}
 
 	private String convertFieldNameToGetterName(String fieldName) {

Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/IJDTFacade.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/IJDTFacade.java?rev=678269&r1=678268&r2=678269&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/IJDTFacade.java (original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/IJDTFacade.java Sun Jul 20 04:37:31 2008
@@ -33,4 +33,5 @@
 	void addField(String targetClass, String fieldName, String fieldType);
 	void addAnnotationToFieldsOfType(String targetClass, Class<?> annotation, Map<String, Object> properties);
 	void addInterface(String ejbClass, String interfaceClass);
+	void addWarning(String warning);
 }

Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/OpenEjbXmlConverter.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/OpenEjbXmlConverter.java?rev=678269&r1=678268&r2=678269&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/OpenEjbXmlConverter.java (original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/OpenEjbXmlConverter.java Sun Jul 20 04:37:31 2008
@@ -31,6 +31,7 @@
 import org.apache.openejb.config.OpenEjb2Conversion;
 import org.apache.openejb.jee.EjbJar;
 import org.apache.openejb.jee.JaxbJavaee;
+import org.apache.openejb.jee.jpa.EntityMappings;
 import org.apache.openejb.jee.oejb2.JaxbOpenejbJar2;
 import org.apache.openejb.jee.oejb2.OpenejbJarType;
 import org.apache.openejb.jee.oejb3.OpenejbJar;
@@ -53,14 +54,23 @@
 	public static final String CLS_MESSAGE_DRIVEN = "javax.ejb.MessageDriven"; //$NON-NLS-1$
 	public static final String STATELESS_CLASS = CLS_STATELESS;
 	private Converter[] converters;
+	private ClassLoader classLoader;
 
 
 
 	public OpenEjbXmlConverter(Converter[] converters) {
 		super();
 		this.converters = converters;
+		this.classLoader = getClass().getClassLoader();
 	}
 
+	public OpenEjbXmlConverter(Converter[] converters, ClassLoader classLoader) {
+		super();
+		this.converters = converters;
+		this.classLoader = classLoader;
+	}
+
+	
 	/**
 	 * Parses the XML
 	 * @param source An input source to the content of ejb-jar.xml
@@ -82,6 +92,10 @@
 	public boolean convert(InputSource ejbJarSrc, InputSource openEjbJarSrc) throws ConversionException {
 		AppModule appModule = getAppModule(ejbJarSrc, openEjbJarSrc);
 
+		if (appModule.getCmpMappings() == null) {
+			appModule.setCmpMappings(new EntityMappings());
+		}
+		
 		for (Converter converter : converters) {
 			converter.convert(appModule);
 		}
@@ -90,11 +104,12 @@
 	}
 
 	private AppModule getAppModule(InputSource ejbJarSrc, InputSource openEjbJarSrc) throws ConversionException {
-		AppModule appModule = new AppModule(getClass().getClassLoader(), "ModuleToConvert"); //$NON-NLS-1$
-
+		AppModule appModule = new AppModule(classLoader, "ModuleToConvert"); //$NON-NLS-1$
+		
 		try {
 			EjbJar ejbJar = (EjbJar) JaxbJavaee.unmarshal(EjbJar.class, ejbJarSrc.getByteStream());
 	        EjbModule ejbModule = new EjbModule(ejbJar, new OpenejbJar());
+	        ejbModule.setClassLoader(classLoader);
 	        appModule.getEjbModules().add(ejbModule);
 
 			if (openEjbJarSrc != null) {

Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/SessionBeanConverter.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/SessionBeanConverter.java?rev=678269&r1=678268&r2=678269&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/SessionBeanConverter.java (original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/SessionBeanConverter.java Sun Jul 20 04:37:31 2008
@@ -21,6 +21,7 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Collection;
 import java.util.Map;
 
 import javax.annotation.security.DeclareRoles;
@@ -52,7 +53,6 @@
 import org.apache.openejb.jee.Method;
 import org.apache.openejb.jee.MethodParams;
 import org.apache.openejb.jee.MethodPermission;
-import org.apache.openejb.jee.MethodTransaction;
 import org.apache.openejb.jee.NamedMethod;
 import org.apache.openejb.jee.RemoteBean;
 import org.apache.openejb.jee.SecurityRoleRef;
@@ -82,7 +82,7 @@
 	}
 
 	private void processApplicationExceptions(EjbJar ejbJar) {
-		List<ApplicationException> exceptionList = ejbJar.getAssemblyDescriptor().getApplicationException();
+		Collection<ApplicationException> exceptionList = ejbJar.getAssemblyDescriptor().getApplicationException();
 		Iterator<ApplicationException> iterator = exceptionList.iterator();
 
 		while (iterator.hasNext()) {
@@ -129,67 +129,71 @@
 			annotationHelper.addClassAnnotation(bean.getEjbClass(), TransactionManagement.class, props);
 		}
 
-		Map<String, List<MethodTransaction>> methodTransactions = descriptor.getMethodTransactions(bean.getEjbName());
-		if (methodTransactions.containsKey("*")) { //$NON-NLS-1$
-			List<MethodTransaction> defaultTransactions = methodTransactions.get("*"); //$NON-NLS-1$
-			MethodTransaction defaultTransaction = defaultTransactions.get(0);
-
-			Map<String, Object> props = new HashMap<String, Object>();
-			props.put("value", TransactionAttributeType.valueOf(defaultTransaction.getAttribute().name())); //$NON-NLS-1$
-			annotationHelper.addClassAnnotation(bean.getEjbClass(), TransactionAttribute.class, props);
-		}
-
-		Iterator<String> iterator = methodTransactions.keySet().iterator();
-		while (iterator.hasNext()) {
-			String methodName = (String) iterator.next();
-			if ("*".equals(methodName)) { //$NON-NLS-1$
-				continue;
-			}
-
-			List<MethodTransaction> transactions = methodTransactions.get(methodName);
-			MethodTransaction methodTransaction = transactions.get(0);
-
-			Map<String, Object> props = new HashMap<String, Object>();
-			props.put("value", TransactionAttributeType.valueOf(methodTransaction.getAttribute().name())); //$NON-NLS-1$
-
-			MethodParams methodParams = methodTransaction.getMethod().getMethodParams();
-			String[] params = methodParams.getMethodParam().toArray(new String[0]);
-			annotationHelper.addMethodAnnotation(bean.getEjbClass(), methodName, params, TransactionAttribute.class, props);
-		}
+		
+		//Map<String, List<MethodAttribute>> methodTransactions = descriptor.getMethodTransactionMap(bean.getEjbName());
+		//if (methodTransactions.containsKey("*")) { //$NON-NLS-1$
+		//	List<MethodAttribute> defaultTransactions = methodTransactions.get("*"); //$NON-NLS-1$
+		//	MethodAttribute defaultTransaction = defaultTransactions.get(0);
+
+		//	Map<String, Object> props = new HashMap<String, Object>();
+		//	props.put("value", TransactionAttributeType.valueOf(defaultTransaction.getAttribute().name())); //$NON-NLS-1$
+		//	annotationHelper.addClassAnnotation(bean.getEjbClass(), TransactionAttribute.class, props);
+		//}
+
+		///Iterator<String> iterator = methodTransactions.keySet().iterator();
+		//while (iterator.hasNext()) {
+		//	String methodName = (String) iterator.next();
+		//	if ("*".equals(methodName)) { //$NON-NLS-1$
+		//		continue;
+		//	}
+
+		//	List<MethodTransaction> transactions = methodTransactions.get(methodName);
+		//	MethodTransaction methodTransaction = transactions.get(0);
+
+		//	Map<String, Object> props = new HashMap<String, Object>();
+		//	props.put("value", TransactionAttributeType.valueOf(methodTransaction.getAttribute().name())); //$NON-NLS-1$
+
+		//	MethodParams methodParams = methodTransaction.getMethod().getMethodParams();
+		//	String[] params = methodParams.getMethodParam().toArray(new String[0]);
+		//	annotationHelper.addMethodAnnotation(bean.getEjbClass(), methodName, params, TransactionAttribute.class, props);
+		//}
 	}
 
 	public void processMessageDrivenBean(MessageDrivenBean bean) {
-		Map<String, Object> props = new HashMap<String, Object>();
-
-		ActivationConfig activationConfig = bean.getActivationConfig();
-		if (activationConfig != null) {
-			List<Map<String, Object>> activationConfigPropertiesList = new ArrayList<Map<String,Object>>();
-
-			List<ActivationConfigProperty> activationConfigProperties = activationConfig.getActivationConfigProperty();
-
-			for (ActivationConfigProperty activationConfigProperty : activationConfigProperties) {
-				HashMap<String, Object> configProps = new HashMap<String, Object>();
-				configProps.put("propertyName", activationConfigProperty.getActivationConfigPropertyName()); //$NON-NLS-1$
-				configProps.put("propertyValue", activationConfigProperty.getActivationConfigPropertyValue()); //$NON-NLS-1$
+		try {
+			Map<String, Object> props = new HashMap<String, Object>();
+			ActivationConfig activationConfig = bean.getActivationConfig();
+			if (activationConfig != null) {
+				List<Map<String, Object>> activationConfigPropertiesList = new ArrayList<Map<String, Object>>();
 
-				activationConfigPropertiesList.add(configProps);
-			}
+				List<ActivationConfigProperty> activationConfigProperties = activationConfig.getActivationConfigProperty();
 
-			if (bean.getMessageDestinationLink() != null && bean.getMessageDestinationLink().length() > 0) {
-				if (! hasConfigProperty(activationConfigPropertiesList, "destination")) { //$NON-NLS-1$
+				for (ActivationConfigProperty activationConfigProperty : activationConfigProperties) {
 					HashMap<String, Object> configProps = new HashMap<String, Object>();
-					configProps.put("propertyName", "destination"); //$NON-NLS-1$ //$NON-NLS-2$
-					configProps.put("propertyValue", bean.getMessageDestinationLink()); //$NON-NLS-1$
+					configProps.put("propertyName", activationConfigProperty.getActivationConfigPropertyName()); //$NON-NLS-1$
+					configProps.put("propertyValue", activationConfigProperty.getActivationConfigPropertyValue()); //$NON-NLS-1$
 
 					activationConfigPropertiesList.add(configProps);
 				}
-			}
 
-			props.put("activationConfig", activationConfigPropertiesList.toArray(new HashMap[0])); //$NON-NLS-1$
-		}
+				if (bean.getMessageDestinationLink() != null && bean.getMessageDestinationLink().length() > 0) {
+					if (!hasConfigProperty(activationConfigPropertiesList, "destination")) { //$NON-NLS-1$
+						HashMap<String, Object> configProps = new HashMap<String, Object>();
+						configProps.put("propertyName", "destination"); //$NON-NLS-1$ //$NON-NLS-2$
+						configProps.put("propertyValue", bean.getMessageDestinationLink()); //$NON-NLS-1$
+
+						activationConfigPropertiesList.add(configProps);
+					}
+				}
 
-		props.put("name", bean.getEjbName()); //$NON-NLS-1$
-		annotationHelper.addClassAnnotation(bean.getEjbClass(), MessageDriven.class, props);
+				props.put("activationConfig", activationConfigPropertiesList.toArray(new HashMap[0])); //$NON-NLS-1$
+			}
+			props.put("name", bean.getEjbName()); //$NON-NLS-1$
+			annotationHelper.addClassAnnotation(bean.getEjbClass(), MessageDriven.class, props);
+		} catch (Exception e) {
+			String warning = String.format(Messages.getString("org.apache.openejb.helper.annotation.warnings.12"), "@javax.ejb.MessageDriven", bean.getEjbClass());
+			annotationHelper.addWarning(warning);
+		}
 	}
 
 
@@ -237,27 +241,29 @@
 			while (methodIter.hasNext()) {
 				Method method = (Method) methodIter.next();
 				EnterpriseBean enterpriseBean = ejbJar.getEnterpriseBean(method.getEjbName());
-
-				MethodParams methodParams = method.getMethodParams();
-				String[] params = methodParams.getMethodParam().toArray(new String[0]);
-
-				if ((! "*".equals(method.getMethodName())) &&  descriptor.getExcludeList().getMethod().contains(method)) { //$NON-NLS-1$
-					annotationHelper.addMethodAnnotation(enterpriseBean.getEjbClass(), method.getMethodName(), params, DenyAll.class, null);
-					continue;
-				}
-
-				if (methodPermission.getUnchecked()) {
-					if ("*".equals(method.getMethodName())) { //$NON-NLS-1$
-						annotationHelper.addClassAnnotation(enterpriseBean.getEjbClass(), PermitAll.class, null);
-					} else {
-						annotationHelper.addMethodAnnotation(enterpriseBean.getEjbClass(), method.getMethodName(), params, PermitAll.class, null);
+				try {
+					MethodParams methodParams = method.getMethodParams();
+					String[] params = methodParams.getMethodParam().toArray(new String[0]);
+					if ((!"*".equals(method.getMethodName())) && descriptor.getExcludeList().getMethod().contains(method)) { //$NON-NLS-1$
+						annotationHelper.addMethodAnnotation(enterpriseBean.getEjbClass(), method.getMethodName(), params, DenyAll.class, null);
+						continue;
 					}
-				} else {
-					if ("*".equals(method.getMethodName())) { //$NON-NLS-1$
-						annotationHelper.addClassAnnotation(enterpriseBean.getEjbClass(), RolesAllowed.class, roleProps);
+					if (methodPermission.getUnchecked()) {
+						if ("*".equals(method.getMethodName())) { //$NON-NLS-1$
+							annotationHelper.addClassAnnotation(enterpriseBean.getEjbClass(), PermitAll.class, null);
+						} else {
+							annotationHelper.addMethodAnnotation(enterpriseBean.getEjbClass(), method.getMethodName(), params, PermitAll.class, null);
+						}
 					} else {
-						annotationHelper.addMethodAnnotation(enterpriseBean.getEjbClass(), method.getMethodName(), params, RolesAllowed.class, roleProps);
+						if ("*".equals(method.getMethodName())) { //$NON-NLS-1$
+							annotationHelper.addClassAnnotation(enterpriseBean.getEjbClass(), RolesAllowed.class, roleProps);
+						} else {
+							annotationHelper.addMethodAnnotation(enterpriseBean.getEjbClass(), method.getMethodName(), params, RolesAllowed.class, roleProps);
+						}
 					}
+				} catch (Exception e) {
+					String warning = String.format(Messages.getString("org.apache.openejb.helper.annotation.warnings.12"), "@javax.persistence.RolesAllowed", enterpriseBean.getEjbClass());
+					annotationHelper.addWarning(warning);
 				}
 			}
 		}
@@ -303,36 +309,38 @@
 		for (InterceptorBinding interceptorBinding : interceptorBindings) {
 			EnterpriseBean bean = ejbJar.getEnterpriseBean(interceptorBinding.getEjbName());
 
-			List<String> interceptorClasses = interceptorBinding.getInterceptorClass();
-
-			String[] classes = interceptorClasses.toArray(new String[0]);
-
-			Map<String, Object> properties = new HashMap<String, Object>();
-			properties.put("value", classes); //$NON-NLS-1$
+			try {
+				List<String> interceptorClasses = interceptorBinding.getInterceptorClass();
+				String[] classes = interceptorClasses.toArray(new String[0]);
+				Map<String, Object> properties = new HashMap<String, Object>();
+				properties.put("value", classes); //$NON-NLS-1$
+				if (interceptorBinding.getMethod() == null) {
+					if (interceptorBinding.getExcludeDefaultInterceptors()) {
+						annotationHelper.addClassAnnotation(bean.getEjbClass(), ExcludeDefaultInterceptors.class, properties);
+					}
 
-			if (interceptorBinding.getMethod() == null) {
-				if (interceptorBinding.getExcludeDefaultInterceptors()) {
-					annotationHelper.addClassAnnotation(bean.getEjbClass(), ExcludeDefaultInterceptors.class, properties);
-				}
+					if (interceptorBinding.getExcludeClassInterceptors()) {
+						annotationHelper.addClassAnnotation(bean.getEjbClass(), ExcludeClassInterceptors.class, properties);
+					}
 
-				if (interceptorBinding.getExcludeClassInterceptors()) {
-					annotationHelper.addClassAnnotation(bean.getEjbClass(), ExcludeClassInterceptors.class, properties);
-				}
+					annotationHelper.addClassAnnotation(bean.getEjbClass(), Interceptors.class, properties);
+				} else {
+					NamedMethod method = interceptorBinding.getMethod();
+					String[] signature = method.getMethodParams().getMethodParam().toArray(new String[0]);
 
-				annotationHelper.addClassAnnotation(bean.getEjbClass(), Interceptors.class, properties);
-			} else {
-				NamedMethod method = interceptorBinding.getMethod();
-				String[] signature = method.getMethodParams().getMethodParam().toArray(new String[0]);
+					if (interceptorBinding.getExcludeDefaultInterceptors()) {
+						annotationHelper.addMethodAnnotation(bean.getEjbClass(), method.getMethodName(), signature, ExcludeDefaultInterceptors.class, properties);
+					}
 
-				if (interceptorBinding.getExcludeDefaultInterceptors()) {
-					annotationHelper.addMethodAnnotation(bean.getEjbClass(), method.getMethodName(), signature, ExcludeDefaultInterceptors.class, properties);
-				}
+					if (interceptorBinding.getExcludeClassInterceptors()) {
+						annotationHelper.addMethodAnnotation(bean.getEjbClass(), method.getMethodName(), signature, ExcludeClassInterceptors.class, properties);
+					}
 
-				if (interceptorBinding.getExcludeClassInterceptors()) {
-					annotationHelper.addMethodAnnotation(bean.getEjbClass(), method.getMethodName(), signature, ExcludeClassInterceptors.class, properties);
+					annotationHelper.addMethodAnnotation(bean.getEjbClass(), method.getMethodName(), signature, Interceptors.class, properties);
 				}
-
-				annotationHelper.addMethodAnnotation(bean.getEjbClass(), method.getMethodName(), signature, Interceptors.class, properties);
+			} catch (Exception e) {
+				String warning = String.format(Messages.getString("org.apache.openejb.helper.annotation.warnings.12"), "@javax.interceptor.Interceptors", bean.getEjbClass());
+				annotationHelper.addWarning(warning);
 			}
 		}
 	}

Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/resources/org/apache/openejb/plugins/common/messages.properties
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/resources/org/apache/openejb/plugins/common/messages.properties?rev=678269&r1=678268&r2=678269&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/resources/org/apache/openejb/plugins/common/messages.properties (original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/resources/org/apache/openejb/plugins/common/messages.properties Sun Jul 20 04:37:31 2008
@@ -15,3 +15,4 @@
 org.apache.openejb.helper.annotation.warnings.10=Error getting return type of %1$s.%2$s
 org.apache.openejb.helper.annotation.warnings.11=Error adding field %1$s on %2$s
 org.apache.openejb.helper.annotation.warnings.12=An error occurred adding %1$s to %2$s
+

Added: openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/java/org/apache/openejb/plugins/common/ConverterTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/java/org/apache/openejb/plugins/common/ConverterTest.java?rev=678269&view=auto
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/java/org/apache/openejb/plugins/common/ConverterTest.java (added)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/java/org/apache/openejb/plugins/common/ConverterTest.java Sun Jul 20 04:37:31 2008
@@ -0,0 +1,58 @@
+package org.apache.openejb.plugins.common;
+
+import junit.framework.TestCase;
+
+import org.xml.sax.InputSource;
+
+public class ConverterTest extends TestCase {
+	
+	private Converter[] getConverter(IJDTFacade facade) {
+		return new Converter[] {
+			new SessionBeanConverter(facade),
+			new EjbReferencesConverter(facade),
+			new EntityBeanConverter(facade),
+			new EntityBeanPojoConverter(facade),
+			new SessionBeanInterfaceModifier(facade),
+			new SessionBeanRemoteAnnotationAdder(facade)
+		};
+	}
+	
+	// dirty hack to get around the CmpJpaConverter trying to load classes
+	// mean we don't need to include classes along with our xml files
+	private class DummyClassLoader extends ClassLoader {
+
+		@Override
+		protected synchronized Class<?> loadClass(String className, boolean resolve) throws ClassNotFoundException {
+			return Object.class;
+		}
+		
+	}
+	
+	public void testShouldGenerateAnnotationsWithoutThrowingAnError1() throws Exception {
+		convert("ejb-jar1.xml", "openejb-jar1.xml");
+	}
+
+	public void testShouldGenerateAnnotationsWithoutThrowingAnError2() throws Exception {
+		convert("ejb-jar2.xml", "openejb-jar2.xml");
+	}
+
+	public void testShouldGenerateAnnotationsWithoutThrowingAnError3() throws Exception {
+		convert("ejb-jar3.xml", "openejb-jar3.xml");
+	}
+
+	
+	private void convert(String ejbJarXml, String openEjbJarXml) throws ConversionException {
+		IJDTFacade stub = new JDTFacadeStub();
+		InputSource ejbJarSrc = null;
+		if (ejbJarXml != null)
+			ejbJarSrc = new InputSource(getClass().getResourceAsStream(ejbJarXml));
+		
+		InputSource openEjbJarSrc = null;
+		if (openEjbJarXml != null) {
+			openEjbJarSrc = new InputSource(getClass().getResourceAsStream(openEjbJarXml));
+		}
+
+		OpenEjbXmlConverter converter = new OpenEjbXmlConverter(getConverter(stub), new DummyClassLoader());
+		converter.convert(ejbJarSrc, openEjbJarSrc);
+	}
+}

Added: openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/java/org/apache/openejb/plugins/common/JDTFacadeStub.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/java/org/apache/openejb/plugins/common/JDTFacadeStub.java?rev=678269&view=auto
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/java/org/apache/openejb/plugins/common/JDTFacadeStub.java (added)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/java/org/apache/openejb/plugins/common/JDTFacadeStub.java Sun Jul 20 04:37:31 2008
@@ -0,0 +1,144 @@
+package org.apache.openejb.plugins.common;
+
+import java.lang.annotation.Annotation;
+import java.util.Iterator;
+import java.util.Map;
+
+public class JDTFacadeStub implements IJDTFacade {
+
+	public void addAnnotationToFieldsOfType(String targetClass, Class<?> annotation, Map<String, Object> properties) {
+		StringBuffer buffer = new StringBuffer();
+		buffer.append("Target field type: ");
+		buffer.append(targetClass);
+		buffer.append("\nAnnotation: ");
+		buffer.append(annotation.getCanonicalName());
+		buffer.append("\nProperies: {\n");
+		writeMapToBuffer(properties, buffer, 1);
+		buffer.append("}\n");
+		
+		System.out.println(buffer.toString());
+	}
+
+	@SuppressWarnings("unchecked")
+	private void writeMapToBuffer(Map<String, Object> properties, StringBuffer buffer, int indent) {
+		if (properties == null) {
+			return;
+		}
+		
+		StringBuffer indentStrBuf = new StringBuffer();
+		for (int i = 0; i < indent; i++) {
+			indentStrBuf.append("\t");
+		}
+		
+		String indentStr = indentStrBuf.toString();
+		
+		Iterator<String> iterator = properties.keySet().iterator();
+		while (iterator.hasNext()) {
+			String key = (String) iterator.next();
+			buffer.append(indentStr);
+			buffer.append(key);
+			buffer.append("=");
+			
+			Object value = properties.get(key);
+			if (value instanceof Map) {
+				buffer.append(" {\n");
+				writeMapToBuffer((Map<String, Object>) value, buffer, indent + 1);
+				buffer.append(indentStr);
+				buffer.append("}");
+			} else {
+				buffer.append(value.toString());
+			}
+			
+			buffer.append("\n");
+		}
+	}
+
+	public void addClassAnnotation(String targetClass, Class<? extends Annotation> annotation, Map<String, Object> properties) {
+		StringBuffer buffer = new StringBuffer();
+		buffer.append("Target class: ");
+		buffer.append(targetClass);
+		buffer.append("\nAnnotation: ");
+		buffer.append(annotation.getCanonicalName());
+		buffer.append("\nProperies: {\n");
+		writeMapToBuffer(properties, buffer, 1);
+		buffer.append("}\n");
+		
+		System.out.println(buffer.toString());
+	}
+
+	public void addField(String targetClass, String fieldName, String fieldType) {
+		// TODO Auto-generated method stub
+
+	}
+
+	public void addFieldAnnotation(String targetClass, String targetField, Class<?> annotation, Map<String, Object> properties) {
+		StringBuffer buffer = new StringBuffer();
+		buffer.append("Target field type: ");
+		buffer.append(targetClass);
+		buffer.append("\nTarget field: ");
+		buffer.append(targetField);
+		buffer.append("\nAnnotation: ");
+		buffer.append(annotation.getCanonicalName());
+		buffer.append("\nProperies: {\n");
+		writeMapToBuffer(properties, buffer, 1);
+		buffer.append("}\n");
+		
+		System.out.println(buffer.toString());
+	}
+
+	public void addInterface(String ejbClass, String interfaceClass) {
+		// TODO Auto-generated method stub
+
+	}
+
+	public void addMethodAnnotation(String fullyQualifiedClassName, String methodName, String[] signature, Class<?> annotationClass, Map<String, Object> properties) {
+		StringBuffer buffer = new StringBuffer();
+		buffer.append("Target field type: ");
+		buffer.append(fullyQualifiedClassName);
+		buffer.append("\nTarget field: ");
+		buffer.append(methodName);
+		buffer.append("\nAnnotation: ");
+		buffer.append(annotationClass.getCanonicalName());
+		buffer.append("\nProperties: {\n");
+		writeMapToBuffer(properties, buffer, 1);
+		buffer.append("}\n");
+		
+		System.out.println(buffer.toString());
+	}
+
+	public void addWarning(String warning) {
+		// TODO Auto-generated method stub
+
+	}
+
+	public boolean classImplements(String targetClass, String targetInterface) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	public String getMethodReturnType(String targetClass, String methodName, String[] signature) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public String getSuperClass(String targetClass) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public void removeAbstractModifierFromClass(String targetClass) {
+		// TODO Auto-generated method stub
+
+	}
+
+	public void removeAbstractModifierFromMethod(String targetClass, String methodName, String[] signature, String methodBody) {
+		// TODO Auto-generated method stub
+
+	}
+
+	public void removeInterface(String targetClass, String interfaceToRemove) {
+		// TODO Auto-generated method stub
+
+	}
+
+}