1 | |
package org.codehaus.mojo.axistools.admin; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.axis.AxisEngine; |
23 | |
import org.apache.axis.MessageContext; |
24 | |
import org.apache.axis.client.AxisClient; |
25 | |
import org.apache.axis.server.AxisServer; |
26 | |
import org.apache.axis.utils.Admin; |
27 | |
import org.apache.axis.utils.Messages; |
28 | |
import org.apache.axis.utils.XMLUtils; |
29 | |
import org.apache.maven.plugin.logging.Log; |
30 | |
import org.codehaus.mojo.axistools.axis.AxisPluginException; |
31 | |
import org.w3c.dom.Document; |
32 | |
|
33 | |
import java.io.BufferedWriter; |
34 | |
import java.io.FileInputStream; |
35 | |
import java.io.FileOutputStream; |
36 | |
import java.io.OutputStreamWriter; |
37 | |
import java.io.PrintWriter; |
38 | |
import java.io.Writer; |
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
public class AdminWrapper |
44 | |
extends Admin |
45 | |
{ |
46 | |
private Log log; |
47 | |
|
48 | |
public AdminWrapper( Log log ) |
49 | 0 | { |
50 | 0 | this.log = log; |
51 | 0 | } |
52 | |
|
53 | |
public void execute( String[] args ) |
54 | |
throws AxisPluginException |
55 | |
{ |
56 | 0 | int i = 0; |
57 | |
|
58 | |
try |
59 | |
{ |
60 | |
AxisEngine engine; |
61 | 0 | if ( args[0].equals( "client" ) ) |
62 | |
{ |
63 | 0 | engine = new AxisClient(); |
64 | |
} |
65 | |
else |
66 | |
{ |
67 | 0 | engine = new AxisServer(); |
68 | |
} |
69 | |
|
70 | 0 | engine.setShouldSaveConfig( false ); |
71 | 0 | engine.init(); |
72 | 0 | MessageContext msgContext = new MessageContext( engine ); |
73 | 0 | Writer osWriter = new OutputStreamWriter( new FileOutputStream( args[1] ), XMLUtils.getEncoding() ); |
74 | 0 | PrintWriter writer = new PrintWriter( new BufferedWriter( osWriter ) ); |
75 | |
|
76 | |
try |
77 | |
{ |
78 | 0 | for ( i = 2; i < args.length; i++ ) |
79 | |
{ |
80 | 0 | log.debug( Messages.getMessage( "process00", args[i] ) ); |
81 | |
|
82 | 0 | Document doc = XMLUtils.newDocument( new FileInputStream( args[i] ) ); |
83 | 0 | Document result = process( msgContext, doc.getDocumentElement() ); |
84 | |
|
85 | 0 | if ( result != null ) |
86 | |
{ |
87 | 0 | System.out.println( XMLUtils.DocumentToString( result ) ); |
88 | |
} |
89 | |
} |
90 | 0 | Document document = Admin.listConfig( engine ); |
91 | 0 | XMLUtils.DocumentToWriter( document, writer ); |
92 | 0 | writer.println(); |
93 | |
} |
94 | 0 | catch ( Exception e ) |
95 | |
{ |
96 | 0 | log.error( Messages.getMessage( "errorProcess00", args[i] ), e ); |
97 | 0 | throw e; |
98 | |
} |
99 | |
finally |
100 | |
{ |
101 | 0 | writer.close(); |
102 | 0 | } |
103 | |
} |
104 | 0 | catch ( Exception e ) |
105 | |
{ |
106 | 0 | throw new AxisPluginException( "Axis Admin had a problem, it returned a failure status: " |
107 | |
+ e.getMessage() ); |
108 | 0 | } |
109 | 0 | } |
110 | |
} |