aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From timothyjw...@apache.org
Subject svn commit: r1152738 - in /aries/trunk/ejb: ./ ejb-modeller/ ejb-modeller/src/ ejb-modeller/src/main/ ejb-modeller/src/main/java/ ejb-modeller/src/main/java/org/ ejb-modeller/src/main/java/org/apache/ ejb-modeller/src/main/java/org/apache/aries/ ejb-mo...
Date Mon, 01 Aug 2011 11:08:05 GMT
Author: timothyjward
Date: Mon Aug  1 11:08:00 2011
New Revision: 1152738

URL: http://svn.apache.org/viewvc?rev=1152738&view=rev
Log:
ARIES-718: Add EJB modelling support

Added:
    aries/trunk/ejb/
    aries/trunk/ejb/ejb-modeller/
    aries/trunk/ejb/ejb-modeller/pom.xml
    aries/trunk/ejb/ejb-modeller/src/
    aries/trunk/ejb/ejb-modeller/src/main/
    aries/trunk/ejb/ejb-modeller/src/main/java/
    aries/trunk/ejb/ejb-modeller/src/main/java/org/
    aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/
    aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/
    aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/
    aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/
    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/
    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/main/resources/
    aries/trunk/ejb/ejb-modeller/src/main/resources/META-INF/
    aries/trunk/ejb/ejb-modeller/src/main/resources/META-INF/services/
    aries/trunk/ejb/ejb-modeller/src/main/resources/META-INF/services/org.apache.aries.application.modelling.ServiceModeller
    aries/trunk/ejb/ejb-modeller/src/main/resources/OSGI-INF/
    aries/trunk/ejb/ejb-modeller/src/main/resources/OSGI-INF/blueprint/
    aries/trunk/ejb/ejb-modeller/src/main/resources/OSGI-INF/blueprint/bp.xml
    aries/trunk/ejb/ejb-modeller/src/test/
    aries/trunk/ejb/ejb-modeller/src/test/java/
    aries/trunk/ejb/ejb-modeller/src/test/java/org/
    aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/
    aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/
    aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/
    aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/
    aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/
    aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/EJBLocatorFactoryTest.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/EJBModellerTest.java
    aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/ParsedEJBServicesTest.java
    aries/trunk/ejb/ejb-modeller/src/test/java/test/
    aries/trunk/ejb/ejb-modeller/src/test/java/test/ejbs/
    aries/trunk/ejb/ejb-modeller/src/test/java/test/ejbs/StatelessSessionBean.java
    aries/trunk/ejb/ejb-modeller/src/test/resources/
    aries/trunk/ejb/ejb-modeller/src/test/resources/MANIFEST_1.MF
    aries/trunk/ejb/ejb-modeller/src/test/resources/MANIFEST_2.MF
    aries/trunk/ejb/ejb-modeller/src/test/resources/ejb-jar.xml
    aries/trunk/ejb/pom.xml

Added: aries/trunk/ejb/ejb-modeller/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/pom.xml?rev=1152738&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller/pom.xml (added)
+++ aries/trunk/ejb/ejb-modeller/pom.xml Mon Aug  1 11:08:00 2011
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+    
+     http://www.apache.org/licenses/LICENSE-2.0
+    
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <parent>
+        <groupId>org.apache.aries</groupId>
+        <artifactId>java5-parent</artifactId>
+        <version>0.4.1-SNAPSHOT</version>
+        <relativePath />
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.apache.aries.ejb</groupId>
+    <artifactId>org.apache.aries.ejb.modeller</artifactId>
+    <packaging>bundle</packaging>
+    <name>Aries EJB Modelling Integration</name>
+    <version>0.1-SNAPSHOT</version>
+
+     <scm>
+         <connection>scm:svn:http://svn.apache.org/repos/asf/aries/trunk/ejb/ejb-modeller</connection>
+         <developerConnection>scm:svn:https://svn.apache.org/repos/asf/aries/trunk/ejb/ejb-modeller</developerConnection>
+         <url>http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller</url>
+     </scm>
+
+    <properties>
+		<aries.osgi.export>
+		  org.apache.aries.ejb.modelling
+		</aries.osgi.export>
+        <aries.osgi.private.pkg>
+          org.apache.aries.ejb.modelling.*
+        </aries.osgi.private.pkg>
+        <aries.osgi.import.pkg > 
+          org.apache.openejb.*;resolution:=optional,
+          org.apache.xbean.*;resolution:=optional,
+          *
+        </aries.osgi.import.pkg>
+    </properties>
+
+    <dependencies>
+    	<dependency>
+    		<groupId>org.apache.aries.application</groupId>
+    		<artifactId>org.apache.aries.application.api</artifactId>
+    		<version>0.3.1-SNAPSHOT</version>
+    		<type>bundle</type>
+    		<scope>compile</scope>
+    	</dependency>
+    	<dependency>
+    		<groupId>org.apache.aries</groupId>
+    		<artifactId>org.apache.aries.util</artifactId>
+    		<version>0.4-SNAPSHOT</version>
+    		<type>bundle</type>
+    		<scope>compile</scope>
+    	</dependency>
+    	<dependency>
+    		<groupId>org.apache.openejb</groupId>
+    		<artifactId>openejb-core</artifactId>
+    		<version>4.0.0-SNAPSHOT</version>
+    		<type>jar</type>
+    		<scope>compile</scope>
+    	</dependency>
+    	<dependency>
+    		<groupId>org.osgi</groupId>
+    		<artifactId>org.osgi.core</artifactId>
+    		<version>4.2.0</version>
+    		<type>jar</type>
+    		<scope>compile</scope>
+    	</dependency>
+    	<dependency>
+    		<groupId>org.apache.aries.application</groupId>
+    		<artifactId>org.apache.aries.application.utils</artifactId>
+    		<version>0.3.1-SNAPSHOT</version>
+    		<type>bundle</type>
+    		<scope>compile</scope>
+    	</dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+        	<groupId>org.apache.aries.testsupport</groupId>
+        	<artifactId>org.apache.aries.testsupport.unit</artifactId>
+        	<version>0.3.1-SNAPSHOT</version>
+        	<scope>compile</scope>
+        </dependency>
+        <dependency>
+        	<groupId>org.apache.geronimo.specs</groupId>
+        	<artifactId>geronimo-ejb_3.1_spec</artifactId>
+        	<version>1.0.2</version>
+        	<type>bundle</type>
+        	<scope>test</scope>
+        </dependency>
+    </dependencies>
+
+</project>

