maven-wagon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michal Maczka <mmac...@interia.pl>
Subject Re: Support for Sessions and other planned changes in Wagon API
Date Thu, 19 Aug 2004 02:34:28 GMT
Jason van Zyl wrote:

>On Wed, 2004-08-18 at 21:38, Michal Maczka wrote:
>  
>
>>Trygve Laugstøl wrote:
>>
>>Plexus will be used for discovering WagonFactory components. 
>>WagonFactory will be used for instatiating Wagons.
>>    
>>
>
>-1
>
>That doesn't make any sense. Why would you use all of plexus simply for
>discovery to use something else to instantiate the component?
>
>  
>
Becouce I don't want to use Wagons as components. As for me they are 
conceptually similar to JDBC connection .
You are not going to do attampt to do things like:

container.lookup( java.sql.Connection.ROLE );

are you?



Note that the differnce for DefaultWagonManager

(http://cvs.apache.org/viewcvs.cgi/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java?rev=1.4&view=auto)

will be almost not existing:

(is)
   private PlexusContainer container;  
  
   public Wagon getWagon( String protocol )
        throws UnsupportedProtocolException
    {
        Wagon wagon;

        try
        {
            wagon = (Wagon) container.lookup( Wagon.ROLE, protocol );
        }
        catch ( ComponentLookupException e )
        {
            throw new UnsupportedProtocolException( "Cannot find wagon which supports the
requested protocol: " + protocol );
        }

        return wagon;
    }

    public void releaseWagon( Wagon wagon )
        throws Exception
    {
        container.release( wagon );
    }


    public void contextualize( Context context )
        throws ContextException
    {
        container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
    }

-------------------------------

    (could be)    
    
    private Map factoryMap; 

    public Wagon getWagon( String protocol )
        throws UnsupportedProtocolException
    {
        Wagon wagon;

        try
        {
            WagonFactory factory = (WagonFactory) factoryMap.lookup( protocol );
            
            wagon = factory.createWagon();
        }
        catch ( ComponentLookupException e )
        {
            throw new UnsupportedProtocolException( "Cannot find wagon which supports the
requested protocol: " + protocol );
        }

        return wagon;
    }
    }

so code will be even shorter

Once generics  will be commonly used (in 2-3 years)  you will be able to 
use this technique to have fully strongly typed code.
So basiclly this makes code more beatiful as you don't have to use 
container.lookup( Wagon.ROLE, protocol );

But this is not at all important  :)


I agree that this is something which I want to put to Wagon in order to 
support your use cases from m2.
I don't care much about anything else.

My main case was to support something which you call "session". 
You mentioned that you want to have wagon as statless components and 
pass to them a kind of memento which encapsulats
state (session).


For me Wagon itself is a __session__ already - in this case state and 
operations using this state are encapsualted
in a single object (which imo is a good thing and something compilant 
with the spirit of OOP). 

As for Factories: There is abolutly no refactoring needed - In case I'll 
go for those changes
I just need to add as many classes as we have wagon providers.
I can even have in components.xml files component descriptors for both: 
Wagon, WagonFactory
and you will be able to choose which way of instantaing wagon you want 
to use.

So if you will want to stick to current desing - you will  not be 
required to touch any code in m2.
In case when you will be thinking about "object kept in MavenSession" in 
the future - this is what I want you propose to use

Michal


-------------------------------------------------------------------
E-maile przez telefon? U nas mozna...
Sprawdz: http://link.interia.pl/f182f


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


Mime
View raw message