aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From timothyjw...@apache.org
Subject svn commit: r1153085 - in /aries/trunk/ejb/ejb-modeller: ./ src/main/java/org/apache/aries/ejb/modelling/ src/main/java/org/apache/aries/ejb/modelling/impl/ src/test/java/org/apache/aries/ejb/modelling/impl/ src/test/java/test/ejbs/
Date Tue, 02 Aug 2011 10:04:47 GMT
Author: timothyjward
Date: Tue Aug  2 10:04:44 2011
New Revision: 1153085

URL: http://svn.apache.org/viewvc?rev=1153085&view=rev
Log:
Documentation and interface usability tweaks

Added:
    aries/trunk/ejb/ejb-modeller/src/test/java/test/ejbs/StatefulSessionBean.java
Modified:
    aries/trunk/ejb/ejb-modeller/pom.xml
    aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/EJBLocator.java
    aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/EJBRegistry.java
    aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBLocationUnavailable.java
    aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBLocatorFactory.java
    aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBModeller.java
    aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBServiceExport.java
    aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/OpenEJBLocator.java
    aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/ParsedEJBServices.java
    aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/StandaloneEJBModeller.java
    aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/EJBLocatorTest.java
    aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/ParsedEJBServicesTest.java

Modified: aries/trunk/ejb/ejb-modeller/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/pom.xml?rev=1153085&r1=1153084&r2=1153085&view=diff
==============================================================================
--- aries/trunk/ejb/ejb-modeller/pom.xml (original)
+++ aries/trunk/ejb/ejb-modeller/pom.xml Tue Aug  2 10:04:44 2011
@@ -39,7 +39,7 @@
 
     <properties>
 		<aries.osgi.export>
-		  org.apache.aries.ejb.modelling
+		  org.apache.aries.ejb.modelling;version="0.1.0"
 		</aries.osgi.export>
         <aries.osgi.private.pkg>
           org.apache.aries.ejb.modelling.*

Modified: aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/EJBLocator.java
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/EJBLocator.java?rev=1153085&r1=1153084&r2=1153085&view=diff
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/EJBLocator.java
(original)
+++ aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/EJBLocator.java
Tue Aug  2 10:04:44 2011
@@ -20,8 +20,20 @@ import org.apache.aries.application.mode
 import org.apache.aries.util.filesystem.IDirectory;
 import org.apache.aries.util.manifest.BundleManifest;
 
