You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by ep...@apache.org on 2004/11/04 21:49:25 UTC

cvs commit: jakarta-turbine-fulcrum/mimetype/api/src/java/org/apache/fulcrum/mimetype MimeTypeServiceFacade.java

epugh       2004/11/04 12:49:25

  Modified:    mimetype/impl/src/java/org/apache/fulcrum/mimetype
                        DefaultMimeTypeService.java
               mimetype/impl project.xml
  Added:       mimetype/impl/src/test/org/apache/fulcrum/mimetype
                        MimeTypeServiceFacadeTest.java
               mimetype/api/src/java/org/apache/fulcrum/mimetype
                        MimeTypeServiceFacade.java
  Log:
  Add a facade helper class
  
  Revision  Changes    Path
  1.1                  jakarta-turbine-fulcrum/mimetype/impl/src/test/org/apache/fulcrum/mimetype/MimeTypeServiceFacadeTest.java
  
  Index: MimeTypeServiceFacadeTest.java
  ===================================================================
  package org.apache.fulcrum.mimetype;
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *     "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache" or
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  //
  import org.apache.fulcrum.testcontainer.BaseUnitTest;
  
  
  /**
   * Test the MimeTypeServiceFacade.
   *
   * @author <a href="epugh@upstate.com">Eric Pugh</a>
   * @version $Id: MimeTypeServiceFacadeTest.java,v 1.1 2004/11/04 20:49:25 epugh Exp $
   */
  public class MimeTypeServiceFacadeTest extends BaseUnitTest
  {
      /**
       * Defines the testcase name for JUnit.
       *
       * @param name the testcase's name.
       */
      public MimeTypeServiceFacadeTest(String name)
      {
          super(name);
      }
  
  
      public void testFacadeNotConfigured() throws Exception
      {
          assertNull(MimeTypeServiceFacade.getService());
          
      }
  
      public void testFacadeConfigured() throws Exception
      {
          // this.lookup causes the service to be configured.
          this.lookup(MimeTypeService.ROLE);
          assertNotNull(MimeTypeServiceFacade.getService());
      }
  
  }
  
  
  
  1.5       +13 -2     jakarta-turbine-fulcrum/mimetype/impl/src/java/org/apache/fulcrum/mimetype/DefaultMimeTypeService.java
  
  Index: DefaultMimeTypeService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/mimetype/impl/src/java/org/apache/fulcrum/mimetype/DefaultMimeTypeService.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultMimeTypeService.java	30 Jun 2004 13:35:53 -0000	1.4
  +++ DefaultMimeTypeService.java	4 Nov 2004 20:49:25 -0000	1.5
  @@ -63,6 +63,8 @@
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.avalon.framework.service.Serviceable;
   import org.apache.fulcrum.mimetype.util.CharSetMap;
   import org.apache.fulcrum.mimetype.util.MimeType;
   import org.apache.fulcrum.mimetype.util.MimeTypeMap;
  @@ -92,7 +94,7 @@
    */
   public class DefaultMimeTypeService
       extends AbstractLogEnabled
  -    implements MimeTypeService, Configurable, Initializable, Contextualizable
  +    implements MimeTypeService, Configurable, Initializable, Contextualizable, Serviceable
   {
       private String applicationRoot;
       /**
  @@ -360,4 +362,13 @@
           this.context = context;
           this.applicationRoot = context.get( "urn:avalon:home" ).toString();
       }
  +    
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void service( ServiceManager manager) {
  +
  +        MimeTypeServiceFacade.setMimeTypeService(this);
  +
  +    }    
   }
  
  
  
  1.8       +1 -1      jakarta-turbine-fulcrum/mimetype/impl/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/mimetype/impl/project.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- project.xml	1 Nov 2004 13:29:22 -0000	1.7
  +++ project.xml	4 Nov 2004 20:49:25 -0000	1.8
  @@ -9,7 +9,7 @@
       <dependency>
         <groupId>fulcrum</groupId>
         <artifactId>fulcrum-mimetype-api</artifactId>
  -      <version>1.0.4</version>
  +      <version>1.0.4-dev</version>
       </dependency>
   
       <!--  Needed only for testing -->
  
  
  
  1.1                  jakarta-turbine-fulcrum/mimetype/api/src/java/org/apache/fulcrum/mimetype/MimeTypeServiceFacade.java
  
  Index: MimeTypeServiceFacade.java
  ===================================================================
  package org.apache.fulcrum.mimetype;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Turbine" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  
  /**
   * <p> This is a facade class for {@link MimeTypeService}.
   *
   * <p> This class provides static methods that retrieve the configured
   *  implementation of {@link
   * MimeTypeService} and perform certain operations on it.  It uses
   * constants defined in {@link MimeTypeService} interface for accessing
   * the service's properties and default values for them.
   *
   * @author <a href="mailto:epugh@opensourceconnections.com">Eric Pugh</a>
   * @version $Id: MimeTypeServiceFacade.java,v 1.1 2004/11/04 20:49:25 epugh Exp $
   */
  public class MimeTypeServiceFacade
  {
      private static MimeTypeService mimetypeService;
  
      public static void setMimeTypeService(MimeTypeService uploadService){
          MimeTypeServiceFacade.mimetypeService = uploadService;
      }
  
      /**
       * <p> Retrieves an instance of system's configured implementation
       * of <code>UploadService</code>
       *
       * @return An instance of UploadService
       */
      public static MimeTypeService getService()
      {
          return mimetypeService;
      }
  
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-turbine-fulcrum/mimetype/api/src/java/org/apache/fulcrum/mimetype

Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
Siegfried Goeschl <si...@it20one.at> writes:

>Hi Henning,

>not sure about understanding it correctly but I thought about 
>implementing such a thingie a while ago ...

>+) lookup a service component in the container, let's say Turbine
>+) if the service component is not found lookup services implementing 
>org.apache.avalon.framework.service.ServiceManager (ECM and Merlin)
>+) invoke ServiceManager.hasService() and ServiceManager.lookup() on 
>this/these service(s)

