@Override public void advise(MethodInvocation invocation) { tracker.run(description, toRunnable(invocation)); } }
@Override public void run(String description, Runnable operation) { operationTracker.run(description, operation); }
@Override public void advise(MethodInvocation invocation) { tracker.run(description, toRunnable(invocation)); } }
@Override public void run(String description, Runnable operation) { operationTracker.run(description, operation); }
public void run(String description, Runnable operation) { tracker.run(description, operation); }
private void loadScript(final Context context, final ScriptableObject scope, final Resource script) { tracker.run(String.format("Loading script %s.", script), new Runnable() { @Override public void run() { InputStream in = null; Reader r = null; try { in = script.openStream(); r = new InputStreamReader(in, "UTF-8"); context.evaluateReader(scope, r, script.toString(), 1, null); } catch (IOException ex) { throw new RuntimeException(String.format("Unable to read script %s: %s", script, ExceptionUtils.toMessage(ex) ), ex); } finally { InternalUtils.close(r); InternalUtils.close(in); } } }); }
@Override public void advise(MethodInvocation invocation) { Object[] parameters = extractParameters(invocation); String description = String.format(format, parameters); tracker.run(description, toRunnable(invocation)); }
@Override public void advise(MethodInvocation invocation) { Object[] parameters = extractParameters(invocation); String description = String.format(format, parameters); tracker.run(description, toRunnable(invocation)); }
private void executeInitializationPLans(final T newInstance) { for (final InitializationPlan<T> plan : initializationPlans) { tracker.run(plan.getDescription(), new Runnable() { @Override public void run() { plan.initialize(newInstance); } }); } } }
private void executeInitializationPLans(final T newInstance) { for (final InitializationPlan<T> plan : initializationPlans) { tracker.run(plan.getDescription(), new Runnable() { @Override public void run() { plan.initialize(newInstance); } }); } } }
@Override public void run(String description, Runnable operation) { try { get().run(description, operation); } finally { cleanup(); } }
@Override public void run(String description, Runnable operation) { try { get().run(description, operation); } finally { cleanup(); } }
private <T> void addToOrderedConfiguration(Orderer<T> orderer, Map<String, OrderedConfigurationOverride<T>> overrides, Class<T> valueType, ServiceDef3 serviceDef, final Module module) { String serviceId = serviceDef.getServiceId(); Set<ContributionDef2> contributions = module.getContributorDefsForService(serviceDef); if (contributions.isEmpty()) return; Logger logger = getServiceLogger(serviceId); final ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, proxyFactory, logger); for (final ContributionDef def : contributions) { final OrderedConfiguration<T> validating = new ValidatingOrderedConfigurationWrapper<T>(valueType, resources, typeCoercerProxy, orderer, overrides, def); String description = "Invoking " + def; logger.debug(description); operationTracker.run(description, new Runnable() { @Override public void run() { def.contribute(module, resources, validating); } }); } }
private <T> void addToUnorderedConfiguration(Collection<T> collection, Class<T> valueType, ServiceDef3 serviceDef, final Module module) { String serviceId = serviceDef.getServiceId(); Set<ContributionDef2> contributions = module.getContributorDefsForService(serviceDef); if (contributions.isEmpty()) return; Logger logger = getServiceLogger(serviceId); final ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, proxyFactory, logger); for (final ContributionDef def : contributions) { final Configuration<T> validating = new ValidatingConfigurationWrapper<T>(valueType, resources, typeCoercerProxy, collection, serviceId); String description = "Invoking " + def; logger.debug(description); operationTracker.run(description, new Runnable() { @Override public void run() { def.contribute(module, resources, validating); } }); } }
private <K, V> void addToMappedConfiguration(Map<K, V> map, Map<K, MappedConfigurationOverride<K, V>> overrides, Map<K, ContributionDef> keyToContribution, Class<K> keyClass, Class<V> valueType, ServiceDef3 serviceDef, final Module module) { String serviceId = serviceDef.getServiceId(); Set<ContributionDef2> contributions = module.getContributorDefsForService(serviceDef); if (contributions.isEmpty()) return; Logger logger = getServiceLogger(serviceId); final ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, proxyFactory, logger); for (final ContributionDef def : contributions) { final MappedConfiguration<K, V> validating = new ValidatingMappedConfigurationWrapper<K, V>(valueType, resources, typeCoercerProxy, map, overrides, serviceId, def, keyClass, keyToContribution); String description = "Invoking " + def; logger.debug(description); operationTracker.run(description, new Runnable() { @Override public void run() { def.contribute(module, resources, validating); } }); } }
private <K, V> void addToMappedConfiguration(Map<K, V> map, Map<K, MappedConfigurationOverride<K, V>> overrides, Map<K, ContributionDef> keyToContribution, Class<K> keyClass, Class<V> valueType, ServiceDef3 serviceDef, final Module module) { String serviceId = serviceDef.getServiceId(); Set<ContributionDef2> contributions = module.getContributorDefsForService(serviceDef); if (contributions.isEmpty()) return; Logger logger = getServiceLogger(serviceId); final ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, proxyFactory, logger); for (final ContributionDef def : contributions) { final MappedConfiguration<K, V> validating = new ValidatingMappedConfigurationWrapper<K, V>(valueType, resources, typeCoercerProxy, map, overrides, serviceId, def, keyClass, keyToContribution); String description = "Invoking " + def; logger.debug(description); operationTracker.run(description, new Runnable() { @Override public void run() { def.contribute(module, resources, validating); } }); } }
private <T> void addToUnorderedConfiguration(Collection<T> collection, Class<T> valueType, ServiceDef3 serviceDef, final Module module) { String serviceId = serviceDef.getServiceId(); Set<ContributionDef2> contributions = module.getContributorDefsForService(serviceDef); if (contributions.isEmpty()) return; Logger logger = getServiceLogger(serviceId); final ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, proxyFactory, logger); for (final ContributionDef def : contributions) { final Configuration<T> validating = new ValidatingConfigurationWrapper<T>(valueType, resources, typeCoercerProxy, collection, serviceId); String description = "Invoking " + def; logger.debug(description); operationTracker.run(description, new Runnable() { @Override public void run() { def.contribute(module, resources, validating); } }); } }
public void transform(final PlasticClass plasticClass, TransformationSupport support, final MutableComponentModel model) { for (final PlasticField field : F.flow(plasticClass.getUnclaimedFields()).filter(MATCHER)) { final String fieldName = field.getName(); tracker.run(String.format("Injecting field %s.%s", plasticClass.getClassName(), fieldName), new Runnable() { public void run() { try { boolean success = injectionProvider.provideInjection(field, locator, model); if (success) { field.claim("@Inject"); } } catch (RuntimeException ex) { throw new RuntimeException(String.format("Error obtaining injected value for field %s.%s: %s", plasticClass.getClassName(), fieldName, ExceptionUtils.toMessage(ex)), ex); } } }); } } }
public void handlePageRender(final PageRenderRequestParameters parameters, final ComponentRequestHandler handler) throws IOException { final Holder<IOException> holder = Holder.create(); tracker.run("Handling page render request for page " + parameters.getLogicalPageName(), new Runnable() { public void run() { try { handler.handlePageRender(parameters); } catch (IOException e) { holder.put(e); } } } ); if (holder.hasValue()) { throw holder.get(); } } }
public void advise(final MethodInvocation invocation) { final ComponentEvent event = (ComponentEvent) invocation.getParameter(0); boolean matches = !event.isAborted() && event.matches(eventType, "", minContextValues); if (matches) { tracker.run(operationDescription, new Runnable() { public void run() { Component instance = (Component) invocation.getInstance(); handler.handleEvent(instance, event); } }); } // Order of operations is key here. This logic takes precedence; base class event dispatch and event handler methods // in the class come AFTER. invocation.proceed(); if (matches) { invocation.setReturnValue(true); } } }