@Override protected String getPayloadToString() { return ((MuleContext) source).getConfiguration().getId(); }
public String getName() { return muleContext.getConfiguration().getId(); }
private String getApplicationName() { return muleContext.getConfiguration().getId(); }
private static String getErrorMappingCacheKey(String protocol, MuleContext muleContext) { return protocol + "-" + muleContext.getConfiguration().getId(); }
public String getServerId() { return muleContext.getConfiguration().getId(); }
public String getInstanceId() { return muleContext.getConfiguration().getId(); }
private static void clearCacheFor(MuleContext muleContext) { List<String> entriesToRemove = new ArrayList<String>(); for (String key : errorMappings.keySet()) { if (key.endsWith(muleContext.getConfiguration().getId())) { entriesToRemove.add(key); } } for (String key : entriesToRemove) { errorMappings.remove(key); } } }
private Properties withFactoryProperties() { Properties factoryProperties = new Properties(); factoryProperties.setProperty(QUARTZ_INSTANCE_NAME_PROPERTY, context.getConfiguration().getId() + "-" + name); factoryProperties.setProperty(THREAD_POLL_CLASS_PROPERTY, THREAD_POLL_CLASS); factoryProperties.setProperty(THREAD_POOL_COUNT_PROPERTY, String.valueOf(context.getDefaultMessageReceiverThreadingProfile().getMaxThreadsActive())); return factoryProperties; }
@Override protected void doHeader(MuleContext context) { header.add("Application: " + context.getConfiguration().getId()); header.add(String.format("OS encoding: %s, Mule encoding: %s", SystemUtils.FILE_SEPARATOR, context.getConfiguration().getDefaultEncoding())); header.add(" "); }
/** * Generate a generic thread name prefix for this context. * @param muleContext context to generate the name prefix for * @return "[appName]." if Mule is running as a container, otherwise empty string */ public static String getPrefix(MuleContext muleContext) { final boolean containerMode = muleContext.getConfiguration().isContainerMode(); final String id = muleContext.getConfiguration().getId(); return containerMode ? String.format("[%s].", id) : StringUtils.EMPTY; } }
@Override public void onNotification(MuleContextNotification notification) { if (notification.getAction() == MuleContextNotification.CONTEXT_DISPOSED) { clearCacheFor(muleContext); disposeListenerRegistered.remove(notification.getMuleContext().getConfiguration().getId()); } } };
private static void registerAppDisposeListener(MuleContext muleContext) { if (!disposeListenerRegistered.containsKey(muleContext.getConfiguration().getId())) { try { muleContext.registerListener(createClearCacheListenerOnContextDispose(muleContext)); disposeListenerRegistered.put(muleContext.getConfiguration().getId(),true); } catch (NotificationException e) { throw new MuleRuntimeException(e); } } }
protected static String generateId(MuleContext context) { MuleConfiguration conf = context.getConfiguration(); return String.format("%s.%s.%s", conf.getDomainId(), context.getClusterId(), conf.getId()); }
@Override public Map<String, Object> getContextInfo(MuleEvent event, MessageProcessor lastProcessed) { Map<String, Object> contextInfo = new HashMap<String, Object>(); contextInfo.put(INFO_LOCATION_KEY, resolveProcessorRepresentation(event.getMuleContext().getConfiguration().getId(), getProcessorPath(event, lastProcessed), lastProcessed)); if (lastProcessed instanceof AnnotatedObject) { String sourceXML = getSourceXML((AnnotatedObject) lastProcessed); if (sourceXML != null) { contextInfo.put(INFO_SOURCE_XML_KEY, sourceXML); } } return contextInfo; }
protected void doHeader(MuleContext context) { long currentTime = System.currentTimeMillis(); header.add(CoreMessages.applicationShutdownNormally(context.getConfiguration().getId(), new Date()).getMessage()); long duration = 10; if (context.getStartDate() > 0) { duration = currentTime - context.getStartDate(); } header.add(CoreMessages.applicationWasUpForDuration(duration).getMessage()); } }
protected MuleWorkManager createWorkManager() { final MuleConfiguration config = getMuleConfiguration(); // still can be embedded, but in container mode, e.g. in a WAR final String threadPrefix = config.isContainerMode() ? String.format("[%s].Mule", config.getId()) : "MuleServer"; ImmutableThreadingProfile threadingProfile = createMuleWorkManager(); return new MuleWorkManager(threadingProfile, threadPrefix, config.getShutdownTimeout()); }
public MuleContextNotification(MuleContext context, int action) { super(generateId(context), action); this.muleContext = context; this.resourceIdentifier = context.getConfiguration().getId(); this.clusterId = context.getClusterId(); this.domain = context.getConfiguration().getDomainId(); }
if (instanceName == null) factoryProperties.setProperty(QUARTZ_INSTANCE_NAME_PROPERTY, getFullName(muleContext.getConfiguration().getId(), getName()));
public String getDomainName(MuleContext context, boolean resolveClash) { String domain = DEFAULT_JMX_DOMAIN_PREFIX; String instanceId = StringUtils.defaultString(context.getConfiguration().getId()); if (instanceId.length() > 0) { domain += "." + instanceId; } JmxRegistrationContext ctx = JmxRegistrationContext.getCurrent(context); String resolvedDomain = ctx.getResolvedDomain(); if (resolveClash) { if (StringUtils.isBlank(resolvedDomain)) { domain = resolveDomainClash(domain); ctx.setResolvedDomain(domain); } } return domain; } }
/** * Callback method for when a message processor is about to be invoked. * <p/> * Updates the internal state of the event's {@link ProcessorsTrace} and {@link FlowCallStack} accordingly. * * @see DefaultProcessorsTrace#addExecutedProcessors(String) * @see DefaultFlowCallStack#setCurrentProcessorPath(String) * * @param notification the notification that contains the event and the processor that is about to be invoked. */ public void onMessageProcessorNotificationPreInvoke(MessageProcessorNotification notification) { String resolveProcessorRepresentation = resolveProcessorRepresentation(muleContext.getConfiguration().getId(), notification.getProcessorPath(), notification.getProcessor()); if (notification.getSource().getProcessorsTrace() instanceof DefaultProcessorsTrace) { ((DefaultProcessorsTrace) notification.getSource().getProcessorsTrace()).addExecutedProcessors(resolveProcessorRepresentation); } if (notification.getSource().getFlowCallStack() instanceof DefaultFlowCallStack) { ((DefaultFlowCallStack) notification.getSource().getFlowCallStack()).setCurrentProcessorPath(resolveProcessorRepresentation); } }