>this allows looking up services no matter where they are instantiated as 
>long as a unique service name is used.

Yep, this is what I meant.

	Regards
		Henning



>Henning P. Schmiedehausen wrote:

>>"Eric Pugh" <ep...@upstate.com> writes:
>>
>>Well, we do already have such a method in Turbine:
>>
>>o.a.t.services.ServiceManager::getService(String serviceName)
>>
>>Currently, an implementation of the ServiceManager is retrieved by calling 
>>TurbineServices.getInstance(). This returns the old service broker.
>>
>>The _cool_ thing here would be to return a service manager, that is
>>able to retrieve the Service from the configured container _and_ the
>>old services system. This would make transition from old/bundled
>>services to Avalon really smooth.
>>
>>For the moment (we are still at milestone level) we can
>>experiment. Getting an "Avalon only" implementation of the
>>ServiceManager interface would IMHO be the way to go. In the end, we
>>can make the whole services system pluggable.
>>
>>	Regards
>>		Henning
>>
>>  
>>
>>>I thought about this, and cursed myself as I added it.   The reason I added
>>>it was I was happily trying to test the latest -dev version of
>>>fulcrum-mimetype by adding it to Scarab, which was using the old stratum
>>>based version.
>>>    
>>>
>>
>>  
>>
>>>So, as I added things in, I realized that Scarab every was using a
>>>TurbineMimetypeService, which was a static facade.  And I thought, okay,
>>>instead of looking up the component, I'll just do what fulcrum-upload has,
>>>and use a facade.  So I added this.  But, since I didn't like it, I just
>>>gave it a getService() method to highlight that this is just a helper.
>>>Still, icky.
>>>    
>>>
>>
>>  
>>
>>>My problem with getting directly the component from the servicebroker is
>>>that I am always loading from different containers.  One container in unit
>>>testing, another in running as a webapp.
>>>    
>>>
>>
>>  
>>
>>>One way I worked around this was to add a static ComponentLocator to my
>>>project that was custom to what I needed.
>>>    
>>>
>>
>>  
>>
>>>So I would do:
>>>ComponentLocator.getMimeTypeService()
>>>    
>>>
>>
>>  
>>
>>>and that would do the lookup.  If I needed to load up a mock version of
>>>MimeTypeService, well, ComponentLocator has a setMimeTypeService that I
>>>could use, and ComponentLocator.mimeTypeService was a private static
>>>variable...
>>>    
>>>
>>
>>  
>>
>>>I am now thinking that this is the way I should have gone for Scarab.
>>>Replace all these facades in scarab with a call to
>>>ComponentLocator.getSomeService() that actually would do the lookup if
>>>required and return it..
>>>    
>>>
>>
>>  
>>
>>>If I do this route, then maybe the other facade guys should be gutted or
>>>removed from Fulcrum?  So, in Turbine, we might have a
>>>TurbineCompoenntLocator static class that we use for all the services (like
>>>pool, factory, etc) that turbine needs....
>>>    
>>>
>>
>>  
>>
>>>What are your opinions?
>>>    
>>>
>>
>>  
>>
>>>Eric
>>>    
>>>
>>
>>  
>>
>>>>-----Original Message-----
>>>>From: Henning P. Schmiedehausen [mailto:hps@intermeta.de]
>>>>Sent: Friday, November 05, 2004 9:06 AM
>>>>To: turbine-dev@jakarta.apache.org
>>>>Subject: Re: cvs commit:
>>>>jakarta-turbine-fulcrum/mimetype/api/src/java/org/apache/fulcrum/mimetyp
>>>>e MimeTypeServiceFacade.java
>>>>
>>>>
>>>>epugh@apache.org writes:
>>>>
>>>>      
>>>>
>>>>> Log:
>>>>> Add a facade helper class
>>>>>        
>>>>>
>>>>Personally, I consider the addition of the static facades to the
>>>>Turbine services (yes, I am very guilty of my share) one of the bigger
>>>>mistakes of Turbine.
>>>>
>>>>Is it so hard to get a Service reference from the container?
>>>>
>>>>      
>>>>
>>>>> +
>>>>> +    /**
>>>>> +     * Avalon component lifecycle method
>>>>> +     */
>>>>> +    public void service( ServiceManager manager) {
>>>>> +
>>>>> +        MimeTypeServiceFacade.setMimeTypeService(this);
>>>>> +
>>>>> +    }
>>>>>        
>>>>>
>>>>Uh; while this looks IoC style, it connects the implementation to the
>>>>facade which is IIRC a violation of the facade pattern (where it
>>>>should be the other way around). And users are in for really nasty
>>>>surprises if their Service implementation forgets to to this setting.
>>>>
>>>>(And while I'm already at it: a "setService()" setter would match the
>>>>getService() getter... :-) )
>>>>
>>>>	Regards
>>>>		Henning
>>>>
>>>>--
>>>>Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
>>>>hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/
>>>>
>>>>RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
>>>>   Linux, Java, perl, Solaris -- Consulting, Training, Development
>>>>
>>>>What is more important to you...
>>>>   [ ] Product Security
>>>>or [ ] Quality of Sales and Marketing Support
>>>>              -- actual question from a Microsoft customer survey
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
>>>>      
>>>>
>>
>>
>>  
>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
>>>    
>>>
>>
>>  
>>