Added: 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=1152738&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/EJBLocator.java (added)
+++ aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/EJBLocator.java Mon Aug  1 11:08:00 2011
@@ -0,0 +1,28 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.ejb.modelling;
+
+import org.apache.aries.application.modelling.ModellerException;
+import org.apache.aries.util.filesystem.IDirectory;
+import org.apache.aries.util.manifest.BundleManifest;
+
+public interface EJBLocator {
+
+  public void findEJBs(BundleManifest manifest, IDirectory bundle, EJBRegistry registry)
+    throws ModellerException;
+  
+}

Added: 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=1152738&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/EJBRegistry.java (added)
+++ aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/EJBRegistry.java Mon Aug  1 11:08:00 2011
@@ -0,0 +1,22 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.ejb.modelling;
+
+public interface EJBRegistry {
+  public void addEJBView(String ejbName, String ejbType, String interfaceName,
+      boolean remote);
+}

Added: 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=1152738&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBLocationUnavailable.java (added)
+++ aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBLocationUnavailable.java Mon Aug  1 11:08:00 2011
@@ -0,0 +1,32 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.ejb.modelling.impl;
+
+import org.apache.aries.application.modelling.ModellerException;
+import org.apache.aries.ejb.modelling.EJBLocator;
+import org.apache.aries.ejb.modelling.EJBRegistry;
+import org.apache.aries.util.filesystem.IDirectory;
+import org.apache.aries.util.manifest.BundleManifest;
+
+public class EJBLocationUnavailable implements EJBLocator {
+
+  public void findEJBs(BundleManifest manifest, IDirectory bundle,
+      EJBRegistry registry) throws ModellerException {
+    throw new ModellerException("No OpenEJB runtime present");
+  }
+
+}

Added: 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=1152738&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBLocatorFactory.java (added)
+++ aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBLocatorFactory.java Mon Aug  1 11:08:00 2011
@@ -0,0 +1,32 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.ejb.modelling.impl;
+
+import org.apache.aries.ejb.modelling.EJBLocator;
+
+public class EJBLocatorFactory {
+  public static EJBLocator getEJBLocator() {
+    try {
+      Class.forName("org.apache.openejb.config.AnnotationDeployer");
+      Class.forName("org.apache.openejb.jee.SessionBean");
+      Class.forName("org.apache.xbean.finder.ClassFinder");
+      return new OpenEJBLocator();
+    } catch (Exception e) {
+      return new EJBLocationUnavailable();
+    }
+  }
+}

