use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class GroupMimeMessageIterator method getXWikiContext.
private XWikiContext getXWikiContext() throws MessagingException {
XWikiContext xWikiContext;
try {
Execution execution = this.componentManager.getInstance(Execution.class);
xWikiContext = (XWikiContext) execution.getContext().getProperty(XWikiContext.EXECUTIONCONTEXT_KEY);
} catch (ComponentLookupException e) {
throw new MessagingException("Failed to find default Execution context", e);
}
return xWikiContext;
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class XDOMOfficeDocument method getContentAsString.
/**
* Renders the XDOM encapsulated by this document into the given syntax.
*
* @param syntaxId string identifier of the syntax.
* @return content of this document in the given syntax or null if the syntax is invalid.
*/
public String getContentAsString(String syntaxId) {
try {
WikiPrinter printer = new DefaultWikiPrinter();
BlockRenderer renderer = this.componentManager.getInstance(BlockRenderer.class, syntaxId);
renderer.render(this.xdom, printer);
return printer.toString();
} catch (ComponentLookupException ex) {
// Nothing to do here.
}
return null;
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class JGroupsNetworkAdapter method loadChannelConfiguration.
/**
* Load channel configuration.
*
* @param channelId the identifier of the channel
* @return the channel configuration
* @throws IOException failed to load configuration file
*/
private ProtocolStackConfigurator loadChannelConfiguration(String channelId) throws IOException {
String channelFile = channelId + ".xml";
String path = "/WEB-INF/" + CONFIGURATION_PATH + channelFile;
InputStream is = null;
try {
Environment environment = this.componentManager.getInstance(Environment.class);
is = environment.getResourceAsStream(path);
} catch (ComponentLookupException e) {
// Environment not found, continue by fallbacking on JGroups's standard configuration.
this.logger.debug("Failed to lookup the Environment component.", e);
}
if (is == null) {
// Fallback on JGroups standard configuration locations
is = ConfiguratorFactory.getConfigStream(channelFile);
if (is == null && !Global.DEFAULT_PROTOCOL_STACK.equals(channelFile)) {
// Fallback on default JGroups configuration
is = ConfiguratorFactory.getConfigStream(Global.DEFAULT_PROTOCOL_STACK);
}
}
return XmlConfigurator.getInstance(is);
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class DefaultRemoteObservationManager method initialize.
@Override
public void initialize() throws InitializationException {
try {
String networkAdapterHint = this.configuration.getNetworkAdapter();
this.networkAdapter = this.componentManager.getInstance(NetworkAdapter.class, networkAdapterHint);
} catch (ComponentLookupException e) {
throw new InitializationException("Failed to initialize network adapter [" + this.configuration.getNetworkAdapter() + "]", e);
}
// Start configured channels and register them against the JMX server
for (String channelId : this.configuration.getChannels()) {
try {
startChannel(channelId);
} catch (RemoteEventException e) {
this.logger.error("Failed to start channel [" + channelId + "]", e);
}
}
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class LocalEventListener method onEvent.
@Override
public void onEvent(Event event, Object source, Object data) {
if (this.remoteObservationManager == null) {
try {
// Make sure to not receive events until RemoteObservationManager is ready
ObservationManager om = this.componentManager.getInstance(ObservationManager.class);
om.removeListener(getName());
this.remoteObservationManager = this.componentManager.getInstance(RemoteObservationManager.class);
om.addListener(this);
this.remoteObservationManager.notify(new LocalEventData(event, source, data));
} catch (ComponentLookupException e) {
this.logger.error("Failed to initialize the Remote Observation Manager", e);
}
} else {
this.remoteObservationManager.notify(new LocalEventData(event, source, data));
}
}
Aggregations