>-- 
>Siegfried Goeschl

>IT20one GmbH
>Bandgasse 2/22
>1070 Wien




>---------------------------------------------------------------------
>To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: turbine-dev-help@jakarta.apache.org

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

What is more important to you...
   [ ] Product Security
or [ ] Quality of Sales and Marketing Support
              -- actual question from a Microsoft customer survey

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


RE: cvs commit: jakarta-turbine-fulcrum/mimetype/api/src/java/org/apache/fulcrum/mimetype MimeTypeServiceFacade.java

Posted by Eric Pugh <ep...@upstate.com>.
Sigi,

I think that is exactly what we are talking about.  I've wanted to be able
to have some sort of object using the Composite pattern where we would just
merge together lots of different types of ServiceManagers.  I pretty much
see them implementing two methods:
public Object lookup(Object key)
public void release(Object object)
public boolean has(Object key)


And pretty much the semantics would be the first one return true to the
has() call would return it.  This to me is a very Turbine specific chunk of
code, so if you get motivated (and I hope you do) lets apply it to o.a.t*
tree.

Henning,
I agree with the static lookups for Fulcrum components.  I think they are a
*smell* as well that was left over from olden times.  I'll go through and
clear them out before calling for a vote.  In many ways *how* you lookup
components is VERY implementation/project specific.

