Author: niclas
Date: Sun Sep 12 20:23:35 2004
New Revision: 45947

Modified:
   
avalon/trunk/central/laboratory/studio/core/templates/composition/application/Application.java
   
avalon/trunk/central/laboratory/studio/core/templates/configuration/HelloComponent.java
   
avalon/trunk/central/laboratory/studio/core/templates/context/casting/DemoContextProvider.java
   
avalon/trunk/central/laboratory/studio/core/templates/context/casting/HelloComponent.java
   
avalon/trunk/central/laboratory/studio/core/templates/context/custom/HelloComponent.java
   
avalon/trunk/central/laboratory/studio/core/templates/context/custom/NumberCruncher.java
   avalon/trunk/central/laboratory/studio/core/templates/context/custom/block.xml
   
avalon/trunk/central/laboratory/studio/core/templates/context/plus/DemoContextProvider.java
   
avalon/trunk/central/laboratory/studio/core/templates/context/strategy/DemoContextualizationHandler.java
   
avalon/trunk/central/laboratory/studio/core/templates/context/strategy/StandardContextImp.java
Log:
Some formatting...

Modified: 
avalon/trunk/central/laboratory/studio/core/templates/composition/application/Application.java
==============================================================================
--- 
avalon/trunk/central/laboratory/studio/core/templates/composition/application/Application.java
      (original)
+++ 
avalon/trunk/central/laboratory/studio/core/templates/composition/application/Application.java
      Sun Sep 12 20:23:35 2004
@@ -1,76 +1,77 @@
-/* 

- * Copyright 2004 Apache Software Foundation

- * Licensed  under the  Apache License,  Version 2.0  (the "License");

- * you may not use  this file  except in  compliance with the License.

- * You may obtain a copy of the License at 

- * 

- *   http://www.apache.org/licenses/LICENSE-2.0

- * 

- * Unless required by applicable law or agreed to in writing, software

- * distributed  under the  License is distributed on an "AS IS" BASIS,

- * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or

- * implied.

- * 

- * See the License for the specific language governing permissions and

- * limitations under the License.

- */

-

-package tutorial.application;

-

-import java.io.File;

-

-import org.apache.avalon.framework.logger.AbstractLogEnabled;

-import org.apache.avalon.framework.service.Serviceable;

-import org.apache.avalon.framework.service.ServiceManager;

-import org.apache.avalon.framework.service.ServiceException;

-import org.apache.avalon.framework.activity.Disposable;

-

-import tutorial.location.LocationService;

-import tutorial.publisher.PublisherService;

-

-/**

- * PublisherComponent from Merlin's Composition Tutorial

- *

- * @avalon.component version="1.0" name="test"

- * @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>

- */

-public class Application extends AbstractLogEnabled implements Serviceable, Disposable

-{

-

-   /**

-    * Servicing of the component by the container during

-    * which service dependencies declared under the component

-    * can be resolved using the supplied service manager.  In this 

-    * example the component uses a LocatorService service to log a 

-    * message exposing a location.

-    *

-    * @param manager the service manager

-    * @avalon.dependency key="locator" type="tutorial.location.LocationService"

-    * @avalon.dependency key="publisher" type="tutorial.publisher.PublisherService"

-    */

-    public void service( ServiceManager manager ) throws ServiceException

-    {

-        getLogger().info( "servicing application" );

-

-        LocationService locator = (LocationService) manager.lookup( "locator" );

-        PublisherService publisher = (PublisherService) manager.lookup( "publisher" );

-

-        //

-        // get the location from the locator and publish

-        // it using the publisher

-        //

-

-        publisher.publish( 

-            "\n******************"

-          + "\n* " + locator.getLocation() 

-          + "\n******************");

-

-        getLogger().info( "done" );

-    }

-

-    public void dispose()

-    {

-        getLogger().info( "disposal" );

-    }

-}

-

+/* 
+ * Copyright 2004 Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tutorial.application;
+
+import java.io.File;
+
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.activity.Disposable;
+
+import tutorial.location.LocationService;
+import tutorial.publisher.PublisherService;
+
+/**
+ * PublisherComponent from Merlin's Composition Tutorial
+ *
+ * @avalon.component version="1.0" name="test"
+ * @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
+ */
+public class Application extends AbstractLogEnabled 
+    implements Serviceable, Disposable
+{
+
+   /**
+    * Servicing of the component by the container during
+    * which service dependencies declared under the component
+    * can be resolved using the supplied service manager.  In this 
+    * example the component uses a LocatorService service to log a 
+    * message exposing a location.
+    *
+    * @param manager the service manager
+    * @avalon.dependency key="locator" type="tutorial.location.LocationService"
+    * @avalon.dependency key="publisher" type="tutorial.publisher.PublisherService"
+    */
+    public void service( ServiceManager manager ) throws ServiceException
+    {
+        getLogger().info( "servicing application" );
+
+        LocationService locator = (LocationService) manager.lookup( "locator" );
+        PublisherService publisher = (PublisherService) manager.lookup( "publisher" );
+
+        //
+        // get the location from the locator and publish
+        // it using the publisher
+        //
+
+        publisher.publish( 
+            "\n******************"
+          + "\n* " + locator.getLocation() 
+          + "\n******************");
+
+        getLogger().info( "done" );
+    }
+
+    public void dispose()
+    {
+        getLogger().info( "disposal" );
+    }
+}
+

