You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2008/03/11 08:04:28 UTC

svn commit: r635829 - in /openejb/trunk/openejb3/examples/expanded-env-entries/src: main/java/org/superbiz/enventries/ main/resources/META-INF/ test/java/org/superbiz/enventries/

Author: dblevins
Date: Tue Mar 11 00:04:25 2008
New Revision: 635829

URL: http://svn.apache.org/viewvc?rev=635829&view=rev
Log:
Updated the expanded injection example to include generic collections
will add enums later, show how to add you own PropertyEditors and likely rename the example to be more descriptive

Added:
    openejb/trunk/openejb3/examples/expanded-env-entries/src/main/java/org/superbiz/enventries/Style.java
Modified:
    openejb/trunk/openejb3/examples/expanded-env-entries/src/main/java/org/superbiz/enventries/Stratocaster.java
    openejb/trunk/openejb3/examples/expanded-env-entries/src/main/java/org/superbiz/enventries/StratocasterImpl.java
    openejb/trunk/openejb3/examples/expanded-env-entries/src/main/resources/META-INF/env-entries.properties
    openejb/trunk/openejb3/examples/expanded-env-entries/src/test/java/org/superbiz/enventries/StratocasterTest.java

Modified: openejb/trunk/openejb3/examples/expanded-env-entries/src/main/java/org/superbiz/enventries/Stratocaster.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/expanded-env-entries/src/main/java/org/superbiz/enventries/Stratocaster.java?rev=635829&r1=635828&r2=635829&view=diff
==============================================================================
--- openejb/trunk/openejb3/examples/expanded-env-entries/src/main/java/org/superbiz/enventries/Stratocaster.java (original)
+++ openejb/trunk/openejb3/examples/expanded-env-entries/src/main/java/org/superbiz/enventries/Stratocaster.java Tue Mar 11 00:04:25 2008
@@ -32,7 +32,7 @@
 
     Date getMyDate();
 
-    File getMyFile();
+    Map<String, File> getMyFiles();
 
     InetAddress getMyInetAddress();
 
@@ -40,7 +40,7 @@
 
     Map getMyMap();
 
-    URI getMyURI();
+    List<URI> getMyURIs();
 
     URL getMyURL();
 }

Modified: openejb/trunk/openejb3/examples/expanded-env-entries/src/main/java/org/superbiz/enventries/StratocasterImpl.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/expanded-env-entries/src/main/java/org/superbiz/enventries/StratocasterImpl.java?rev=635829&r1=635828&r2=635829&view=diff
==============================================================================
--- openejb/trunk/openejb3/examples/expanded-env-entries/src/main/java/org/superbiz/enventries/StratocasterImpl.java (original)
+++ openejb/trunk/openejb3/examples/expanded-env-entries/src/main/java/org/superbiz/enventries/StratocasterImpl.java Tue Mar 11 00:04:25 2008
@@ -31,26 +31,31 @@
  * OpenEJB supports many other types.
  *
  * This bean has just about every flavor of env-entry OpenEJB supports.
- *
- * @version $Rev$ $Date$
  */
 @Stateless
 public class StratocasterImpl implements Stratocaster {
 
     @Resource(name = "myClass")
     private Class myClass;
+
     @Resource(name = "myDate")
     private Date myDate;
-    @Resource(name = "myFile")
-    private File myFile;
+
+    @Resource(name = "myFiles")
+    private Map<String, File> myFiles;
+
     @Resource(name = "myInetAddress")
     private InetAddress myInetAddress;
+
     @Resource(name = "myList")
     private List myList;
+
     @Resource(name = "myMap")
     private Map myMap;
-    @Resource(name = "myURI")
-    private URI myURI;
+
+    @Resource(name = "myURIs")
+    private List<URI> myURIs;
+
     @Resource(name = "myURL")
     private URL myURL;
 
@@ -62,8 +67,8 @@
         return myDate;
     }
 