Added: 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=1152738&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBModeller.java (added)
+++ aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBModeller.java Mon Aug  1 11:08:00 2011
@@ -0,0 +1,74 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.ejb.modelling.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.aries.application.modelling.ModellerException;
+import org.apache.aries.application.modelling.ParsedServiceElements;
+import org.apache.aries.application.modelling.ServiceModeller;
+import org.apache.aries.ejb.modelling.EJBLocator;
+import org.apache.aries.util.filesystem.IDirectory;
+import org.apache.aries.util.manifest.BundleManifest;
+import org.apache.aries.util.manifest.ManifestHeaderProcessor;
+import org.apache.aries.util.manifest.ManifestHeaderProcessor.NameValuePair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class EJBModeller implements ServiceModeller {
+
+  private static final Logger logger = LoggerFactory.getLogger(EJBModeller.class);
+  
+  private EJBLocator locator;
+  
+  public void setLocator(EJBLocator locator) {
+    this.locator = locator;
+  }
+  
+  public ParsedServiceElements modelServices(BundleManifest manifest, IDirectory bundle) 
+    throws ModellerException {
+    logger.trace("modelServices", new Object[] {manifest, bundle});
+    ParsedEJBServices ejbServices = new ParsedEJBServices();
+    
+    String header = manifest.getRawAttributes().getValue("Export-EJB");
+    logger.debug("Export-EJB header is " + header);
+    
+    if(header == null || "".equals(header))
+      return ejbServices;
+    
+    Collection<String> allowedNames = getNames(header);
+    
+    if(allowedNames.contains("NONE"))
+      return ejbServices;
+
+    ejbServices.setAllowedNames(allowedNames);
+    locator.findEJBs(manifest, bundle, ejbServices);
+    
+    logger.trace("modelServices", ejbServices);
+    return ejbServices;
+  }
+
+  private Collection<String> getNames(String header) {
+    Collection<String> names = new ArrayList<String>();
+    for(NameValuePair nvp: ManifestHeaderProcessor.parseExportString(header)){
+      names.add(nvp.getName().trim());
+    }
+    return names;
+  }
+
+}

Added: 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=1152738&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBServiceExport.java (added)
+++ aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/EJBServiceExport.java Mon Aug  1 11:08:00 2011
@@ -0,0 +1,113 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.ejb.modelling.impl;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.aries.application.modelling.ExportedService;
+import org.apache.aries.application.modelling.ModellingConstants;
+import org.apache.aries.application.modelling.ResourceType;
+import org.apache.aries.application.modelling.WrappedServiceMetadata;
+import org.apache.aries.application.utils.service.ExportedServiceHelper;
+import org.osgi.framework.Constants;
+
+public class EJBServiceExport implements ExportedService {
+
+  private final String interfaceName;
+  private final String ejbName;
+  
+  private final Map<String, Object> _attributes;
+  
+  private final Map<String, Object> serviceProperties;
+  private String _toString;
+  
+  public EJBServiceExport(String ejbName, String ejbType, String interfaceName,
+      boolean remote) {
+    this.interfaceName = interfaceName;
+    this.ejbName = ejbName;
+    
+    serviceProperties = new HashMap<String, Object>();
+    serviceProperties.put("ejb.name", ejbName);
+    serviceProperties.put("ejb.type", ejbType);
+    if(remote)
+      serviceProperties.put("service.exported.interfaces", interfaceName);
+    
+    _attributes = new HashMap<String, Object>(serviceProperties);
+    
+    _attributes.put(Constants.OBJECTCLASS, interfaceName);
+    _attributes.put (Constants.SERVICE_RANKING, "0");
+    _attributes.put(ModellingConstants.OBR_SERVICE, ModellingConstants.OBR_SERVICE);
+  }
+
+  public Map<String, Object> getAttributes() {
+    return _attributes;
+  }
+
+  public ResourceType getType() {
+    return ResourceType.SERVICE;
+  }
+
+  public Collection<String> getInterfaces() {
+    
+    return Arrays.asList(interfaceName);
+  }
+
+  public String getName() {
+    return ejbName;
+  }
+
+  public int getRanking() {
+    return 0;
+  }
+
+  public Map<String, Object> getServiceProperties() {
+    return serviceProperties;
+  }
+
+  public int compareTo(WrappedServiceMetadata o) {
+    return ExportedServiceHelper.portableExportedServiceCompareTo(this, o);
+  }
+
+  @Override
+  public boolean equals (Object o) { 
+    return ExportedServiceHelper.portableExportedServiceEquals(this, o);
+  }
+  
+  
+  @Override
+  public int hashCode() {
+    return ExportedServiceHelper.portableExportedServiceHashCode(this);
+  }
+  
+  @Override 
+  public String toString() { 
+    if (_toString == null) { 
+      _toString = ExportedServiceHelper.generatePortableExportedServiceToString(this);
+    }
+    return _toString;    
+  }
+  
+
+  public boolean identicalOrDiffersOnlyByName(WrappedServiceMetadata wsmi) {
+   return ExportedServiceHelper.
+        portableExportedServiceIdenticalOrDiffersOnlyByName(this, wsmi);
+  }
+
+}
\ No newline at end of file