Modified: 
avalon/trunk/central/laboratory/studio/core/templates/configuration/HelloComponent.java
==============================================================================
--- 
avalon/trunk/central/laboratory/studio/core/templates/configuration/HelloComponent.java
     (original)
+++ 
avalon/trunk/central/laboratory/studio/core/templates/configuration/HelloComponent.java
     Sun Sep 12 20:23:35 2004
@@ -1,60 +1,62 @@
-/*

- * Copyright 2004 The Apache Software Foundation

- * 

- * Licensed under the Apache License, Version 2.0 (the "License");

- * you may not use this file except in compliance with the License.

- * You may obtain a copy of the License at

- * 

- *     http://www.apache.org/licenses/LICENSE-2.0

- * 

- * Unless required by applicable law or agreed to in writing, software

- * distributed under the License is distributed on an "AS IS" BASIS,

- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

- * See the License for the specific language governing permissions and

- * limitations under the License.

- */

-

-package tutorial;

-

-import org.apache.avalon.framework.logger.AbstractLogEnabled;

-import org.apache.avalon.framework.activity.Initializable;

-import org.apache.avalon.framework.configuration.Configurable;

-import org.apache.avalon.framework.configuration.Configuration;

-import org.apache.avalon.framework.configuration.ConfigurationException;

-

-/**

- * A configurable component.

- *

- * @avalon.component version="1.0" name="simple"

- */

-public class HelloComponent extends AbstractLogEnabled 

-  implements Configurable, Initializable

-{

-    private String m_source = "undefined";

-

-   /**

-    * Configuration of the component by the container.  The 

-    * implementation get a child element named 'source' and 

-    * assigns the value of the element to a local variable.

-    *

-    * @param config the component configuration

-    * @exception ConfigurationException if a configuration error occurs

-    */

-    public void configure( Configuration config ) throws ConfigurationException

-    {

-        getLogger().info( "configuration stage" );

-        m_source = config.getChild( "source" ).getValue( "unknown" );

-    }

-

-   /**

-    * Initialization of the component by the container.

-    * @exception Exception if an initialization error occurs

-    */

-    public void initialize() throws Exception

-    {

-        getLogger().info( "initialization stage" );

-        final String message = 

-          "source: " + m_source;

-        getLogger().info( message );

-    }

-}

+/*
+ * Copyright 2004 The Apache Software Foundation
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tutorial;
+
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+
+/**
+ * A configurable component.
+ *
+ * @avalon.component version="1.0" name="simple"
+ */
+public class HelloComponent extends AbstractLogEnabled 
+    implements Configurable, Initializable
+{
+    private String m_source = "undefined";
+
+   /**
+    * Configuration of the component by the container.  The 
+    * implementation get a child element named 'source' and 
+    * assigns the value of the element to a local variable.
+    *
+    * @param config the component configuration
+    * @exception ConfigurationException if a configuration error occurs
+    */
+    public void configure( Configuration config ) 
+        throws ConfigurationException
+    {
+        getLogger().info( "configuration stage" );
+        m_source = config.getChild( "source" ).getValue( "unknown" );
+    }
+
+   /**
+    * Initialization of the component by the container.
+    * @exception Exception if an initialization error occurs
+    */
+    public void initialize() 
+        throws Exception
+    {
+        getLogger().info( "initialization stage" );
+        final String message = 
+          "source: " + m_source;
+        getLogger().info( message );
+    }
+}

Modified: 
avalon/trunk/central/laboratory/studio/core/templates/context/casting/DemoContextProvider.java
==============================================================================
--- 
avalon/trunk/central/laboratory/studio/core/templates/context/casting/DemoContextProvider.java
      (original)
+++ 
avalon/trunk/central/laboratory/studio/core/templates/context/casting/DemoContextProvider.java
      Sun Sep 12 20:23:35 2004