Eric

> -----Original Message-----
> From: Siegfried Goeschl [mailto:siegfried.goeschl@it20one.at]
> Sent: Friday, November 05, 2004 3:16 PM
> To: Turbine Developers List
> Subject: Re: cvs commit:
> jakarta-turbine-fulcrum/mimetype/api/src/java/org/apache/fulcrum/mimetyp
> e MimeTypeServiceFacade.java
>
>
> Hi Henning,
>
> not sure about understanding it correctly but I thought about
> implementing such a thingie a while ago ...
>
> +) lookup a service component in the container, let's say Turbine
> +) if the service component is not found lookup services implementing
> org.apache.avalon.framework.service.ServiceManager (ECM and Merlin)
> +) invoke ServiceManager.hasService() and ServiceManager.lookup() on
> this/these service(s)
>
> this allows looking up services no matter where they are instantiated as
> long as a unique service name is used.
>
> Cheers,
>
> Siegfried Goeschl
>
>
> Henning P. Schmiedehausen wrote:
>
> >"Eric Pugh" <ep...@upstate.com> writes:
> >
> >Well, we do already have such a method in Turbine:
> >
> >o.a.t.services.ServiceManager::getService(String serviceName)
> >
> >Currently, an implementation of the ServiceManager is retrieved
> by calling
> >TurbineServices.getInstance(). This returns the old service broker.
> >
> >The _cool_ thing here would be to return a service manager, that is
> >able to retrieve the Service from the configured container _and_ the
> >old services system. This would make transition from old/bundled
> >services to Avalon really smooth.
> >
> >For the moment (we are still at milestone level) we can
> >experiment. Getting an "Avalon only" implementation of the
> >ServiceManager interface would IMHO be the way to go. In the end, we
> >can make the whole services system pluggable.
> >
> >	Regards
> >		Henning
> >
> >
> >
> >>I thought about this, and cursed myself as I added it.   The
> reason I added
> >>it was I was happily trying to test the latest -dev version of
> >>fulcrum-mimetype by adding it to Scarab, which was using the old stratum
> >>based version.
> >>
> >>
> >
> >
> >
> >>So, as I added things in, I realized that Scarab every was using a
> >>TurbineMimetypeService, which was a static facade.  And I thought, okay,
> >>instead of looking up the component, I'll just do what
> fulcrum-upload has,
> >>and use a facade.  So I added this.  But, since I didn't like it, I just
> >>gave it a getService() method to highlight that this is just a helper.
> >>Still, icky.
> >>
> >>
> >
> >
> >
> >>My problem with getting directly the component from the servicebroker is
> >>that I am always loading from different containers.  One
> container in unit
> >>testing, another in running as a webapp.
> >>
> >>
> >
> >
> >
> >>One way I worked around this was to add a static ComponentLocator to my
> >>project that was custom to what I needed.
> >>
> >>
> >
> >
> >
> >>So I would do:
> >>ComponentLocator.getMimeTypeService()
> >>
> >>
> >
> >
> >
> >>and that would do the lookup.  If I needed to load up a mock version of
> >>MimeTypeService, well, ComponentLocator has a setMimeTypeService that I
> >>could use, and ComponentLocator.mimeTypeService was a private static
> >>variable...
> >>
> >>
> >
> >
> >
> >>I am now thinking that this is the way I should have gone for Scarab.
> >>Replace all these facades in scarab with a call to
> >>ComponentLocator.getSomeService() that actually would do the lookup if
> >>required and return it..
> >>
> >>
> >
> >
> >
> >>If I do this route, then maybe the other facade guys should be gutted or
> >>removed from Fulcrum?  So, in Turbine, we might have a
> >>TurbineCompoenntLocator static class that we use for all the
> services (like
> >>pool, factory, etc) that turbine needs....
> >>
> >>
> >
> >
> >
> >>What are your opinions?
> >>
> >>
> >
> >
> >
> >>Eric
> >>
> >>
> >
> >
> >
> >>>-----Original Message-----
> >>>From: Henning P. Schmiedehausen [mailto:hps@intermeta.de]
> >>>Sent: Friday, November 05, 2004 9:06 AM
> >>>To: turbine-dev@jakarta.apache.org
> >>>Subject: Re: cvs commit:
> >>>jakarta-turbine-fulcrum/mimetype/api/src/java/org/apache/fulcru
> m/mimetyp
> >>>e MimeTypeServiceFacade.java
> >>>
> >>>
> >>>epugh@apache.org writes:
> >>>
> >>>
> >>>
> >>>> Log:
> >>>> Add a facade helper class
> >>>>
> >>>>
> >>>Personally, I consider the addition of the static facades to the
> >>>Turbine services (yes, I am very guilty of my share) one of the bigger
> >>>mistakes of Turbine.
> >>>
> >>>Is it so hard to get a Service reference from the container?
> >>>
> >>>
> >>>
> >>>> +
> >>>> +    /**
> >>>> +     * Avalon component lifecycle method
> >>>> +     */
> >>>> +    public void service( ServiceManager manager) {
> >>>> +
> >>>> +        MimeTypeServiceFacade.setMimeTypeService(this);
> >>>> +
> >>>> +    }
> >>>>
> >>>>
> >>>Uh; while this looks IoC style, it connects the implementation to the
> >>>facade which is IIRC a violation of the facade pattern (where it
> >>>should be the other way around). And users are in for really nasty
> >>>surprises if their Service implementation forgets to to this setting.
> >>>
> >>>(And while I'm already at it: a "setService()" setter would match the
> >>>getService() getter... :-) )
> >>>
> >>>	Regards
> >>>		Henning
> >>>
> >>>--
> >>>Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
> >>>hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/
> >>>
> >>>RedHat Certified Engineer -- Jakarta Turbine Development  --
> hero for hire
> >>>   Linux, Java, perl, Solaris -- Consulting, Training, Development
> >>>
> >>>What is more important to you...
> >>>   [ ] Product Security
> >>>or [ ] Quality of Sales and Marketing Support
> >>>              -- actual question from a Microsoft customer survey
> >>>
> >>>---------------------------------------------------------------------
> >>>To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> >>>For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
> >>>
> >>>
> >
> >
> >
> >
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
> >>
> >>
> >
> >
> >
>
>
> --
> Siegfried Goeschl
>
> IT20one GmbH
> Bandgasse 2/22
> 1070 Wien
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-turbine-fulcrum/mimetype/api/src/java/org/apache/fulcrum/mimetype MimeTypeServiceFacade.java

