0
# Framework Integration
1
2
Spring Framework configuration, development tools, plugin management, and hot deployment capabilities providing comprehensive integration support for the Liferay portal framework.
3
4
## Capabilities
5
6
### Spring Framework Integration
7
8
Comprehensive Spring Framework integration providing dependency injection, configuration management, and lifecycle coordination.
9
10
```java { .api }
11
/**
12
* Spring configurator for portal integration
13
*/
14
public class SpringConfigurator {
15
16
/**
17
* Configures Spring application context for portal
18
* @param servletContext servlet context
19
* @return configured ApplicationContext
20
*/
21
public ApplicationContext configureApplicationContext(ServletContext servletContext);
22
23
/**
24
* Registers portal beans in Spring context
25
* @param applicationContext Spring application context
26
*/
27
public void registerPortalBeans(ApplicationContext applicationContext);
28
29
/**
30
* Sets up Spring profiles for different environments
31
* @param profiles active Spring profiles
32
*/
33
public void setActiveProfiles(String... profiles);
34
}
35
```
36
37
### Development Tools
38
39
Development and build tools for portal customization and extension development.
40
41
```java { .api }
42
/**
43
* Development utilities for portal development
44
*/
45
public class DevelopmentUtil {
46
47
/**
48
* Enables development mode features
49
* @param enabled true to enable development mode
50
*/
51
public static void setDevelopmentMode(boolean enabled);
52
53
/**
54
* Generates portal extension scaffolding
55
* @param extensionName name of extension to create
56
* @param extensionType type of extension (portlet, theme, hook)
57
* @return generated extension structure
58
*/
59
public static ExtensionStructure generateExtension(String extensionName, String extensionType);
60
61
/**
62
* Validates portal configuration
63
* @return list of configuration issues found
64
*/
65
public static List<ConfigurationIssue> validateConfiguration();
66
}
67
```
68
69
### Hot Deployment
70
71
Hot deployment functionality enabling runtime plugin deployment and updates without server restart.
72
73
```java { .api }
74
/**
75
* Hot deploy manager for plugin deployment
76
*/
77
public class HotDeployManager {
78
79
/**
80
* Deploys plugin from file
81
* @param pluginFile plugin WAR file
82
* @throws DeploymentException if deployment fails
83
*/
84
public void deployPlugin(File pluginFile) throws DeploymentException;
85
86
/**
87
* Undeploys plugin by name
88
* @param pluginName plugin name to undeploy
89
* @throws DeploymentException if undeployment fails
90
*/
91
public void undeployPlugin(String pluginName) throws DeploymentException;
92
93
/**
94
* Lists deployed plugins
95
* @return Set of deployed plugin names
96
*/
97
public Set<String> getDeployedPlugins();
98
99
/**
100
* Checks if plugin is deployed
101
* @param pluginName plugin name to check
102
* @return true if plugin is deployed
103
*/
104
public boolean isPluginDeployed(String pluginName);
105
}
106
107
/**
108
* Hot deploy event listener for plugin lifecycle events
109
*/
110
public interface HotDeployListener {
111
112
/**
113
* Called before plugin deployment
114
* @param event hot deploy event
115
*/
116
void invokeDeploy(HotDeployEvent event);
117
118
/**
119
* Called before plugin undeployment
120
* @param event hot deploy event
121
*/
122
void invokeUndeploy(HotDeployEvent event);
123
}
124
```
125
126
### Plugin Management
127
128
Comprehensive plugin management system for portal extensions and customizations.
129
130
```java { .api }
131
/**
132
* Plugin manager for managing portal plugins
133
*/
134
public class PluginManager {
135
136
/**
137
* Installs plugin from repository
138
* @param pluginName plugin name to install
139
* @param version plugin version
140
* @throws PluginException if installation fails
141
*/
142
public void installPlugin(String pluginName, String version) throws PluginException;
143
144
/**
145
* Updates plugin to newer version
146
* @param pluginName plugin name to update
147
* @param newVersion new plugin version
148
* @throws PluginException if update fails
149
*/
150
public void updatePlugin(String pluginName, String newVersion) throws PluginException;
151
152
/**
153
* Uninstalls plugin
154
* @param pluginName plugin name to uninstall
155
* @throws PluginException if uninstallation fails
156
*/
157
public void uninstallPlugin(String pluginName) throws PluginException;
158
159
/**
160
* Gets plugin information
161
* @param pluginName plugin name
162
* @return PluginInfo object or null if not found
163
*/
164
public PluginInfo getPluginInfo(String pluginName);
165
166
/**
167
* Lists available plugins in repository
168
* @return List of available plugins
169
*/
170
public List<PluginInfo> getAvailablePlugins();
171
}
172
173
/**
174
* Plugin information container
175
*/
176
public class PluginInfo {
177
178
/**
179
* Gets plugin name
180
* @return plugin name
181
*/
182
public String getName();
183
184
/**
185
* Gets plugin version
186
* @return plugin version
187
*/
188
public String getVersion();
189
190
/**
191
* Gets plugin description
192
* @return plugin description
193
*/
194
public String getDescription();
195
196
/**
197
* Gets plugin dependencies
198
* @return List of plugin dependencies
199
*/
200
public List<String> getDependencies();
201
202
/**
203
* Checks if plugin is installed
204
* @return true if plugin is installed
205
*/
206
public boolean isInstalled();
207
}
208
```
209
210
## Usage Examples
211
212
**Spring Configuration:**
213
214
```java
215
// Configure Spring application context
216
SpringConfigurator configurator = new SpringConfigurator();
217
ApplicationContext context = configurator.configureApplicationContext(servletContext);
218
219
// Register custom beans
220
configurator.registerPortalBeans(context);
221
222
// Set development profile
223
configurator.setActiveProfiles("development");
224
```
225
226
**Hot Deployment:**
227
228
```java
229
// Deploy plugin
230
HotDeployManager manager = new HotDeployManager();
231
File pluginFile = new File("/path/to/plugin.war");
232
manager.deployPlugin(pluginFile);
233
234
// Check deployment status
235
boolean isDeployed = manager.isPluginDeployed("my-plugin");
236
237
// Custom deployment listener
238
public class CustomHotDeployListener implements HotDeployListener {
239
@Override
240
public void invokeDeploy(HotDeployEvent event) {
241
System.out.println("Deploying: " + event.getPluginName());
242
}
243
244
@Override
245
public void invokeUndeploy(HotDeployEvent event) {
246
System.out.println("Undeploying: " + event.getPluginName());
247
}
248
}
249
```
250
251
**Plugin Management:**
252
253
```java
254
// Install plugin
255
PluginManager manager = new PluginManager();
256
manager.installPlugin("sample-portlet", "1.0.0");
257
258
// Get plugin information
259
PluginInfo info = manager.getPluginInfo("sample-portlet");
260
System.out.println("Version: " + info.getVersion());
261
System.out.println("Description: " + info.getDescription());
262
263
// List available plugins
264
List<PluginInfo> available = manager.getAvailablePlugins();
265
for (PluginInfo plugin : available) {
266
System.out.println(plugin.getName() + " - " + plugin.getVersion());
267
}
268
```
269
270
## Integration with Portal Framework
271
272
Framework integration provides:
273
274
- **Dependency Injection** - Spring-based bean management
275
- **Configuration Management** - Centralized configuration system
276
- **Plugin Architecture** - Extensible plugin system
277
- **Development Support** - Tools for portal development
278
- **Runtime Deployment** - Hot deployment capabilities
279
- **Extension Points** - Hooks for customization
280
281
## Error Handling
282
283
Framework integration exceptions:
284
285
- **DeploymentException** - Plugin deployment failures
286
- **PluginException** - Plugin management errors
287
- **ConfigurationException** - Configuration issues
288
- **HotDeployException** - Hot deployment problems
289
- **SpringException** - Spring framework errors
290
291
Best practices include comprehensive error logging, graceful fallback procedures, proper resource cleanup, and validation of plugin compatibility before deployment.