svn commit: rev 22616 - in avalon/trunk/planet/tutorials/main: . src/main/tutorial

[email protected]
Newsgroups gmane.comp.jakarta.avalon.cvs
Message-ID <[email protected]>
Author: mcconnell
Date: Tue Jul  6 01:57:33 2004
New Revision: 22616

Modified:
   avalon/trunk/planet/tutorials/main/build.xml
   avalon/trunk/planet/tutorials/main/src/main/tutorial/Main.java
Log:
Update the tutorial so that it does not assume a merlin installation.

Modified: avalon/trunk/planet/tutorials/main/build.xml
==============================================================================
--- avalon/trunk/planet/tutorials/main/build.xml	(original)
+++ avalon/trunk/planet/tutorials/main/build.xml	Tue Jul  6 01:57:33 2004
@@ -15,12 +15,14 @@
 
   <target name="test" depends="standard.test">
     <x:path id="deps"/>
-    <java classname="tutorial.Main" fork="true" dir="target\test">
+    <java classname="tutorial.Main" fork="true" dir="target\test" failonerror="true">
       <classpath>
         <path refid="deps"/>
         <pathelement location="target/deliverables/jars/${project.filename}"/>
       </classpath>
+      <sysproperty key="project.cache" value="${magic.cache}"/>
     </java>
+    
   </target>
 
 </project>

Modified: avalon/trunk/planet/tutorials/main/src/main/tutorial/Main.java
==============================================================================
--- avalon/trunk/planet/tutorials/main/src/main/tutorial/Main.java	(original)
+++ avalon/trunk/planet/tutorials/main/src/main/tutorial/Main.java	Tue Jul  6 01:57:33 2004
@@ -19,6 +19,7 @@
 
 import java.io.File;
 import java.util.Map;
+import java.lang.reflect.Method;
 
 import org.apache.avalon.repository.Artifact;
 import org.apache.avalon.repository.provider.Builder;
@@ -43,11 +44,14 @@
         // be resolved. It also provides operations supporting 
         // customization of the application environment.
         //
+
+        String cache = System.getProperty( "project.cache" );
 
         InitialContextFactory initial = 
-          new DefaultInitialContextFactory( "merlin" );
+          new DefaultInitialContextFactory( "demo" );
         File home = initial.getHomeDirectory();
-        initial.setCacheDirectory( new File( home, "system" ) );
+        initial.setCacheDirectory( new File( cache ) );
+        initial.setHosts( new String[0] );
         InitialContext context = initial.createInitialContext();
 
         //
@@ -75,13 +79,13 @@
         Factory factory = builder.getFactory();
         Map criteria = factory.createDefaultCriteria();
         criteria.put( "merlin.server", "false" );
-        try
-        {
-            Object kernel = factory.create( criteria );
-        }
-        catch( Throwable e )
-        {
-            e.printStackTrace();
-        }
+        Object kernel = factory.create( criteria );
+
+        System.out.println( "Kernel established." );
+
+        Method shutdown = kernel.getClass().getMethod( "shutdown", new Class[0] );
+        shutdown.invoke( kernel, new Object[0] );
+
+        System.out.println( "Shutdown complete." );
     }
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.