Posted by Siegfried Goeschl <si...@it20one.at>.
Hi Henning,

not sure about understanding it correctly but I thought about 
implementing such a thingie a while ago ...

+) lookup a service component in the container, let's say Turbine
+) if the service component is not found lookup services implementing 
org.apache.avalon.framework.service.ServiceManager (ECM and Merlin)
+) invoke ServiceManager.hasService() and ServiceManager.lookup() on 
this/these service(s)

this allows looking up services no matter where they are instantiated as 
long as a unique service name is used.

Cheers,

Siegfried Goeschl


Henning P. Schmiedehausen wrote:

>"Eric Pugh" <ep...@upstate.com> writes:
>
>Well, we do already have such a method in Turbine:
>
>o.a.t.services.ServiceManager::getService(String serviceName)
>
>Currently, an implementation of the ServiceManager is retrieved by calling 
>TurbineServices.getInstance(). This returns the old service broker.
>
>The _cool_ thing here would be to return a service manager, that is
>able to retrieve the Service from the configured container _and_ the
>old services system. This would make transition from old/bundled
>services to Avalon really smooth.
>
>For the moment (we are still at milestone level) we can
>experiment. Getting an "Avalon only" implementation of the
>ServiceManager interface would IMHO be the way to go. In the end, we
>can make the whole services system pluggable.
>
>	Regards
>		Henning
>
>  
>
>>I thought about this, and cursed myself as I added it.   The reason I added
>>it was I was happily trying to test the latest -dev version of
>>fulcrum-mimetype by adding it to Scarab, which was using the old stratum
>>based version.
>>    
>>
>
>  
>
>>So, as I added things in, I realized that Scarab every was using a
>>TurbineMimetypeService, which was a static facade.  And I thought, okay,
>>instead of looking up the component, I'll just do what fulcrum-upload has,
>>and use a facade.  So I added this.  But, since I didn't like it, I just
>>gave it a getService() method to highlight that this is just a helper.
>>Still, icky.
>>    
>>
>
>  
>
>>My problem with getting directly the component from the servicebroker is
>>that I am always loading from different containers.  One container in unit
>>testing, another in running as a webapp.
>>    
>>
>
>  
>
>>One way I worked around this was to add a static ComponentLocator to my
>>project that was custom to what I needed.
>>    
>>
>
>  
>
>>So I would do:
>>ComponentLocator.getMimeTypeService()
>>    
>>
>
>  
>
>>and that would do the lookup.  If I needed to load up a mock version of
>>MimeTypeService, well, ComponentLocator has a setMimeTypeService that I
>>could use, and ComponentLocator.mimeTypeService was a private static
>>variable...
>>    
>>
>
>  
>
>>I am now thinking that this is the way I should have gone for Scarab.
>>Replace all these facades in scarab with a call to
>>ComponentLocator.getSomeService() that actually would do the lookup if
>>required and return it..
>>    
>>
>
>  
>
>>If I do this route, then maybe the other facade guys should be gutted or
>>removed from Fulcrum?  So, in Turbine, we might have a
>>TurbineCompoenntLocator static class that we use for all the services (like
>>pool, factory, etc) that turbine needs....
>>    
>>
>
>  
>
>>What are your opinions?
>>    
>>
>
>  
>
>>Eric
>>    
>>
>
>  
>
>>>-----Original Message-----
>>>From: Henning P. Schmiedehausen [mailto:hps@intermeta.de]
>>>Sent: Friday, November 05, 2004 9:06 AM
>>>To: turbine-dev@jakarta.apache.org
>>>Subject: Re: cvs commit:
>>>jakarta-turbine-fulcrum/mimetype/api/src/java/org/apache/fulcrum/mimetyp
>>>e MimeTypeServiceFacade.java
>>>
>>>
>>>epugh@apache.org writes:
>>>
>>>      
>>>
>>>> Log:
>>>> Add a facade helper class
>>>>        
>>>>
>>>Personally, I consider the addition of the static facades to the
>>>Turbine services (yes, I am very guilty of my share) one of the bigger
>>>mistakes of Turbine.
>>>
>>>Is it so hard to get a Service reference from the container?
>>>
>>>      
>>>
>>>> +
>>>> +    /**
>>>> +     * Avalon component lifecycle method
>>>> +     */
>>>> +    public void service( ServiceManager manager) {
>>>> +
>>>> +        MimeTypeServiceFacade.setMimeTypeService(this);
>>>> +
>>>> +    }
>>>>        
>>>>
>>>Uh; while this looks IoC style, it connects the implementation to the
>>>facade which is IIRC a violation of the facade pattern (where it
>>>should be the other way around). And users are in for really nasty
>>>surprises if their Service implementation forgets to to this setting.
>>>
>>>(And while I'm already at it: a "setService()" setter would match the
>>>getService() getter... :-) )
>>>
>>>	Regards
>>>		Henning
>>>
>>>--
>>>Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
>>>hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/
>>>
>>>RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
>>>   Linux, Java, perl, Solaris -- Consulting, Training, Development
>>>
>>>What is more important to you...
>>>   [ ] Product Security
>>>or [ ] Quality of Sales and Marketing Support
>>>              -- actual question from a Microsoft customer survey
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
>>>      
>>>
>
>
>  
>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
>>    
>>
>
>  
>


