KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fulcrum > yaafi > framework > container > ServiceContainerImpl


1 package org.apache.fulcrum.yaafi.framework.container;
2
3 /*
4  * Copyright 2004 Apache Software Foundation
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14  * implied.
15  *
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */

19
20 import java.io.File JavaDoc;
21 import java.io.FileInputStream JavaDoc;
22 import java.io.InputStream JavaDoc;
23 import java.util.ArrayList JavaDoc;
24 import java.util.Arrays JavaDoc;
25 import java.util.Hashtable JavaDoc;
26 import java.util.List JavaDoc;
27 import java.util.Properties JavaDoc;
28
29 import org.apache.avalon.framework.configuration.Configuration;
30 import org.apache.avalon.framework.configuration.ConfigurationException;
31 import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
32 import org.apache.avalon.framework.context.Context;
33 import org.apache.avalon.framework.context.ContextException;
34 import org.apache.avalon.framework.context.DefaultContext;
35 import org.apache.avalon.framework.logger.Logger;
36 import org.apache.avalon.framework.parameters.ParameterException;
37 import org.apache.avalon.framework.parameters.Parameters;
38 import org.apache.avalon.framework.service.ServiceException;
39
40 /**
41  * Yet another avalon framework implementation (yaafi).
42  *
43  * @author <a HREF="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
44  */