-    public File getMyFile() {
-        return myFile;
+    public Map<String, File> getMyFiles() {
+        return myFiles;
     }
 
     public InetAddress getMyInetAddress() {
@@ -78,8 +83,8 @@
         return myMap;
     }
 
-    public URI getMyURI() {
-        return myURI;
+    public List<URI> getMyURIs() {
+        return myURIs;
     }
 
     public URL getMyURL() {

Added: openejb/trunk/openejb3/examples/expanded-env-entries/src/main/java/org/superbiz/enventries/Style.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/expanded-env-entries/src/main/java/org/superbiz/enventries/Style.java?rev=635829&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/expanded-env-entries/src/main/java/org/superbiz/enventries/Style.java (added)
+++ openejb/trunk/openejb3/examples/expanded-env-entries/src/main/java/org/superbiz/enventries/Style.java Tue Mar 11 00:04:25 2008
@@ -0,0 +1,23 @@
+/**
+ * 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.superbiz.enventries;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public enum Style {
+}

Modified: openejb/trunk/openejb3/examples/expanded-env-entries/src/main/resources/META-INF/env-entries.properties
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/expanded-env-entries/src/main/resources/META-INF/env-entries.properties?rev=635829&r1=635828&r2=635829&view=diff
==============================================================================
--- openejb/trunk/openejb3/examples/expanded-env-entries/src/main/resources/META-INF/env-entries.properties (original)
+++ openejb/trunk/openejb3/examples/expanded-env-entries/src/main/resources/META-INF/env-entries.properties Tue Mar 11 00:04:25 2008
@@ -1,27 +1,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.
-#
-# $Rev$ $Date$
-#
 myClass = org.superbiz.enventries.Stratocaster
-myDate = locale=en_US style=MEDIUM Mar 1, 1954
-myFile = /tmp/play-history.txt
+myDate = 1954-03-01
+myFiles = history=/tmp/play-history.txt\nartists=/tmp/famous-artists.txt
 myInetAddress = localhost
 myList = [Stevie Ray Vaughan, Eric Johnson, Mark Knopfler, Buddy Guy]
 myMap = color=3-Color Sunburst\nneck=maple\nfretboard=African rosewood\npickups=Texas Special
-myURI = game://guitarheroII/?mode=expert
+myURIs = game://guitarheroII/?mode=expert,game://guitarheroIII/?guitar=wireless
 myURL = http://www.fender.com/
-

Modified: openejb/trunk/openejb3/examples/expanded-env-entries/src/test/java/org/superbiz/enventries/StratocasterTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/expanded-env-entries/src/test/java/org/superbiz/enventries/StratocasterTest.java?rev=635829&r1=635828&r2=635829&view=diff
==============================================================================
--- openejb/trunk/openejb3/examples/expanded-env-entries/src/test/java/org/superbiz/enventries/StratocasterTest.java (original)
+++ openejb/trunk/openejb3/examples/expanded-env-entries/src/test/java/org/superbiz/enventries/StratocasterTest.java Tue Mar 11 00:04:25 2008
@@ -28,6 +28,9 @@
 import java.util.List;
 import java.util.Map;
 import java.util.LinkedHashMap;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.ArrayList;
 import java.io.File;
 import java.net.URI;
 import java.net.URL;
@@ -57,8 +60,10 @@
         Date date = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.US).parse("Mar 1, 1954");
         assertEquals("Stratocaster.getMyDate()", date, stratocaster.getMyDate());
 
-        File file = new File("/tmp/play-history.txt");
-        assertEquals("Stratocaster.getMyFile()", file, stratocaster.getMyFile());
+        Map<String, File> files = new HashMap<String, File>();
+        files.put("history", new File("/tmp/play-history.txt"));
+        files.put("artists", new File("/tmp/famous-artists.txt"));
+        assertEquals("Stratocaster.getMyFiles()", files, stratocaster.getMyFiles());
 
         InetAddress host = InetAddress.getByName("localhost");
         assertEquals("Stratocaster.getMyInetAddress()", host, stratocaster.getMyInetAddress());
@@ -77,7 +82,10 @@
         map.put("pickups", "Texas Special");
         assertEquals("Stratocaster.getMyMap()", map, stratocaster.getMyMap());
 
-        assertEquals("Stratocaster.getMyURI()", new URI("game://guitarheroII/?mode=expert"), stratocaster.getMyURI());
+        List<URI> uris = new ArrayList<URI>();
+        uris.add(new URI("game://guitarheroII/?mode=expert"));
+        uris.add(new URI("game://guitarheroIII/?guitar=wireless"));
+        assertEquals("Stratocaster.getMyURIs()", uris, stratocaster.getMyURIs());
 
         assertEquals("Stratocaster.getMyURL()", new URL("http://www.fender.com/"), stratocaster.getMyURL());