[jboss-cvs] JBossAS SVN: r65638 - in projects/metadata/trunk/src: main/java/org/jboss/metadata/annotation and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Sep 26 18:20:40 EDT 2007
Author: wolfc
Date: 2007-09-26 18:20:40 -0400 (Wed, 26 Sep 2007)
New Revision: 65638
Added:
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractEnterpriseBeanProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractFinderUser.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractSessionBeanProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/Creator.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/EJBAnnotationProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/EjbJar30Creator.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/InitProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/LocalHomeProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/LocalProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/MethodParametersHelper.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/Processor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/StatefulProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/StatelessProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/finder/
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/finder/AnnotationFinder.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/finder/DefaultAnnotationFinder.java
projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/
projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/
projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/AnnotationEjb3UnitTestCase.java
projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStateful.java
projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatefulBean.java
projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStateless21Bean.java
projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStateless21Home.java
projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatelessBean.java
projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatelessLocal.java
Log:
Initial annotation translation
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractEnterpriseBeanProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractEnterpriseBeanProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractEnterpriseBeanProcessor.java 2007-09-26 22:20:40 UTC (rev 65638)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metadata.annotation.creator;
+
+import java.lang.reflect.AnnotatedElement;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.spec.EjbJar3xMetaData;
+import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.spec.EnterpriseBeansMetaData;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public abstract class AbstractEnterpriseBeanProcessor<MD extends EnterpriseBeanMetaData> extends AbstractFinderUser implements Processor<EjbJar3xMetaData, Class<?>>
+{
+ protected abstract MD create(Class<?> beanClass);
+
+ protected final List<Processor<MD, Class<?>>> typeProcessors;
+
+ protected AbstractEnterpriseBeanProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+
+ // TODO: configure somehow
+
+ typeProcessors = new ArrayList<Processor<MD,Class<?>>>();
+ typeProcessors.add(new TransactionAttributeProcessor<MD>(finder));
+ }
+
+ public void process(EjbJar3xMetaData ejbJarMetaData, Class<?> beanClass)
+ {
+ MD beanMetaData = create(beanClass);
+ if(beanMetaData == null)
+ return;
+
+ if(ejbJarMetaData.getEnterpriseBeans() == null)
+ ejbJarMetaData.setEnterpriseBeans(new EnterpriseBeansMetaData());
+
+ ejbJarMetaData.getEnterpriseBeans().add(beanMetaData);
+
+ processClass(beanMetaData, beanClass);
+ }
+
+ private void processClass(MD bean, Class<?> cls)
+ {
+ for(Processor<MD, Class<?>> processor : typeProcessors)
+ {
+ processor.process(bean, cls);
+ }
+
+ for(Class<?> intf : cls.getInterfaces())
+ {
+ for(Processor<MD, Class<?>> processor : typeProcessors)
+ {
+ processor.process(bean, intf);
+ }
+ }
+
+ if(cls.getSuperclass() != null)
+ processClass(bean, cls.getSuperclass());
+ }
+}
Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractEnterpriseBeanProcessor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractFinderUser.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractFinderUser.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractFinderUser.java 2007-09-26 22:20:40 UTC (rev 65638)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metadata.annotation.creator;
+
+import java.lang.reflect.AnnotatedElement;
+
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public abstract class AbstractFinderUser
+{
+ protected final AnnotationFinder<AnnotatedElement> finder;
+
+ protected AbstractFinderUser(AnnotationFinder<AnnotatedElement> finder)
+ {
+ assert finder != null : "finder is null";
+
+ this.finder = finder;
+ }
+}
Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractFinderUser.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractSessionBeanProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractSessionBeanProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractSessionBeanProcessor.java 2007-09-26 22:20:40 UTC (rev 65638)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metadata.annotation.creator;
+
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.spec.EjbJar3xMetaData;
+import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
+import org.jboss.metadata.javaee.spec.DescriptionGroupMetaData;
+import org.jboss.metadata.javaee.spec.DescriptionImpl;
+import org.jboss.metadata.javaee.spec.DescriptionsImpl;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public abstract class AbstractSessionBeanProcessor extends AbstractEnterpriseBeanProcessor<SessionBeanMetaData> implements Creator<Class<?>, SessionBeanMetaData>, Processor<EjbJar3xMetaData, Class<?>>
+{
+ private List<Processor<SessionBeanMetaData, Class<?>>> topLevelProcessors;
+ private List<Processor<SessionBeanMetaData, Method>> methodProcessors;
+ private List<Processor<SessionBeanMetaData, Field>> fieldProcessors;
+
+ protected AbstractSessionBeanProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+
+ // TODO: configure somehow
+
+ topLevelProcessors = new ArrayList<Processor<SessionBeanMetaData,Class<?>>>();
+ topLevelProcessors.add(new LocalHomeProcessor(finder));
+
+ typeProcessors.add(new LocalProcessor(finder));
+ }
+
+ public abstract SessionBeanMetaData create(Class<?> beanClass);
+
+ protected SessionBeanMetaData create(Class<?> beanClass, String name, String mappedName, String description)
+ {
+ SessionBeanMetaData bean = new SessionBeanMetaData();
+ bean.setEjbClass(beanClass.getName());
+ String ejbName;
+ if(name == null || name.length() == 0)
+ ejbName = beanClass.getSimpleName();
+ else
+ ejbName = name;
+ bean.setEjbName(ejbName);
+ if(mappedName != null && mappedName.length() > 0)
+ bean.setMappedName(mappedName);
+ if(description != null && description.length() > 0)
+ {
+ DescriptionGroupMetaData descriptionGroup = new DescriptionGroupMetaData();
+ DescriptionsImpl descriptions = new DescriptionsImpl();
+ DescriptionImpl descriptionImpl = new DescriptionImpl();
+ descriptionImpl.setDescription(description);
+ descriptions.add(descriptionImpl);
+ descriptionGroup.setDescriptions(descriptions);
+ bean.setDescriptionGroup(descriptionGroup);
+ }
+
+ processTopLevel(bean, beanClass);
+
+ return bean;
+ }
+
+ private void processTopLevel(SessionBeanMetaData bean, Class<?> cls)
+ {
+ for(Processor<SessionBeanMetaData, Class<?>> processor : topLevelProcessors)
+ {
+ processor.process(bean, cls);
+ }
+ }
+}
Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractSessionBeanProcessor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/Creator.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/Creator.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/Creator.java 2007-09-26 22:20:40 UTC (rev 65638)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metadata.annotation.creator;
+
+/**
+ * Based on the element meta data is created.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface Creator<E, MD>
+{
+ MD create(E element);
+}
Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/Creator.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/EJBAnnotationProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/EJBAnnotationProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/EJBAnnotationProcessor.java 2007-09-26 22:20:40 UTC (rev 65638)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metadata.annotation.creator;
+
+/**
+ * An EJB annotation can be found on a class or property.
+ *
+ * TODO: we don't know whether we want a remote interface or a local one.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class EJBAnnotationProcessor
+{
+
+}
Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/EJBAnnotationProcessor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/EjbJar30Creator.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/EjbJar30Creator.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/EjbJar30Creator.java 2007-09-26 22:20:40 UTC (rev 65638)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metadata.annotation.creator;
+
+import java.lang.reflect.AnnotatedElement;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.spec.EjbJar30MetaData;
+import org.jboss.metadata.ejb.spec.EjbJar3xMetaData;
+
+/**
+ * Create the correct meta data for a set of annotated classes.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class EjbJar30Creator extends AbstractFinderUser implements Creator<Collection<Class<?>>, EjbJar30MetaData>
+{
+ private List<Processor<EjbJar3xMetaData, Class<?>>> processors;
+
+ public EjbJar30Creator(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+
+ processors = new ArrayList<Processor<EjbJar3xMetaData,Class<?>>>();
+ processors.add(new StatefulProcessor(finder));
+ processors.add(new StatelessProcessor(finder));
+ }
+
+ public EjbJar30MetaData create(Collection<Class<?>> classes)
+ {
+ EjbJar30MetaData metaData = new EjbJar30MetaData();
+ metaData.setVersion("3.0");
+
+ for(Class<?> cls : classes)
+ {
+ for(Processor<EjbJar3xMetaData, Class<?>> processor : processors)
+ {
+ processor.process(metaData, cls);
+ }
+ }
+
+ return metaData;
+ }
+}
Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/EjbJar30Creator.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/InitProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/InitProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/InitProcessor.java 2007-09-26 22:20:40 UTC (rev 65638)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metadata.annotation.creator;
+
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Method;
+
+import javax.ejb.Init;
+
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.spec.InitMethodMetaData;
+import org.jboss.metadata.ejb.spec.InitMethodsMetaData;
+import org.jboss.metadata.ejb.spec.MethodParametersMetaData;
+import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
+import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class InitProcessor extends AbstractFinderUser implements Creator<Method, InitMethodMetaData>, Processor<SessionBeanMetaData, Method>
+{
+ public InitProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+ }
+
+ public InitMethodMetaData create(Method method)
+ {
+ Init init = finder.getAnnotation(method, Init.class);
+ if(init == null)
+ return null;
+
+ InitMethodMetaData metaData = new InitMethodMetaData();
+ NamedMethodMetaData beanMethod = new NamedMethodMetaData();
+ metaData.setBeanMethod(beanMethod);
+ NamedMethodMetaData createMethod = new NamedMethodMetaData();
+ metaData.setCreateMethod(createMethod);
+
+ String alternativeName = init.value().length() > 0 ? init.value() : method.getName();
+
+ // Is the init declared on the home interface?
+ if(method.getDeclaringClass().isInterface())
+ {
+ beanMethod.setMethodName(alternativeName);
+ createMethod.setMethodName(method.getName());
+ }
+ else
+ {
+ beanMethod.setMethodName(method.getName());
+ createMethod.setMethodName(alternativeName);
+ }
+
+ MethodParametersMetaData methodParams = MethodParametersHelper.create(method);
+ beanMethod.setMethodParams(methodParams);
+ createMethod.setMethodParams(methodParams);
+
+ return metaData;
+ }
+
+ public void process(SessionBeanMetaData bean, Method method)
+ {
+ InitMethodMetaData initMethod = create(method);
+ if(initMethod == null)
+ return;
+
+ if(bean.getInitMethods() == null)
+ bean.setInitMethods(new InitMethodsMetaData());
+
+ bean.getInitMethods().add(initMethod);
+ }
+}
Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/InitProcessor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/LocalHomeProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/LocalHomeProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/LocalHomeProcessor.java 2007-09-26 22:20:40 UTC (rev 65638)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metadata.annotation.creator;
+
+import java.lang.reflect.AnnotatedElement;
+
+import javax.ejb.LocalHome;
+
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class LocalHomeProcessor extends AbstractFinderUser implements Processor<SessionBeanMetaData, Class<?>>
+{
+ public LocalHomeProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+ }
+
+ public void process(SessionBeanMetaData metaData, Class<?> type)
+ {
+ LocalHome annotation = finder.getAnnotation(type, LocalHome.class);
+ if(annotation == null)
+ return;
+
+ metaData.setLocalHome(annotation.value().getName());
+ }
+}
Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/LocalHomeProcessor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/LocalProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/LocalProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/LocalProcessor.java 2007-09-26 22:20:40 UTC (rev 65638)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metadata.annotation.creator;
+
+import java.lang.reflect.AnnotatedElement;
+
+import javax.ejb.Local;
+
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.spec.BusinessLocalsMetaData;
+import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class LocalProcessor extends AbstractFinderUser implements Processor<SessionBeanMetaData, Class<?>>
+{
+ public LocalProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+ }
+
+ public void process(SessionBeanMetaData metaData, Class<?> type)
+ {
+ Local local = finder.getAnnotation(type, Local.class);
+ if(local == null)
+ return;
+
+ if(type.isInterface())
+ {
+ if(metaData.getLocalHome() != null)
+ {
+ if(metaData.getLocal() != null)
+ throw new IllegalArgumentException("2.1 bean " + metaData.getEjbName() + " already has a local interface " + metaData.getLocal() + ", can't add " + type.getName());
+ metaData.setLocal(type.getName());
+ }
+ else
+ {
+ if(metaData.getBusinessLocals() == null)
+ metaData.setBusinessLocals(new BusinessLocalsMetaData());
+
+ metaData.getBusinessLocals().add(type.getName());
+ }
+ }
+ else
+ {
+ if(local.value() == null || local.value().length == 0)
+ throw new IllegalArgumentException("Empty @Local on bean class " + type.getName() + " is not allowed");
+
+ if(metaData.getLocalHome() != null)
+ {
+ if(metaData.getLocal() != null)
+ throw new IllegalArgumentException("2.1 bean " + metaData.getEjbName() + " already has a local interface " + metaData.getLocal() + ", can't add " + type.getName());
+ if(local.value().length > 1)
+ throw new IllegalArgumentException("2.1 bean " + type.getName() + " has more than one local interface defined");
+ metaData.setLocal(local.value()[0].getName());
+ }
+ else
+ {
+ if(metaData.getBusinessLocals() == null)
+ metaData.setBusinessLocals(new BusinessLocalsMetaData());
+
+ for(Class<?> businessInterface : local.value())
+ {
+ metaData.getBusinessLocals().add(businessInterface.getName());
+ }
+ }
+ }
+ }
+}
Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/LocalProcessor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/MethodParametersHelper.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/MethodParametersHelper.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/MethodParametersHelper.java 2007-09-26 22:20:40 UTC (rev 65638)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metadata.annotation.creator;
+
+import java.lang.reflect.Method;
+
+import org.jboss.metadata.ejb.spec.MethodParametersMetaData;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class MethodParametersHelper
+{
+ public static MethodParametersMetaData create(Method method)
+ {
+ MethodParametersMetaData metaData = new MethodParametersMetaData();
+ for(Class<?> parameterType : method.getParameterTypes())
+ {
+ metaData.add(parameterType.getName());
+ }
+ return metaData;
+ }
+}
Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/MethodParametersHelper.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/Processor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/Processor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/Processor.java 2007-09-26 22:20:40 UTC (rev 65638)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metadata.annotation.creator;
+
+/**
+ * Creates and places a piece of meta data into the right place.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface Processor<MD, T>
+{
+ void process(MD metaData, T type);
+}
Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/Processor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/StatefulProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/StatefulProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/StatefulProcessor.java 2007-09-26 22:20:40 UTC (rev 65638)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metadata.annotation.creator;
+
+import java.lang.reflect.AnnotatedElement;
+
+import javax.ejb.Stateful;
+
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
+import org.jboss.metadata.ejb.spec.SessionType;
+
+/**
+ * Create the correct meta data for a stateful annotation.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class StatefulProcessor extends AbstractSessionBeanProcessor
+{
+ public StatefulProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+ }
+
+ public SessionBeanMetaData create(Class<?> beanClass)
+ {
+ Stateful annotation = finder.getAnnotation(beanClass, Stateful.class);
+ if(annotation == null)
+ return null;
+
+ SessionBeanMetaData beanMetaData = create(beanClass, annotation);
+ beanMetaData.setSessionType(SessionType.Stateful);
+ return beanMetaData;
+ }
+
+ protected SessionBeanMetaData create(Class<?> beanClass, Stateful annotation)
+ {
+ return create(beanClass, annotation.name(), annotation.mappedName(), annotation.description());
+ }
+}
Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/StatefulProcessor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/StatelessProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/StatelessProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/StatelessProcessor.java 2007-09-26 22:20:40 UTC (rev 65638)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metadata.annotation.creator;
+
+import java.lang.reflect.AnnotatedElement;
+
+import javax.ejb.Stateless;
+
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
+import org.jboss.metadata.ejb.spec.SessionType;
+
+/**
+ * Create the correct meta data for a stateless annotation.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class StatelessProcessor extends AbstractSessionBeanProcessor
+{
+ public StatelessProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+ }
+
+ public SessionBeanMetaData create(Class<?> beanClass)
+ {
+ Stateless annotation = finder.getAnnotation(beanClass, Stateless.class);
+ if(annotation == null)
+ return null;
+
+ SessionBeanMetaData beanMetaData = create(beanClass, annotation);
+ beanMetaData.setSessionType(SessionType.Stateless);
+ return beanMetaData;
+ }
+
+ protected SessionBeanMetaData create(Class<?> beanClass, Stateless annotation)
+ {
+ return create(beanClass, annotation.name(), annotation.mappedName(), annotation.description());
+ }
+}
Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/StatelessProcessor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeProcessor.java 2007-09-26 22:20:40 UTC (rev 65638)
@@ -0,0 +1,143 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metadata.annotation.creator;
+
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Method;
+
+import javax.ejb.TransactionAttribute;
+
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData;
+import org.jboss.metadata.ejb.spec.ContainerTransactionMetaData;
+import org.jboss.metadata.ejb.spec.ContainerTransactionsMetaData;
+import org.jboss.metadata.ejb.spec.EjbJar3xMetaData;
+import org.jboss.metadata.ejb.spec.EjbJarMetaData;
+import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.spec.MethodMetaData;
+import org.jboss.metadata.ejb.spec.MethodParametersMetaData;
+import org.jboss.metadata.ejb.spec.MethodsMetaData;
+import org.jboss.metadata.ejb.spec.TransAttributeType;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class TransactionAttributeProcessor<T extends EnterpriseBeanMetaData> extends AbstractFinderUser implements Processor<T, Class<?>>
+{
+ public TransactionAttributeProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+ }
+
+ private ContainerTransactionMetaData createContainerTransaction(String ejbName, TransactionAttribute annotation, Class<?> beanClass)
+ {
+ ContainerTransactionMetaData containerTransaction = new ContainerTransactionMetaData();
+ containerTransaction.setMethods(createMethods(ejbName, null));
+ containerTransaction.setTransAttribute(createTransAttributeType(annotation));
+ return containerTransaction;
+ }
+
+// private ContainerTransactionMetaData createContainerTransaction(String ejbName, TransactionAttribute annotation, Method method)
+// {
+// ContainerTransactionMetaData containerTransaction = new ContainerTransactionMetaData();
+// containerTransaction.setMethods(createMethods(ejbName, method));
+// containerTransaction.setTransAttribute(createTransAttributeType(annotation));
+// return containerTransaction;
+// }
+
+ private MethodMetaData createMethod(String ejbName, Method method)
+ {
+ MethodMetaData methodMetaData = new MethodMetaData();
+ methodMetaData.setEjbName(ejbName);
+ if(method == null)
+ methodMetaData.setMethodName("*");
+ else
+ {
+ methodMetaData.setMethodName(method.getName());
+ MethodParametersMetaData methodParameters = MethodParametersHelper.create(method);
+ if(methodParameters != null)
+ methodMetaData.setMethodParams(methodParameters);
+ }
+ return methodMetaData;
+ }
+
+ private MethodsMetaData createMethods(String ejbName, Method method)
+ {
+ MethodsMetaData methods = new MethodsMetaData();
+ methods.add(createMethod(ejbName, method));
+ return methods;
+ }
+
+ private TransAttributeType createTransAttributeType(TransactionAttribute annotation)
+ {
+ switch(annotation.value())
+ {
+ case MANDATORY:
+ return TransAttributeType.Mandatory;
+ case NEVER:
+ return TransAttributeType.Never;
+ case NOT_SUPPORTED:
+ return TransAttributeType.NotSupported;
+ case REQUIRED:
+ return TransAttributeType.Required;
+ case REQUIRES_NEW:
+ return TransAttributeType.RequiresNew;
+ case SUPPORTS:
+ return TransAttributeType.Supports;
+ }
+ throw new IllegalArgumentException("Unknown transaction attribute value " + annotation.value());
+ }
+
+ private EnterpriseBeanMetaData findEnterpriseBean(EjbJar3xMetaData ejbJar, String ejbClass)
+ {
+ if(ejbJar.getEnterpriseBeans() == null)
+ return null;
+
+ for(EnterpriseBeanMetaData bean : ejbJar.getEnterpriseBeans())
+ {
+ if(bean.getEjbClass().equals(ejbClass))
+ {
+ return bean;
+ }
+ }
+ return null;
+ }
+
+ public void process(EnterpriseBeanMetaData bean, Class<?> cls)
+ {
+ TransactionAttribute annotation = finder.getAnnotation(cls, TransactionAttribute.class);
+ if(annotation == null)
+ return;
+
+ EjbJarMetaData ejbJarMetaData = bean.getEjbJarMetaData();
+
+ if(ejbJarMetaData.getAssemblyDescriptor() == null)
+ ejbJarMetaData.setAssemblyDescriptor(new AssemblyDescriptorMetaData());
+ if(ejbJarMetaData.getAssemblyDescriptor().getContainerTransactions() == null)
+ ejbJarMetaData.getAssemblyDescriptor().setContainerTransactions(new ContainerTransactionsMetaData());
+
+ ejbJarMetaData.getAssemblyDescriptor().getContainerTransactions().add(createContainerTransaction(bean.getEjbName(), annotation, cls));
+ }
+}
Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeProcessor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/finder/AnnotationFinder.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/finder/AnnotationFinder.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/finder/AnnotationFinder.java 2007-09-26 22:20:40 UTC (rev 65638)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metadata.annotation.finder;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+
+/**
+ * Provides a way to look for annotations in an alternate registry.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface AnnotationFinder<E extends AnnotatedElement>
+{
+ <T extends Annotation> T getAnnotation(E element, Class<T> annotationType);
+
+ Annotation[] getAnnotations(E element);
+
+ Annotation[] getDeclaredAnnotations(E element);
+
+ boolean isAnnotationPresent(E element, Class<? extends Annotation> annotationType);
+}
Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/finder/AnnotationFinder.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/finder/DefaultAnnotationFinder.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/finder/DefaultAnnotationFinder.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/finder/DefaultAnnotationFinder.java 2007-09-26 22:20:40 UTC (rev 65638)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metadata.annotation.finder;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+
+/**
+ * The default annotation processor finder will look for annotations
+ * directly on the annotated element.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class DefaultAnnotationFinder<E extends AnnotatedElement> implements AnnotationFinder<E>
+{
+ public <T extends Annotation> T getAnnotation(E element, Class<T> annotationType)
+ {
+ return element.getAnnotation(annotationType);
+ }
+
+ public Annotation[] getAnnotations(E element)
+ {
+ return element.getAnnotations();
+ }
+
+ public Annotation[] getDeclaredAnnotations(E element)
+ {
+ return element.getDeclaredAnnotations();
+ }
+
+ public boolean isAnnotationPresent(E element, Class<? extends Annotation> annotationType)
+ {
+ return element.isAnnotationPresent(annotationType);
+ }
+}
Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/finder/DefaultAnnotationFinder.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/AnnotationEjb3UnitTestCase.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/AnnotationEjb3UnitTestCase.java (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/AnnotationEjb3UnitTestCase.java 2007-09-26 22:20:40 UTC (rev 65638)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.metadata.annotation.ejb3;
+
+import java.lang.reflect.AnnotatedElement;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import junit.framework.TestCase;
+
+import org.jboss.metadata.annotation.creator.EjbJar30Creator;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
+import org.jboss.metadata.ejb.spec.EjbJar30MetaData;
+import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
+import org.jboss.metadata.ejb.spec.SessionType;
+
+/**
+ * This tests the annotation translation framework.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class AnnotationEjb3UnitTestCase extends TestCase
+{
+ public void test1() throws Exception
+ {
+ AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+
+ // In real life the deployer will pass probably pass a class scanner
+ Collection<Class<?>> classes = new ArrayList<Class<?>>();
+ classes.add(MyStatelessBean.class);
+ classes.add(MyStateless21Bean.class);
+ classes.add(MyStatefulBean.class);
+
+ EjbJar30Creator creator = new EjbJar30Creator(finder);
+
+ EjbJar30MetaData metaData = creator.create(classes);
+
+ assertTrue(metaData.isEJB3x());
+ assertEquals("3.0", metaData.getVersion());
+
+ assertEquals(3, metaData.getEnterpriseBeans().size());
+ SessionBeanMetaData bean = (SessionBeanMetaData) metaData.getEnterpriseBeans().iterator().next();
+ assertEquals(SessionType.Stateless, bean.getSessionType());
+ assertEquals(MyStatelessBean.class.getName(), bean.getEjbClass());
+ assertEquals("MyStatelessBean", bean.getEjbName());
+
+ assertNotNull("bean has no business locals", bean.getBusinessLocals());
+ assertEquals(1, bean.getBusinessLocals().size());
+ assertTrue(bean.getBusinessLocals().contains(MyStatelessLocal.class.getName()));
+
+ System.out.println(metaData.getAssemblyDescriptor().getContainerTransactionsByEjbName("MyStatelessBean"));
+ }
+}
Property changes on: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/AnnotationEjb3UnitTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStateful.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStateful.java (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStateful.java 2007-09-26 22:20:40 UTC (rev 65638)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.metadata.annotation.ejb3;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface MyStateful
+{
+
+}
Property changes on: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStateful.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatefulBean.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatefulBean.java (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatefulBean.java 2007-09-26 22:20:40 UTC (rev 65638)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.metadata.annotation.ejb3;
+
+import javax.ejb.Init;
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Stateful
+ at Remote(MyStateful.class)
+public class MyStatefulBean
+{
+ @Init
+ public void init()
+ {
+
+ }
+}
Property changes on: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatefulBean.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStateless21Bean.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStateless21Bean.java (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStateless21Bean.java 2007-09-26 22:20:40 UTC (rev 65638)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.metadata.annotation.ejb3;
+
+import javax.ejb.Local;
+import javax.ejb.LocalHome;
+import javax.ejb.Stateless;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Stateless
+ at Local(MyStatelessLocal.class)
+ at LocalHome(MyStateless21Home.class)
+public class MyStateless21Bean
+{
+
+}
Property changes on: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStateless21Bean.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStateless21Home.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStateless21Home.java (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStateless21Home.java 2007-09-26 22:20:40 UTC (rev 65638)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.metadata.annotation.ejb3;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface MyStateless21Home
+{
+
+}
Property changes on: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStateless21Home.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatelessBean.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatelessBean.java (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatelessBean.java 2007-09-26 22:20:40 UTC (rev 65638)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.metadata.annotation.ejb3;
+
+import javax.ejb.EJB;
+import javax.ejb.Init;
+import javax.ejb.LocalHome;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at SuppressWarnings("unused")
+ at Stateless
+ at TransactionAttribute(TransactionAttributeType.NEVER)
+public class MyStatelessBean implements MyStatelessLocal
+{
+ @EJB
+ private MyStatelessLocal injectedField;
+
+ @EJB(name="overrideName")
+ private MyStatelessLocal injectedFieldWithOverridenName;
+
+ @TransactionAttribute(TransactionAttributeType.MANDATORY)
+ public void transactionAttributeMandatory()
+ {
+
+ }
+}
Property changes on: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatelessBean.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatelessLocal.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatelessLocal.java (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatelessLocal.java 2007-09-26 22:20:40 UTC (rev 65638)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.metadata.annotation.ejb3;
+
+import javax.ejb.Local;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Local
+public interface MyStatelessLocal
+{
+
+}
Property changes on: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatelessLocal.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
More information about the jboss-cvs-commits
mailing list