History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: CARGO-288
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Vincent Massol
Reporter: Juri Artamonov
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Cargo

Add support for starting/stopping/redeploying deployables

Created: 10/Mar/06 07:34 AM   Updated: 30/Mar/06 04:24 AM
Component/s: Maven2
Affects Version/s: 0.1-maven2
Fix Version/s: 0.2-maven2

Time Tracking:
Not Specified

File Attachments: 1. Java Source File AbstractModuleMojo.java (3 kb)
2. Java Source File ModuleStartMojo.java (2 kb)
3. Java Source File ModuleStartMojo.java (2 kb)
4. Java Source File ModuleStopMojo.java (2 kb)
5. Java Source File ModuleStopMojo.java (2 kb)
6. Text File patch.txt (15 kb)

Environment: maven2 plugin


 Description  « Hide
Add support of starting/stopping applications in specified container through m2 plugin. Attached mojos used start-module and stop-module goal names which were suggested by Vincent Massol.

 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Vincent Massol - 11/Mar/06 08:40 AM
Very cool, thanks Juri!

Some remarks:

  • We would need some tests. Unit tests would be fine I think.
  • We'll need some documentation on the wiki too
  • You need to put the copyright notice at the top of the file
  • The class javadoc should not have any @author element but it should have a @version tag
  • The ModuleStartMojo.java has a startSingleDeployable() method but the debug comment says it's stopping the deployable...
  • Some typos: "appliaction" for ex
  • Wrong comment: "// Stop all deployables defined in the deployer config element (if any)"
  • I think "Starting deployable..." would be better than "Starting application" as it's more Cargo-centric
  • As ModuleStartMojo and ModuleStopMojo are 90% similar I'd recommend having an AbstractModuleMojo class for common code
  • The DeployMojo and UndeployMojo classes need to be renamed to ModuleDeployMojo and ModuleUndeployMojo to be consistent with the 2 new mojos. And they should probably share the AbstractModuleMojo class too

Juri Artamonov - 13/Mar/06 10:02 AM
Refactored StartMojo

Juri Artamonov - 13/Mar/06 10:03 AM
Refactored StopMojo

Juri Artamonov - 13/Mar/06 10:04 AM
Abstract Class for deployable start stop actions

Juri Artamonov - 13/Mar/06 10:18 AM
Thank you Vincent for the comments.

Some remarks from my side as well:

We would need some tests. Unit tests would be fine I think.
> What these tests should verify?
We'll need some documentation on the wiki too
>How to do this?
You need to put the copyright notice at the top of the file
>Done
The class javadoc should not have any @author element but it should have a @version tag
>Done
The ModuleStartMojo.java has a startSingleDeployable() method but the debug comment says it's stopping the deployable...
>Fixed
Some typos: "appliaction" for ex
>Fixed
Wrong comment: "// Stop all deployables defined in the deployer config element (if any)"
>Fixed
I think "Starting deployable..." would be better than "Starting application" as it's more Cargo-centric
>Fixed
As ModuleStartMojo and ModuleStopMojo are 90% similar I'd recommend having an AbstractModuleMojo class for common code
>Done
The DeployMojo and UndeployMojo classes need to be renamed to ModuleDeployMojo and ModuleUndeployMojo to be consistent with the 2 new mojos. And they should probably share the AbstractModuleMojo class too
>How to commit renamed files ? Just also commiting it here and yes, sure if you want I can do sharing for this mojos as well and also I see DeployMojo can use then URL as additional argument.

All updated files are attached.


Vincent Massol - 15/Mar/06 03:02 AM
> What these tests should verify?

We have a ContainerStartMojoTest class. We need something similar for the deploy mojos.

>How to commit renamed files ? Just also commiting it here and yes, sure if you want I can do sharing for this mojos as well and also I see DeployMojo can use then URL as additional argument.

You need to create a patch. Almost all SVN clients have a "create patch" feature. For new files you need to "svn add" them before creating the patch or they won't be in the patch.

I'll have a look at the new files you've committed later today, thanks.


Vincent Massol - 15/Mar/06 03:12 AM
Juri, I think you're preparing a new patch so I'll wait for it before applying anything. Let me know if this is ok.

Juri Artamonov - 17/Mar/06 04:02 PM
Here is updated and renamed DeployerMojos that uses new AbstractClass with common code, except DeployMojo. Deploy Mojo contains PingUrl attribute which belong to Deployable object for m2 not for real Deployable. I think this is up to you Vincent to decide if real Deployable could have getPingUrl attribute. Anyway this will be like ahack not like a fix
Please let me know what do you think.

Best regards,
Juri.


Vincent Massol - 18/Mar/06 07:10 AM
Hi Juri. Thanks a lot for your patch! I've applied it. Here are the things I had to change. I'm just listing them so that you know what can be improved for the next time you send some patches. Some of them are important and others are minor but I'm listing them all in order to be exhaustive:
  • The patch is not created from the right directory. For example in the patch file it says:

D:/workspace/cargo-svn/extensions/maven2/src/main/java/org/codehaus/cargo/maven2/ModuleStopMojo.java

The root of the patch should be extensions/. I've fixed this manually for now but please make sure this is fine for the next patches you send.

  • The copyright year should be the year when the file was created till the last time it was modified. Thus new files should have a copyright of 2006.
  • The @version is not correct. It must be: "@version $Id: $" so that the SVN client replaces the value when the file is committed. For example you'll get:

@version $Id: AbstractCargoMojo.java 940 2006-03-17 21:29:46Z vmassol $

  • Your patch should include deleted files too. It did not include deletion of currnet DeployMojo/UndeployMojo
  • There are several blank lines that shouldn't exist as in:
private void deploySingleDeployable(org.codehaus.cargo.container.deployer.Deployer deployer, 
        org.codehaus.cargo.container.deployable.Deployable deployable, URL pingURL)
    {
        
        
        getLog().debug("Deploying [" + deployable.getFile() + "]"
            + ((pingURL == null) ? "..." : " using ping URL [" + pingURL + "]"));
                
        
        if (pingURL != null)
        {
            deployer.deploy(deployable, createDeployableMonitor(pingURL, deployable));
        }
        else
        {
            deployer.deploy(deployable);
        }
        
    }

(in this example you can remove 4 lines).

  • Method shoud be verbs. I've replaced moduleAction() by performDeployerAction(). (Note: I make this mistake myself but this doesn't mean someone shouldn't correct me! )
  • I've replaced all Module names with Deployer instead so that it's easier to relate code to the Cargo API. Module is a term that doesn't exist in cargo. Right now as I've suggetsed on the mailing list (I don't think anyone answered) I had suggested deployer-start, deployer-deploy, deployer-undeploy, deployer-stop, which I think is better than module-start, etc.
  • Added some comments to the code
  • Refactored more (execute in parent class, removed duplications in deploy and undeploy mojos). The pingURL should be passed to all. In the future there should be APIs in the Deployer interface for using them when starting and stopping deployables too.
  • Add redeploy mojo to fully implement the Deployer interface
  • Changed goal name. I'm happy to change it back to what you defined or whatever we all agree on. I've sent again a mail on the cargo dev list for feedback.

Once more thanks a lot for your patch!


Vincent Massol - 18/Mar/06 07:20 AM
Applied thanks.