-- 
Siegfried Goeschl

IT20one GmbH
Bandgasse 2/22
1070 Wien




---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-turbine-fulcrum/mimetype/api/src/java/org/apache/fulcrum/mimetype MimeTypeServiceFacade.java

Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
"Eric Pugh" <ep...@upstate.com> writes:

Well, we do already have such a method in Turbine:

o.a.t.services.ServiceManager::getService(String serviceName)

Currently, an implementation of the ServiceManager is retrieved by calling 
TurbineServices.getInstance(). This returns the old service broker.

The _cool_ thing here would be to return a service manager, that is
able to retrieve the Service from the configured container _and_ the
old services system. This would make transition from old/bundled
services to Avalon really smooth.

For the moment (we are still at milestone level) we can
experiment. Getting an "Avalon only" implementation of the
ServiceManager interface would IMHO be the way to go. In the end, we
can make the whole services system pluggable.

	Regards
		Henning

>I thought about this, and cursed myself as I added it.   The reason I added
>it was I was happily trying to test the latest -dev version of
>fulcrum-mimetype by adding it to Scarab, which was using the old stratum
>based version.

>So, as I added things in, I realized that Scarab every was using a
>TurbineMimetypeService, which was a static facade.  And I thought, okay,
>instead of looking up the component, I'll just do what fulcrum-upload has,
>and use a facade.  So I added this.  But, since I didn't like it, I just
>gave it a getService() method to highlight that this is just a helper.
>Still, icky.

