forked from liferay/liferay-portal
/
ModuleFrameworkUtilAdapter.java
143 lines (109 loc) · 3.93 KB
/
ModuleFrameworkUtilAdapter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.module.framework;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.util.ClassLoaderUtil;
import java.io.InputStream;
/**
* This class is a simple wrapper in order to make the framework module running
* under its own class loader.
*
* @author Miguel Pastor
* @author Raymond Augé
* @see ModuleFrameworkClassLoader
*/
public class ModuleFrameworkUtilAdapter {
public static long addBundle(String location) throws PortalException {
return _moduleFramework.addBundle(location);
}
public static long addBundle(String location, InputStream inputStream)
throws PortalException {
return _moduleFramework.addBundle(location, inputStream);
}
public static Object getFramework() {
return _moduleFramework.getFramework();
}
public static String getState(long bundleId) throws PortalException {
return _moduleFramework.getState(bundleId);
}
public static void initFramework() throws Exception {
ClassLoader classLoader = ClassLoaderUtil.getContextClassLoader();
ClassLoaderUtil.setContextClassLoader(
ModuleFrameworkAdapterHelper.getClassLoader());
try {
_moduleFramework.initFramework();
}
finally {
ClassLoaderUtil.setContextClassLoader(classLoader);
}
}
public static void registerContext(Object context) {
_moduleFramework.registerContext(context);
}
public static void setBundleStartLevel(long bundleId, int startLevel)
throws PortalException {
_moduleFramework.setBundleStartLevel(bundleId, startLevel);
}
public static void setModuleFramework(ModuleFramework moduleFramework) {
_moduleFramework = moduleFramework;
_moduleFrameworkAdapterHelper.exec(
"setModuleFramework", new Class[] {ModuleFramework.class},
_moduleFramework);
}
public static void startBundle(long bundleId) throws PortalException {
_moduleFramework.startBundle(bundleId);
}
public static void startBundle(long bundleId, int options)
throws PortalException {
_moduleFramework.startBundle(bundleId, options);
}
public static void startFramework() throws Exception {
_moduleFramework.startFramework();
}
public static void startRuntime() throws Exception {
_moduleFramework.startRuntime();
}
public static void stopBundle(long bundleId) throws PortalException {
_moduleFramework.stopBundle(bundleId);
}
public static void stopBundle(long bundleId, int options)
throws PortalException {
_moduleFramework.stopBundle(bundleId, options);
}
public static void stopFramework() throws Exception {
_moduleFramework.stopFramework();
}
public static void stopRuntime() throws Exception {
_moduleFramework.stopRuntime();
}
public static void uninstallBundle(long bundleId) throws PortalException {
_moduleFramework.uninstallBundle(bundleId);
}
public static void updateBundle(long bundleId) throws PortalException {
_moduleFramework.updateBundle(bundleId);
}
public static void updateBundle(long bundleId, InputStream inputStream)
throws PortalException {
_moduleFramework.updateBundle(bundleId, inputStream);
}
private static ModuleFramework _moduleFramework;
private static final ModuleFrameworkAdapterHelper
_moduleFrameworkAdapterHelper = new ModuleFrameworkAdapterHelper(
"com.liferay.portal.bootstrap.ModuleFrameworkUtil");
static {
_moduleFramework =
(ModuleFramework)_moduleFrameworkAdapterHelper.execute(
"getModuleFramework");
}
}