Added: 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=1152738&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/OpenEJBLocator.java (added)
+++ aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/OpenEJBLocator.java Mon Aug  1 11:08:00 2011
@@ -0,0 +1,189 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.ejb.modelling.impl;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.aries.application.modelling.ModellerException;
+import org.apache.aries.ejb.modelling.EJBLocator;
+import org.apache.aries.ejb.modelling.EJBRegistry;
+import org.apache.aries.util.filesystem.IDirectory;
+import org.apache.aries.util.filesystem.IFile;
+import org.apache.aries.util.manifest.BundleManifest;
+import org.apache.aries.util.manifest.ManifestHeaderProcessor;
+import org.apache.aries.util.manifest.ManifestHeaderProcessor.NameValuePair;
+import org.apache.openejb.config.AnnotationDeployer;
+import org.apache.openejb.config.AppModule;
+import org.apache.openejb.config.EjbModule;
+import org.apache.openejb.config.ReadDescriptors;
+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;
+
+public class OpenEJBLocator implements EJBLocator {
+
+  private static final Logger logger = LoggerFactory.getLogger(OpenEJBLocator.class);
+  
+  public static class ResourceClassLoader extends ClassLoader {
+
+    private final List<IDirectory> classpath;
+    public ResourceClassLoader(List<IDirectory> cpEntries) {
+      classpath = cpEntries;
+    }
+    
+    @Override
+    protected URL findResource(String resName) {
+      for(IDirectory id : classpath) {
+        IFile f = id.getFile(resName);
+        if(f != null)
+          try {
+            return f.toURL();
+          } catch (MalformedURLException e) {
+            logger.error("Error getting URL for file " + f, e);
+          }
+      }
+      return null;
+    }
+  }
+
+  public void findEJBs(BundleManifest manifest, IDirectory bundle,
+      EJBRegistry registry) throws ModellerException {
+
+    try {
+      IFile file = bundle.getFile("META-INF/ejb-jar.xml");
+      EjbJar ejbJar = (file == null) ? new EjbJar() : ReadDescriptors.readEjbJar(file.toURL());
+      
+      EjbModule module = new EjbModule(ejbJar);
+      
+      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!
+      module.setFinder(new ClassFinder(cl, getClassPathURLs(cpEntries)));
+      
+      AppModule app = new AppModule(module);
+      
+      new AnnotationDeployer().deploy(app);
+      
+      for(EnterpriseBean eb : ejbJar.getEnterpriseBeans()) {
+        
+        if(!!!(eb instanceof SessionBean))
+          continue;
+        else
+          registerSessionBean(registry, (SessionBean) eb);
+      }
+      
+    } catch (Exception e) {
+      throw new ModellerException(e);
+    }
+  }
+
+  private List<URL> getClassPathURLs(List<IDirectory> cpEntries) throws MalformedURLException {
+    List<URL> result = new ArrayList<URL>();
+    
+    for(IDirectory id : cpEntries) {
+      result.add(id.toURL());
+    }
+    return result;
+  }
+
+  private List<IDirectory> getClassPathLocations(BundleManifest manifest,
+      IDirectory bundle) {
+    List<IDirectory> result = new ArrayList<IDirectory>();
+    
+    String rawCp = manifest.getRawAttributes().getValue(Constants.BUNDLE_CLASSPATH);
+    
+    if(rawCp == null || rawCp.trim() == "")
+      result.add(bundle);
+    else {
+      List<NameValuePair> splitCp = ManifestHeaderProcessor.parseExportString(rawCp);
+      
+      for(NameValuePair nvp : splitCp) {
+        String name = nvp.getName().trim();
+        if(".".equals(name))
+          result.add(bundle);
+        else {
+          IFile f = bundle.getFile(name);
+          
+          if(f==null)
+            continue;
+          
+          IDirectory converted = f.convertNested();
+          if(converted != null)
+            result.add(converted);
+        }
+      }
+    }
+    return result;
+  }
+
+  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()) {
+      added = true;
+      registry.addEJBView(name, type, iface, false);
+    }
+    
+    for(String iface : sb.getBusinessRemote()) {
+      added = true;
+      registry.addEJBView(name, type, iface, true);
+    }
+    
+    if(sb.getLocal() != null) {
+      added = true;
+      registry.addEJBView(name, type, sb.getLocal(), false);
+    }
+    
+    if(sb.getLocalHome() != null) {
+      added = true;
+      registry.addEJBView(name, type, sb.getLocalHome(), false);
+    }
+      
+    if(sb.getRemote() != null) {
+      added = true;
+      registry.addEJBView(name, type, sb.getRemote(), true);
+    }
+    
+    if(sb.getHome() != null) {
+      added = true;
+      registry.addEJBView(name, type, sb.getHome(), true);
+    }
+    //If not added elsewhere then we have a no-interface view
+    if(!!!added) {
+      registry.addEJBView(name, type, sb.getEjbClass(), false);
+    }
+  }
+}