@@ -1,113 +1,114 @@
-/* 

- * Copyright 2004 Apache Software Foundation

- * Licensed  under the  Apache License,  Version 2.0  (the "License");

- * you may not use  this file  except in  compliance with the License.

- * You may obtain a copy of the License at 

- * 

- *   http://www.apache.org/licenses/LICENSE-2.0

- * 

- * Unless required by applicable law or agreed to in writing, software

- * distributed  under the  License is distributed on an "AS IS" BASIS,

- * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or

- * implied.

- * 

- * See the License for the specific language governing permissions and

- * limitations under the License.

- */

-

-package tutorial;

-

-import java.util.Map;

-import java.io.File;

-

-import org.apache.avalon.framework.context.Context;

-import org.apache.avalon.framework.context.DefaultContext;

-import org.apache.avalon.framework.context.ContextException;

-

-

-/**

- * A demonstration class that that we will instantiate via 

- * context directives within the component declaration.

- */

-public class DemoContextProvider extends DefaultContext implements DemoContext

-{

-

-   /**

-    * A custom context type implementation must provide

-    * the following constructor.

-    * @param entries a map of context entries

-    */

-    public DemoContextProvider( Context context )

-    {

-        super( context );

-    }

- 

-   /**

-    * Return the component name.

-    * @return the component name

-    */

-    public String getName()

-    {

-        try

-        {

-            return (String) super.get( "urn:avalon:name" );

-        }

-        catch( ContextException ce )

-        {

-            // should not happen 

-            throw new RuntimeException( ce.toString() );

-        }

-    }

-

-   /**

-    * Return the name of the partition assigned to the component.

-    * @return the partition name

-    */

-    public String getPartition()

-    {

-        try

-        {

-            return (String) super.get( "urn:avalon:partition" );

-        }

-        catch( ContextException ce )

-        {

-            // should not happen 

-            throw new RuntimeException( ce.toString() );

-        }

-    }

-

-   /**

-    * Return the home directory.

-    * @return the home directory

-    */

-    public File getHomeDirectory()

-    {

-        try

-        {

-            return (File) super.get( "urn:avalon:home" );

-        }

-        catch( ContextException ce )

-        {

-            // should not happen 

-            throw new RuntimeException( ce.toString() );

-        }

-    }

-

-

-   /**

-    * Return the temporary working directory.

-    * @return the temp directory

-    */

-    public File getWorkingDirectory()

-    {

-        try

-        {

-            return (File) super.get( "urn:avalon:temp" );

-        }

-        catch( ContextException ce )

-        {

-            // should not happen 

-            throw new RuntimeException( ce.toString() );

-        }

-    }

-}

+/* 
+ * Copyright 2004 Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tutorial;
+
+import java.util.Map;
+import java.io.File;
+
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.DefaultContext;
+import org.apache.avalon.framework.context.ContextException;
+
+
+/**
+ * A demonstration class that that we will instantiate via 
+ * context directives within the component declaration.
+ */
+public class DemoContextProvider extends DefaultContext 
+    implements DemoContext
+{
+
+   /**
+    * A custom context type implementation must provide
+    * the following constructor.
+    * @param entries a map of context entries
+    */
+    public DemoContextProvider( Context context )
+    {
+        super( context );
+    }
+ 
+   /**
+    * Return the component name.
+    * @return the component name
+    */
+    public String getName()
+    {
+        try
+        {
+            return (String) super.get( "urn:avalon:name" );
+        }
+        catch( ContextException ce )
+        {
+            // should not happen 
+            throw new RuntimeException( ce.toString() );
+        }
+    }
+
+   /**
+    * Return the name of the partition assigned to the component.
+    * @return the partition name
+    */
+    public String getPartition()
+    {
+        try
+        {
+            return (String) super.get( "urn:avalon:partition" );
+        }
+        catch( ContextException ce )
+        {
+            // should not happen 
+            throw new RuntimeException( ce.toString() );
+        }
+    }
+
+   /**
+    * Return the home directory.
+    * @return the home directory
+    */
+    public File getHomeDirectory()
+    {
+        try
+        {
+            return (File) super.get( "urn:avalon:home" );
+        }
+        catch( ContextException ce )
+        {
+            // should not happen 
+            throw new RuntimeException( ce.toString() );
+        }
+    }
+
+
+   /**
+    * Return the temporary working directory.
+    * @return the temp directory
+    */
+    public File getWorkingDirectory()
+    {
+        try
+        {
+            return (File) super.get( "urn:avalon:temp" );
+        }
+        catch( ContextException ce )
+        {
+            // should not happen 
+            throw new RuntimeException( ce.toString() );
+        }
+    }
+}

