Search in sources :

Example 6 with ComponentLookupException

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;
}
Also used : Execution(org.xwiki.context.Execution) MessagingException(javax.mail.MessagingException) XWikiContext(com.xpn.xwiki.XWikiContext) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException)

Example 7 with ComponentLookupException

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;
}
Also used : DefaultWikiPrinter(org.xwiki.rendering.renderer.printer.DefaultWikiPrinter) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException) WikiPrinter(org.xwiki.rendering.renderer.printer.WikiPrinter) DefaultWikiPrinter(org.xwiki.rendering.renderer.printer.DefaultWikiPrinter) BlockRenderer(org.xwiki.rendering.renderer.BlockRenderer)

Example 8 with ComponentLookupException

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);
}
Also used : InputStream(java.io.InputStream) Environment(org.xwiki.environment.Environment) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException)

Example 9 with ComponentLookupException

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);
        }
    }
}
Also used : NetworkAdapter(org.xwiki.observation.remote.NetworkAdapter) RemoteEventException(org.xwiki.observation.remote.RemoteEventException) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException) InitializationException(org.xwiki.component.phase.InitializationException)

Example 10 with ComponentLookupException

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));
    }
}
Also used : LocalEventData(org.xwiki.observation.remote.LocalEventData) ObservationManager(org.xwiki.observation.ObservationManager) RemoteObservationManager(org.xwiki.observation.remote.RemoteObservationManager) RemoteObservationManager(org.xwiki.observation.remote.RemoteObservationManager) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException)

Aggregations

ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)104 ComponentManager (org.xwiki.component.manager.ComponentManager)24 Test (org.junit.Test)15 DocumentReference (org.xwiki.model.reference.DocumentReference)12 XWikiContext (com.xpn.xwiki.XWikiContext)10 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)10 InitializationException (org.xwiki.component.phase.InitializationException)8 ArrayList (java.util.ArrayList)7 XWikiException (com.xpn.xwiki.XWikiException)5 HashMap (java.util.HashMap)5 DefaultComponentDescriptor (org.xwiki.component.descriptor.DefaultComponentDescriptor)5 NamespacedComponentManager (org.xwiki.component.manager.NamespacedComponentManager)5 FilterException (org.xwiki.filter.FilterException)5 ExtendedURL (org.xwiki.url.ExtendedURL)5 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)4 Type (java.lang.reflect.Type)4 HashSet (java.util.HashSet)4 WikiComponentException (org.xwiki.component.wiki.WikiComponentException)4 ExecutionContext (org.xwiki.context.ExecutionContext)4 WikiReference (org.xwiki.model.reference.WikiReference)4