Added: 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=1152738&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/ParsedEJBServices.java (added)
+++ aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/ParsedEJBServices.java Mon Aug  1 11:08:00 2011
@@ -0,0 +1,71 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.ejb.modelling.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.aries.application.modelling.ExportedService;
+import org.apache.aries.application.modelling.ImportedService;
+import org.apache.aries.application.modelling.ParsedServiceElements;
+import org.apache.aries.ejb.modelling.EJBRegistry;
+
+public class ParsedEJBServices implements ParsedServiceElements, EJBRegistry {
+
+  private final Collection<ImportedService> references;
+  private final Collection<ExportedService> services;
+  
+  private boolean all;
+  private Set<String> allowedNames; 
+  
+  public ParsedEJBServices() {
+    this.references = Collections.emptyList();
+    this.services = new ArrayList<ExportedService>();
+    allowedNames = new HashSet<String>();
+    all = false;
+  }
+
+  public Collection<ImportedService> getReferences() {
+    return references;
+  }
+
+  public Collection<ExportedService> getServices() {
+    return Collections.unmodifiableCollection(services);
+  }
+  
+  public void setAllowedNames(Collection<String> names) {
+    if(names.contains("NONE")) {
+      all= false;
+      allowedNames.clear();
+      return;
+    }
+    if(names.contains("ALL")) {
+      all = true;
+      return;
+    }
+    allowedNames.addAll(names);
+  }
+  
+  public void addEJBView(String ejbName, String ejbType, String interfaceName,
+      boolean remote) {
+    if(all || allowedNames.contains(ejbName))
+      services.add(new EJBServiceExport(ejbName, ejbType, interfaceName, remote));
+  }
+}

Added: 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=1152738&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/StandaloneEJBModeller.java (added)
+++ aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/StandaloneEJBModeller.java Mon Aug  1 11:08:00 2011
@@ -0,0 +1,24 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.ejb.modelling.impl;
+
+public class StandaloneEJBModeller extends EJBModeller {
+
+  public StandaloneEJBModeller() {
+    setLocator(EJBLocatorFactory.getEJBLocator());
+  }  
+}

Added: aries/trunk/ejb/ejb-modeller/src/main/resources/META-INF/services/org.apache.aries.application.modelling.ServiceModeller
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/main/resources/META-INF/services/org.apache.aries.application.modelling.ServiceModeller?rev=1152738&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/main/resources/META-INF/services/org.apache.aries.application.modelling.ServiceModeller (added)
+++ aries/trunk/ejb/ejb-modeller/src/main/resources/META-INF/services/org.apache.aries.application.modelling.ServiceModeller Mon Aug  1 11:08:00 2011
@@ -0,0 +1 @@
+org.apache.aries.ejb.modelling.impl.StandaloneEJBModeller
\ No newline at end of file

Added: aries/trunk/ejb/ejb-modeller/src/main/resources/OSGI-INF/blueprint/bp.xml
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/main/resources/OSGI-INF/blueprint/bp.xml?rev=1152738&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/main/resources/OSGI-INF/blueprint/bp.xml (added)
+++ aries/trunk/ejb/ejb-modeller/src/main/resources/OSGI-INF/blueprint/bp.xml Mon Aug  1 11:08:00 2011
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+	<!--
+		Licensed to the Apache Software Foundation (ASF) under one or more
+		contributor license agreements. See the NOTICE file distributed with
+		this work for additional information regarding copyright ownership.
+		The ASF licenses this file to You under the Apache License, Version
+		2.0 (the "License"); you may not use this file except in compliance
+		with the License. You may obtain a copy of the License at
+
+		http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+		applicable law or agreed to in writing, software distributed under the
+		License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+		CONDITIONS OF ANY KIND, either express or implied. See the License for
+		the specific language governing permissions and limitations under the
+		License.
+	-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+	xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.1.0"
+	default-availability="optional">
+
+    <service interface="org.apache.aries.application.modelling.ServiceModeller">
+      <bean class="org.apache.aries.ejb.modelling.impl.EJBModeller">
+        <property name="locator" ref="EJBLocator"/>
+      </bean>
+    </service>
+	
+	<reference id="EJBLocator" interface="org.apache.aries.ejb.modelling.EJBLocator" 
+	    ext:default="defaultLocator" timeout="100"/>
+	<bean id="defaultLocator" class="org.apache.aries.ejb.modelling.impl.EJBLocatorFactory"
+	   factory-method="getEJBLocator"/>
+
+	
+</blueprint>
+

Added: aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/EJBLocatorFactoryTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/EJBLocatorFactoryTest.java?rev=1152738&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/EJBLocatorFactoryTest.java (added)
+++ aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/EJBLocatorFactoryTest.java Mon Aug  1 11:08:00 2011
@@ -0,0 +1,69 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.ejb.modelling.impl;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import org.apache.aries.ejb.modelling.EJBLocator;
+import org.apache.aries.util.io.IOUtils;
+import org.junit.Test;
+
+public class EJBLocatorFactoryTest {
+
+  @Test
+  public void testGetEJBLocator() {
+    EJBLocator locator = EJBLocatorFactory.getEJBLocator();
+    
+    assertNotNull(locator);
+    assertTrue(locator.getClass().getName(), locator instanceof OpenEJBLocator);
+  }
+
+  
+  @Test
+  public void testGetEJBLocatorNoOpenEJB() throws Exception {
+    Class<?> elf = new ClassLoader(getClass().getClassLoader()) {
+
+      @Override
+      public Class<?> loadClass(String className) throws ClassNotFoundException {
+        if(className.startsWith("org.apache.openejb"))
+          throw new ClassNotFoundException(className);
+        
+        if(className.equals(EJBLocatorFactory.class.getName())) {
+          ByteArrayOutputStream baos = new ByteArrayOutputStream();
+          try {
+            IOUtils.copy(getResourceAsStream(className.replace('.', '/') + ".class"), baos);
+          } catch (IOException e) {
+            throw new ClassNotFoundException(className, e);
+          }
+          return defineClass(className, baos.toByteArray(), 0, baos.size());
+        }
+        
+        return super.loadClass(className);
+      } 
+      
+    }.loadClass(EJBLocatorFactory.class.getName());
+    
+    EJBLocator locator = (EJBLocator) elf.getMethod("getEJBLocator").invoke(null);
+    
+    assertNotNull(locator);
+    assertTrue(locator.getClass().getName(), locator instanceof EJBLocationUnavailable);
+  }
+}

