Author: dblevins
Date: Fri Aug 22 20:45:54 2008
New Revision: 688257

URL: http://svn.apache.org/viewvc?rev=688257&view=rev
Log:
Added @Startup and lifecycle callbacks

Modified:
    
openejb/trunk/openejb3/examples/simple-singleton/src/main/java/org/superbiz/registry/PropertyRegistryBean.java

Modified: 
openejb/trunk/openejb3/examples/simple-singleton/src/main/java/org/superbiz/registry/PropertyRegistryBean.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/simple-singleton/src/main/java/org/superbiz/registry/PropertyRegistryBean.java?rev=688257&r1=688256&r2=688257&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/examples/simple-singleton/src/main/java/org/superbiz/registry/PropertyRegistryBean.java
 (original)
+++ 
openejb/trunk/openejb3/examples/simple-singleton/src/main/java/org/superbiz/registry/PropertyRegistryBean.java
 Fri Aug 22 20:45:54 2008
@@ -20,10 +20,14 @@
 import static javax.ejb.ConcurrencyManagementType.BEAN;
 import javax.ejb.Singleton;
 import javax.ejb.ConcurrencyManagement;
+import javax.ejb.Startup;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
 import java.util.Properties;
 
 @Singleton
 @ConcurrencyManagement(BEAN)
[EMAIL PROTECTED]
 public class PropertyRegistryBean implements PropertyRegistry {
 
     // Note the java.util.Properties object is a thread-safe
@@ -32,6 +36,18 @@
     // to ensure the PropertyRegistryBean is thread-safe.
     private final Properties properties = new Properties();
 
+    // The @Startup method ensures that this method is
+    // called when the application starts up.
+    @PostConstruct
+    public void applicationStartup() {
+        properties.putAll(System.getProperties());
+    }
+
+    @PreDestroy
+    public void applicationShutdown() {
+        properties.clear();
+    }
+
     public String getProperty(String key) {
         return properties.getProperty(key);
     }


Reply via email to