Modified: 
avalon/trunk/central/laboratory/studio/core/templates/context/casting/HelloComponent.java
==============================================================================
--- 
avalon/trunk/central/laboratory/studio/core/templates/context/casting/HelloComponent.java
   (original)
+++ 
avalon/trunk/central/laboratory/studio/core/templates/context/casting/HelloComponent.java
   Sun Sep 12 20:23:35 2004
@@ -1,55 +1,55 @@
-/* 

- * Copyright 2004 Apache Software Foundation

- * Licensed  under the  Apache License,  Version 2.0  (the "License");

- * you may not use  this file  except in  compliance with the License.

- * You may obtain a copy of the License at 

- * 

- *   http://www.apache.org/licenses/LICENSE-2.0

- * 

- * Unless required by applicable law or agreed to in writing, software

- * distributed  under the  License is distributed on an "AS IS" BASIS,

- * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or

- * implied.

- * 

- * See the License for the specific language governing permissions and

- * limitations under the License.

- */

-package tutorial;

-

-import org.apache.avalon.framework.logger.AbstractLogEnabled;

-import org.apache.avalon.framework.context.Contextualizable;

-import org.apache.avalon.framework.context.Context;

-import org.apache.avalon.framework.context.ContextException;

-

-/**

- * Component implementation that demonstrates type safe casting of a supplied 

- * context object.

- *

- * @avalon.component name="demo" lifestyle="singleton"

- */

-public class HelloComponent extends AbstractLogEnabled 

-  implements Contextualizable

-{

-

-   /**

-    * Contextualization of the component using a context

-    * class that implements a domain specific context interface.

-    *

-    * @avalon.context type="tutorial.DemoContext"

-    * @avalon.entry key="urn:avalon:name"

-    * @avalon.entry key="urn:avalon:partition"

-    * @avalon.entry key="urn:avalon:home" type="java.io.File"

-    * @avalon.entry key="urn:avalon:temp" type="java.io.File"

-    */

-    public void contextualize( Context context )

-      throws ContextException

-    {

-        DemoContext c = (DemoContext) context;

-        getLogger().info( "listing values resolved from domain specific context" );

-        getLogger().info( "supplied context class: " + context.getClass().getName() );

-        getLogger().info( "name: " + c.getName() );

-        getLogger().info( "partition: " + c.getPartition() );

-        getLogger().info( "home: " + c.getHomeDirectory() );

-        getLogger().info( "temp: " + c.getWorkingDirectory() );

-    }

-}

+/* 
+ * Copyright 2004 Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package tutorial;
+
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+
+/**
+ * Component implementation that demonstrates type safe casting of a supplied 
+ * context object.
+ *
+ * @avalon.component name="demo" lifestyle="singleton"
+ */
+public class HelloComponent extends AbstractLogEnabled 
+    implements Contextualizable
+{
+
+   /**
+    * Contextualization of the component using a context
+    * class that implements a domain specific context interface.
+    *
+    * @avalon.context type="tutorial.DemoContext"
+    * @avalon.entry key="urn:avalon:name"
+    * @avalon.entry key="urn:avalon:partition"
+    * @avalon.entry key="urn:avalon:home" type="java.io.File"
+    * @avalon.entry key="urn:avalon:temp" type="java.io.File"
+    */
+    public void contextualize( Context context )
+      throws ContextException
+    {
+        DemoContext c = (DemoContext) context;
+        getLogger().info( "listing values resolved from domain specific context" );
+        getLogger().info( "supplied context class: " + context.getClass().getName() );
+        getLogger().info( "name: " + c.getName() );
+        getLogger().info( "partition: " + c.getPartition() );
+        getLogger().info( "home: " + c.getHomeDirectory() );
+        getLogger().info( "temp: " + c.getWorkingDirectory() );
+    }
+}

Modified: 
avalon/trunk/central/laboratory/studio/core/templates/context/custom/HelloComponent.java
==============================================================================
--- 
avalon/trunk/central/laboratory/studio/core/templates/context/custom/HelloComponent.java
    (original)
+++ 
avalon/trunk/central/laboratory/studio/core/templates/context/custom/HelloComponent.java
    Sun Sep 12 20:23:35 2004
@@ -1,49 +1,49 @@
-/* 

- * Copyright 2004 Apache Software Foundation

- * Licensed  under the  Apache License,  Version 2.0  (the "License");

- * you may not use  this file  except in  compliance with the License.

- * You may obtain a copy of the License at 

- * 

- *   http://www.apache.org/licenses/LICENSE-2.0

- * 

- * Unless required by applicable law or agreed to in writing, software

- * distributed  under the  License is distributed on an "AS IS" BASIS,

- * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or

- * implied.

- * 

- * See the License for the specific language governing permissions and

- * limitations under the License.

- */