Added: 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=1152738&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/EJBLocatorTest.java (added)
+++ aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/EJBLocatorTest.java Mon Aug  1 11:08:00 2011
@@ -0,0 +1,154 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.ejb.modelling.impl;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import org.apache.aries.application.modelling.ModellerException;
+import org.apache.aries.ejb.modelling.EJBRegistry;
+import org.apache.aries.unittest.mocks.MethodCall;
+import org.apache.aries.unittest.mocks.Skeleton;
+import org.apache.aries.util.filesystem.FileSystem;
+import org.apache.aries.util.filesystem.ICloseableDirectory;
+import org.apache.aries.util.io.IOUtils;
+import org.apache.aries.util.manifest.BundleManifest;
+import org.junit.Test;
+
+public class EJBLocatorTest {
+
+  private EJBRegistry registry;
+  
+  @Test(expected=ModellerException.class)
+  public void testUnavailable() throws ModellerException {
+    new EJBLocationUnavailable().findEJBs(null, null, null);
+  }
+  
+  @Test
+  public void testEJBJARInZip() throws Exception {
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    ZipOutputStream zos = new ZipOutputStream(baos);
+    addToZip(zos, "ejb-jar.xml", "META-INF/ejb-jar.xml");
+    zos.close();
+    
+    runTest(baos.toByteArray(), "MANIFEST_1.MF");
+    
+    assertXML(true);
+    assertAnnotation(false);
+  }
+
+  @Test
+  public void testEJBJARAndAnnotatedInZip() throws Exception {
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    ZipOutputStream zos = new ZipOutputStream(baos);
+    addToZip(zos, "ejb-jar.xml", "META-INF/ejb-jar.xml");
+    addToZip(zos, "test/ejbs/StatelessSessionBean.class");
+    zos.close();
+    
+    runTest(baos.toByteArray(), "MANIFEST_1.MF");
+    
+    assertXML(true);
+    assertAnnotation(true);
+  }
+  
+  @Test
+  public void testAnnotatedOnlyInZip() throws Exception {
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    ZipOutputStream zos = new ZipOutputStream(baos);
+    addToZip(zos, "test/ejbs/StatelessSessionBean.class");
+    zos.close();
+    
+    runTest(baos.toByteArray(), "MANIFEST_1.MF");
+    
+    assertXML(false);
+    assertAnnotation(true);
+  }
+  
+  @Test
+  public void testEJBJARAndAnnotatedNotOnClasspathInZip() throws Exception {
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    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");
+    zos.close();
+    
+    runTest(baos.toByteArray(), "MANIFEST_2.MF");
+    
+    assertXML(true);
+    assertAnnotation(false);
+  }
+
+  private void runTest(byte[] zip, String manifest) throws ModellerException,
+      IOException {
+    ICloseableDirectory icd = FileSystem.getFSRoot(new 
+        ByteArrayInputStream(zip));
+    new OpenEJBLocator().findEJBs(new BundleManifest(getClass().getClassLoader().
+        getResourceAsStream(manifest)), icd, registry);
+    icd.close();
+  }
+  
+  private void addToZip(ZipOutputStream zos, String src) throws IOException {
+    addToZip(zos, src, src);
+  }
+  
+  private void addToZip(ZipOutputStream zos, String src, String outLocation) throws IOException {
+    zos.putNextEntry(new ZipEntry(outLocation));
+    IOUtils.copy(getClass().getClassLoader().
+        getResourceAsStream("ejb-jar.xml"), zos);
+    zos.closeEntry();
+  }
+  
+  private void assertXML(boolean b) {
+
+    Skeleton s = Skeleton.getSkeleton(registry);
+    MethodCall mc = new MethodCall(EJBRegistry.class, "addEJBView",
+        "XML", "SINGLETON", "local.Iface", false);
+    
+    if(b)
+      s.assertCalledExactNumberOfTimes(mc, 1);
+    else
+      s.assertNotCalled(mc);
+    
+    mc = new MethodCall(EJBRegistry.class, "addEJBView",
+        "XML", "SINGLETON", "remote.Iface", true);
+    
+    if(b)
+      s.assertCalledExactNumberOfTimes(mc, 1);
+    else
+      s.assertNotCalled(mc);
+  }
+
+  private void assertAnnotation(boolean b) {
+
+    Skeleton s = Skeleton.getSkeleton(registry);
+    MethodCall mc = new MethodCall(EJBRegistry.class, "addEJBView",
+        "Annotated", "STATELESS", "test.ejbs.StatelessSessionBean", false);
+    
+    if(b)
+      s.assertCalledExactNumberOfTimes(mc, 1);
+    else
+      s.assertNotCalled(mc);
+  }
+  
+}