>My problem with getting directly the component from the servicebroker is
>that I am always loading from different containers.  One container in unit
>testing, another in running as a webapp.

>One way I worked around this was to add a static ComponentLocator to my
>project that was custom to what I needed.

>So I would do:
>ComponentLocator.getMimeTypeService()

>and that would do the lookup.  If I needed to load up a mock version of
>MimeTypeService, well, ComponentLocator has a setMimeTypeService that I
>could use, and ComponentLocator.mimeTypeService was a private static
>variable...

>I am now thinking that this is the way I should have gone for Scarab.
>Replace all these facades in scarab with a call to
>ComponentLocator.getSomeService() that actually would do the lookup if
>required and return it..

>If I do this route, then maybe the other facade guys should be gutted or
>removed from Fulcrum?  So, in Turbine, we might have a
>TurbineCompoenntLocator static class that we use for all the services (like
>pool, factory, etc) that turbine needs....

>What are your opinions?

>Eric

>> -----Original Message-----
>> From: Henning P. Schmiedehausen [mailto:hps@intermeta.de]
>> Sent: Friday, November 05, 2004 9:06 AM
>> To: turbine-dev@jakarta.apache.org
>> Subject: Re: cvs commit:
>> jakarta-turbine-fulcrum/mimetype/api/src/java/org/apache/fulcrum/mimetyp
>> e MimeTypeServiceFacade.java
>>
>>
>> epugh@apache.org writes:
>>
>> >  Log:
>> >  Add a facade helper class
>>
>> Personally, I consider the addition of the static facades to the
>> Turbine services (yes, I am very guilty of my share) one of the bigger
>> mistakes of Turbine.
>>
>> Is it so hard to get a Service reference from the container?
>>
>> >  +
>> >  +    /**
>> >  +     * Avalon component lifecycle method
>> >  +     */
>> >  +    public void service( ServiceManager manager) {
>> >  +
>> >  +        MimeTypeServiceFacade.setMimeTypeService(this);
>> >  +
>> >  +    }
>>
>> Uh; while this looks IoC style, it connects the implementation to the
>> facade which is IIRC a violation of the facade pattern (where it
>> should be the other way around). And users are in for really nasty
>> surprises if their Service implementation forgets to to this setting.
>>
>> (And while I'm already at it: a "setService()" setter would match the
>> getService() getter... :-) )
>>
>> 	Regards
>> 		Henning
>>
>> --
>> Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
>> hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/
>>
>> RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
>>    Linux, Java, perl, Solaris -- Consulting, Training, Development
>>
>> What is more important to you...
>>    [ ] Product Security
>> or [ ] Quality of Sales and Marketing Support
>>               -- actual question from a Microsoft customer survey
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


>---------------------------------------------------------------------
>To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: turbine-dev-help@jakarta.apache.org

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

What is more important to you...
   [ ] Product Security
or [ ] Quality of Sales and Marketing Support
              -- actual question from a Microsoft customer survey

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


RE: cvs commit: jakarta-turbine-fulcrum/mimetype/api/src/java/org/apache/fulcrum/mimetype MimeTypeServiceFacade.java