-package tutorial;

-

-import org.apache.avalon.framework.logger.AbstractLogEnabled;

-import org.apache.avalon.framework.context.Contextualizable;

-import org.apache.avalon.framework.context.Context;

-import org.apache.avalon.framework.context.ContextException;

-

-/**

- * Demonstration of a component that uses a constructed context entry.

- * 

- * @avalon.component name="demo" lifestyle="singleton"

- */

-public class HelloComponent extends AbstractLogEnabled 

-  implements Contextualizable

-{

-

-   /**

-    * Contextualization of the component by the container.

-    * The context supplied by the container shall contain

-    * a NumberCruncher instance as declared in the xinfo resource.

-    *

-    * @avalon.context

-    * @avalon.entry key="cruncher" type="tutorial.NumberCruncher"

-    */

-    public void contextualize( Context context )

-      throws ContextException

-    {

-        NumberCruncher cruncher = 

-          (NumberCruncher) context.get( "cruncher" );

-        float value = cruncher.crunch();

-        getLogger().info( "result: " + value );

-    }

-}

+/* 
+ * Copyright 2004 Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package tutorial;
+
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+
+/**
+ * Demonstration of a component that uses a constructed context entry.
+ * 
+ * @avalon.component name="demo" lifestyle="singleton"
+ */
+public class HelloComponent extends AbstractLogEnabled 
+    implements Contextualizable
+{
+
+   /**
+    * Contextualization of the component by the container.
+    * The context supplied by the container shall contain
+    * a NumberCruncher instance as declared in the xinfo resource.
+    *
+    * @avalon.context
+    * @avalon.entry key="cruncher" type="tutorial.NumberCruncher"
+    */
+    public void contextualize( Context context )
+      throws ContextException
+    {
+        NumberCruncher cruncher = 
+          (NumberCruncher) context.get( "cruncher" );
+        float value = cruncher.crunch();
+        getLogger().info( "result: " + value );
+    }
+}

Modified: 
avalon/trunk/central/laboratory/studio/core/templates/context/custom/NumberCruncher.java
==============================================================================
--- 
avalon/trunk/central/laboratory/studio/core/templates/context/custom/NumberCruncher.java
    (original)
+++ 
avalon/trunk/central/laboratory/studio/core/templates/context/custom/NumberCruncher.java
    Sun Sep 12 20:23:35 2004
@@ -1,43 +1,43 @@
-/* 

- * Copyright 2004 Apache Software Foundation

- * Licensed  under the  Apache License,  Version 2.0  (the "License");

- * you may not use  this file  except in  compliance with the License.

- * You may obtain a copy of the License at 

- * 

- *   http://www.apache.org/licenses/LICENSE-2.0

- * 

- * Unless required by applicable law or agreed to in writing, software

- * distributed  under the  License is distributed on an "AS IS" BASIS,

- * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or

- * implied.

- * 

- * See the License for the specific language governing permissions and

- * limitations under the License.

- */

-

-package tutorial;

-

-/**

- * A demonstration class that that we will instantiate via 

- * context directives within the component declaration.

- */

-public class NumberCruncher

-{

-    private final int m_primary;

-    private final float m_secondary;

-

-    public NumberCruncher( Integer primary, Double secondary )

-    {

-        m_primary = primary.intValue();

-        m_secondary = secondary.floatValue();

-    }

- 

-   /**

-    * Multiply the supplied constructor arguments together and 

-    * return the value.

-    */

-    public float crunch()

-    {

-       return ( m_secondary * m_primary );

-    }

-}

+/* 
+ * Copyright 2004 Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tutorial;
+
+/**
+ * A demonstration class that that we will instantiate via 
+ * context directives within the component declaration.
+ */
+public class NumberCruncher
+{
+    private final int m_primary;
+    private final float m_secondary;
+
+    public NumberCruncher( Integer primary, Float secondary )
+    {
+        m_primary = primary.intValue();
+        m_secondary = secondary.floatValue();
+    }
+ 
+   /**
+    * Multiply the supplied constructor arguments together and 
+    * return the value.
+    */
+    public float crunch()
+    {
+       return ( m_secondary * m_primary );
+    }
+}

Modified: 
avalon/trunk/central/laboratory/studio/core/templates/context/custom/block.xml
==============================================================================
--- avalon/trunk/central/laboratory/studio/core/templates/context/custom/block.xml     
 (original)
+++ avalon/trunk/central/laboratory/studio/core/templates/context/custom/block.xml     
 Sun Sep 12 20:23:35 2004
