1 | /*
|
---|
2 | * Copyright 2001-2004 The Apache Software Foundation
|
---|
3 | *
|
---|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
5 | * you may not use this file except in compliance with the License.
|
---|
6 | * You may obtain a copy of the License at
|
---|
7 | *
|
---|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
9 | *
|
---|
10 | * Unless required by applicable law or agreed to in writing, software
|
---|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
13 | * See the License for the specific language governing permissions and
|
---|
14 | * limitations under the License.
|
---|
15 | *
|
---|
16 | */
|
---|
17 |
|
---|
18 | package org.apache.tools.ant.taskdefs.rmic;
|
---|
19 |
|
---|
20 | import java.lang.reflect.Method;
|
---|
21 | import org.apache.tools.ant.AntClassLoader;
|
---|
22 | import org.apache.tools.ant.BuildException;
|
---|
23 | import org.apache.tools.ant.Project;
|
---|
24 | import org.apache.tools.ant.types.Commandline;
|
---|
25 |
|
---|
26 | /**
|
---|
27 | * The implementation of the rmic for WebLogic
|
---|
28 | *
|
---|
29 | * @since Ant 1.4
|
---|
30 | */
|
---|
31 | public class WLRmic extends DefaultRmicAdapter {
|
---|
32 |
|
---|
33 | public boolean execute() throws BuildException {
|
---|
34 | getRmic().log("Using WebLogic rmic", Project.MSG_VERBOSE);
|
---|
35 | Commandline cmd = setupRmicCommand(new String[] {"-noexit"});
|
---|
36 |
|
---|
37 | AntClassLoader loader = null;
|
---|
38 | try {
|
---|
39 | // Create an instance of the rmic
|
---|
40 | Class c = null;
|
---|
41 | if (getRmic().getClasspath() == null) {
|
---|
42 | c = Class.forName("weblogic.rmic");
|
---|
43 | } else {
|
---|
44 | loader
|
---|
45 | = getRmic().getProject().createClassLoader(getRmic().getClasspath());
|
---|
46 | c = Class.forName("weblogic.rmic", true, loader);
|
---|
47 | }
|
---|
48 | Method doRmic = c.getMethod("main",
|
---|
49 | new Class [] {String[].class});
|
---|
50 | doRmic.invoke(null, new Object[] {cmd.getArguments()});
|
---|
51 | return true;
|
---|
52 | } catch (ClassNotFoundException ex) {
|
---|
53 | throw new BuildException("Cannot use WebLogic rmic, as it is not "
|
---|
54 | + "available. A common solution is to "
|
---|
55 | + "set the environment variable "
|
---|
56 | + "CLASSPATH.", getRmic().getLocation());
|
---|
57 | } catch (Exception ex) {
|
---|
58 | if (ex instanceof BuildException) {
|
---|
59 | throw (BuildException) ex;
|
---|
60 | } else {
|
---|
61 | throw new BuildException("Error starting WebLogic rmic: ", ex,
|
---|
62 | getRmic().getLocation());
|
---|
63 | }
|
---|
64 | } finally {
|
---|
65 | if (loader != null) {
|
---|
66 | loader.cleanup();
|
---|
67 | }
|
---|
68 | }
|
---|
69 | }
|
---|
70 |
|
---|
71 | /**
|
---|
72 | * Get the suffix for the rmic stub classes
|
---|
73 | */
|
---|
74 | public String getStubClassSuffix() {
|
---|
75 | return "_WLStub";
|
---|
76 | }
|
---|
77 |
|
---|
78 | /**
|
---|
79 | * Get the suffix for the rmic skeleton classes
|
---|
80 | */
|
---|
81 | public String getSkelClassSuffix() {
|
---|
82 | return "_WLSkel";
|
---|
83 | }
|
---|
84 | }
|
---|