felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From don...@apache.org
Subject svn commit: r706138 - in /felix/sandbox/donsez/shutdownhook: pom.xml src/main/java/org/apache/felix/sandbox/shutdownhook/ShutdownHook.java src/main/resources/shutdownbanner.txt src/main/resources/startbanner.txt src/main/resources/stopbanner.txt
Date Mon, 20 Oct 2008 07:34:32 GMT
Author: donsez
Date: Mon Oct 20 00:34:31 2008
New Revision: 706138

URL: http://svn.apache.org/viewvc?rev=706138&view=rev
Log:
add banners for banner start and stop

Added:
    felix/sandbox/donsez/shutdownhook/src/main/resources/startbanner.txt   (with props)
    felix/sandbox/donsez/shutdownhook/src/main/resources/stopbanner.txt   (with props)
Modified:
    felix/sandbox/donsez/shutdownhook/pom.xml
    felix/sandbox/donsez/shutdownhook/src/main/java/org/apache/felix/sandbox/shutdownhook/ShutdownHook.java
    felix/sandbox/donsez/shutdownhook/src/main/resources/shutdownbanner.txt

Modified: felix/sandbox/donsez/shutdownhook/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/shutdownhook/pom.xml?rev=706138&r1=706137&r2=706138&view=diff
==============================================================================
--- felix/sandbox/donsez/shutdownhook/pom.xml (original)
+++ felix/sandbox/donsez/shutdownhook/pom.xml Mon Oct 20 00:34:31 2008
@@ -49,6 +49,17 @@
   </dependencies>
 
   <build>
+
+     <resources>
+      <resource>
+        <directory>src/main/resources</directory>
+        <filtering>true</filtering>
+        <includes>
+          <include>**/*.txt</include>
+        </includes>
+      </resource>
+    </resources>
+
     <plugins>
       <plugin>
 	        <groupId>org.apache.felix</groupId>

Modified: felix/sandbox/donsez/shutdownhook/src/main/java/org/apache/felix/sandbox/shutdownhook/ShutdownHook.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/shutdownhook/src/main/java/org/apache/felix/sandbox/shutdownhook/ShutdownHook.java?rev=706138&r1=706137&r2=706138&view=diff
==============================================================================
--- felix/sandbox/donsez/shutdownhook/src/main/java/org/apache/felix/sandbox/shutdownhook/ShutdownHook.java
(original)
+++ felix/sandbox/donsez/shutdownhook/src/main/java/org/apache/felix/sandbox/shutdownhook/ShutdownHook.java
Mon Oct 20 00:34:31 2008
@@ -47,17 +47,7 @@
 		hook=new Thread() {
 		    public void run() {
 		    	shutdownFlag=true;
-		    	try {
-			    	BufferedReader br = new BufferedReader(new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream("/shutdownbanner.txt")));
-			    	log(bundleContext.getProperty(Constants.FRAMEWORK_VENDOR));		    		
-			    	String line;
-			    	while((line=br.readLine())!=null) {
-				    	log(line);		    		
-			    	}
-					br.close();
-				} catch (IOException ioe) {
-					ioe.printStackTrace();
-				}
+		    	banner("/shutdownbanner.txt", null);
 		    	try {
 					bundleContext.getBundle(0).stop();
 				} catch (BundleException be) {
@@ -66,20 +56,36 @@
 		    }
 		};
 		Runtime.getRuntime().addShutdownHook(hook);
-    	log("ADD Shutdown hook");
+    	banner("/startbanner.txt", null);
 
 	}
 
 	public void stop(BundleContext context) throws Exception {
 		if(!shutdownFlag){
 			Runtime.getRuntime().removeShutdownHook(hook);
-	    	log("REMOVE Shutdown hook");
+	    	banner("/stopbanner.txt", null);
 		}
 	}
 	
-	private void log(String message){
+	private void banner(String bannerResource, String lineHeader){
+    	try {
+	    	InputStream is=this.getClass().getClassLoader().getResourceAsStream(bannerResource);
+	    	if(is==null) return;
+	    	BufferedReader br = new BufferedReader(new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream(bannerResource)));
+	    	//log(bundleContext.getProperty(Constants.FRAMEWORK_VENDOR), lineHeader);		    		
+	    	String line;
+	    	while((line=br.readLine())!=null) {
+		    	log(line, lineHeader);		    		
+	    	}
+			br.close();
+		} catch (IOException ioe) {
+			ioe.printStackTrace();
+		}		
+	}	
+	
+	private void log(String message, String lineHeader){
 //		if(logService==null) {
-			System.out.println("Bundle " + bundleContext.getBundle().getBundleId()+ ":"+ message);
+			System.out.println((lineHeader==null?"":lineHeader) + message);
 //		} else {
 //			logService.log(LogService.LOG_INFO, message);
 //		}

Modified: felix/sandbox/donsez/shutdownhook/src/main/resources/shutdownbanner.txt
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/shutdownhook/src/main/resources/shutdownbanner.txt?rev=706138&r1=706137&r2=706138&view=diff
==============================================================================
--- felix/sandbox/donsez/shutdownhook/src/main/resources/shutdownbanner.txt (original)
+++ felix/sandbox/donsez/shutdownhook/src/main/resources/shutdownbanner.txt Mon Oct 20 00:34:31
2008
@@ -1,3 +1,3 @@
-==================================
-Bye Bye !
-==================================
\ No newline at end of file
+==========================================================
+${pom.artifactId} : Bye Bye !
+==========================================================

Added: felix/sandbox/donsez/shutdownhook/src/main/resources/startbanner.txt
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/shutdownhook/src/main/resources/startbanner.txt?rev=706138&view=auto
==============================================================================
--- felix/sandbox/donsez/shutdownhook/src/main/resources/startbanner.txt (added)
+++ felix/sandbox/donsez/shutdownhook/src/main/resources/startbanner.txt Mon Oct 20 00:34:31
2008
@@ -0,0 +1,3 @@
+==========================================================
+${pom.artifactId} : Hello !
+==========================================================

Propchange: felix/sandbox/donsez/shutdownhook/src/main/resources/startbanner.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: felix/sandbox/donsez/shutdownhook/src/main/resources/stopbanner.txt
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/shutdownhook/src/main/resources/stopbanner.txt?rev=706138&view=auto
==============================================================================
--- felix/sandbox/donsez/shutdownhook/src/main/resources/stopbanner.txt (added)
+++ felix/sandbox/donsez/shutdownhook/src/main/resources/stopbanner.txt Mon Oct 20 00:34:31
2008
@@ -0,0 +1,3 @@
+==========================================================
+${pom.artifactId} : Just stopping !
+==========================================================

Propchange: felix/sandbox/donsez/shutdownhook/src/main/resources/stopbanner.txt
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message