@@ -1,23 +1,23 @@
-

-<container name="tutorial">

-

-   <classloader>

-     <classpath>

-       <repository>

-         <resource id="avalon-framework:avalon-framework-impl" version="4.2.0"/>

-       </repository>

-     </classpath>

-   </classloader>

-

-   <component name="hello" class="tutorial.HelloComponent">

-     <context>

-       <entry key="cruncher">

-         <constructor class="tutorial.NumberCruncher">

-           <param class="java.lang.Integer">7</param>

-           <param class="java.lang.Double">1.5</param>

-         </constructor>

-       </entry>

-     </context>

-   </component>

-

-</container>

+
+<container name="tutorial">
+
+   <classloader>
+     <classpath>
+       <repository>
+         <resource id="avalon-framework:avalon-framework-impl" version="4.2.0"/>
+       </repository>
+     </classpath>
+   </classloader>
+
+   <component name="hello" class="tutorial.HelloComponent">
+     <context>
+       <entry key="cruncher">
+         <constructor class="tutorial.NumberCruncher">
+           <param class="java.lang.Integer">7</param>
+           <param class="java.lang.Float">1.5</param>
+         </constructor>
+       </entry>
+     </context>
+   </component>
+
+</container>

Modified: 
avalon/trunk/central/laboratory/studio/core/templates/context/plus/DemoContextProvider.java
==============================================================================
--- 
avalon/trunk/central/laboratory/studio/core/templates/context/plus/DemoContextProvider.java
 (original)
+++ 
avalon/trunk/central/laboratory/studio/core/templates/context/plus/DemoContextProvider.java
 Sun Sep 12 20:23:35 2004
@@ -1,61 +1,62 @@
-/* 

- * Copyright 2004 Apache Software Foundation

- * Licensed  under the  Apache License,  Version 2.0  (the "License");

- * you may not use  this file  except in  compliance with the License.

- * You may obtain a copy of the License at 

- * 

- *   http://www.apache.org/licenses/LICENSE-2.0

- * 

- * Unless required by applicable law or agreed to in writing, software

- * distributed  under the  License is distributed on an "AS IS" BASIS,

- * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or

- * implied.

- * 

- * See the License for the specific language governing permissions and

- * limitations under the License.

- */

-

-package tutorial;

-

-import java.util.Map;

-import java.io.File;

-

-import org.apache.avalon.framework.context.Context;

-import org.apache.avalon.framework.context.DefaultContext;

-import org.apache.avalon.framework.context.ContextException;

-

-

-/**

- * A demonstration class that that we will instantiate via 

- * context directives within the component declaration.

- */

-public class DemoContextProvider extends DefaultContext implements DemoContext

-{

-

-   /**

-    * A custom context type implementation must provide

-    * the following constructor.

-    * @param entries a map of context entries

-    */

-    public DemoContextProvider( Context context )

-    {

-        super( context );

-    }

- 

-   /**

-    * Return the working directory.

-    * @return the directory

-    */

-    public File getWorkingDirectory()

-    {

-        try

-        {

-            return (File) super.get( "urn:avalon:home" );

-        }

-        catch( ContextException ce )

-        {

-            // should not happen 

-            throw new RuntimeException( ce.toString() );

-        }

-    }

-}

+/* 
+ * Copyright 2004 Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tutorial;
+
+import java.util.Map;
+import java.io.File;
+
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.DefaultContext;
+import org.apache.avalon.framework.context.ContextException;
+
+
+/**
+ * A demonstration class that that we will instantiate via 
+ * context directives within the component declaration.
+ */
+public class DemoContextProvider extends DefaultContext 
+    implements DemoContext
+{
+
+   /**
+    * A custom context type implementation must provide
+    * the following constructor.
+    * @param entries a map of context entries
+    */
+    public DemoContextProvider( Context context )
+    {
+        super( context );
+    }
+ 
+   /**
+    * Return the working directory.
+    * @return the directory
+    */
+    public File getWorkingDirectory()
+    {
+        try
+        {
+            return (File) super.get( "urn:avalon:home" );
+        }
+        catch( ContextException ce )
+        {
+            // should not happen 
+            throw new RuntimeException( ce.toString() );
+        }
+    }
+}

Modified: 
avalon/trunk/central/laboratory/studio/core/templates/context/strategy/DemoContextualizationHandler.java
==============================================================================
--- 
avalon/trunk/central/laboratory/studio/core/templates/context/strategy/DemoContextualizationHandler.java
    (original)
+++ 
avalon/trunk/central/laboratory/studio/core/templates/context/strategy/DemoContextualizationHandler.java
    Sun Sep 12 20:23:35 2004