45
46 public class ServiceContainerImpl
47     implements ServiceContainer
48 {
49     /** The role configuration file to be used */
50     private String JavaDoc componentRolesLocation = COMPONENT_ROLE_VALUE;
51
52     /** The service configuration file to be used */
53     private String JavaDoc componentConfigurationLocation = COMPONENT_CONFIG_VALUE;
54
55     /** The parameters file to be used */
56     private String JavaDoc parametersLocation = COMPONENT_PARAMETERS_VALUE;
57
58     /** The application directory aka the current woring directory */
59     private File JavaDoc applicationRootDir;
60
61     /** The directory for storing temporary files */
62     private File JavaDoc tempRootDir;
63
64     /** The logger to be used */
65     private Logger logger;
66
67     /** The list of services instantiated */
68     private List JavaDoc serviceList;
69     
70     /** The map of services used for the lookup */
71     private Hashtable JavaDoc serviceMap;
72
73     /** The Avalon role configuration loaded by this class */
74     private Configuration roleConfiguration;
75
76     /** The Avalon service configuration loaded by this class */
77     private Configuration serviceConfiguration;
78
79     /** The default Avalon context passed to the services */
80     private Context context;
81
82     /** The default Avalon parameters */
83     private Parameters parameters;
84     
85     /** Is this instance initiaized */
86     private boolean isDisposed;
87
88     /////////////////////////////////////////////////////////////////////////
89
// Service Manager Lifecycle
90
/////////////////////////////////////////////////////////////////////////
91

92     /**
93      * Constructor using sensible defaults.
94      */

95     public ServiceContainerImpl()
96     {
97         super();
98
99         this.componentRolesLocation = COMPONENT_ROLE_VALUE;
100         this.componentConfigurationLocation = COMPONENT_CONFIG_VALUE;
101         this.parametersLocation = COMPONENT_PARAMETERS_VALUE;
102         
103         this.isDisposed = false;
104         this.applicationRootDir = new File JavaDoc( new File JavaDoc("").getAbsolutePath() );
105         this.tempRootDir = new File JavaDoc( System.getProperty("java.io.tmpdir","."));
106         this.serviceList = new ArrayList JavaDoc();
107         this.serviceMap = new Hashtable JavaDoc();
108     }
109
110     
111     /**
112      * @see org.apache.avalon.framework.logger.LogEnabled#enableLogging(org.apache.avalon.framework.logger.Logger)
113      */

114     public void enableLogging(Logger logger)
115     {
116         this.logger = logger;
117     }
118     
119     /**
120      * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
121      */

122     public void configure(Configuration configuration) throws ConfigurationException
123     {
124         this.setComponentRolesLocation(
125             configuration.getChild(this.COMPONENT_ROLE_KEYS).getValue(
126                 this.COMPONENT_ROLE_VALUE )
127                 );
128
129         this.setComponentConfigurationLocation(
130             configuration.getChild(this.COMPONENT_CONFIG_KEY).getValue(
131                 this.COMPONENT_CONFIG_VALUE )
132                 );
133
134         this.setParametersLocation(
135             configuration.getChild( this.COMPONENT_PARAMETERS_KEY).getValue(
136                 this.COMPONENT_PARAMETERS_VALUE )
137                 );
138     }
139
140     /**
141      * Initializes the service container implementation.
142      * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
143      */

144
145     public void initialize() throws Exception JavaDoc
146     {
147         this.getLogger().debug( "Service Framework is starting up");
148         
149         // print some diagnostics
150

151         this.getLogger().debug(
152             "Using the following applicationRootDir : " + this.applicationRootDir.getAbsolutePath()
153             );
154
155         this.getLogger().debug(
156             "Using the following tempRootDir : " + this.tempRootDir.getAbsolutePath()
157             );
158
159         // get the configuration files
160

161         this.serviceConfiguration = loadConfiguration(this.componentConfigurationLocation);
162         this.roleConfiguration = loadConfiguration(this.componentRolesLocation);
163
164         if( roleConfiguration == null )
165         {
166             String JavaDoc msg = "Unable to locate the role configuration : " + this.componentRolesLocation;
167             this.getLogger().error( msg );
168             throw new ConfigurationException( msg );
169         }
170         
171         // create a default context
172

173         if( this.context == null )
174         {
175             this.getLogger().debug("Creating a DefaultContext");
176             this.context = this.createDefaultContext();
177         }
178
179         // create the default parameters
180

181         if( this.parameters == null )
182         {
183             this.parameters = this.loadParameters( this.parametersLocation );
184         }
185
186         // create the service implementaion instances
187

188         List JavaDoc currServiceList = this.createServiceComponents(this.roleConfiguration,this.logger);
189         this.setServiceList( currServiceList );
190
191         // fill the service map
192

193         for( int i=0; i<this.serviceList.size(); i++ )
194         {
195             ServiceComponent serviceComponent = (ServiceComponent) this.serviceList.get(i);
196             this.serviceMap.put( serviceComponent.getName(), serviceComponent );
197         }
198         
199         // run the various lifecycle stages
200

201         this.incarnate( this.serviceList );
202         
203         // we are up and running
204

205         this.isDisposed = false;
206         this.getLogger().debug( "Service Framework is up and running");
207     }
208
209     /**
210      * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
211      */

212     public void contextualize(Context context) throws ContextException
213     {
214         Object JavaDoc entry = null;
215         File JavaDoc currApplicationRootDir = null;
216         File JavaDoc currTempRootDir = null;
217         
218         this.context = context;
219         
220         // check for URN_AVALON_HOME - according to the Merlin Spec it is a file
221
// but Fulcrum passes in a string ... :-(
222

223         if( this.isInContext( context, this.URN_AVALON_HOME ) )
224         {
225             entry = context.get( this.URN_AVALON_HOME );
226             
227             if( entry instanceof String JavaDoc )
228             {
229                 String JavaDoc dirName = (String JavaDoc) entry;
230                 
231                 if( dirName.length() == 0 )
232                 {
233                     currApplicationRootDir = new File JavaDoc( new File JavaDoc(dirName).getAbsolutePath() );
234                 }
235                 else
236                 {
237                     currApplicationRootDir = new File JavaDoc( dirName );
238                 }
239             }
240             
241             if( entry instanceof File JavaDoc )
242             {
243                 currApplicationRootDir = (File JavaDoc) context.get( this.URN_AVALON_HOME );
244             }
245         }
246         
247         if( currApplicationRootDir != null )
248         {
249             this.setApplicationRootDir( currApplicationRootDir );
250         }
251                 
252         // check for URN_AVALON_TEMP
253

254         if( this.isInContext( context, this.URN_AVALON_TEMP ) )
255         {
256             entry = context.get( this.URN_AVALON_TEMP );
257             
258             if( entry instanceof String JavaDoc )
259             {
260                 currTempRootDir = new File JavaDoc( (String JavaDoc) entry );
261             }
262             
263             if( entry instanceof File JavaDoc )
264             {
265                 currTempRootDir = (File JavaDoc) context.get( this.URN_AVALON_TEMP );
266             }
267         }
268
269         if( currTempRootDir != null )
270         {
271             this.setTempRootDir( currTempRootDir );
272         }
273     }
274     
275     /**
276      * Disposes the service container implementation.
277      * @see org.apache.avalon.framework.activity.Disposable#dispose()
278      */

279     public synchronized void dispose()
280     {
281         if( this.isDisposed ) return;
282         
283         this.getLogger().info("Disposing all services");
284         
285         // decommision all servcies
286

287         this.decommision( this.getServiceList() );
288
289         // clean up
290

291         this.serviceList.clear();
292         this.serviceMap.clear();
293         
294         this.componentRolesLocation = null;
295         this.componentConfigurationLocation = null;
296         this.context = null;
297         this.parametersLocation = null;
298         this.roleConfiguration = null;
299         this.serviceConfiguration = null;
300         this.parameters = null;
301         
302         this.isDisposed = true;
303         this.getLogger().debug( "All services are disposed" );
304     }
305
306     /**
307      * Reconfiguring the services. I'm not sure hopw to implement this properly since
308      * the Avalon docs is vague on this subject. For now we suspend, reconfigure and
309      * resume the services in the correct order.
310      * @see org.apache.avalon.framework.configuration.Reconfigurable#reconfigure(org.apache.avalon.framework.configuration.Configuration)
311      */

312     public synchronized void reconfigure(Configuration configuration) throws ConfigurationException
313     {
314         ServiceComponent serviceComponent = null;
315
316         this.getLogger().info("Reconfiguring all services");
317
318         // 1) suspend the services
319

320         for( int i=this.getServiceList().size()-1; i>=0; i-- )
321         {
322             serviceComponent = (ServiceComponent) this.getServiceList().get(i);
323             serviceComponent.suspend();
324         }
325
326         // 2) reconfigure the services
327

328         for( int i=0; i<this.getServiceList().size(); i++ )
329         {
330             serviceComponent = (ServiceComponent) this.getServiceList().get(i);
331             serviceComponent.reconfigure(this.getServiceConfiguration());
332         }
333
334         // 3) resume the services
335

336         for( int i=0; i<this.getServiceList().size(); i++ )
337         {
338             serviceComponent = (ServiceComponent) this.getServiceList().get(i);
339             serviceComponent.resume();
340         }
341     }
342
343     /////////////////////////////////////////////////////////////////////////
344
// Service Manager Implementation
345
/////////////////////////////////////////////////////////////////////////
346

347     /**
348      * @see org.apache.avalon.framework.service.ServiceContainer#hasService(java.lang.String)
349      */

350     public synchronized boolean hasService(String JavaDoc name)
351     {
352         ServiceComponent serviceComponent =
353             (ServiceComponent) this. getServiceMap().get(name);
354         
355         return ( serviceComponent != null ? true : false );
356     }
357
358     /**
359      * @see org.apache.avalon.framework.service.ServiceContainer#lookup(java.lang.String)
360      */

361     public synchronized Object JavaDoc lookup(String JavaDoc name) throws ServiceException
362     {
363         Object JavaDoc result = null;
364         ServiceComponent serviceComponent = null;
365
366         serviceComponent = (ServiceComponent) this. getServiceMap().get(name);
367         
368         if( serviceComponent != null )
369         {
370             try
371             {
372                 if( serviceComponent.isInstantiated() )
373                 {
374                     // This component is initialized early
375
result = serviceComponent.getInstance();
376                 }
377                 else
378                 {
379                     // This component is initialized lazily
380
result = serviceComponent.create();
381                     this.incarnate( serviceComponent );
382                 }
383             }
384             catch (Exception JavaDoc e)
385             {
386                 String JavaDoc msg = "Failed to lookup the service " + serviceComponent.getShorthand();
387                 this.getLogger().error( msg, e );
388                 throw new ServiceException( serviceComponent.getShorthand(), msg, e );
389             }
390         }
391         
392         if( result == null )
393         {
394             String JavaDoc msg = "Service not found : " + name;
395             this.getLogger().error(msg);
396             throw new ServiceException(name, msg );
397         }
398         else
399         {
400             return result;
401         }
402     }
403
404     /**
405      * @see org.apache.avalon.framework.service.ServiceContainer#release(java.lang.Object)
406      */

407     public synchronized void release(Object JavaDoc arg0)
408     {
409     }
410
411     /////////////////////////////////////////////////////////////////////////
412
// Service YaffiContainer Implementation
413
/////////////////////////////////////////////////////////////////////////
414

415     /**
416      * @param string The location of the component configuration file
417      */

418     protected void setComponentConfigurationLocation(String JavaDoc string)
419     {
420         this.componentConfigurationLocation = string;
421     }
422
423     /**
424      * @param string The location of the component role file
425      */

426     protected void setComponentRolesLocation(String JavaDoc string)
427     {
428         this.componentRolesLocation = string;
429     }
430
431     /**
432      * @param string The location of the parameters file
433      */

434     protected void setParametersLocation(String JavaDoc string)
435     {
436         this.parametersLocation = string;
437     }
438     
439     /**
440      * @return The logger of the service containe
441      */

442     protected Logger getLogger()
443     {
444         return logger;
445     }
446
447     /**
448      * @return Returns the serviceMap.
449      */

450     protected Hashtable JavaDoc getServiceMap()
451     {
452         return serviceMap;
453     }
454     
455     /**
456      * Incarnation of a single service component. Incarnation consists of running the
457      * whole Avalon incarnation lifecycle process for a service component. After the
458      * incarnation the service if operational.
459      *
460      * @param serviceComponent The service component to incarnate
461      */

462     protected void incarnate( ServiceComponent serviceComponent )
463         throws ContextException, ServiceException, ConfigurationException, ParameterException, Exception JavaDoc
464     {
465         this.getLogger().debug( "Incarnating the service " + serviceComponent.getShorthand() );
466         
467         serviceComponent.enableLogging( this.getLogger() );
468         serviceComponent.contextualize( context );
469         serviceComponent.service( this );
470         serviceComponent.configure( this.getServiceConfiguration() );
471         serviceComponent.parameterize( parameters );
472         serviceComponent.initialize();
473         serviceComponent.execute();
474         serviceComponent.start();
475     }
476
477     /**
478      * Decommision of a single service component. Decommision consists of running the
479      * whole Avalon decommision lifecycle process for a service component. After the
480      * Decommision the service is not operational any longer. During decommisioning
481      * we ignore any sxceptions since it is quite common that something goes wrong.
482      *
483      * @param serviceComponent The service component to decommision
484      */

485     
486     protected void decommision( ServiceComponent serviceComponent )
487     {
488         this.getLogger().debug( "Decommisioning the service " + serviceComponent.getShorthand() );
489         
490         try
491         {
492             serviceComponent.stop();
493         }
494         catch (Throwable JavaDoc e)
495         {
496             String JavaDoc msg = "Stopping the following service failed : " + serviceComponent.getName();
497             this.getLogger().error( msg, e );
498         }
499
500         try
501         {
502             serviceComponent.dispose();
503         }
504         catch (Throwable JavaDoc e)
505         {
506             String JavaDoc msg = "Disposing the following service failed : " + serviceComponent.getName();
507             this.getLogger().error( msg, e );
508         }
509     }
510
511     /**
512      * Incarnation of a list of services
513      */

514     private void incarnate(List JavaDoc serviceList)
515         throws ContextException, ServiceException, ConfigurationException, ParameterException, Exception JavaDoc
516     {
517         ServiceComponent serviceComponent = null;
518
519         for( int i=0; i<serviceList.size(); i++ )
520         {
521             serviceComponent = (ServiceComponent) this.serviceList.get(i);
522             this.incarnate( serviceComponent );
523         }
524     }
525
526     /**
527      * Decommision a ist of services
528      */

529     private void decommision(List JavaDoc serviceList)
530     {
531         ServiceComponent serviceComponent = null;
532
533         for( int i=serviceList.size()-1; i>=0; i-- )
534         {
535             serviceComponent = (ServiceComponent) this.getServiceList().get(i);
536
537         }
538     }
539         
540     /**
541      * @return The list of currently know services
542      */

543     private List JavaDoc getServiceList()
544     {
545         return this.serviceList;
546     }
547
548     /**
549      * @param list The list of known services
550      */

551     private void setServiceList(List JavaDoc list)
552     {
553         this.serviceList = list;
554     }
555
556     /**
557      * @return The service configuration
558      */

559     private Configuration getServiceConfiguration()
560     {
561         return this.serviceConfiguration;
562     }
563
564     /**
565      * Factory method for creating services
566      * @param serviceList
567      * @throws Exception
568      */

569
570     private List JavaDoc createServiceComponents(Configuration roleConfiguration, Logger logger )
571         throws ConfigurationException
572     {
573         if( roleConfiguration == null )
574         {
575             String JavaDoc msg = "The roleConfiguration is <null>";
576             throw new ConfigurationException(msg);
577         }
578
579         ArrayList JavaDoc result = new ArrayList JavaDoc();
580         Configuration[] roleListEntries = getRoleConfigurationList(roleConfiguration);
581
582         ServiceComponent serviceComponent = null;
583
584         for ( int i=0; i<roleListEntries.length; i++ )
585         {
586             try
587             {
588                 serviceComponent = new ServiceComponentImpl(roleListEntries[i],logger);
589                 
590                 // If late initialization is used we still load the class to
591
// ensure the integrity of the configuration
592

593                 if( serviceComponent.isEarlyInit() )
594                 {
595                     serviceComponent.loadClass();
596                     serviceComponent.create();
597                 }
598                 else
599                 {
600                     serviceComponent.loadClass();
601                 }
602                 
603                 result.add( serviceComponent );
604             }
605             catch( Throwable JavaDoc t )
606             {
607                 String JavaDoc msg = "Failed to load the service " + serviceComponent.getName();
608                 this.getLogger().error( msg, t );
609                 throw new ConfigurationException( msg, t );
610             }
611         }
612
613         return result;
614     }
615
616     /**
617      * Load a configuration file either from a file or using the class loader.
618      * @param location The location as a file
619      * @return The loaded configuration
620      * @throws Exception Something went wrong
621      */

622     private Configuration loadConfiguration( String JavaDoc location ) throws Exception JavaDoc
623     {
624         Configuration result = null;
625         InputStream JavaDoc is = this.getInputStream( location );
626         DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
627
628         if( is != null )
629         {
630             result = builder.build( is );
631         }
632
633         return result;
634     }
635
636     /**
637      * Load the parameters
638      * @param location The location as a file
639      * @return The loaded configuration
640      * @throws Exception Something went wrong
641      */

642     private Parameters loadParameters( String JavaDoc location ) throws Exception JavaDoc
643     {
644         InputStream JavaDoc is = this.getInputStream( location );
645         Configuration conf = null;
646         Parameters result = new Parameters();
647
648         if( is != null )
649         {
650             if( location.endsWith(".xml") )
651             {
652                 result = Parameters.fromConfiguration( conf );
653             }
654             else
655             {
656                 Properties JavaDoc props = new Properties JavaDoc();
657                 props.load( is );
658                 result = Parameters.fromProperties( props );
659             }
660         }
661
662         return result;
663     }
664
665
666     /**
667      * Locate the file with the given position
668      */

669     private InputStream JavaDoc getInputStream( String JavaDoc location ) throws Exception JavaDoc
670     {
671         if( ( location == null ) || ( location.length() == 0 ) )
672         {
673             return null;
674         }
675
676         File JavaDoc file = null;
677         InputStream JavaDoc is = null;
678
679         // try to load a relative location with the given application root dir
680
// e.g. "componentRoles.xml" located in the current working directory
681

682         if( ( is == null ) && ( location.startsWith( "/" ) == false ) )
683         {
684             file = new File JavaDoc( this.applicationRootDir, location );
685
686             this.getLogger().debug("Looking for " + location + " in the application directory");
687             
688             if( file.exists() )
689             {
690                 is = new FileInputStream JavaDoc( file );
691             }
692         }
693
694         // try to load an absolute location as file
695
// e.g. "/foo/componentRoles.xml" from the root of the file system
696

697         if( is == null )
698         {
699             file = new File JavaDoc( location );
700
701             this.getLogger().debug("Looking for " + location + " as absolute file location");
702             
703             if( file.isAbsolute() && file.exists() )
704             {
705                 is = new FileInputStream JavaDoc( file );
706             }
707         }
708
709         // try to load an absolute location through the classpath
710
// e.g. "/componentRoles.xml" located in the classpath
711

712         if( ( is == null ) && ( location.startsWith( "/" ) == true ) )
713         {
714             this.getLogger().debug("Looking for " + location + " using the class loader");
715             is = getClass().getResourceAsStream( location );
716         }
717
718         if( is == null )
719         {
720             this.getLogger().warn("Unable to locate " + location);
721         }
722         else
723         {
724             this.getLogger().debug("Successfully located " + location);
725         }
726         
727         return is;
728     }
729     
730     /**
731      * Extract the metadate for creating the services
732      * @param roleConfiguration
733      * @return
734      */

735     private Configuration[] getRoleConfigurationList( Configuration roleConfiguration )
736     {
737         Configuration[] result = null;
738         ArrayList JavaDoc roleListEntries = new ArrayList JavaDoc();
739         String JavaDoc rootElementName = roleConfiguration.getName();
740         
741         if( rootElementName.equals("role-list") )
742         {
743             // Excalibur style definition using /role-list/role
744

745             roleListEntries.addAll( Arrays.asList( roleConfiguration.getChildren() ) );
746         }
747         else if( rootElementName.equals("container") )
748         {
749             // Merlin style definition using /container/component
750

751             Configuration[] temp = roleConfiguration.getChildren();
752             for( int i=0; i<temp.length; i++ )
753             {
754                 if( temp[i].getName().equals("component") )
755                 {
756                     roleListEntries.add(temp[i]);
757                 }
758             }
759         }
760         else
761         {
762             throw new RuntimeException JavaDoc(
763                 "Don't know how to parse the roleConfiguration"
764                 );
765         }
766         
767         result = (Configuration[]) roleListEntries.toArray(
768             new Configuration[roleListEntries.size()]
769             );
770         
771         return result;
772     }
773     
774     private DefaultContext createDefaultContext()
775     {
776         DefaultContext result = new DefaultContext();
777
778         result.put( ServiceConstants.URN_AVALON_HOME, this.applicationRootDir );
779         result.put( ServiceConstants.URN_AVALON_TEMP, this.tempRootDir );
780         result.put( ServiceConstants.COMPONENT_APP_ROOT, this.applicationRootDir.getAbsolutePath() );
781         
782         return result;
783     }
784     
785     /**
786      * Determines if an entry exists within the given context.
787      *
788      * @param context the contect to look at
789      * @param name the name of the parameter within the context
790      */

791     
792     private boolean isInContext( Context context, String JavaDoc name )
793     {
794         if( context == null )
795         {
796             return false;
797         }
798         
799         try
800         {
801             if( context.get(name) != null )
802             {
803                 return true;
804             }
805             else
806             {
807                 return false;
808             }
809         }
810         catch (ContextException e)
811         {
812             return false;
813         }
814     }
815     
816     /**
817      * @param applicationRootDir The applicationRootDir to set.
818      */

819     private void setApplicationRootDir(File JavaDoc dir)
820     {
821         if( dir == null )
822         {
823             String JavaDoc msg = "The applicationRootDir is <null>";
824             throw new IllegalArgumentException JavaDoc ( msg );
825         }
826         
827         if( dir.exists() == false )
828         {
829             String JavaDoc msg = "The applicatonRootDir " + dir.getAbsolutePath() + " does not exist";
830             throw new IllegalArgumentException JavaDoc ( msg );
831         }
832         
833         this.getLogger().debug( "Setting applicationRootDir to " + dir.getAbsolutePath() );
834         
835         this.applicationRootDir = dir;
836     }
837     
838     /**
839      * @param tempRootDir The tempRootDir to set.
840      */

841     public void setTempRootDir(File JavaDoc dir)
842     {
843         if( dir == null )
844         {
845             String JavaDoc msg = "The tempRootDir is <null>";
846             throw new IllegalArgumentException JavaDoc ( msg );
847         }
848         
849         if( dir.exists() == false )
850         {
851             String JavaDoc msg = "The tempRootDir " + dir.getAbsolutePath() + " does not exist";
852             throw new IllegalArgumentException JavaDoc ( msg );
853         }
854      
855         this.getLogger().debug( "Setting tempRootDir to " + dir.getAbsolutePath() );
856         
857         this.tempRootDir = dir;
858     }
859 }
860
Popular Tags