View Javadoc
1   package org.codehaus.mojo.axistools.admin;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.codehaus.mojo.axistools.axis.AbstractAxisPlugin;
23  import org.codehaus.mojo.axistools.axis.AxisPluginException;
24  
25  import java.io.File;
26  import java.util.ArrayList;
27  import java.util.Iterator;
28  
29  /**
30   * @author mlake <mlake@netvue.com>
31   */
32  public class DefaultAdminPlugin
33      extends AbstractAxisPlugin
34      implements AdminPlugin
35  {
36      private File configOutputDirectory;
37  
38      private boolean isServerConfig;
39  
40      private ArrayList inputFiles;
41  
42      public void setServerConfig( boolean serverConfig )
43      {
44          isServerConfig = serverConfig;
45      }
46  
47      public void setConfigOutputDirectory( File configOutputDirectory )
48      {
49          this.configOutputDirectory = configOutputDirectory;
50      }
51  
52      public void setInputFiles( ArrayList inputFiles )
53      {
54          this.inputFiles = inputFiles;
55      }
56  
57      public void execute()
58          throws AxisPluginException
59      {
60          ArrayList argsList = new ArrayList();
61  
62          if ( !configOutputDirectory.exists() )
63          {
64              configOutputDirectory.mkdirs();
65          }
66          String mode = "client";
67          if ( isServerConfig )
68          {
69              mode = "server";
70          }
71  
72          // set the mode to server or config
73          argsList.add( mode );
74  
75          // set the output file
76          argsList.add( configOutputDirectory.getAbsolutePath() + File.separator + mode + "-config.wsdd" );
77  
78          if ( inputFiles != null && inputFiles.size() > 0 )
79          {
80              for ( Iterator i = inputFiles.iterator(); i.hasNext(); )
81              {
82                  argsList.add( i.next() );
83              }
84          }
85          else
86          {
87              throw new AxisPluginException( "You must specify at least one inputfile in the pom" );
88          }
89  
90          try
91          {
92  
93              AdminWrapper wrapper = new AdminWrapper( getLog() );
94              wrapper.execute( (String[]) argsList.toArray( new String[]{} ) );
95          }
96          catch ( Throwable t )
97          {
98              throw new AxisPluginException( "Admin execution failed", t );
99          }
100     }
101 }