[jboss-cvs] JBossAS SVN: r108544 - in projects/metadata/ejb/trunk/src: main/java/org/jboss/metadata/process/processor/ejb/jboss and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 13 09:22:04 EDT 2010
Author: jaikiran
Date: 2010-10-13 09:22:03 -0400 (Wed, 13 Oct 2010)
New Revision: 108544
Added:
projects/metadata/ejb/trunk/src/test/java/org/jboss/test/metadata/jbmeta302/
projects/metadata/ejb/trunk/src/test/java/org/jboss/test/metadata/jbmeta302/DoNothing.java
projects/metadata/ejb/trunk/src/test/java/org/jboss/test/metadata/jbmeta302/NoInterfaceViewBean.java
projects/metadata/ejb/trunk/src/test/java/org/jboss/test/metadata/jbmeta302/unit/
projects/metadata/ejb/trunk/src/test/java/org/jboss/test/metadata/jbmeta302/unit/DefaultLocalViewProcessorTestCase.java
Modified:
projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossSessionBean31MetaData.java
projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossSessionBeanMetaData.java
projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/process/processor/ejb/jboss/SetDefaultLocalBusinessInterfaceProcessor.java
Log:
JBMETA-302 Don't set the default (implicit) local business interface in the presence of nointerface view
Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossSessionBean31MetaData.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossSessionBean31MetaData.java 2010-10-13 11:21:53 UTC (rev 108543)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossSessionBean31MetaData.java 2010-10-13 13:22:03 UTC (rev 108544)
@@ -322,7 +322,21 @@
this.timers.add(timer);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
+ public boolean hasEJB3xView()
+ {
+ if (this.isNoInterfaceBean())
+ {
+ return true;
+ }
+
+ return super.hasEJB3xView();
+ }
+
+ @Override
public void merge(JBossEnterpriseBeanMetaData override, JBossEnterpriseBeanMetaData original)
{
super.merge(override, original);
Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossSessionBeanMetaData.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossSessionBeanMetaData.java 2010-10-13 11:21:53 UTC (rev 108543)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossSessionBeanMetaData.java 2010-10-13 13:22:03 UTC (rev 108544)
@@ -874,6 +874,43 @@
throw new IllegalArgumentException("Null remoteBinding");
this.remoteBindings = remoteBindings;
}
+
+ /**
+ * Returns true if this session bean exposes a EJB 3.x view. Else
+ * returns false
+ * @return
+ */
+ public boolean hasEJB3xView()
+ {
+ if (this.businessRemotes != null && !this.businessRemotes.isEmpty())
+ {
+ return true;
+ }
+
+ if (this.businessLocals != null && !this.businessLocals.isEmpty())
+ {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Returns true if this session bean exposes a EJB2.x view. Else
+ * returns false
+ * @return
+ */
+ public boolean hasEJB2xView()
+ {
+ if (this.remote != null && !this.remote.isEmpty())
+ {
+ return true;
+ }
+ if (this.local != null && !this.local.isEmpty())
+ {
+ return true;
+ }
+ return false;
+ }
@Override
public void merge(JBossEnterpriseBeanMetaData override, EnterpriseBeanMetaData original, String overridenFile, String overrideFile, boolean mustOverride)
Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/process/processor/ejb/jboss/SetDefaultLocalBusinessInterfaceProcessor.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/process/processor/ejb/jboss/SetDefaultLocalBusinessInterfaceProcessor.java 2010-10-13 11:21:53 UTC (rev 108543)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/process/processor/ejb/jboss/SetDefaultLocalBusinessInterfaceProcessor.java 2010-10-13 13:22:03 UTC (rev 108544)
@@ -119,14 +119,12 @@
+ " from the specified ClassLoader: " + cl);
}
- // If there are already local business interfaces specified
- if (smd.getBusinessLocals() != null && smd.getBusinessLocals().size() > 0)
+ // If the bean already has an EJB3.x view, then nothing to do.
+ if (smd.hasEJB3xView())
+ {
continue;
+ }
- // If there are already remote business interfaces specified
- if (smd.getBusinessRemotes() != null && smd.getBusinessRemotes().size() > 0)
- continue;
-
// Get the a single interface
Class<?> businessInterface = ClassHelper.extractInterface(ejbImplementationClass.getInterfaces());
if (businessInterface == null)
Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/test/metadata/jbmeta302/DoNothing.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/test/metadata/jbmeta302/DoNothing.java (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/test/metadata/jbmeta302/DoNothing.java 2010-10-13 13:22:03 UTC (rev 108544)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jbmeta302;
+
+/**
+ * DoNothing
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface DoNothing
+{
+
+}
Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/test/metadata/jbmeta302/NoInterfaceViewBean.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/test/metadata/jbmeta302/NoInterfaceViewBean.java (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/test/metadata/jbmeta302/NoInterfaceViewBean.java 2010-10-13 13:22:03 UTC (rev 108544)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jbmeta302;
+
+import javax.ejb.LocalBean;
+import javax.ejb.Stateless;
+
+/**
+ * NoInterfaceViewBean
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Stateless
+ at LocalBean
+public class NoInterfaceViewBean implements DoNothing
+{
+
+}
Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/test/metadata/jbmeta302/unit/DefaultLocalViewProcessorTestCase.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/test/metadata/jbmeta302/unit/DefaultLocalViewProcessorTestCase.java (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/test/metadata/jbmeta302/unit/DefaultLocalViewProcessorTestCase.java 2010-10-13 13:22:03 UTC (rev 108544)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jbmeta302.unit;
+
+import java.lang.reflect.AnnotatedElement;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import junit.framework.Assert;
+
+import org.jboss.metadata.annotation.creator.ejb.jboss.JBoss50Creator;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.process.processor.ejb.jboss.SetDefaultLocalBusinessInterfaceProcessor;
+import org.jboss.test.metadata.jbmeta302.NoInterfaceViewBean;
+import org.junit.Test;
+
+/**
+ * Tests the bug fix for JBMETA-302
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class DefaultLocalViewProcessorTestCase
+{
+
+ /**
+ * Test that the {@link SetDefaultLocalBusinessInterfaceProcessor} does *not* set a
+ * default local business view for a bean which exposes a nointerface view.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testBeanWithNoInterfaceView() throws Exception
+ {
+
+ Class<?> noInterfaceViewBean = NoInterfaceViewBean.class;
+
+ // Create an AnnotationFinder for the EJB impl class
+ AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+ Collection<Class<?>> classes = new ArrayList<Class<?>>();
+ classes.add(noInterfaceViewBean);
+
+ // Create
+ JBoss50Creator creator = new JBoss50Creator(finder);
+ JBossMetaData metadata = creator.create(classes);
+
+ // Run the implicit local processor
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ SetDefaultLocalBusinessInterfaceProcessor<JBossMetaData> processor = new SetDefaultLocalBusinessInterfaceProcessor<JBossMetaData>(cl);
+
+ // process the metadata
+ metadata = processor.process(metadata);
+
+ JBossSessionBeanMetaData sessionBean = (JBossSessionBeanMetaData) metadata.getEnterpriseBean(NoInterfaceViewBean.class.getSimpleName());
+ Assert.assertTrue("Bean (unexpectedly) exposes local business interface view", sessionBean.getBusinessLocals() == null || sessionBean.getBusinessLocals().isEmpty());
+
+ // just one additional check to make sure it's considered a no-interface view bean
+ Assert.assertTrue("Unexpected bean metadata type", (sessionBean instanceof JBossSessionBean31MetaData));
+
+ JBossSessionBean31MetaData sessionBean31 = (JBossSessionBean31MetaData) sessionBean;
+ Assert.assertTrue("Bean was expected to expose a nointerface view", sessionBean31.isNoInterfaceBean());
+
+ }
+}
More information about the jboss-cvs-commits
mailing list