Added: aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/EJBModellerTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/EJBModellerTest.java?rev=1152738&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/EJBModellerTest.java (added)
+++ aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/EJBModellerTest.java Mon Aug  1 11:08:00 2011
@@ -0,0 +1,93 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.ejb.modelling.impl;
+
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import org.apache.aries.application.modelling.ModellerException;
+import org.apache.aries.ejb.modelling.EJBLocator;
+import org.apache.aries.unittest.mocks.MethodCall;
+import org.apache.aries.unittest.mocks.Skeleton;
+import org.apache.aries.util.filesystem.IDirectory;
+import org.apache.aries.util.manifest.BundleManifest;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Constants;
+
+public class EJBModellerTest {
+
+  private EJBModeller modeller;
+  private Skeleton ejbLocator; 
+  
+  private IDirectory bundleLocation;
+  
+  @Before
+  public void setup() {
+    modeller = new EJBModeller();
+
+    EJBLocator locator = Skeleton.newMock(EJBLocator.class);
+    modeller.setLocator(locator);
+    
+    ejbLocator = Skeleton.getSkeleton(locator);
+    
+    bundleLocation = Skeleton.newMock(IDirectory.class);
+  }
+  
+  @Test
+  public void testModelServicesNoExportEJB() throws ModellerException {
+    Manifest man = new Manifest();
+    setBasicHeaders(man);
+    modeller.modelServices(new BundleManifest(man), bundleLocation);
+    ejbLocator.assertSkeletonNotCalled();
+  }
+  
+  @Test
+  public void testModelServicesEmptyExportEJB() throws ModellerException {
+    Manifest man = new Manifest();
+    setBasicHeaders(man);
+    man.getMainAttributes().putValue("Export-EJB", "");
+    modeller.modelServices(new BundleManifest(man), bundleLocation);
+    ejbLocator.assertSkeletonNotCalled();
+  }
+  
+  @Test
+  public void testModelServicesNoneExportEJB() throws ModellerException {
+    Manifest man = new Manifest();
+    setBasicHeaders(man);
+    man.getMainAttributes().putValue("Export-EJB", "NONE,anEJB , another");
+    modeller.modelServices(new BundleManifest(man), bundleLocation);
+    ejbLocator.assertSkeletonNotCalled();
+  }
+  
+  @Test
+  public void testModelServicesExportEJB() throws ModellerException {
+    Manifest man = new Manifest();
+    setBasicHeaders(man);
+    man.getMainAttributes().putValue("Export-EJB", "anEJB , another");
+    modeller.modelServices(new BundleManifest(man), bundleLocation);
+    ejbLocator.assertCalled(new MethodCall(EJBLocator.class, "findEJBs", BundleManifest.class,
+        bundleLocation, ParsedEJBServices.class));
+  }
+
+  private void setBasicHeaders(Manifest man) {
+    Attributes att = man.getMainAttributes();
+    att.putValue(Constants.BUNDLE_MANIFESTVERSION, "2");
+    att.putValue(Constants.BUNDLE_SYMBOLICNAME, "testBundle");
+  }
+
+}

