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