[jboss-cvs] JBossAS SVN: r67165 - in projects/metadata/trunk/src: main/java/org/jboss/metadata/annotation/creator/ejb and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Nov 16 03:56:21 EST 2007
Author: scott.stark at jboss.org
Date: 2007-11-16 03:56:21 -0500 (Fri, 16 Nov 2007)
New Revision: 67165
Added:
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractPersistenceContextProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceContextClassProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceContextFieldProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceContextMethodProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ProcessorUtils.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/AbstractEnterpriseBeanProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/AbstractSessionBeanProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/AbstractTransactionAttributeProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/ApplicationExceptionProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/EjbJar30Creator.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/EntityProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/InitProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/LocalHomeProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/LocalProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/PostActivateMethodProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/PrePassivateMethodProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/RemoteHomeProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/RemoteProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/RemoveProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/StatefulProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/StatelessProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/TransactionAttributeClassProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/TransactionAttributeMethodProcessor.java
projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/IStateless.java
projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyBaseInterceptor.java
projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/SecureBean.java
projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/SomeEntity.java
Removed:
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractEnterpriseBeanProcessor.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/AbstractTransactionAttributeProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ApplicationExceptionProcessor.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/PostActivateMethodProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PrePassivateMethodProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/RemoteHomeProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/RemoteProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/RemoveProcessor.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/TransactionAttributeClassProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeMethodProcessor.java
Modified:
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractComponentProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractResourceProcessor.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/web/Web25MetaDataCreator.java
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/repository/MetaDataRepositoryUnitTestCase.java
projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/web/MyServlet.java
Log:
Move ejb specified processors into ejb subpackage and add @PersistenceContext processors
Modified: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractComponentProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractComponentProcessor.java 2007-11-16 08:49:36 UTC (rev 67164)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractComponentProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -28,16 +28,25 @@
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceUnit;
+import javax.xml.ws.WebServiceRefs;
+
import org.jboss.logging.Logger;
import org.jboss.metadata.annotation.finder.AnnotationFinder;
import org.jboss.metadata.javaee.spec.AnnotatedEJBReferencesMetaData;
import org.jboss.metadata.javaee.spec.EnvironmentRefsGroupMetaData;
+import org.jboss.metadata.javaee.spec.PersistenceContextReferencesMetaData;
+import org.jboss.metadata.javaee.spec.PersistenceUnitReferencesMetaData;
+import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
+import org.jboss.metadata.javaee.spec.ServiceReferencesMetaData;
/**
* A base javaee component processor.
@@ -82,6 +91,10 @@
addFieldProcessor(new EJBFieldProcessor(finder));
addTypeProcessor(new EJBClassProcessor(finder));
addTypeProcessor(new EJBsClassProcessor(finder));
+ // @PersistenceContext
+ addFieldProcessor(new PersistenceContextFieldProcessor(finder));
+ addMethodProcessor(new PersistenceContextMethodProcessor(finder));
+ addTypeProcessor(new PersistenceContextClassProcessor(finder));
// @PostConstruct/@PreDestroy
addMethodProcessor(new PostConstructMethodProcessor(finder));
addMethodProcessor(new PreDestroyMethodProcessor(finder));
@@ -132,10 +145,10 @@
*/
public void process(EnvironmentRefsGroupMetaData metaData, Class<?> type)
{
- // For Resources/Resource
+ // @Resources/@Resource
processClass(metaData, type);
- // @EJB
+ // @EJBs/@EJB
AnnotatedEJBReferencesMetaData aejbRefs = metaData.getAnnotatedEjbReferences();
if(aejbRefs == null)
{
@@ -143,7 +156,31 @@
metaData.setAnnotatedEjbReferences(aejbRefs);
}
processClass(aejbRefs, type);
-
+
+ // @PersistenceContext
+ PersistenceContextReferencesMetaData pcRefs = metaData.getPersistenceContextRefs();
+ if(pcRefs == null)
+ {
+ pcRefs = new PersistenceContextReferencesMetaData();
+ metaData.setPersistenceContextRefs(pcRefs);
+ }
+ processClass(pcRefs, type);
+ // @PersistenceUnit
+ PersistenceUnitReferencesMetaData puRefs = metaData.getPersistenceUnitRefs();
+ if(puRefs == null)
+ {
+ puRefs = new PersistenceUnitReferencesMetaData();
+ metaData.setPersistenceUnitRefs(puRefs);
+ }
+ processClass(puRefs, type);
+ // @WebServiceRefs/@WebServiceRef
+ ServiceReferencesMetaData wsRefs = metaData.getServiceReferences();
+ if(wsRefs == null)
+ {
+ wsRefs = new ServiceReferencesMetaData();
+ metaData.setServiceReferences(wsRefs);
+ }
+ processClass(wsRefs, type);
}
/**
* Process type for component metadata related annotations
@@ -286,4 +323,5 @@
}
return t;
}
+
}
Deleted: 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 2007-11-16 08:49:36 UTC (rev 67164)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractEnterpriseBeanProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -1,69 +0,0 @@
-/*
- * 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;
-import org.jboss.metadata.ejb.spec.EjbJar3xMetaData;
-import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
-import org.jboss.metadata.ejb.spec.EnterpriseBeansMetaData;
-import org.jboss.metadata.javaee.spec.EnvironmentRefsGroupMetaData;
-
-/**
- * Comment
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public abstract class AbstractEnterpriseBeanProcessor<MD extends EnterpriseBeanMetaData>
- extends AbstractComponentProcessor<MD>
- implements Processor<EjbJar3xMetaData, Class<?>>
-{
- protected abstract MD create(Class<?> beanClass);
-
- protected AbstractEnterpriseBeanProcessor(AnnotationFinder<AnnotatedElement> finder)
- {
- super(finder);
- addTypeProcessor(new TransactionAttributeClassProcessor<MD>(finder));
- addMethodProcessor(new TransactionAttributeMethodProcessor<MD>(finder));
- }
-
- public void process(EjbJar3xMetaData ejbJarMetaData, Class<?> beanClass)
- {
- MD beanMetaData = create(beanClass);
- if(beanMetaData == null)
- return;
-
- EnvironmentRefsGroupMetaData env = new EnvironmentRefsGroupMetaData();
- super.process(env, beanClass);
- beanMetaData.setJndiEnvironmentRefsGroup(env);
-
- if(ejbJarMetaData.getEnterpriseBeans() == null)
- ejbJarMetaData.setEnterpriseBeans(new EnterpriseBeansMetaData());
-
- ejbJarMetaData.getEnterpriseBeans().add(beanMetaData);
-
- processClass(beanMetaData, beanClass);
- }
-
-}
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractPersistenceContextProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractPersistenceContextProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractPersistenceContextProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.Set;
+
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.PersistenceProperty;
+
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.javaee.spec.PersistenceContextReferenceMetaData;
+import org.jboss.metadata.javaee.spec.PersistenceContextReferencesMetaData;
+import org.jboss.metadata.javaee.spec.PropertiesMetaData;
+import org.jboss.metadata.javaee.spec.PropertyMetaData;
+import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
+
+/**
+ * Base class for @PersistenceContext processors
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public abstract class AbstractPersistenceContextProcessor<E extends AnnotatedElement>
+ extends AbstractFinderUser
+{
+ /**
+ * @param finder
+ */
+ public AbstractPersistenceContextProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+ }
+
+ public void process(PersistenceContextReferencesMetaData refs, E element)
+ {
+ PersistenceContext annotation = finder.getAnnotation(element, PersistenceContext.class);
+ if(annotation == null)
+ return;
+
+ process(refs, element, annotation);
+ }
+
+ protected void process(PersistenceContextReferencesMetaData refs, E element, PersistenceContext annotation)
+ {
+ PersistenceContextReferenceMetaData ref = createPC(element, annotation);
+ refs.add(ref);
+ }
+
+ protected PersistenceContextReferenceMetaData createPC(E element, PersistenceContext annotation)
+ {
+ PersistenceContextReferenceMetaData ref = new PersistenceContextReferenceMetaData();
+ String name = annotation.name();
+ if(name.length() == 0)
+ name = ProcessorUtils.getName(element);
+ ref.setPersistenceContextRefName(name);
+ if(annotation.unitName().length() > 0)
+ ref.setPersistenceUnitName(annotation.unitName());
+ PersistenceContextType type = annotation.type();
+ ref.setPersistenceContextType(type);
+
+ PersistenceProperty[] properties = annotation.properties();
+ if(properties.length > 0 )
+ {
+ PropertiesMetaData refProperties = new PropertiesMetaData();
+ for(PersistenceProperty p : properties)
+ {
+ PropertyMetaData pmd = new PropertyMetaData();
+ pmd.setName(p.name());
+ pmd.setValue(p.value());
+ refProperties.add(pmd);
+ }
+ ref.setProperties(refProperties);
+ }
+
+ Set<ResourceInjectionTargetMetaData> injectionTargets = ProcessorUtils.getInjectionTargets(name, element);
+ if(injectionTargets != null)
+ ref.setInjectionTargets(injectionTargets);
+
+ return ref;
+ }
+}
Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractPersistenceContextProcessor.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Modified: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractResourceProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractResourceProcessor.java 2007-11-16 08:49:36 UTC (rev 67164)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractResourceProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -273,7 +273,7 @@
else
ref.setType(getType(element));
- Set<ResourceInjectionTargetMetaData> injectionTargets = getInjectionTargets(name, element);
+ Set<ResourceInjectionTargetMetaData> injectionTargets = ProcessorUtils.getInjectionTargets(name, element);
if(injectionTargets != null)
ref.setInjectionTargets(injectionTargets);
@@ -296,7 +296,7 @@
entry.setType(getType(element));
if(annotation.mappedName().length() > 0)
entry.setValue(annotation.mappedName());
- Set<ResourceInjectionTargetMetaData> injectionTargets = getInjectionTargets(name, element);
+ Set<ResourceInjectionTargetMetaData> injectionTargets = ProcessorUtils.getInjectionTargets(name, element);
if(injectionTargets != null)
entry.setInjectionTargets(injectionTargets);
@@ -320,7 +320,7 @@
ref.setServiceRefType(annotation.type().getName());
else
ref.setServiceRefType(getType(element));
- Set<ResourceInjectionTargetMetaData> injectionTargets = getInjectionTargets(name, element);
+ Set<ResourceInjectionTargetMetaData> injectionTargets = ProcessorUtils.getInjectionTargets(name, element);
if(injectionTargets != null)
ref.setInjectionTargets(injectionTargets);
@@ -343,7 +343,7 @@
Descriptions descriptions = getDescription(annotation.description());
if(descriptions != null)
ref.setDescriptions(descriptions);
- Set<ResourceInjectionTargetMetaData> injectionTargets = getInjectionTargets(name, element);
+ Set<ResourceInjectionTargetMetaData> injectionTargets = ProcessorUtils.getInjectionTargets(name, element);
if(injectionTargets != null)
ref.setInjectionTargets(injectionTargets);
@@ -366,7 +366,7 @@
Descriptions descriptions = getDescription(annotation.description());
if(descriptions != null)
ref.setDescriptions(descriptions);
- Set<ResourceInjectionTargetMetaData> injectionTargets = getInjectionTargets(name, element);
+ Set<ResourceInjectionTargetMetaData> injectionTargets = ProcessorUtils.getInjectionTargets(name, element);
if(injectionTargets != null)
ref.setInjectionTargets(injectionTargets);
@@ -396,17 +396,4 @@
}
return dg;
}
- protected Set<ResourceInjectionTargetMetaData> getInjectionTargets(String name, E element)
- {
- Set<ResourceInjectionTargetMetaData> injectionTargets = null;
- if((element instanceof Class) == false)
- {
- // Create an injection target for non-class elements
- ResourceInjectionTargetMetaData target = new ResourceInjectionTargetMetaData();
- target.setInjectionTargetClass(getDeclaringClass(element));
- target.setInjectionTargetName(name);
- injectionTargets = Collections.singleton(target);
- }
- return injectionTargets;
- }
}
Deleted: 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 2007-11-16 08:49:36 UTC (rev 67164)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractSessionBeanProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -1,99 +0,0 @@
-/*
- * 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.SessionBeanMetaData;
-import org.jboss.metadata.javaee.spec.DescriptionGroupMetaData;
-import org.jboss.metadata.javaee.spec.DescriptionImpl;
-import org.jboss.metadata.javaee.spec.DescriptionsImpl;
-
-/**
- * Abstract processor for helping a processor which creates
- * session bean meta data.
- *
- * @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;
-
- protected AbstractSessionBeanProcessor(AnnotationFinder<AnnotatedElement> finder)
- {
- super(finder);
-
- // TODO: configure somehow
-
- topLevelProcessors = new ArrayList<Processor<SessionBeanMetaData,Class<?>>>();
- topLevelProcessors.add(new LocalHomeProcessor(finder));
-
- addTypeProcessor(new LocalProcessor(finder));
- addTypeProcessor(new RemoteProcessor(finder));
- addTypeProcessor(new RemoteHomeProcessor(finder));
-
- addMethodProcessor(new InitProcessor(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);
- }
- }
-}
Deleted: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractTransactionAttributeProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractTransactionAttributeProcessor.java 2007-11-16 08:49:36 UTC (rev 67164)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractTransactionAttributeProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -1,115 +0,0 @@
-/*
- * 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.common.ejb.IEjbJarMetaData;
-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.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;
-
-/**
- * E defines the actual annotated element we're working for.
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision$
- */
-public abstract class AbstractTransactionAttributeProcessor<E extends AnnotatedElement, T extends EnterpriseBeanMetaData> extends AbstractFinderUser
-{
- protected AbstractTransactionAttributeProcessor(AnnotationFinder<AnnotatedElement> finder)
- {
- super(finder);
- }
-
- protected abstract ContainerTransactionMetaData createContainerTransaction(String ejbName, TransactionAttribute annotation, E element);
-
- 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;
- }
-
- protected MethodsMetaData createMethods(String ejbName, Method method)
- {
- MethodsMetaData methods = new MethodsMetaData();
- methods.add(createMethod(ejbName, method));
- return methods;
- }
-
- protected 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());
- }
-
- public void process(T bean, E element)
- {
- TransactionAttribute annotation = finder.getAnnotation(element, TransactionAttribute.class);
- if(annotation == null)
- return;
-
- IEjbJarMetaData ejbJarMetaData = bean.getEjbJarMetaData();
-
- if(ejbJarMetaData.getAssemblyDescriptor() == null)
- ejbJarMetaData.setAssemblyDescriptor(new AssemblyDescriptorMetaData());
- if(ejbJarMetaData.getAssemblyDescriptor().getContainerTransactions() == null)
- ejbJarMetaData.getAssemblyDescriptor().setContainerTransactions(new ContainerTransactionsMetaData());
-
- ContainerTransactionMetaData transaction = createContainerTransaction(bean.getEjbName(), annotation, element);
- ejbJarMetaData.getAssemblyDescriptor().getContainerTransactions().add(transaction);
- }
-}
Deleted: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ApplicationExceptionProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ApplicationExceptionProcessor.java 2007-11-16 08:49:36 UTC (rev 67164)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ApplicationExceptionProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -1,76 +0,0 @@
-/*
- * 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.ApplicationException;
-
-import org.jboss.metadata.annotation.finder.AnnotationFinder;
-import org.jboss.metadata.ejb.spec.ApplicationExceptionMetaData;
-import org.jboss.metadata.ejb.spec.ApplicationExceptionsMetaData;
-import org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData;
-import org.jboss.metadata.ejb.spec.EjbJar3xMetaData;
-
-/**
- * Process an application exception annotation.
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class ApplicationExceptionProcessor extends AbstractFinderUser implements Creator<Class<?>, ApplicationExceptionMetaData>, Processor<EjbJar3xMetaData, Class<?>>
-{
- protected ApplicationExceptionProcessor(AnnotationFinder<AnnotatedElement> finder)
- {
- super(finder);
- }
-
- public ApplicationExceptionMetaData create(Class<?> element)
- {
- ApplicationException annotation = finder.getAnnotation(element, ApplicationException.class);
- if(annotation == null)
- return null;
-
- if(!Exception.class.isAssignableFrom(element))
- throw new IllegalArgumentException("ApplicationException is only valid on an Exception");
-
- ApplicationExceptionMetaData metaData = new ApplicationExceptionMetaData();
- metaData.setExceptionClass(element.getName());
- metaData.setRollback(annotation.rollback());
-
- return metaData;
- }
-
- public void process(EjbJar3xMetaData ejbJar, Class<?> type)
- {
- ApplicationExceptionMetaData applicationException = create(type);
- if(applicationException == null)
- return;
-
- if(ejbJar.getAssemblyDescriptor() == null)
- ejbJar.setAssemblyDescriptor(new AssemblyDescriptorMetaData());
- if(ejbJar.getAssemblyDescriptor().getApplicationExceptions() == null)
- ejbJar.getAssemblyDescriptor().setApplicationExceptions(new ApplicationExceptionsMetaData());
-
- ejbJar.getAssemblyDescriptor().getApplicationExceptions().add(applicationException);
- }
-}
Deleted: 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 2007-11-16 08:49:36 UTC (rev 67164)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/EjbJar30Creator.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -1,69 +0,0 @@
-/*
- * 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));
- processors.add(new ApplicationExceptionProcessor(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;
- }
-}
Deleted: 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 2007-11-16 08:49:36 UTC (rev 67164)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/InitProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -1,97 +0,0 @@
-/*
- * 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;
-import org.jboss.metadata.ejb.spec.SessionType;
-
-/**
- * Process an init annotation.
- *
- * @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.getSessionType() != SessionType.Stateful)
- throw new IllegalArgumentException("Init annotation is only valid on a stateful bean");
-
- if(bean.getInitMethods() == null)
- bean.setInitMethods(new InitMethodsMetaData());
-
- bean.getInitMethods().add(initMethod);
- }
-}
Deleted: 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 2007-11-16 08:49:36 UTC (rev 67164)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/LocalHomeProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -1,52 +0,0 @@
-/*
- * 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());
- }
-}
Deleted: 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 2007-11-16 08:49:36 UTC (rev 67164)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/LocalProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -1,92 +0,0 @@
-/*
- * 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());
- }
- }
- }
- }
-}
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceContextClassProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceContextClassProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceContextClassProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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;
+import org.jboss.metadata.javaee.spec.PersistenceContextReferencesMetaData;
+
+/**
+ * @PersistenceContext for Methods
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class PersistenceContextClassProcessor
+ extends AbstractPersistenceContextProcessor<Class>
+ implements Processor<PersistenceContextReferencesMetaData, Class>
+{
+
+ /**
+ * @param finder
+ */
+ public PersistenceContextClassProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+ }
+
+}
Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceContextClassProcessor.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceContextFieldProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceContextFieldProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceContextFieldProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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 org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.javaee.spec.PersistenceContextReferencesMetaData;
+
+/**
+ * @PersistenceContext for Fields
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class PersistenceContextFieldProcessor
+ extends AbstractPersistenceContextProcessor<Field>
+ implements Processor<PersistenceContextReferencesMetaData, Field>
+{
+
+ /**
+ * @param finder
+ */
+ public PersistenceContextFieldProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+ }
+
+}
Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceContextFieldProcessor.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceContextMethodProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceContextMethodProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceContextMethodProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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 org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.javaee.spec.PersistenceContextReferencesMetaData;
+
+/**
+ * @PersistenceContext for Methods
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class PersistenceContextMethodProcessor
+ extends AbstractPersistenceContextProcessor<Method>
+ implements Processor<PersistenceContextReferencesMetaData, Method>
+{
+
+ /**
+ * @param finder
+ */
+ public PersistenceContextMethodProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+ }
+
+}
Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceContextMethodProcessor.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Deleted: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PostActivateMethodProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PostActivateMethodProcessor.java 2007-11-16 08:49:36 UTC (rev 67164)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PostActivateMethodProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -1,69 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * 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.PostActivate;
-
-import org.jboss.metadata.annotation.finder.AnnotationFinder;
-import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
-import org.jboss.metadata.javaee.spec.LifecycleCallbackMetaData;
-import org.jboss.metadata.javaee.spec.LifecycleCallbacksMetaData;
-
-/**
- * Translate @PostActivate into LifecycleCallbackMetaData for
- * SessionBeanMetaData
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class PostActivateMethodProcessor
- extends AbstractLifeCycleMethodProcessor
- implements Processor<SessionBeanMetaData, Method>
-{
- /**
- * @param finder
- */
- public PostActivateMethodProcessor(AnnotationFinder<AnnotatedElement> finder)
- {
- super(finder);
- }
-
- public void process(SessionBeanMetaData metaData, Method element)
- {
- PostActivate annotation = finder.getAnnotation(element, PostActivate.class);
- if(annotation == null)
- return;
-
- LifecycleCallbackMetaData callback = super.create(element);
- LifecycleCallbacksMetaData preDestroys = metaData.getPostActivates();
- if(preDestroys == null)
- {
- preDestroys = new LifecycleCallbacksMetaData();
- metaData.setPostActivates(preDestroys);
- }
- preDestroys.add(callback);
- }
-
-}
Deleted: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PrePassivateMethodProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PrePassivateMethodProcessor.java 2007-11-16 08:49:36 UTC (rev 67164)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PrePassivateMethodProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -1,69 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * 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.PrePassivate;
-
-import org.jboss.metadata.annotation.finder.AnnotationFinder;
-import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
-import org.jboss.metadata.javaee.spec.LifecycleCallbackMetaData;
-import org.jboss.metadata.javaee.spec.LifecycleCallbacksMetaData;
-
-/**
- * Translate @PrePassivate into LifecycleCallbackMetaData for
- * SessionBeanMetaData
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class PrePassivateMethodProcessor
- extends AbstractLifeCycleMethodProcessor
- implements Processor<SessionBeanMetaData, Method>
-{
- /**
- * @param finder
- */
- public PrePassivateMethodProcessor(AnnotationFinder<AnnotatedElement> finder)
- {
- super(finder);
- }
-
- public void process(SessionBeanMetaData metaData, Method element)
- {
- PrePassivate annotation = finder.getAnnotation(element, PrePassivate.class);
- if(annotation == null)
- return;
-
- LifecycleCallbackMetaData callback = super.create(element);
- LifecycleCallbacksMetaData preDestroys = metaData.getPrePassivates();
- if(preDestroys == null)
- {
- preDestroys = new LifecycleCallbacksMetaData();
- metaData.setPrePassivates(preDestroys);
- }
- preDestroys.add(callback);
- }
-
-}
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ProcessorUtils.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ProcessorUtils.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ProcessorUtils.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.Collections;
+import java.util.Set;
+
+import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class ProcessorUtils
+{
+ public static <E extends AnnotatedElement> Set<ResourceInjectionTargetMetaData> getInjectionTargets(String name, E element)
+ {
+ Set<ResourceInjectionTargetMetaData> injectionTargets = null;
+ if((element instanceof Class) == false)
+ {
+ // Create an injection target for non-class elements
+ ResourceInjectionTargetMetaData target = new ResourceInjectionTargetMetaData();
+ target.setInjectionTargetClass(getDeclaringClass(element));
+ target.setInjectionTargetName(name);
+ injectionTargets = Collections.singleton(target);
+ }
+ return injectionTargets;
+ }
+
+ public static <E extends AnnotatedElement> String getName(E element)
+ {
+ String name = element.getClass().getSimpleName();
+ if(element instanceof Class)
+ {
+ Class c = (Class) element;
+ name = c.getSimpleName();
+ }
+ else if(element instanceof Field)
+ {
+ Field f = (Field) element;
+ name = f.getName();
+ }
+ else if(element instanceof Method)
+ {
+ Method m = (Method) element;
+ name = m.getName();
+ }
+ return name;
+ }
+
+ public static <E extends AnnotatedElement> String getDeclaringClass(E element)
+ {
+ String c = null;
+ if(element instanceof Field)
+ {
+ Field f = (Field) element;
+ c = f.getDeclaringClass().getName();
+ }
+ else if(element instanceof Method)
+ {
+ Method m = (Method) element;
+ c = m.getDeclaringClass().getName();
+ }
+ return c;
+ }
+}
Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ProcessorUtils.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Deleted: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/RemoteHomeProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/RemoteHomeProcessor.java 2007-11-16 08:49:36 UTC (rev 67164)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/RemoteHomeProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -1,53 +0,0 @@
-/*
- * 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.RemoteHome;
-
-import org.jboss.metadata.annotation.finder.AnnotationFinder;
-import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
-
-/**
- * @RemoteHome annotation processor.
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision: $
- */
-public class RemoteHomeProcessor extends AbstractFinderUser
- implements Processor<SessionBeanMetaData, Class<?>>
-{
- public RemoteHomeProcessor(AnnotationFinder<AnnotatedElement> finder)
- {
- super(finder);
- }
-
- public void process(SessionBeanMetaData metaData, Class<?> type)
- {
- RemoteHome remote = finder.getAnnotation(type, RemoteHome.class);
- if(remote == null)
- return;
-
- metaData.setHome(remote.value().getName());
- }
-}
Deleted: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/RemoteProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/RemoteProcessor.java 2007-11-16 08:49:36 UTC (rev 67164)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/RemoteProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -1,92 +0,0 @@
-/*
- * 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.Remote;
-
-import org.jboss.metadata.annotation.finder.AnnotationFinder;
-import org.jboss.metadata.ejb.spec.BusinessRemotesMetaData;
-import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
-
-/**
- * Remote annotation processor.
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class RemoteProcessor extends AbstractFinderUser implements Processor<SessionBeanMetaData, Class<?>>
-{
- public RemoteProcessor(AnnotationFinder<AnnotatedElement> finder)
- {
- super(finder);
- }
-
- public void process(SessionBeanMetaData metaData, Class<?> type)
- {
- Remote remote = finder.getAnnotation(type, Remote.class);
- if(remote == null)
- return;
-
- if(type.isInterface())
- {
- if(metaData.getHome() != null)
- {
- if(metaData.getRemote() != null)
- throw new IllegalArgumentException("2.1 bean " + metaData.getEjbName() + " already has a remote interface " + metaData.getRemote() + ", can't add " + type.getName());
- metaData.setRemote(type.getName());
- }
- else
- {
- if(metaData.getBusinessRemotes() == null)
- metaData.setBusinessRemotes(new BusinessRemotesMetaData());
-
- metaData.getBusinessRemotes().add(type.getName());
- }
- }
- else
- {
- if(remote.value() == null || remote.value().length == 0)
- throw new IllegalArgumentException("Empty @Remote on bean class " + type.getName() + " is not allowed");
-
- if(metaData.getHome() != null)
- {
- if(metaData.getRemote() != null)
- throw new IllegalArgumentException("2.1 bean " + metaData.getEjbName() + " already has a remote interface " + metaData.getRemote() + ", can't add " + type.getName());
- if(remote.value().length > 1)
- throw new IllegalArgumentException("2.1 bean " + type.getName() + " has more than one remote interface defined");
- metaData.setRemote(remote.value()[0].getName());
- }
- else
- {
- if(metaData.getBusinessRemotes() == null)
- metaData.setBusinessRemotes(new BusinessRemotesMetaData());
-
- for(Class<?> businessInterface : remote.value())
- {
- metaData.getBusinessRemotes().add(businessInterface.getName());
- }
- }
- }
- }
-}
Deleted: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/RemoveProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/RemoveProcessor.java 2007-11-16 08:49:36 UTC (rev 67164)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/RemoveProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -1,84 +0,0 @@
-/*
- * 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.Remove;
-
-import org.jboss.metadata.annotation.finder.AnnotationFinder;
-import org.jboss.metadata.ejb.spec.RemoveMethodMetaData;
-import org.jboss.metadata.ejb.spec.RemoveMethodsMetaData;
-import org.jboss.metadata.ejb.spec.MethodParametersMetaData;
-import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
-import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
-import org.jboss.metadata.ejb.spec.SessionType;
-
-/**
- * Process @Remove annotation.
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision: $
- */
-public class RemoveProcessor extends AbstractFinderUser
- implements Creator<Method, RemoveMethodMetaData>,
- Processor<SessionBeanMetaData, Method>
-{
- public RemoveProcessor(AnnotationFinder<AnnotatedElement> finder)
- {
- super(finder);
- }
-
- public RemoveMethodMetaData create(Method method)
- {
- Remove remove = finder.getAnnotation(method, Remove.class);
- if(remove == null)
- return null;
-
- RemoveMethodMetaData metaData = new RemoveMethodMetaData();
- NamedMethodMetaData beanMethod = new NamedMethodMetaData();
- beanMethod.setMethodName(method.getName());
- metaData.setBeanMethod(beanMethod);
- metaData.setRetainIfException(remove.retainIfException());
-
- MethodParametersMetaData methodParams = MethodParametersHelper.create(method);
- beanMethod.setMethodParams(methodParams);
-
- return metaData;
- }
-
- public void process(SessionBeanMetaData bean, Method method)
- {
- RemoveMethodMetaData removeMethod = create(method);
- if(removeMethod == null)
- return;
-
- if(bean.getSessionType() != SessionType.Stateful)
- throw new IllegalArgumentException("Remove annotation is only valid on a stateful bean");
-
- if(bean.getRemoveMethods() == null)
- bean.setRemoveMethods(new RemoveMethodsMetaData());
-
- bean.getRemoveMethods().add(removeMethod);
- }
-}
Deleted: 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 2007-11-16 08:49:36 UTC (rev 67164)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/StatefulProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -1,64 +0,0 @@
-/*
- * 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>
- * @author Scott.Stark at jboss.org
- * @version $Revision: $
- */
-public class StatefulProcessor extends AbstractSessionBeanProcessor
-{
- public StatefulProcessor(AnnotationFinder<AnnotatedElement> finder)
- {
- super(finder);
- addMethodProcessor(new RemoveProcessor(finder));
- addMethodProcessor(new PostActivateMethodProcessor(finder));
- addMethodProcessor(new PrePassivateMethodProcessor(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());
- }
-}
Deleted: 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 2007-11-16 08:49:36 UTC (rev 67164)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/StatelessProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -1,60 +0,0 @@
-/*
- * 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());
- }
-}
Deleted: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeClassProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeClassProcessor.java 2007-11-16 08:49:36 UTC (rev 67164)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeClassProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -1,58 +0,0 @@
-/*
- * 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.TransactionAttribute;
-
-import org.jboss.logging.Logger;
-import org.jboss.metadata.annotation.finder.AnnotationFinder;
-import org.jboss.metadata.ejb.spec.ContainerTransactionMetaData;
-import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
-
-/**
- * Process transaction attribute annotations on classes.
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class TransactionAttributeClassProcessor<T extends EnterpriseBeanMetaData> extends AbstractTransactionAttributeProcessor<Class<?>, T>
- implements Processor<T, Class<?>>
-{
- private static final Logger log = Logger.getLogger(TransactionAttributeClassProcessor.class);
-
- public TransactionAttributeClassProcessor(AnnotationFinder<AnnotatedElement> finder)
- {
- super(finder);
- }
-
- @Override
- protected ContainerTransactionMetaData createContainerTransaction(String ejbName, TransactionAttribute annotation, Class<?> cls)
- {
- ContainerTransactionMetaData containerTransaction = new ContainerTransactionMetaData();
- log.info(containerTransaction);
- containerTransaction.setMethods(createMethods(ejbName, null));
- containerTransaction.setTransAttribute(createTransAttributeType(annotation));
- return containerTransaction;
- }
-}
Deleted: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeMethodProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeMethodProcessor.java 2007-11-16 08:49:36 UTC (rev 67164)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeMethodProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -1,60 +0,0 @@
-/*
- * 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.logging.Logger;
-import org.jboss.metadata.annotation.finder.AnnotationFinder;
-import org.jboss.metadata.ejb.spec.ContainerTransactionMetaData;
-import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
-
-/**
- * Process transaction attribute annotations on methods.
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class TransactionAttributeMethodProcessor<T extends EnterpriseBeanMetaData>
- extends AbstractTransactionAttributeProcessor<Method, T>
- implements Processor<T, Method>
-{
- private static final Logger log = Logger.getLogger(TransactionAttributeMethodProcessor.class);
-
- public TransactionAttributeMethodProcessor(AnnotationFinder<AnnotatedElement> finder)
- {
- super(finder);
- }
-
- @Override
- protected ContainerTransactionMetaData createContainerTransaction(String ejbName, TransactionAttribute annotation, Method method)
- {
- ContainerTransactionMetaData containerTransaction = new ContainerTransactionMetaData();
- log.info(containerTransaction);
- containerTransaction.setMethods(createMethods(ejbName, method));
- containerTransaction.setTransAttribute(createTransAttributeType(annotation));
- return containerTransaction;
- }
-}
Copied: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/AbstractEnterpriseBeanProcessor.java (from rev 67163, projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractEnterpriseBeanProcessor.java)
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/AbstractEnterpriseBeanProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/AbstractEnterpriseBeanProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -0,0 +1,71 @@
+/*
+ * 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.ejb;
+
+import java.lang.reflect.AnnotatedElement;
+
+import org.jboss.metadata.annotation.creator.AbstractComponentProcessor;
+import org.jboss.metadata.annotation.creator.Processor;
+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;
+import org.jboss.metadata.javaee.spec.EnvironmentRefsGroupMetaData;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public abstract class AbstractEnterpriseBeanProcessor<MD extends EnterpriseBeanMetaData>
+ extends AbstractComponentProcessor<MD>
+ implements Processor<EjbJar3xMetaData, Class<?>>
+{
+ protected abstract MD create(Class<?> beanClass);
+
+ protected AbstractEnterpriseBeanProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+ addTypeProcessor(new TransactionAttributeClassProcessor<MD>(finder));
+ addMethodProcessor(new TransactionAttributeMethodProcessor<MD>(finder));
+ }
+
+ public void process(EjbJar3xMetaData ejbJarMetaData, Class<?> beanClass)
+ {
+ MD beanMetaData = create(beanClass);
+ if(beanMetaData == null)
+ return;
+
+ EnvironmentRefsGroupMetaData env = new EnvironmentRefsGroupMetaData();
+ super.process(env, beanClass);
+ beanMetaData.setJndiEnvironmentRefsGroup(env);
+
+ if(ejbJarMetaData.getEnterpriseBeans() == null)
+ ejbJarMetaData.setEnterpriseBeans(new EnterpriseBeansMetaData());
+
+ ejbJarMetaData.getEnterpriseBeans().add(beanMetaData);
+
+ processClass(beanMetaData, beanClass);
+ }
+
+}
Copied: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/AbstractSessionBeanProcessor.java (from rev 67163, projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractSessionBeanProcessor.java)
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/AbstractSessionBeanProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/AbstractSessionBeanProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -0,0 +1,101 @@
+/*
+ * 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.ejb;
+
+import java.lang.reflect.AnnotatedElement;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.metadata.annotation.creator.Creator;
+import org.jboss.metadata.annotation.creator.Processor;
+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;
+
+/**
+ * Abstract processor for helping a processor which creates
+ * session bean meta data.
+ *
+ * @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;
+
+ protected AbstractSessionBeanProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+
+ // TODO: configure somehow
+
+ topLevelProcessors = new ArrayList<Processor<SessionBeanMetaData,Class<?>>>();
+ topLevelProcessors.add(new LocalHomeProcessor(finder));
+
+ addTypeProcessor(new LocalProcessor(finder));
+ addTypeProcessor(new RemoteProcessor(finder));
+ addTypeProcessor(new RemoteHomeProcessor(finder));
+
+ addMethodProcessor(new InitProcessor(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);
+ }
+ }
+}
Copied: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/AbstractTransactionAttributeProcessor.java (from rev 67163, projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractTransactionAttributeProcessor.java)
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/AbstractTransactionAttributeProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/AbstractTransactionAttributeProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -0,0 +1,117 @@
+/*
+ * 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.ejb;
+
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Method;
+
+import javax.ejb.TransactionAttribute;
+
+import org.jboss.metadata.annotation.creator.AbstractFinderUser;
+import org.jboss.metadata.annotation.creator.MethodParametersHelper;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.common.ejb.IEjbJarMetaData;
+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.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;
+
+/**
+ * E defines the actual annotated element we're working for.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public abstract class AbstractTransactionAttributeProcessor<E extends AnnotatedElement, T extends EnterpriseBeanMetaData> extends AbstractFinderUser
+{
+ protected AbstractTransactionAttributeProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+ }
+
+ protected abstract ContainerTransactionMetaData createContainerTransaction(String ejbName, TransactionAttribute annotation, E element);
+
+ 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;
+ }
+
+ protected MethodsMetaData createMethods(String ejbName, Method method)
+ {
+ MethodsMetaData methods = new MethodsMetaData();
+ methods.add(createMethod(ejbName, method));
+ return methods;
+ }
+
+ protected 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());
+ }
+
+ public void process(T bean, E element)
+ {
+ TransactionAttribute annotation = finder.getAnnotation(element, TransactionAttribute.class);
+ if(annotation == null)
+ return;
+
+ IEjbJarMetaData ejbJarMetaData = bean.getEjbJarMetaData();
+
+ if(ejbJarMetaData.getAssemblyDescriptor() == null)
+ ejbJarMetaData.setAssemblyDescriptor(new AssemblyDescriptorMetaData());
+ if(ejbJarMetaData.getAssemblyDescriptor().getContainerTransactions() == null)
+ ejbJarMetaData.getAssemblyDescriptor().setContainerTransactions(new ContainerTransactionsMetaData());
+
+ ContainerTransactionMetaData transaction = createContainerTransaction(bean.getEjbName(), annotation, element);
+ ejbJarMetaData.getAssemblyDescriptor().getContainerTransactions().add(transaction);
+ }
+}
Copied: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/ApplicationExceptionProcessor.java (from rev 67163, projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ApplicationExceptionProcessor.java)
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/ApplicationExceptionProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/ApplicationExceptionProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -0,0 +1,79 @@
+/*
+ * 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.ejb;
+
+import java.lang.reflect.AnnotatedElement;
+
+import javax.ejb.ApplicationException;
+
+import org.jboss.metadata.annotation.creator.AbstractFinderUser;
+import org.jboss.metadata.annotation.creator.Creator;
+import org.jboss.metadata.annotation.creator.Processor;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.spec.ApplicationExceptionMetaData;
+import org.jboss.metadata.ejb.spec.ApplicationExceptionsMetaData;
+import org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData;
+import org.jboss.metadata.ejb.spec.EjbJar3xMetaData;
+
+/**
+ * Process an application exception annotation.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class ApplicationExceptionProcessor extends AbstractFinderUser implements Creator<Class<?>, ApplicationExceptionMetaData>, Processor<EjbJar3xMetaData, Class<?>>
+{
+ protected ApplicationExceptionProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+ }
+
+ public ApplicationExceptionMetaData create(Class<?> element)
+ {
+ ApplicationException annotation = finder.getAnnotation(element, ApplicationException.class);
+ if(annotation == null)
+ return null;
+
+ if(!Exception.class.isAssignableFrom(element))
+ throw new IllegalArgumentException("ApplicationException is only valid on an Exception");
+
+ ApplicationExceptionMetaData metaData = new ApplicationExceptionMetaData();
+ metaData.setExceptionClass(element.getName());
+ metaData.setRollback(annotation.rollback());
+
+ return metaData;
+ }
+
+ public void process(EjbJar3xMetaData ejbJar, Class<?> type)
+ {
+ ApplicationExceptionMetaData applicationException = create(type);
+ if(applicationException == null)
+ return;
+
+ if(ejbJar.getAssemblyDescriptor() == null)
+ ejbJar.setAssemblyDescriptor(new AssemblyDescriptorMetaData());
+ if(ejbJar.getAssemblyDescriptor().getApplicationExceptions() == null)
+ ejbJar.getAssemblyDescriptor().setApplicationExceptions(new ApplicationExceptionsMetaData());
+
+ ejbJar.getAssemblyDescriptor().getApplicationExceptions().add(applicationException);
+ }
+}
Copied: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/EjbJar30Creator.java (from rev 67163, projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/EjbJar30Creator.java)
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/EjbJar30Creator.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/EjbJar30Creator.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -0,0 +1,72 @@
+/*
+ * 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.ejb;
+
+import java.lang.reflect.AnnotatedElement;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.jboss.metadata.annotation.creator.AbstractFinderUser;
+import org.jboss.metadata.annotation.creator.Creator;
+import org.jboss.metadata.annotation.creator.Processor;
+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));
+ processors.add(new ApplicationExceptionProcessor(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;
+ }
+}
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/EntityProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/EntityProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/EntityProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.ejb;
+
+import java.lang.reflect.AnnotatedElement;
+
+import javax.persistence.Entity;
+
+import org.jboss.metadata.annotation.creator.Creator;
+import org.jboss.metadata.annotation.creator.Processor;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.spec.EjbJar3xMetaData;
+import org.jboss.metadata.ejb.spec.EntityBeanMetaData;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class EntityProcessor
+ extends AbstractEnterpriseBeanProcessor<EntityBeanMetaData>
+ implements Creator<Class<?>, EntityBeanMetaData>,
+ Processor<EjbJar3xMetaData, Class<?>>
+{
+
+ /**
+ * @param finder
+ */
+ public EntityProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+ // TODO: all entity processors
+
+ }
+
+ @Override
+ public EntityBeanMetaData create(Class<?> beanClass)
+ {
+ Entity annotation = finder.getAnnotation(beanClass, Entity.class);
+ if(annotation == null)
+ return null;
+
+ EntityBeanMetaData metaData = new EntityBeanMetaData();
+ if(annotation.name().length() > 0)
+ metaData.setEjbName(annotation.name());
+ else
+ metaData.setEjbName(beanClass.getSimpleName());
+ return metaData;
+ }
+
+}
Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/EntityProcessor.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Copied: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/InitProcessor.java (from rev 67163, projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/InitProcessor.java)
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/InitProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/InitProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -0,0 +1,101 @@
+/*
+ * 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.ejb;
+
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Method;
+
+import javax.ejb.Init;
+
+import org.jboss.metadata.annotation.creator.AbstractFinderUser;
+import org.jboss.metadata.annotation.creator.Creator;
+import org.jboss.metadata.annotation.creator.MethodParametersHelper;
+import org.jboss.metadata.annotation.creator.Processor;
+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;
+import org.jboss.metadata.ejb.spec.SessionType;
+
+/**
+ * Process an init annotation.
+ *
+ * @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.getSessionType() != SessionType.Stateful)
+ throw new IllegalArgumentException("Init annotation is only valid on a stateful bean");
+
+ if(bean.getInitMethods() == null)
+ bean.setInitMethods(new InitMethodsMetaData());
+
+ bean.getInitMethods().add(initMethod);
+ }
+}
Copied: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/LocalHomeProcessor.java (from rev 67163, projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/LocalHomeProcessor.java)
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/LocalHomeProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/LocalHomeProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -0,0 +1,54 @@
+/*
+ * 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.ejb;
+
+import java.lang.reflect.AnnotatedElement;
+
+import javax.ejb.LocalHome;
+
+import org.jboss.metadata.annotation.creator.AbstractFinderUser;
+import org.jboss.metadata.annotation.creator.Processor;
+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());
+ }
+}
Copied: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/LocalProcessor.java (from rev 67163, projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/LocalProcessor.java)
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/LocalProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/LocalProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -0,0 +1,94 @@
+/*
+ * 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.ejb;
+
+import java.lang.reflect.AnnotatedElement;
+
+import javax.ejb.Local;
+
+import org.jboss.metadata.annotation.creator.AbstractFinderUser;
+import org.jboss.metadata.annotation.creator.Processor;
+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());
+ }
+ }
+ }
+ }
+}
Copied: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/PostActivateMethodProcessor.java (from rev 67163, projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PostActivateMethodProcessor.java)
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/PostActivateMethodProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/PostActivateMethodProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.ejb;
+
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Method;
+
+import javax.ejb.PostActivate;
+
+import org.jboss.metadata.annotation.creator.AbstractLifeCycleMethodProcessor;
+import org.jboss.metadata.annotation.creator.Processor;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
+import org.jboss.metadata.javaee.spec.LifecycleCallbackMetaData;
+import org.jboss.metadata.javaee.spec.LifecycleCallbacksMetaData;
+
+/**
+ * Translate @PostActivate into LifecycleCallbackMetaData for
+ * SessionBeanMetaData
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class PostActivateMethodProcessor
+ extends AbstractLifeCycleMethodProcessor
+ implements Processor<SessionBeanMetaData, Method>
+{
+ /**
+ * @param finder
+ */
+ public PostActivateMethodProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+ }
+
+ public void process(SessionBeanMetaData metaData, Method element)
+ {
+ PostActivate annotation = finder.getAnnotation(element, PostActivate.class);
+ if(annotation == null)
+ return;
+
+ LifecycleCallbackMetaData callback = super.create(element);
+ LifecycleCallbacksMetaData preDestroys = metaData.getPostActivates();
+ if(preDestroys == null)
+ {
+ preDestroys = new LifecycleCallbacksMetaData();
+ metaData.setPostActivates(preDestroys);
+ }
+ preDestroys.add(callback);
+ }
+
+}
Copied: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/PrePassivateMethodProcessor.java (from rev 67163, projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PrePassivateMethodProcessor.java)
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/PrePassivateMethodProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/PrePassivateMethodProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.ejb;
+
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Method;
+
+import javax.ejb.PrePassivate;
+
+import org.jboss.metadata.annotation.creator.AbstractLifeCycleMethodProcessor;
+import org.jboss.metadata.annotation.creator.Processor;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
+import org.jboss.metadata.javaee.spec.LifecycleCallbackMetaData;
+import org.jboss.metadata.javaee.spec.LifecycleCallbacksMetaData;
+
+/**
+ * Translate @PrePassivate into LifecycleCallbackMetaData for
+ * SessionBeanMetaData
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class PrePassivateMethodProcessor
+ extends AbstractLifeCycleMethodProcessor
+ implements Processor<SessionBeanMetaData, Method>
+{
+ /**
+ * @param finder
+ */
+ public PrePassivateMethodProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+ }
+
+ public void process(SessionBeanMetaData metaData, Method element)
+ {
+ PrePassivate annotation = finder.getAnnotation(element, PrePassivate.class);
+ if(annotation == null)
+ return;
+
+ LifecycleCallbackMetaData callback = super.create(element);
+ LifecycleCallbacksMetaData preDestroys = metaData.getPrePassivates();
+ if(preDestroys == null)
+ {
+ preDestroys = new LifecycleCallbacksMetaData();
+ metaData.setPrePassivates(preDestroys);
+ }
+ preDestroys.add(callback);
+ }
+
+}
Copied: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/RemoteHomeProcessor.java (from rev 67163, projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/RemoteHomeProcessor.java)
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/RemoteHomeProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/RemoteHomeProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -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.creator.ejb;
+
+import java.lang.reflect.AnnotatedElement;
+
+import javax.ejb.RemoteHome;
+
+import org.jboss.metadata.annotation.creator.AbstractFinderUser;
+import org.jboss.metadata.annotation.creator.Processor;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
+
+/**
+ * @RemoteHome annotation processor.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: $
+ */
+public class RemoteHomeProcessor extends AbstractFinderUser
+ implements Processor<SessionBeanMetaData, Class<?>>
+{
+ public RemoteHomeProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+ }
+
+ public void process(SessionBeanMetaData metaData, Class<?> type)
+ {
+ RemoteHome remote = finder.getAnnotation(type, RemoteHome.class);
+ if(remote == null)
+ return;
+
+ metaData.setHome(remote.value().getName());
+ }
+}
Copied: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/RemoteProcessor.java (from rev 67163, projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/RemoteProcessor.java)
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/RemoteProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/RemoteProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -0,0 +1,94 @@
+/*
+ * 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.ejb;
+
+import java.lang.reflect.AnnotatedElement;
+
+import javax.ejb.Remote;
+
+import org.jboss.metadata.annotation.creator.AbstractFinderUser;
+import org.jboss.metadata.annotation.creator.Processor;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.spec.BusinessRemotesMetaData;
+import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
+
+/**
+ * Remote annotation processor.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class RemoteProcessor extends AbstractFinderUser implements Processor<SessionBeanMetaData, Class<?>>
+{
+ public RemoteProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+ }
+
+ public void process(SessionBeanMetaData metaData, Class<?> type)
+ {
+ Remote remote = finder.getAnnotation(type, Remote.class);
+ if(remote == null)
+ return;
+
+ if(type.isInterface())
+ {
+ if(metaData.getHome() != null)
+ {
+ if(metaData.getRemote() != null)
+ throw new IllegalArgumentException("2.1 bean " + metaData.getEjbName() + " already has a remote interface " + metaData.getRemote() + ", can't add " + type.getName());
+ metaData.setRemote(type.getName());
+ }
+ else
+ {
+ if(metaData.getBusinessRemotes() == null)
+ metaData.setBusinessRemotes(new BusinessRemotesMetaData());
+
+ metaData.getBusinessRemotes().add(type.getName());
+ }
+ }
+ else
+ {
+ if(remote.value() == null || remote.value().length == 0)
+ throw new IllegalArgumentException("Empty @Remote on bean class " + type.getName() + " is not allowed");
+
+ if(metaData.getHome() != null)
+ {
+ if(metaData.getRemote() != null)
+ throw new IllegalArgumentException("2.1 bean " + metaData.getEjbName() + " already has a remote interface " + metaData.getRemote() + ", can't add " + type.getName());
+ if(remote.value().length > 1)
+ throw new IllegalArgumentException("2.1 bean " + type.getName() + " has more than one remote interface defined");
+ metaData.setRemote(remote.value()[0].getName());
+ }
+ else
+ {
+ if(metaData.getBusinessRemotes() == null)
+ metaData.setBusinessRemotes(new BusinessRemotesMetaData());
+
+ for(Class<?> businessInterface : remote.value())
+ {
+ metaData.getBusinessRemotes().add(businessInterface.getName());
+ }
+ }
+ }
+ }
+}
Copied: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/RemoveProcessor.java (from rev 67163, projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/RemoveProcessor.java)
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/RemoveProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/RemoveProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -0,0 +1,88 @@
+/*
+ * 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.ejb;
+
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Method;
+
+import javax.ejb.Remove;
+
+import org.jboss.metadata.annotation.creator.AbstractFinderUser;
+import org.jboss.metadata.annotation.creator.Creator;
+import org.jboss.metadata.annotation.creator.MethodParametersHelper;
+import org.jboss.metadata.annotation.creator.Processor;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.spec.RemoveMethodMetaData;
+import org.jboss.metadata.ejb.spec.RemoveMethodsMetaData;
+import org.jboss.metadata.ejb.spec.MethodParametersMetaData;
+import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
+import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
+import org.jboss.metadata.ejb.spec.SessionType;
+
+/**
+ * Process @Remove annotation.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: $
+ */
+public class RemoveProcessor extends AbstractFinderUser
+ implements Creator<Method, RemoveMethodMetaData>,
+ Processor<SessionBeanMetaData, Method>
+{
+ public RemoveProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+ }
+
+ public RemoveMethodMetaData create(Method method)
+ {
+ Remove remove = finder.getAnnotation(method, Remove.class);
+ if(remove == null)
+ return null;
+
+ RemoveMethodMetaData metaData = new RemoveMethodMetaData();
+ NamedMethodMetaData beanMethod = new NamedMethodMetaData();
+ beanMethod.setMethodName(method.getName());
+ metaData.setBeanMethod(beanMethod);
+ metaData.setRetainIfException(remove.retainIfException());
+
+ MethodParametersMetaData methodParams = MethodParametersHelper.create(method);
+ beanMethod.setMethodParams(methodParams);
+
+ return metaData;
+ }
+
+ public void process(SessionBeanMetaData bean, Method method)
+ {
+ RemoveMethodMetaData removeMethod = create(method);
+ if(removeMethod == null)
+ return;
+
+ if(bean.getSessionType() != SessionType.Stateful)
+ throw new IllegalArgumentException("Remove annotation is only valid on a stateful bean");
+
+ if(bean.getRemoveMethods() == null)
+ bean.setRemoveMethods(new RemoveMethodsMetaData());
+
+ bean.getRemoveMethods().add(removeMethod);
+ }
+}
Copied: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/StatefulProcessor.java (from rev 67163, projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/StatefulProcessor.java)
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/StatefulProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/StatefulProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -0,0 +1,64 @@
+/*
+ * 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.ejb;
+
+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>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: $
+ */
+public class StatefulProcessor extends AbstractSessionBeanProcessor
+{
+ public StatefulProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+ addMethodProcessor(new RemoveProcessor(finder));
+ addMethodProcessor(new PostActivateMethodProcessor(finder));
+ addMethodProcessor(new PrePassivateMethodProcessor(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());
+ }
+}
Copied: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/StatelessProcessor.java (from rev 67163, projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/StatelessProcessor.java)
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/StatelessProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/StatelessProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -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.ejb;
+
+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());
+ }
+}
Copied: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/TransactionAttributeClassProcessor.java (from rev 67163, projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeClassProcessor.java)
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/TransactionAttributeClassProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/TransactionAttributeClassProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -0,0 +1,59 @@
+/*
+ * 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.ejb;
+
+import java.lang.reflect.AnnotatedElement;
+
+import javax.ejb.TransactionAttribute;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.annotation.creator.Processor;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.spec.ContainerTransactionMetaData;
+import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
+
+/**
+ * Process transaction attribute annotations on classes.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class TransactionAttributeClassProcessor<T extends EnterpriseBeanMetaData> extends AbstractTransactionAttributeProcessor<Class<?>, T>
+ implements Processor<T, Class<?>>
+{
+ private static final Logger log = Logger.getLogger(TransactionAttributeClassProcessor.class);
+
+ public TransactionAttributeClassProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+ }
+
+ @Override
+ protected ContainerTransactionMetaData createContainerTransaction(String ejbName, TransactionAttribute annotation, Class<?> cls)
+ {
+ ContainerTransactionMetaData containerTransaction = new ContainerTransactionMetaData();
+ log.info(containerTransaction);
+ containerTransaction.setMethods(createMethods(ejbName, null));
+ containerTransaction.setTransAttribute(createTransAttributeType(annotation));
+ return containerTransaction;
+ }
+}
Copied: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/TransactionAttributeMethodProcessor.java (from rev 67163, projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeMethodProcessor.java)
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/TransactionAttributeMethodProcessor.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/TransactionAttributeMethodProcessor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -0,0 +1,61 @@
+/*
+ * 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.ejb;
+
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Method;
+
+import javax.ejb.TransactionAttribute;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.annotation.creator.Processor;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.spec.ContainerTransactionMetaData;
+import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
+
+/**
+ * Process transaction attribute annotations on methods.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class TransactionAttributeMethodProcessor<T extends EnterpriseBeanMetaData>
+ extends AbstractTransactionAttributeProcessor<Method, T>
+ implements Processor<T, Method>
+{
+ private static final Logger log = Logger.getLogger(TransactionAttributeMethodProcessor.class);
+
+ public TransactionAttributeMethodProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+ }
+
+ @Override
+ protected ContainerTransactionMetaData createContainerTransaction(String ejbName, TransactionAttribute annotation, Method method)
+ {
+ ContainerTransactionMetaData containerTransaction = new ContainerTransactionMetaData();
+ log.info(containerTransaction);
+ containerTransaction.setMethods(createMethods(ejbName, method));
+ containerTransaction.setTransAttribute(createTransAttributeType(annotation));
+ return containerTransaction;
+ }
+}
Modified: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/web/Web25MetaDataCreator.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/web/Web25MetaDataCreator.java 2007-11-16 08:49:36 UTC (rev 67164)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/web/Web25MetaDataCreator.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -27,11 +27,11 @@
import java.util.List;
import org.jboss.metadata.annotation.creator.AbstractFinderUser;
-import org.jboss.metadata.annotation.creator.ApplicationExceptionProcessor;
import org.jboss.metadata.annotation.creator.Creator;
import org.jboss.metadata.annotation.creator.Processor;
-import org.jboss.metadata.annotation.creator.StatefulProcessor;
-import org.jboss.metadata.annotation.creator.StatelessProcessor;
+import org.jboss.metadata.annotation.creator.ejb.ApplicationExceptionProcessor;
+import org.jboss.metadata.annotation.creator.ejb.StatefulProcessor;
+import org.jboss.metadata.annotation.creator.ejb.StatelessProcessor;
import org.jboss.metadata.annotation.finder.AnnotationFinder;
import org.jboss.metadata.ejb.spec.EjbJar3xMetaData;
import org.jboss.metadata.web.spec.Web25MetaData;
Modified: 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 2007-11-16 08:49:36 UTC (rev 67164)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/AnnotationEjb3UnitTestCase.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -31,7 +31,7 @@
import java.util.Collection;
import java.util.Iterator;
-import org.jboss.metadata.annotation.creator.EjbJar30Creator;
+import org.jboss.metadata.annotation.creator.ejb.EjbJar30Creator;
import org.jboss.metadata.annotation.finder.AnnotationFinder;
import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
import org.jboss.metadata.common.ejb.IEnterpriseBeanMetaData;
@@ -267,7 +267,7 @@
System.out.println(transaction);
}
- assertEquals(3, metaData.getEnterpriseBeans().size());
+ assertEquals(4, metaData.getEnterpriseBeans().size());
assertMyStatefulBean(metaData.getEnterpriseBean("AnotherName"));
assertMyStateless21Bean(metaData.getEnterpriseBean("MyStateless21Bean"));
Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/IStateless.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/IStateless.java (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/IStateless.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -0,0 +1,17 @@
+package org.jboss.test.metadata.annotation.ejb3;
+
+public interface IStateless
+{
+ int unchecked(int i);
+
+ int checked(int i);
+
+ SomeEntity insertSomeEntity();
+
+ SomeEntity readSomeEntity(int key);
+
+ void updateSomeEntity(SomeEntity e);
+
+ void deleteSomeEntity(SomeEntity e);
+
+}
Property changes on: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/IStateless.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyBaseInterceptor.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyBaseInterceptor.java (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyBaseInterceptor.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.annotation.Resource;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceUnit;
+import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class MyBaseInterceptor
+{
+ @EJB MyStatelessLocal baseSession2;
+ @Resource(mappedName="java:/TransactionManager") TransactionManager baseTm;
+ @Resource(name="DefaultDS", mappedName="java:DefaultDS") DataSource baseDs;
+ @PersistenceContext(unitName="interceptors-test") EntityManager baseEm;
+ @PersistenceUnit(unitName="interceptors-test") EntityManagerFactory baseFactory;
+
+ MyStatelessLocal baseSession2Method;
+ TransactionManager baseTmMethod;
+ DataSource baseDsMethod;
+ EntityManager baseEmMethod;
+ EntityManagerFactory baseFactoryMethod;
+
+ @EJB
+ public void setBaseSession2Method(MyStatelessLocal session2Method)
+ {
+ this.baseSession2Method = session2Method;
+ }
+ @Resource(name="DefaultDS", mappedName="java:DefaultDS")
+ public void setBaseDsMethod(DataSource dsMethod)
+ {
+ this.baseDsMethod = dsMethod;
+ }
+ @PersistenceContext(unitName="interceptors-test")
+ public void setBaseEmMethod(EntityManager emMethod)
+ {
+ this.baseEmMethod = emMethod;
+ }
+ @PersistenceUnit(unitName="interceptors-test")
+ public void setBaseFactoryMethod(EntityManagerFactory factoryMethod)
+ {
+ this.baseFactoryMethod = factoryMethod;
+ }
+
+ @AroundInvoke
+ public Object baseInvoke(InvocationContext ctx) throws Exception
+ {
+ return null;
+ }
+}
Property changes on: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyBaseInterceptor.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/SecureBean.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/SecureBean.java (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/SecureBean.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.annotation.security.RolesAllowed;
+import javax.annotation.security.PermitAll;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+/**
+ *
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+ at Stateless
+ at Remote(Stateless.class)
+public class SecureBean
+{
+ @PersistenceContext(unitName="jacc-test")
+ EntityManager em;
+
+ @PermitAll
+ public int unchecked(int i)
+ {
+ System.out.println("stateless unchecked");
+ return i;
+ }
+
+ @RolesAllowed ("allowed")
+ public int checked(int i)
+ {
+ System.out.println("stateless checked");
+ return i;
+ }
+
+ @PermitAll
+ public SomeEntity insertSomeEntity()
+ {
+ SomeEntity e = new SomeEntity();
+ e.val = "x";
+ em.persist(e);
+ return e;
+ }
+
+ @PermitAll
+ public SomeEntity readSomeEntity(int key)
+ {
+ SomeEntity e = em.find(SomeEntity.class, key);
+ return e;
+ }
+
+ @PermitAll
+ public void updateSomeEntity(SomeEntity e)
+ {
+ em.merge(e);
+ }
+
+ @PermitAll
+ public void deleteSomeEntity(SomeEntity e)
+ {
+ em.remove(e);
+ }
+}
Property changes on: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/SecureBean.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/SomeEntity.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/SomeEntity.java (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/SomeEntity.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.io.Serializable;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+ at Entity
+public class SomeEntity implements Serializable
+{
+ @Id @GeneratedValue(strategy=GenerationType.AUTO)
+ public int id;
+
+ public String val;
+}
Property changes on: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/SomeEntity.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Modified: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/repository/MetaDataRepositoryUnitTestCase.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/repository/MetaDataRepositoryUnitTestCase.java 2007-11-16 08:49:36 UTC (rev 67164)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/repository/MetaDataRepositoryUnitTestCase.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -26,7 +26,8 @@
import java.util.Collection;
import java.util.List;
import java.util.Set;
-import org.jboss.metadata.annotation.creator.EjbJar30Creator;
+
+import org.jboss.metadata.annotation.creator.ejb.EjbJar30Creator;
import org.jboss.metadata.annotation.finder.AnnotationFinder;
import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
Modified: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/web/MyServlet.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/web/MyServlet.java 2007-11-16 08:49:36 UTC (rev 67164)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/web/MyServlet.java 2007-11-16 08:56:21 UTC (rev 67165)
@@ -11,6 +11,10 @@
import javax.ejb.EJB;
import javax.ejb.EJBs;
import javax.jms.Queue;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceUnit;
import javax.sql.DataSource;
import javax.transaction.UserTransaction;
import javax.xml.ws.WebServiceRef;
@@ -46,6 +50,10 @@
UserTransaction utx;
@EJB
private MyStatelessLocal injectedField;
+ @PersistenceContext(unitName="../dd-web-ejbs.jar#tempdb")
+ EntityManager injectedEntityManager;
+ @PersistenceUnit(unitName="../dd-web-ejbs.jar#tempdb")
+ EntityManagerFactory injectedEntityManagerFactory;
@Resource(description="string-env-entry")
private String sfield;
More information about the jboss-cvs-commits
mailing list