Posted by Eric Pugh <ep...@upstate.com>.
I thought about this, and cursed myself as I added it.   The reason I added
it was I was happily trying to test the latest -dev version of
fulcrum-mimetype by adding it to Scarab, which was using the old stratum
based version.

So, as I added things in, I realized that Scarab every was using a
TurbineMimetypeService, which was a static facade.  And I thought, okay,
instead of looking up the component, I'll just do what fulcrum-upload has,
and use a facade.  So I added this.  But, since I didn't like it, I just
gave it a getService() method to highlight that this is just a helper.
Still, icky.

My problem with getting directly the component from the servicebroker is
that I am always loading from different containers.  One container in unit
testing, another in running as a webapp.

One way I worked around this was to add a static ComponentLocator to my
project that was custom to what I needed.

So I would do:
ComponentLocator.getMimeTypeService()

and that would do the lookup.  If I needed to load up a mock version of
MimeTypeService, well, ComponentLocator has a setMimeTypeService that I
could use, and ComponentLocator.mimeTypeService was a private static
variable...

I am now thinking that this is the way I should have gone for Scarab.
Replace all these facades in scarab with a call to
ComponentLocator.getSomeService() that actually would do the lookup if
required and return it..

If I do this route, then maybe the other facade guys should be gutted or
removed from Fulcrum?  So, in Turbine, we might have a
TurbineCompoenntLocator static class that we use for all the services (like
pool, factory, etc) that turbine needs....

What are your opinions?

Eric

> -----Original Message-----
> From: Henning P. Schmiedehausen [mailto:hps@intermeta.de]
> Sent: Friday, November 05, 2004 9:06 AM
> To: turbine-dev@jakarta.apache.org
> Subject: Re: cvs commit:
> jakarta-turbine-fulcrum/mimetype/api/src/java/org/apache/fulcrum/mimetyp
> e MimeTypeServiceFacade.java
>
>
> epugh@apache.org writes:
>
> >  Log:
> >  Add a facade helper class
>
> Personally, I consider the addition of the static facades to the
> Turbine services (yes, I am very guilty of my share) one of the bigger
> mistakes of Turbine.
>
> Is it so hard to get a Service reference from the container?
>
> >  +
> >  +    /**
> >  +     * Avalon component lifecycle method
> >  +     */
> >  +    public void service( ServiceManager manager) {
> >  +
> >  +        MimeTypeServiceFacade.setMimeTypeService(this);
> >  +
> >  +    }
>
> Uh; while this looks IoC style, it connects the implementation to the
> facade which is IIRC a violation of the facade pattern (where it
> should be the other way around). And users are in for really nasty
> surprises if their Service implementation forgets to to this setting.
>
> (And while I'm already at it: a "setService()" setter would match the
> getService() getter... :-) )
>
> 	Regards
> 		Henning
>
> --
> Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
> hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/
>
> RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
>    Linux, Java, perl, Solaris -- Consulting, Training, Development
>
> What is more important to you...
>    [ ] Product Security
> or [ ] Quality of Sales and Marketing Support
>               -- actual question from a Microsoft customer survey
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-turbine-fulcrum/mimetype/api/src/java/org/apache/fulcrum/mimetype MimeTypeServiceFacade.java

Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
epugh@apache.org writes:

>  Log:
>  Add a facade helper class

Personally, I consider the addition of the static facades to the
Turbine services (yes, I am very guilty of my share) one of the bigger
mistakes of Turbine.

Is it so hard to get a Service reference from the container? 

>  +    
>  +    /**
>  +     * Avalon component lifecycle method
>  +     */
>  +    public void service( ServiceManager manager) {
>  +
>  +        MimeTypeServiceFacade.setMimeTypeService(this);
>  +
>  +    }    

Uh; while this looks IoC style, it connects the implementation to the
facade which is IIRC a violation of the facade pattern (where it
should be the other way around). And users are in for really nasty
surprises if their Service implementation forgets to to this setting.

(And while I'm already at it: a "setService()" setter would match the
getService() getter... :-) )

	Regards
		Henning

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

What is more important to you...
   [ ] Product Security
or [ ] Quality of Sales and Marketing Support
              -- actual question from a Microsoft customer survey

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org