Added: 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=1152738&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/ParsedEJBServicesTest.java (added)
+++ aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/ParsedEJBServicesTest.java Mon Aug  1 11:08:00 2011
@@ -0,0 +1,79 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.ejb.modelling.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.Iterator;
+
+import org.apache.aries.application.modelling.ModellerException;
+import org.junit.Test;
+
+public class ParsedEJBServicesTest {
+  
+  @Test
+  public void testNoAllowedNames() throws ModellerException {
+    ParsedEJBServices pes = new ParsedEJBServices();
+    pes.addEJBView("Foo", "Stateless", "com.acme.Bar", false);
+    
+    assertTrue(pes.getServices().isEmpty());
+  }
+  
+  @Test
+  public void testNONE() throws ModellerException {
+    ParsedEJBServices pes = new ParsedEJBServices();
+    pes.setAllowedNames(Arrays.asList("NONE", "Foo"));
+    pes.addEJBView("Foo", "Stateless", "com.acme.Bar", false);
+    
+    assertTrue(pes.getServices().isEmpty());
+  }  
+  
+  @Test
+  public void testALL() throws ModellerException {
+    ParsedEJBServices pes = new ParsedEJBServices();
+    pes.setAllowedNames(Arrays.asList("ALL", "Foo"));
+    pes.addEJBView("Foo", "Stateless", "com.acme.Bar", false);
+    pes.addEJBView("Baz", "Stateless", "com.acme.Bar", true);
+    
+    assertEquals(2, pes.getServices().size());
+    
+    Iterator it = pes.getServices().iterator();
+    assertEquals(new EJBServiceExport("Foo", "Stateless", "com.acme.Bar", false), 
+        it.next());
+    
+    assertEquals(new EJBServiceExport("Baz", "Stateless", "com.acme.Bar", true),
+        it.next());
+  } 
+  
+  @Test
+  public void testSome() throws ModellerException {
+    ParsedEJBServices pes = new ParsedEJBServices();
+    pes.setAllowedNames(Arrays.asList("Bar", "Baz"));
+    pes.addEJBView("Foo", "Stateless", "com.acme.Bar", false);
+    pes.addEJBView("Baz", "Stateless", "com.acme.Bar", true);
+    
+    assertEquals(1, pes.getServices().size());
+    
+    Iterator it = pes.getServices().iterator();
+    
+    assertEquals(new EJBServiceExport("Baz", "Stateless", "com.acme.Bar", true),
+        it.next());
+  } 
+
+}

Added: aries/trunk/ejb/ejb-modeller/src/test/java/test/ejbs/StatelessSessionBean.java
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/test/java/test/ejbs/StatelessSessionBean.java?rev=1152738&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/test/java/test/ejbs/StatelessSessionBean.java (added)
+++ aries/trunk/ejb/ejb-modeller/src/test/java/test/ejbs/StatelessSessionBean.java Mon Aug  1 11:08:00 2011
@@ -0,0 +1,8 @@
+package test.ejbs;
+
+import javax.ejb.Stateless;
+
+@Stateless(name="Annotated")
+public class StatelessSessionBean {
+
+}

Added: aries/trunk/ejb/ejb-modeller/src/test/resources/MANIFEST_1.MF
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/test/resources/MANIFEST_1.MF?rev=1152738&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/test/resources/MANIFEST_1.MF (added)
+++ aries/trunk/ejb/ejb-modeller/src/test/resources/MANIFEST_1.MF Mon Aug  1 11:08:00 2011
@@ -0,0 +1,3 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: foo
+

Added: aries/trunk/ejb/ejb-modeller/src/test/resources/MANIFEST_2.MF
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/test/resources/MANIFEST_2.MF?rev=1152738&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/test/resources/MANIFEST_2.MF (added)
+++ aries/trunk/ejb/ejb-modeller/src/test/resources/MANIFEST_2.MF Mon Aug  1 11:08:00 2011
@@ -0,0 +1,4 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: foo
+Bundle-ClassPath: yes
+

Added: aries/trunk/ejb/ejb-modeller/src/test/resources/ejb-jar.xml
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/test/resources/ejb-jar.xml?rev=1152738&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/test/resources/ejb-jar.xml (added)
+++ aries/trunk/ejb/ejb-modeller/src/test/resources/ejb-jar.xml Mon Aug  1 11:08:00 2011
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+    <!--
+        Licensed to the Apache Software Foundation (ASF) under one or more
+        contributor license agreements. See the NOTICE file distributed with
+        this work for additional information regarding copyright ownership.
+        The ASF licenses this file to You under the Apache License, Version
+        2.0 (the "License"); you may not use this file except in compliance
+        with the License. You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+        applicable law or agreed to in writing, software distributed under the
+        License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+        CONDITIONS OF ANY KIND, either express or implied. See the License for
+        the specific language governing permissions and limitations under the
+        License.
+    -->
+<ejb-jar version="3.1" xmlns="http://java.sun.com/xml/ns/javaee" 
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
+                             http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd">
+
+<enterprise-beans>
+	<session>
+		<ejb-name>XML</ejb-name>
+		<business-local>local.Iface</business-local>
+		<business-remote>remote.Iface</business-remote>
+		<ejb-class>test.xml</ejb-class>
+		<session-type>Singleton</session-type>
+	</session>
+</enterprise-beans>
+</ejb-jar>
\ No newline at end of file

Added: aries/trunk/ejb/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/pom.xml?rev=1152738&view=auto
==============================================================================
--- aries/trunk/ejb/pom.xml (added)
+++ aries/trunk/ejb/pom.xml Mon Aug  1 11:08:00 2011
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+    
+     http://www.apache.org/licenses/LICENSE-2.0
+    
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <parent>
+        <artifactId>java5-parent</artifactId>
+        <groupId>org.apache.aries</groupId>
+        <version>0.4</version>
+        <relativePath />
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.apache.aries.ejb</groupId>
+    <artifactId>ejb</artifactId>
+    <packaging>pom</packaging>
+    <name>Aries EJB Component</name>
+
+    <modules>
+        <module>ejb-modeller</module>
+    </modules>
+
+</project>



Mime
View raw message