View Javadoc

1   package org.codehaus.mojo.weblogic;
2   
3   /*
4    * Copyright 2006 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import org.apache.maven.plugin.MojoExecutionException;
20  import weblogic.Deployer;
21  
22  /**
23   * List the atifacts on Weblogic server(s) or cluster(s).
24   *
25   * @author <a href="mailto:scott@theryansplace.com">Scott Ryan</a>
26   * @version $Id: ListAppsMojo.java 6645 2008-04-02 01:38:51Z jonnio $
27   * @description This mojo will start a component (EAR, WAR) on a server or group of servers.
28   * @goal listapps
29   */
30  public class ListAppsMojo
31      extends DeployMojoBase
32  {
33  
34      /**
35       * This method will list the artifacts on a server(s) or cluster(s).
36       *
37       * @throws MojoExecutionException Thrown if we fail to obtain a Weblogic deployment instance.
38       */
39      public void execute()
40          throws MojoExecutionException
41      {
42  
43          if ( getLog().isInfoEnabled() )
44          {
45              getLog().info( "Weblogic list apps beginning with parameters " + this.toString() );
46          }
47  
48          // get the basic parameters
49          final String[] parameters = this.getInputParameters( "listapps" );
50          final boolean success = super.executeDeployer( parameters, "Exception encountered during artifact listapps" );
51  
52          try
53          {
54  
55              // Deploy with the parameters
56              Deployer deployer = new Deployer( parameters );
57              deployer.run();
58          }
59          catch ( Exception ex )
60          {
61              getLog().error( "Exception encountered during list apps ", ex );
62              throw new MojoExecutionException( "Exception encountered during listapps", ex );
63          }
64  
65          if ( getLog().isInfoEnabled() )
66          {
67              if ( success )
68              {
69                  getLog().info( "Weblogic artifact listapps successful " );
70              }
71              else
72              {
73                  getLog().info( "Weblogic artifact listapps failed " );
74              }
75          }
76  
77      }
78  
79  }