+/**
+ * A plug point for locating session EJBs in a bundle.
+ */
 public interface EJBLocator {
 
+  /**
+   * Find any session beans defined in the IDirectory bundle and register them
+   * with the supplied {@link EJBRegistry}.
+   * 
+   * @param manifest The manifest for the bundle
+   * @param bundle The bundle binary
+   * @param registry The registry of located Session EJBs
+   * @throws ModellerException
+   */
   public void findEJBs(BundleManifest manifest, IDirectory bundle, EJBRegistry registry)
     throws ModellerException;
   

Modified: aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/EJBRegistry.java
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/EJBRegistry.java?rev=1153085&r1=1153084&r2=1153085&view=diff
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/EJBRegistry.java
(original)
+++ aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/EJBRegistry.java
Tue Aug  2 10:04:44 2011
@@ -16,7 +16,18 @@
  */
 package org.apache.aries.ejb.modelling;
 
+/**
+ * A registry of located Session EJBs
+ */
 public interface EJBRegistry {
+  /**
+   * Add a view of a session EJB, e.g. a local home, remote business interface etc.
+   * 
+   * @param ejbName The ejb name
+   * @param ejbType The ejb type (e.g. stateless)
+   * @param interfaceName The fully qualified Java type name for this view
+   * @param remote
+   */
   public void addEJBView(String ejbName, String ejbType, String interfaceName,
       boolean remote);
 }

Modified: aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBLocationUnavailable.java
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBLocationUnavailable.java?rev=1153085&r1=1153084&r2=1153085&view=diff
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBLocationUnavailable.java
(original)
+++ aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBLocationUnavailable.java
Tue Aug  2 10:04:44 2011
@@ -22,6 +22,10 @@ import org.apache.aries.ejb.modelling.EJ
 import org.apache.aries.util.filesystem.IDirectory;
 import org.apache.aries.util.manifest.BundleManifest;
 
+/**
+ * An EJB Locator implementation for when EJB location is unavailable.
+ * It will cause any modelling that might involve EJBs to fail.
+ */
 public class EJBLocationUnavailable implements EJBLocator {
 
   public void findEJBs(BundleManifest manifest, IDirectory bundle,

Modified: aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBLocatorFactory.java
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBLocatorFactory.java?rev=1153085&r1=1153084&r2=1153085&view=diff
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBLocatorFactory.java
(original)
+++ aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBLocatorFactory.java
Tue Aug  2 10:04:44 2011
@@ -18,6 +18,10 @@ package org.apache.aries.ejb.modelling.i
 
 import org.apache.aries.ejb.modelling.EJBLocator;
 
+/**
+ * A factory for creating our internal EJBLocator without a hard dependency on
+ * OpenEJB
+ */
 public class EJBLocatorFactory {
   public static EJBLocator getEJBLocator() {
     try {

Modified: aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBModeller.java
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBModeller.java?rev=1153085&r1=1153084&r2=1153085&view=diff
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBModeller.java
(original)
+++ aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBModeller.java
Tue Aug  2 10:04:44 2011
@@ -40,6 +40,10 @@ public class EJBModeller implements Serv
     this.locator = locator;
   }
   
+  /**
+   * This modeller only searches for EJBs if there is an Export-EJB header with
+   * a value other than NONE (which is also the default).
+   */
   public ParsedServiceElements modelServices(BundleManifest manifest, IDirectory bundle)

     throws ModellerException {
     logger.trace("modelServices", new Object[] {manifest, bundle});

Modified: aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBServiceExport.java
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBServiceExport.java?rev=1153085&r1=1153084&r2=1153085&view=diff
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBServiceExport.java
(original)
+++ aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBServiceExport.java
Tue Aug  2 10:04:44 2011
@@ -28,6 +28,9 @@ import org.apache.aries.application.mode
 import org.apache.aries.application.utils.service.ExportedServiceHelper;
 import org.osgi.framework.Constants;
 
+/**
+ * This class represents the service exported on behalf of a Session Bean
+ */
 public class EJBServiceExport implements ExportedService {
 
   private final String interfaceName;
@@ -38,6 +41,13 @@ public class EJBServiceExport implements
   private final Map<String, Object> serviceProperties;
   private String _toString;
   
+  /**
+   * Set up this {@link ExportedService} with the right EJB properties
+   * @param ejbName
+   * @param ejbType
+   * @param interfaceName
+   * @param remote
+   */
   public EJBServiceExport(String ejbName, String ejbType, String interfaceName,
       boolean remote) {
     this.interfaceName = interfaceName;
@@ -45,7 +55,7 @@ public class EJBServiceExport implements
     
     serviceProperties = new HashMap<String, Object>();
     serviceProperties.put("ejb.name", ejbName);
-    serviceProperties.put("ejb.type", ejbType);
+    serviceProperties.put("ejb.type", correctCase(ejbType));
     if(remote)
       serviceProperties.put("service.exported.interfaces", interfaceName);
     
@@ -56,6 +66,17 @@ public class EJBServiceExport implements
     _attributes.put(ModellingConstants.OBR_SERVICE, ModellingConstants.OBR_SERVICE);
   }
 
+  /**
+   * The ejb.type property is always capitalised first letter, lowercase otherwise
+   * @param ejbType
+   * @return
+   */
+  private String correctCase(String ejbType) {
+    String result = ejbType.substring(0, 1).toUpperCase();
+    result += ejbType.substring(1).toLowerCase();
+    return result;
+  }
+
   public Map<String, Object> getAttributes() {
     return _attributes;
   }

Modified: aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/OpenEJBLocator.java
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/OpenEJBLocator.java?rev=1153085&r1=1153084&r2=1153085&view=diff
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/OpenEJBLocator.java
(original)
+++ aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/OpenEJBLocator.java
Tue Aug  2 10:04:44 2011
@@ -36,16 +36,23 @@ import org.apache.openejb.config.ReadDes
 import org.apache.openejb.jee.EjbJar;
 import org.apache.openejb.jee.EnterpriseBean;
 import org.apache.openejb.jee.SessionBean;
-import org.apache.openejb.jee.SessionType;
 import org.apache.xbean.finder.ClassFinder;
 import org.osgi.framework.Constants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+/**
+ * An {@link EJBLocator} that uses OpenEJB to find EJBs
+ * @author Tim
+ *
+ */
 public class OpenEJBLocator implements EJBLocator {
 
   private static final Logger logger = LoggerFactory.getLogger(OpenEJBLocator.class);
   
+  /**
+   * A ClassLoader used by OpenEJB in annotation scanning
+   */
   public static class ResourceClassLoader extends ClassLoader {
 
     private final List<IDirectory> classpath;
@@ -72,24 +79,26 @@ public class OpenEJBLocator implements E
       EJBRegistry registry) throws ModellerException {
 
     try {
+      //If we have an ejb-jar.xml then parse it 
       IFile file = bundle.getFile("META-INF/ejb-jar.xml");
       EjbJar ejbJar = (file == null) ? new EjbJar() : ReadDescriptors.readEjbJar(file.toURL());
       
       EjbModule module = new EjbModule(ejbJar);
       
+      //Find our classpath so we can scan the module
       List<IDirectory> cpEntries = getClassPathLocations(manifest, bundle);
       
       ClassLoader cl = new ResourceClassLoader(cpEntries);
       module.setClassLoader(cl);
       
-      //This may become AnnotationFinder at some point in the future. We build our
-      //own because we can't trust anyone to get the classpath right otherwise!
+      //We build our own because we can't trust anyone to get the classpath right otherwise!
       module.setFinder(new ClassFinder(cl, getClassPathURLs(cpEntries)));
       
+      //Scan our app for annotated EJBs
       AppModule app = new AppModule(module);
-      
       new AnnotationDeployer().deploy(app);
       
+      //Register our session beans
       for(EnterpriseBean eb : ejbJar.getEnterpriseBeans()) {
         
         if(!!!(eb instanceof SessionBean))
@@ -102,7 +111,13 @@ public class OpenEJBLocator implements E
       throw new ModellerException(e);
     }
   }
-
+  
+  /**
+   * Get URLs for creating a {@link ClassFinder}
+   * @param cpEntries
+   * @return
+   * @throws MalformedURLException
+   */
   private List<URL> getClassPathURLs(List<IDirectory> cpEntries) throws MalformedURLException
{
     List<URL> result = new ArrayList<URL>();
     
@@ -112,6 +127,13 @@ public class OpenEJBLocator implements E
     return result;
   }
 
+  /**
+   * Find the classpath entries for our bundle
+   * 
+   * @param manifest
+   * @param bundle
+   * @return
+   */
   private List<IDirectory> getClassPathLocations(BundleManifest manifest,
       IDirectory bundle) {
     List<IDirectory> result = new ArrayList<IDirectory>();
@@ -142,14 +164,16 @@ public class OpenEJBLocator implements E
     return result;
   }
 
+  /**
+   * Register a located session bean with the {@link EJBRegistry}
+   * @param registry
+   * @param sb
+   */
   private void registerSessionBean(EJBRegistry registry, SessionBean sb) {
     
     String name = sb.getEjbName();
     String type = sb.getSessionType().toString();
     
-    if(sb.getSessionType() == SessionType.STATEFUL)
-      return;
-    
     boolean added = false;
     
     for(String iface : sb.getBusinessLocal()) {

Modified: aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/ParsedEJBServices.java
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/ParsedEJBServices.java?rev=1153085&r1=1153084&r2=1153085&view=diff
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/ParsedEJBServices.java
(original)
+++ aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/ParsedEJBServices.java
Tue Aug  2 10:04:44 2011
@@ -27,6 +27,12 @@ import org.apache.aries.application.mode
 import org.apache.aries.application.modelling.ParsedServiceElements;
 import org.apache.aries.ejb.modelling.EJBRegistry;
 
+/**
+ * An {@link EJBRegistry} that marks the {@link ParsedServiceElements} provided
+ * by the EJB bundle.
+ * @author Tim
+ *
+ */
 public class ParsedEJBServices implements ParsedServiceElements, EJBRegistry {
 
   private final Collection<ImportedService> references;
@@ -65,6 +71,9 @@ public class ParsedEJBServices implement
   
   public void addEJBView(String ejbName, String ejbType, String interfaceName,
       boolean remote) {
+    if(ejbType.equalsIgnoreCase("Stateful"))
+      return;
+    
     if(all || allowedNames.contains(ejbName))
       services.add(new EJBServiceExport(ejbName, ejbType, interfaceName, remote));
   }

Modified: aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/StandaloneEJBModeller.java
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/StandaloneEJBModeller.java?rev=1153085&r1=1153084&r2=1153085&view=diff
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/StandaloneEJBModeller.java
(original)
+++ aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/StandaloneEJBModeller.java
Tue Aug  2 10:04:44 2011
@@ -16,6 +16,9 @@
  */
 package org.apache.aries.ejb.modelling.impl;
 
+/**
+ * An {@link EJBModeller} for use in standalone modelling
+ */
 public class StandaloneEJBModeller extends EJBModeller {
 
   public StandaloneEJBModeller() {

Modified: aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/EJBLocatorTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/EJBLocatorTest.java?rev=1153085&r1=1153084&r2=1153085&view=diff
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/EJBLocatorTest.java
(original)
+++ aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/EJBLocatorTest.java
Tue Aug  2 10:04:44 2011
@@ -68,6 +68,7 @@ public class EJBLocatorTest {
     ZipOutputStream zos = new ZipOutputStream(baos);
     addToZip(zos, "ejb-jar.xml", "META-INF/ejb-jar.xml");
     addToZip(zos, "test/ejbs/StatelessSessionBean.class");
+    addToZip(zos, "test/ejbs/StatefulSessionBean.class");
     zos.close();
     
     runTest(baos.toByteArray(), "MANIFEST_1.MF");
@@ -82,6 +83,7 @@ public class EJBLocatorTest {
     ByteArrayOutputStream baos = new ByteArrayOutputStream();
     ZipOutputStream zos = new ZipOutputStream(baos);
     addToZip(zos, "test/ejbs/StatelessSessionBean.class");
+    addToZip(zos, "test/ejbs/StatefulSessionBean.class");
     zos.close();
     
     runTest(baos.toByteArray(), "MANIFEST_1.MF");
@@ -97,6 +99,7 @@ public class EJBLocatorTest {
     ZipOutputStream zos = new ZipOutputStream(baos);
     addToZip(zos, "ejb-jar.xml", "META-INF/ejb-jar.xml");
     addToZip(zos, "test/ejb/StatelessSessionBean.class", "no/test/ejb/StatelessSessionBean.class");
+    addToZip(zos, "test/ejb/StatefulSessionBean.class", "no/test/ejb/StatefulSessionBean.class");
     zos.close();
     
     runTest(baos.toByteArray(), "MANIFEST_2.MF");
@@ -155,6 +158,14 @@ public class EJBLocatorTest {
       s.assertCalledExactNumberOfTimes(mc, 1);
     else
       s.assertNotCalled(mc);
+    
+    mc = new MethodCall(EJBRegistry.class, "addEJBView",
+        String.class, "STATEFUL", String.class, boolean.class);
+    
+    if(b)
+      s.assertCalledExactNumberOfTimes(mc, 1);
+    else
+      s.assertNotCalled(mc);
   }
   
 }

Modified: aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/ParsedEJBServicesTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/ParsedEJBServicesTest.java?rev=1153085&r1=1153084&r2=1153085&view=diff
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/ParsedEJBServicesTest.java
(original)
+++ aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/ParsedEJBServicesTest.java
Tue Aug  2 10:04:44 2011
@@ -76,4 +76,32 @@ public class ParsedEJBServicesTest {
         it.next());
   } 
 
+  
+  @Test
+  public void testStateful() throws ModellerException {
+    ParsedEJBServices pes = new ParsedEJBServices();
+    pes.setAllowedNames(Arrays.asList("Bar", "Baz"));
+    pes.addEJBView("Baz", "Stateful", "com.acme.Bar", true);
+    
+    assertEquals(0, pes.getServices().size());
+  } 
+  
+  @Test
+  public void testCases() throws ModellerException {
+    ParsedEJBServices pes = new ParsedEJBServices();
+    pes.setAllowedNames(Arrays.asList("ALL", "Foo"));
+    pes.addEJBView("Foo", "STATELESS", "com.acme.Bar", false);
+    pes.addEJBView("Bar", "StAtElEsS", "com.acme.Bar", true);
+    pes.addEJBView("Baz", "stateless", "com.acme.Baz", true);
+    assertEquals(3, pes.getServices().size());
+    
+    Iterator it = pes.getServices().iterator();
+    assertEquals(new EJBServiceExport("Foo", "Stateless", "com.acme.Bar", false), 
+        it.next());
+    
+    assertEquals(new EJBServiceExport("Bar", "Stateless", "com.acme.Bar", true),
+        it.next());
+    assertEquals(new EJBServiceExport("Baz", "Stateless", "com.acme.Baz", true),
+        it.next());
+  }
 }

Added: aries/trunk/ejb/ejb-modeller/src/test/java/test/ejbs/StatefulSessionBean.java
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/test/java/test/ejbs/StatefulSessionBean.java?rev=1153085&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/test/java/test/ejbs/StatefulSessionBean.java (added)
+++ aries/trunk/ejb/ejb-modeller/src/test/java/test/ejbs/StatefulSessionBean.java Tue Aug
 2 10:04:44 2011
@@ -0,0 +1,8 @@
+package test.ejbs;
+
+import javax.ejb.Stateful;
+
+@Stateful(name="Stateful")
+public class StatefulSessionBean {
+
+}



Mime
View raw message