@@ -1,71 +1,71 @@
-/* 

- * Copyright 2004 Apache Software Foundation

- * Licensed  under the  Apache License,  Version 2.0  (the "License");

- * you may not use  this file  except in  compliance with the License.

- * You may obtain a copy of the License at 

- * 

- *   http://www.apache.org/licenses/LICENSE-2.0

- * 

- * Unless required by applicable law or agreed to in writing, software

- * distributed  under the  License is distributed on an "AS IS" BASIS,

- * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or

- * implied.

- * 

- * See the License for the specific language governing permissions and

- * limitations under the License.

- */

-

-package tutorial;

-

-import java.lang.reflect.Constructor;

-import java.util.Map;

-

-import org.apache.avalon.composition.model.ContextualizationHandler;

-import org.apache.avalon.framework.context.ContextException;

-import org.apache.avalon.framework.context.Context;

-

-/**

- * Definition of an extension handler that handles the Expoitable

- * extension stage interface.

- *

- * @avalon.component name="demo"

- * @avalon.extension id="tutorial.Contextualizable"

- * @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>

- */

-public class DemoContextualizationHandler implements ContextualizationHandler

-{

-    //=======================================================================

-    // Extension

-    //=======================================================================

-

-    /**

-     * Handle the contextualization stage of a component lifecycle.

-     * @param object the object to contextualize

-     * @param context the component context argument

-     * @exception ContextException if a contextualization error occurs

-     */

-    public void contextualize(

-      Object object, Context context )

-      throws ContextException

-    {

-

-        //

-        // based on the supplied context directives, the container supplied 

-        // map of base context entries and a classloader, build and apply

-        // a context object to the supplied target object

-        //

-

-        if( object instanceof Contextualizable )

-        {

-            StandardContext standard = new StandardContextImp( context );

-            ( (Contextualizable)object ).contextualize( standard );

-        }

-        else

-        {

-            final String error =

-              "Target object does not implement the "

-              + Contextualizable.class.getName() + " interface.";

-            throw new ContextException( error );

-        }

-    }

-}

+/* 
+ * Copyright 2004 Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tutorial;
+
+import java.lang.reflect.Constructor;
+import java.util.Map;
+
+import org.apache.avalon.composition.model.ContextualizationHandler;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Context;
+
+/**
+ * Definition of an extension handler that handles the Expoitable
+ * extension stage interface.
+ *
+ * @avalon.component name="demo"
+ * @avalon.extension id="tutorial.Contextualizable"
+ * @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
+ */
+public class DemoContextualizationHandler 
+    implements ContextualizationHandler
+{
+    //=======================================================================
+    // Extension
+    //=======================================================================
+
+    /**
+     * Handle the contextualization stage of a component lifecycle.
+     * @param object the object to contextualize
+     * @param context the component context argument
+     * @exception ContextException if a contextualization error occurs
+     */
+    public void contextualize( Object object, Context context )
+      throws ContextException
+    {
+
+        //
+        // based on the supplied context directives, the container supplied 
+        // map of base context entries and a classloader, build and apply
+        // a context object to the supplied target object
+        //
+
+        if( object instanceof Contextualizable )
+        {
+            StandardContext standard = new StandardContextImp( context );
+            ( (Contextualizable)object ).contextualize( standard );
+        }
+        else
+        {
+            final String error =
+              "Target object does not implement the "
+              + Contextualizable.class.getName() + " interface.";
+            throw new ContextException( error );
+        }
+    }
+}

Modified: 
avalon/trunk/central/laboratory/studio/core/templates/context/strategy/StandardContextImp.java
==============================================================================
--- 
avalon/trunk/central/laboratory/studio/core/templates/context/strategy/StandardContextImp.java
      (original)
+++ 
avalon/trunk/central/laboratory/studio/core/templates/context/strategy/StandardContextImp.java
      Sun Sep 12 20:23:35 2004
@@ -1,118 +1,119 @@
-/* 

- * Copyright 2004 Apache Software Foundation

- * Licensed  under the  Apache License,  Version 2.0  (the "License");

- * you may not use  this file  except in  compliance with the License.

- * You may obtain a copy of the License at 

- * 

- *   http://www.apache.org/licenses/LICENSE-2.0

- * 

- * Unless required by applicable law or agreed to in writing, software

- * distributed  under the  License is distributed on an "AS IS" BASIS,

- * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or

- * implied.

- * 

- * See the License for the specific language governing permissions and

- * limitations under the License.

- */

-

-package tutorial;

-

-import java.io.File;

-import java.util.Map;

-

-import org.apache.avalon.framework.context.ContextException;

