server = new AssetServer();
context.setAttribute("asset.server", server);
}
// The portlet logger
Logger portletLogger = JUL.getLogger(JuzuPortlet.class.getName() + "." + config.getPortletName());
//
BridgeConfig bridgeConfig;
try {
bridgeConfig = new BridgeConfig(portletLogger, new SimpleMap<String, String>() {
@Override
protected Iterator<String> keys() {
return BridgeConfig.NAMES.iterator();
}
@Override
public String get(Object key) {
if (BridgeConfig.APP_NAME.equals(key)) {
return getApplicationName(config);
} else if (BridgeConfig.INJECT.equals(key)) {
// Cascade:
// 1/ portlet init param
// 2/ servket context init param
String inject = config.getInitParameter((String)key);
if (inject == null) {
inject = context.getInitParameter((String)key);
}
return inject;
} else if (BridgeConfig.NAMES.contains(key)) {
return config.getInitParameter((String)key);
} else {
return null;
}
}
});
}
catch (Exception e) {
String msg = "Could not find an application to start";
if (e instanceof PortletException) {
String nested = e.getMessage();
if (nested != null) {
msg += ":" + nested;
}
throw Tools.initCause(new UnavailableException(msg), e.getCause());
} else {
throw new PortletException(msg, e);
}
}
//
final BridgeContext bridgeContext = new AbstractBridgeContext() {
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
final ResourceResolver resolver = new ResourceResolver() {
public URL resolve(String uri) {
try {
return context.getResource(uri);
}
catch (MalformedURLException e) {
return null;
}
}
};
public ReadFileSystem<?> getResourcePath() {
return WarFileSystem.create(context, "/WEB-INF/");
}
public ReadFileSystem<?> getClassPath() {
return WarFileSystem.create(context, "/WEB-INF/classes/");
}
public ClassLoader getClassLoader() {
return classLoader;
}
public String getInitParameter(String name) {
return context.getInitParameter(name);
}
public ResourceResolver getResolver() {
return resolver;
}
public Object getAttribute(String key) {
return context.getAttribute(key);
}
public void setAttribute(String key, Object value) {
context.setAttribute(key, value);
}
};
//
InjectorProvider injectorProvider = bridgeConfig.injectorProvider;
if (injectorProvider == null) {
throw new UnavailableException("No inject implementation selected");
} else {
portletLogger.info("Using inject implementation " + injectorProvider.getValue());
}
//
Injector injector = injectorProvider.get();
if (injector instanceof SpringInjector) {