mcconnell 2003/01/18 08:19:32 Modified: assembly/src/java/org/apache/avalon/assembly/appliance Appliance.java ApplianceContext.java DefaultAppliance.java DefaultApplianceContext.java assembly/src/java/org/apache/avalon/assembly/lifecycle DefaultDeploymentService.java Log: Added startup policy so we can programatically control if the deployment system starts/stops a component or a container handles this function. Revision Changes Path 1.23 +11 -1 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/Appliance.java Index: Appliance.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/Appliance.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- Appliance.java 17 Jan 2003 11:38:49 -0000 1.22 +++ Appliance.java 18 Jan 2003 16:19:31 -0000 1.23 @@ -131,6 +131,16 @@ boolean getActivationPolicy(); /** + * Return the startup policy for the component. If TRUE, startup + * of the component will be executed during normal lifecycle processing + * on request for a new component instance. If FALSE the startup phase + * will be ommitted. + * + * @return the startup policy + */ + boolean getStartupPolicy(); + + /** * Test is this appliance is enabled. A appliance is enabled unless explicitly disabled by an * assembly directive, or implicity disabled as a result of an assembly failure. * 1.10 +12 -1 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/ApplianceContext.java Index: ApplianceContext.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/ApplianceContext.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- ApplianceContext.java 9 Jan 2003 15:08:09 -0000 1.9 +++ ApplianceContext.java 18 Jan 2003 16:19:31 -0000 1.10 @@ -232,4 +232,15 @@ */ Configuration getConfiguration(); + /** + * Return the startup policy for the component. If TRUE, startup + * of the component will be executed during normal lifecycle processing + * on request for a new component instance. If FALSE the startup phase + * will be ommitted. + * + * @return the startup policy + */ + boolean getStartupPolicy(); + + } 1.24 +14 -2 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultAppliance.java Index: DefaultAppliance.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultAppliance.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- DefaultAppliance.java 15 Jan 2003 09:09:23 -0000 1.23 +++ DefaultAppliance.java 18 Jan 2003 16:19:31 -0000 1.24 @@ -279,7 +279,6 @@ // Reclaimable //===================================================================== - /** * Resolve a object to a value. * @@ -416,6 +415,19 @@ public boolean getActivationPolicy() { return m_applianceContext.getActivationPolicy(); + } + + /** + * Return the startup policy for the component. If TRUE, startup + * of the component will be executed during normal lifecycle processing + * on request for a new component instance. If FALSE the startup phase + * will be ommitted. + * + * @return the startup policy + */ + public boolean getStartupPolicy() + { + return m_applianceContext.getStartupPolicy(); } /** 1.8 +34 -1 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceContext.java Index: DefaultApplianceContext.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceContext.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- DefaultApplianceContext.java 15 Jan 2003 09:09:23 -0000 1.7 +++ DefaultApplianceContext.java 18 Jan 2003 16:19:31 -0000 1.8 @@ -164,6 +164,11 @@ */ private String m_factory; + /** + * The startup policy. + */ + private boolean m_startup = true; + //============================================================== // constructor //============================================================== @@ -511,6 +516,34 @@ return m_config; } } + + /** + * Return the startup policy for the component. If TRUE, startup + * of the component will be executed during normal lifecycle processing + * on request for a new component instance. If FALSE the startup phase + * will be ommitted. + * + * @return the startup policy + */ + public boolean getStartupPolicy() + { + return m_startup; + } + + /** + * Set the startup policy for the component. If TRUE, startup + * of the component will be executed during normal lifecycle processing + * on request for a new component instance. If FALSE the startup phase + * will be ommitted. + * + * @param policy the startup policy + */ + public void setStartupPolicy( boolean policy ) + { + checkWriteable(); + m_startup = policy; + } + /** * Create a consolidated logging descriptor that takes into account both type logging 1.14 +17 -23 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/DefaultDeploymentService.java Index: DefaultDeploymentService.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/DefaultDeploymentService.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- DefaultDeploymentService.java 15 Jan 2003 09:09:24 -0000 1.13 +++ DefaultDeploymentService.java 18 Jan 2003 16:19:32 -0000 1.14 @@ -258,21 +258,6 @@ } // - // make sure we are deploying a fully assembled appliance - // - - //try - //{ - // appliance.assemble(); - //} - //catch( Throwable e ) - //{ - // final String error = - // "Unresolved dependencies in appliance: " + appliance; - // throw new DeploymentException( error, e ); - //} - - // // commence deployment // @@ -301,7 +286,10 @@ m_configuration.configure( appliance, instance ); m_parameters.parameterize( appliance, instance ); m_initialization.initialize( appliance, instance ); - m_startup.start( appliance, instance ); + if( appliance.getStartupPolicy() ) + { + m_startup.start( appliance, instance ); + } return instance; } catch( Throwable e ) @@ -340,14 +328,20 @@ appliance.disassemble(); } - try + if( appliance.getStartupPolicy() ) { - m_startup.stop( appliance, instance ); - } - catch( Throwable e ) - { - // log a warning + try + { + m_startup.stop( appliance, instance ); + } + catch( Throwable e ) + { + final String warning = + "Ignoring shutdown error raised by component: " + appliance; + getLogger().warn( warning, e ); + } } + m_disposal.dispose( appliance, instance ); }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>