-import org.apache.avalon.framework.context.DefaultContext;

-import org.apache.avalon.framework.context.Context;

-

-/**

- * This is example of a custom context class.  It is used in the demonsteation

- * of a context management fraework to show how a context class can be

- * supplied to a component declaring a context interface criteria.

- *

- * @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>

- */

-public class StandardContextImp extends DefaultContext implements StandardContext

-{

-

-    //-----------------------------------------------------------------

-    // constructor

-    //-----------------------------------------------------------------

-

-    /**

-     * Creation of a new custom context instance.

-     * @param map the context name/value map

-     * @param parent a possibly parent context

-     */

-    public StandardContextImp( Context context ) throws ContextException

-    {

-        super( context );

-    }

-

-    //-----------------------------------------------------------------

-    // StandardContext

-    //-----------------------------------------------------------------

-

-    /**

-     * Return the name assigned to the component

-     * @return the name

-     */

-    public String getName()

-    {

-        try

-        {

-            return (String)super.get( StandardContext.NAME_KEY );

-        }

-        catch( Throwable e )

-        {

-            throw new IllegalStateException( StandardContext.NAME_KEY );

-        }

-    }

-

-    /**

-     * Return the partition name assigned to the component

-     * @return the partition name

-     * @exception IllegalStateException if the partition name is undefined

-     */

-    public String getPartitionName()

-    {

-        try

-        {

-            return (String)super.get( StandardContext.PARTITION_KEY );

-        }

-        catch( Throwable e )

-        {

-            throw new IllegalStateException( StandardContext.PARTITION_KEY );

-        }

-    }

-

-    /**

-     * Returns the home directory for this component.

-     * @return the home directory

-     */

-    public File getHomeDirectory()

-    {

-        try

-        {

-            return (File)super.get( StandardContext.HOME_KEY );

-        }

-        catch( Throwable e )

-        {

-            throw new IllegalStateException( StandardContext.HOME_KEY );

-        }

-    }

-

-    /**

-     * @return the working directory

-     */

-    public File getWorkingDirectory()

-    {

-        try

-        {

-            return (File)super.get( StandardContext.WORKING_KEY );

-        }

-        catch( Throwable e )

-        {

-            throw new IllegalStateException( StandardContext.WORKING_KEY );

-        }

-    }

-}

+/* 
+ * Copyright 2004 Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tutorial;
+
+import java.io.File;
+import java.util.Map;
+
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.DefaultContext;
+import org.apache.avalon.framework.context.Context;
+
+/**
+ * This is example of a custom context class.  It is used in the demonsteation
+ * of a context management fraework to show how a context class can be
+ * supplied to a component declaring a context interface criteria.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
+ */
+public class StandardContextImp extends DefaultContext 
+    implements StandardContext
+{
+
+    //-----------------------------------------------------------------
+    // constructor
+    //-----------------------------------------------------------------
+
+    /**
+     * Creation of a new custom context instance.
+     * @param map the context name/value map
+     * @param parent a possibly parent context
+     */
+    public StandardContextImp( Context context ) throws ContextException
+    {
+        super( context );
+    }
+
+    //-----------------------------------------------------------------
+    // StandardContext
+    //-----------------------------------------------------------------
+
+    /**
+     * Return the name assigned to the component
+     * @return the name
+     */
+    public String getName()
+    {
+        try
+        {
+            return (String) super.get( StandardContext.NAME_KEY );
+        }
+        catch( Throwable e )
+        {
+            throw new IllegalStateException( StandardContext.NAME_KEY );
+        }
+    }
+
+    /**
+     * Return the partition name assigned to the component
+     * @return the partition name
+     * @exception IllegalStateException if the partition name is undefined
+     */
+    public String getPartitionName()
+    {
+        try
+        {
+            return (String) super.get( StandardContext.PARTITION_KEY );
+        }
+        catch( Throwable e )
+        {
+            throw new IllegalStateException( StandardContext.PARTITION_KEY );
+        }
+    }
+
+    /**
+     * Returns the home directory for this component.
+     * @return the home directory
+     */
+    public File getHomeDirectory()
+    {
+        try
+        {
+            return (File) super.get( StandardContext.HOME_KEY );
+        }
+        catch( Throwable e )
+        {
+            throw new IllegalStateException( StandardContext.HOME_KEY );
+        }
+    }
+
+    /**
+     * @return the working directory
+     */
+    public File getWorkingDirectory()
+    {
+        try
+        {
+            return (File) super.get( StandardContext.WORKING_KEY );
+        }
+        catch( Throwable e )
+        {
+            throw new IllegalStateException( StandardContext.WORKING_KEY );
+        }
+    }
+}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to