1
19
20 package com.liferay.portal.kernel.util;
21
22
28 public class PortalClassInvoker {
29
30 public static Object invoke(String className, String methodName)
31 throws Exception {
32
33 return invoke(className, methodName, new Object[] {});
34 }
35
36 public static Object invoke(String className, String methodName, Object arg)
37 throws Exception {
38
39 return invoke(className, methodName, new Object[] {arg});
40 }
41
42 public static Object invoke(
43 String className, String methodName, Object arg1, Object arg2)
44 throws Exception {
45
46 return invoke(className, methodName, new Object[] {arg1, arg2});
47 }
48
49 public static Object invoke(
50 String className, String methodName, Object arg1, Object arg2,
51 Object arg3)
52 throws Exception {
53
54 return invoke(className, methodName, new Object[] {arg1, arg2, arg3});
55 }
56
57 public static Object invoke(
58 String className, String methodName, Object[] args)
59 throws Exception {
60
61 return invoke(className, methodName, args, true);
62 }
63
64 public static Object invoke(
65 String className, String methodName, boolean newInstance)
66 throws Exception {
67
68 return invoke(className, methodName, new Object[] {}, newInstance);
69 }
70
71 public static Object invoke(
72 String className, String methodName, Object arg,
73 boolean newInstance)
74 throws Exception {
75
76 return invoke(className, methodName, new Object[] {arg}, newInstance);
77 }
78
79 public static Object invoke(
80 String className, String methodName, Object arg1, Object arg2,
81 boolean newInstance)
82 throws Exception {
83
84 return invoke(
85 className, methodName, new Object[] {arg1, arg2}, newInstance);
86 }
87
88 public static Object invoke(
89 String className, String methodName, Object arg1, Object arg2,
90 Object arg3, boolean newInstance)
91 throws Exception {
92
93 return invoke(
94 className, methodName, new Object[] {arg1, arg2, arg3},
95 newInstance);
96 }
97
98 public static Object invoke(
99 String className, String methodName, Object[] args,
100 boolean newInstance)
101 throws Exception {
102
103 Thread currentThread = Thread.currentThread();
104
105 ClassLoader contextClassLoader = currentThread.getContextClassLoader();
106
107 try {
108 currentThread.setContextClassLoader(
109 PortalClassLoaderUtil.getClassLoader());
110
111 MethodWrapper methodWrapper = new MethodWrapper(
112 className, methodName, args);
113
114 return MethodInvoker.invoke(methodWrapper, newInstance);
115 }
116 finally {
117 currentThread.setContextClassLoader(contextClassLoader);
118 }
119 }
120
121 }