@Override public void initialise() throws InitialisationException { if (xPathFactory == null) { xPathFactory = XPathFactory.newInstance(); } if (manager == null) { throw new InitialisationException(createStaticMessage("Expected ExpressionManager to be injected but was null"), this); } }
private void globalConfigNotHonored(String element, String[] elementArray) throws InitialisationException { throw new InitialisationException(createStaticMessage(String .format("Some selected %1$s are invalid. Valid %1$s according to your TLS configuration file are: %2$s", element, Joiner.on(", ").join(elementArray))), this); }
private void checkState(String expected) throws InitialisationException { if (!state.equals(expected)) { throw new InitialisationException( createStaticMessage("Invalid state: expected %s but as %s", expected, state), this); } } }
private void checkState(String expected) throws InitialisationException { if (!state.equals(expected)) { throw new InitialisationException( createStaticMessage("Invalid state: expected %s but as %s", expected, state), this); } }
/** * Creates a folder for this service to upload tooling applications. * * @return {@link File} working folder. * @throws InitialisationException if there was an error while creating the folder. */ private File createToolingServiceAppsFolder() throws InitialisationException { File toolingServiceAppsFolder = new File(getToolingWorkingDir(), TOOLING_APPS_FOLDER); if (!toolingServiceAppsFolder.exists()) { boolean folderCreated = toolingServiceAppsFolder.mkdirs(); if (!folderCreated) { throw new InitialisationException(createStaticMessage("Couldn't start up the service"), new IOException("Couldn't create tooling service resources folder: " + toolingServiceAppsFolder), this); } if (logger.isDebugEnabled()) { logger.debug("Created tooling service resources folder at: " + toolingServiceAppsFolder); } } else { try { cleanDirectory(toolingServiceAppsFolder); } catch (IOException e) { logger.warn("Could not clean up tooling service resources folder at: " + toolingServiceAppsFolder); } } return toolingServiceAppsFolder; }
private void enableNotifications(ServerNotificationManager notificationManager, Map<String, Class<? extends Notification>> eventMap, Map<String, Class<? extends NotificationListener>> interfaceMap) throws InitialisationException { for (NotificationConfig<?, ?> notification : enabledNotifications) { final Supplier<InitialisationException> noNotificationExceptionSupplier = () -> new InitialisationException(createStaticMessage("No notification '%s' declared in this applications plugins to enable. Expected one of %s", notification.getEventName(), eventMap.keySet().toString()), this); notificationManager .addInterfaceToType(getInterfaceClass(notification, interfaceMap).orElseThrow(noNotificationExceptionSupplier), getEventClass(notification, eventMap).orElseThrow(noNotificationExceptionSupplier)); } }
public ServerNotificationManager populateNotificationTypeMappings(Map<String, Class<? extends Notification>> eventMap, Map<String, Class<? extends NotificationListener>> interfaceMap) throws InitialisationException { Map<String, NotificationsProvider> providersMap = new HashMap<>(); for (NotificationsProvider provider : registry.lookupAllByType(NotificationsProvider.class)) { for (Entry<String, Pair<Class<? extends Notification>, Class<? extends NotificationListener>>> entry : provider .getEventListenerMapping().entrySet()) { final String notificationType = entry.getKey(); if (!notificationType.matches("[a-zA-Z]+:[A-Z\\-]+")) { throw new InitialisationException(createStaticMessage("Notification '%s' declared in '%s' doesn't comply with the '[artifactID]:[NOTIFICATION-ID]' format", notificationType, provider.toString()), this); } if (eventMap.containsKey(notificationType)) { throw new InitialisationException(createStaticMessage("Notification '%s' declared in '%s' is already declared for another artifact in provider '%s'.", notificationType, provider.toString(), eventMap.get(notificationType)), this); } eventMap.put(notificationType, entry.getValue().getFirst()); interfaceMap.put(notificationType, entry.getValue().getSecond()); providersMap.put(notificationType, provider); } } ServerNotificationManager notificationManager = muleContext.getNotificationManager(); if (dynamic != null) { notificationManager.setNotificationDynamic(dynamic.booleanValue()); } return notificationManager; }
@Override public void initialise() throws InitialisationException { try { coreExtensions = coreExtensionDiscoverer.discover(); orderedCoreExtensions = coreExtensionDependencyResolver.resolveDependencies(coreExtensions); initializeCoreExtensions(); } catch (Exception e) { throw new InitialisationException(e, this); } }
@Override public void initialise() throws InitialisationException { if (enableMessageHistory) { messageHistory = new CopyOnWriteArrayList<>(); } for (LifecycleCallback callback : lifecycleCallbacks) { callback.onTransition(id, Initialisable.PHASE_NAME); } if (processorClass != null) { try { processor = (Processor) instantiateClass(processorClass); initialiseIfNeeded(processor, true, muleContext); } catch (Exception e) { throw new InitialisationException(e, this); } } }
private void reallyDoInitialise() throws InitialisationException { try { lifecycle(() -> lifecycleManager.fireInitialisePhase((phase, o) -> { sourceConnectionManager = new SourceConnectionManager(connectionManager); try { createSource(); initialiseIfNeeded(sourceAdapter); } catch (Exception e) { throw new InitialisationException(e, this); } })); } catch (MuleException e) { if (e instanceof InitialisationException) { throw (InitialisationException) e; } else { throw new InitialisationException(e, this); } } }
@Override public void initialise() throws InitialisationException { try { muleContext.getInjector().inject(javaInternalSerializerProtocol); muleContext.getInjector().inject(javaExternalSerializerProtocol); } catch (MuleException e) { throw new InitialisationException(e, this); } } }
@Override public void initialise() throws InitialisationException { try { muleContext.getInjector().inject(delegate); initialiseIfNeeded(delegate, muleContext); } catch (MuleException e) { throw new InitialisationException( createStaticMessage("Failed to initialise the delegate ValueResolver for ConfigOverride wrapper"), e, this); } }
private void disableNotifications(ServerNotificationManager notificationManager, Map<String, Class<? extends Notification>> eventMap, Map<String, Class<? extends NotificationListener>> interfaceMap) throws InitialisationException { for (NotificationConfig<?, ?> disabledNotification : disabledNotifications) { final Supplier<InitialisationException> noNotificationExceptionSupplier = () -> new InitialisationException(createStaticMessage("No notification '%s' declared in this applications plugins to disable. Expected one of %s", disabledNotification.getEventName(), eventMap.keySet().toString()), this); if (disabledNotification.isInterfaceExplicitlyConfigured()) { notificationManager .disableInterface(getInterfaceClass(disabledNotification, interfaceMap).orElseThrow(noNotificationExceptionSupplier)); } if (disabledNotification.isEventExplicitlyConfigured()) { notificationManager .disableType(getEventClass(disabledNotification, eventMap).orElseThrow(noNotificationExceptionSupplier)); } } }
private void validateConfigurationProviderIsNotExpression() throws InitialisationException { if (isConfigurationSpecified() && expressionParser.isContainsTemplate(configurationProvider.get().getName())) { throw new InitialisationException( createStaticMessage( format("Root component '%s' defines component '%s' which specifies the expression '%s' as a config-ref. " + "Expressions are not allowed as config references", getLocation().getRootContainerName(), hyphenize(componentModel.getName()), configurationProvider)), this); } }
/** * Initialises this instance by * <ul> * <li>Initialising the {@link #configurationStats}</li> * <li>Performs dependency injection on the {@link #value} and each item in {@link #getInterceptors()}</li> * <li>Propagates this lifecycle phase into the the {@link #value} and each item in {@link #getInterceptors()}</li> * </ul> * * @throws InitialisationException if an exception is found */ @Override public synchronized void initialise() throws InitialisationException { if (!initialized) { initialized = true; testConnectivityLock = lockFactory.createLock(this.getClass().getName() + "-testConnectivity-" + getName()); try { initStats(); doInitialise(); super.initialise(); } catch (Exception e) { if (e instanceof InitialisationException) { throw (InitialisationException) e; } else { throw new InitialisationException(e, this); } } } }
@Override public void initialise() throws InitialisationException { try { componentInitializedLatch.release(); waitLatch.await(); } catch (InterruptedException e) { throw new InitialisationException(e, this); } }
/** * Performs dependency injection into all the currently provided configurations, and when needed, fires the * {@link Initialisable#initialise()} phase on them * * @throws InitialisationException if an exception is found */ @Override public void initialise() throws InitialisationException { withContextClassLoader(extensionClassLoader, () -> { lifecycleManager.fireInitialisePhase((phaseName, object) -> { for (ConfigurationInstance configurationInstance : configurationInstances) { initialiseIfNeeded(configurationInstance, true, muleContext); } doInitialise(); }); return null; }, InitialisationException.class, e -> { throw new InitialisationException(e, this); }); }
/** * Makes sure that the operation is valid by invoking {@link #validateOperationConfiguration(ConfigurationProvider)} and then * delegates on {@link #doInitialise()} for custom initialisation * * @throws InitialisationException if a fatal error occurs causing the Mule instance to shutdown */ @Override public final void initialise() throws InitialisationException { if (cursorProviderFactory == null) { cursorProviderFactory = componentModel.getModelProperty(PagedOperationModelProperty.class) .map(p -> (CursorProviderFactory) streamingManager.forObjects().getDefaultCursorProviderFactory()) .orElseGet(() -> streamingManager.forBytes().getDefaultCursorProviderFactory()); } withContextClassLoader(classLoader, () -> { validateConfigurationProviderIsNotExpression(); findConfigurationProvider().ifPresent(this::validateOperationConfiguration); doInitialise(); return null; }, InitialisationException.class, e -> { throw new InitialisationException(e, this); }); setCacheIdGenerator(); }
@Override public void initialise() throws InitialisationException { if (initialised) { return; } flowBackPressueErrorType = errorTypeRepository.getErrorType(FLOW_BACK_PRESSURE) .orElseThrow(() -> new IllegalStateException("FLOW_BACK_PRESSURE error type not found")); initialiseIfNeeded(nonCallbackParameters, true, muleContext); initialiseIfNeeded(errorCallbackParameters, true, muleContext); initialiseIfNeeded(successCallbackParameters, true, muleContext); injectComponentLocation(); try { setConfiguration(configurationInstance); setConnection(); muleContext.getInjector().inject(sourceInvokationTarget.get()); if (source instanceof SourceWrapper) { muleContext.getInjector().inject(source); } } catch (Exception e) { throw new InitialisationException(e, this); } initialiseIfNeeded(source); initialised = true; }
@Override public void initialise() throws InitialisationException { if (initialized.getAndSet(true)) { return; } try { tlsConfiguration.initialise(null == getKeyStorePath(), null); } catch (CreateException e) { throw new InitialisationException(createStaticMessage("Unable to initialise TLS configuration"), e, this); } if (!isUseDefaults(enabledProtocols)) { String[] globalEnabledProtocols = tlsConfiguration.getEnabledProtocols(); if (globalEnabledProtocols != null) { String[] validProtocols = ArrayUtils.intersection(enabledProtocols, globalEnabledProtocols); if (validProtocols.length < enabledProtocols.length) { globalConfigNotHonored("protocols", globalEnabledProtocols); } } } if (!isUseDefaults(enabledCipherSuites)) { String[] globalEnabledCipherSuites = tlsConfiguration.getEnabledCipherSuites(); if (globalEnabledCipherSuites != null) { String[] validCipherSuites = ArrayUtils.intersection(enabledCipherSuites, globalEnabledCipherSuites); if (validCipherSuites.length < enabledCipherSuites.length) { globalConfigNotHonored("cipher suites", globalEnabledCipherSuites); } } } }