/** * @param updateListenerHub * invoked, at intervals, to spur the process of detecting changes * @param checkInterval * interval, in milliseconds, between checks * @param updateTimeout * time, in milliseconds, to wait to obtain update lock. */ public CheckForUpdatesFilter(UpdateListenerHub updateListenerHub, @Symbol(SymbolConstants.FILE_CHECK_INTERVAL) @IntermediateType(TimeInterval.class) long checkInterval, @Symbol(SymbolConstants.FILE_CHECK_UPDATE_TIMEOUT) @IntermediateType(TimeInterval.class) long updateTimeout) { this.updateListenerHub = updateListenerHub; this.checkInterval = checkInterval; this.updateTimeout = updateTimeout; }
protected final void train_value(IntermediateType it, Class value) { expect(it.value()).andReturn(value); }
@Override @Advise(id = "id", serviceInterface = NonAnnotatedServiceInterface.class) public String execute2(@IntermediateType(String.class) final String t) { return null; }
protected final void train_value(IntermediateType it, Class value) { expect(it.value()).andReturn(value); }
@Override @Advise(id = "id", serviceInterface = NonAnnotatedServiceInterface.class) public String execute2(@IntermediateType(String.class) String t, String s) { return null; }
@Override public <T> T provide(Class<T> objectType, AnnotationProvider annotationProvider, ObjectLocator locator) { Value annotation = annotationProvider.getAnnotation(Value.class); if (annotation == null) return null; String value = annotation.value(); Object expanded = symbolSource.expandSymbols(value); IntermediateType intermediate = annotationProvider.getAnnotation(IntermediateType.class); if (intermediate != null) expanded = typeCoercer.coerce(expanded, intermediate.value()); return typeCoercer.coerce(expanded, objectType); } }
/** * @param request * @param cookieSource * @param cookieSink * @param contextPath * @param defaultMaxAge * default cookie expiration time in milliseconds */ public CookiesImpl(Request request, CookieSource cookieSource, CookieSink cookieSink, @Symbol(SymbolConstants.CONTEXT_PATH) String contextPath, @Symbol("tapestry.default-cookie-max-age") @IntermediateType(TimeInterval.class) long defaultMaxAge) { this.request = request; this.cookieSource = cookieSource; this.cookieSink = cookieSink; this.defaultCookiePath = contextPath + "/"; this.defaultMaxAge = (int) (defaultMaxAge / 1000l); }
@Override public <T> T provide(Class<T> objectType, AnnotationProvider annotationProvider, ObjectLocator locator) { Symbol annotation = annotationProvider.getAnnotation(Symbol.class); if (annotation == null) return null; Object value = symbolSource.valueForSymbol(annotation.value()); IntermediateType it = annotationProvider.getAnnotation(IntermediateType.class); if (it != null) value = typeCoercer.coerce(value, it.value()); return typeCoercer.coerce(value, objectType); }
@Advise(id = "right") public String duplicatedAnnotation(@IntermediateType(String.class) String parameter) { return null; }
@Override public <T> T provide(Class<T> objectType, AnnotationProvider annotationProvider, ObjectLocator locator) { Value annotation = annotationProvider.getAnnotation(Value.class); if (annotation == null) return null; String value = annotation.value(); Object expanded = symbolSource.expandSymbols(value); IntermediateType intermediate = annotationProvider.getAnnotation(IntermediateType.class); if (intermediate != null) expanded = typeCoercer.coerce(expanded, intermediate.value()); return typeCoercer.coerce(expanded, objectType); } }
@Override @Advise(id = "id", serviceInterface = NonAnnotatedServiceInterface.class) public String execute1(@IntermediateType(String.class) final int i) { return null; }
@Override public <T> T provide(Class<T> objectType, AnnotationProvider annotationProvider, ObjectLocator locator) { Symbol annotation = annotationProvider.getAnnotation(Symbol.class); if (annotation == null) return null; Object value = symbolSource.valueForSymbol(annotation.value()); IntermediateType it = annotationProvider.getAnnotation(IntermediateType.class); if (it != null) value = typeCoercer.coerce(value, it.value()); return typeCoercer.coerce(value, objectType); }
@Override @Advise(id = "id", serviceInterface = NonAnnotatedServiceInterface.class) public String execute3(@IntermediateType(String.class) int i) { return null; }
@Override public void advise(MethodInvocation invocation) { final Method method = invocation.getMethod(); boolean annotationFoundInMethod = checkAnnotation(method.getAnnotation(Advise.class)); boolean annotationFoundThroughAnnotationProvider = checkAnnotation(invocation.getAnnotation(Advise.class)); IntermediateType parameterAnnotation = null; final Annotation[][] parameterAnnotations = method.getParameterAnnotations(); if (parameterAnnotations.length > 0 && parameterAnnotations[0].length > 0) { parameterAnnotation = (IntermediateType) parameterAnnotations[0][0]; } boolean annotationParameter = parameterAnnotation != null && parameterAnnotation.value() == String.class; if (annotationFoundInMethod && annotationFoundThroughAnnotationProvider && annotationParameter) { invocation.setReturnValue(ANNOTATION_FOUND); } else { invocation.proceed(); } }
@Advise(id = "id", serviceInterface = NonAnnotatedServiceInterface.class) public String execute(@IntermediateType(String.class) int i);
@Advise(id = "wrong") public String duplicatedAnnotation(@IntermediateType(Object.class) String parameter);
@Override @Advise(id = "id", serviceInterface = NonAnnotatedServiceInterface.class) public String execute(@IntermediateType(String.class) int i) // annotation just for checking too { // a try/catch block, as it caused some troubles with proxy class generation try { System.out.println(); } catch (Exception e) { e.printStackTrace(); } return null; }
public static ParallelExecutor buildDeferredExecution(@Symbol(IOCSymbols.THREAD_POOL_CORE_SIZE) int coreSize, @Symbol(IOCSymbols.THREAD_POOL_MAX_SIZE) int maxSize, @Symbol(IOCSymbols.THREAD_POOL_KEEP_ALIVE) @IntermediateType(TimeInterval.class) int keepAliveMillis, @Symbol(IOCSymbols.THREAD_POOL_ENABLED) boolean threadPoolEnabled, @Symbol(IOCSymbols.THREAD_POOL_QUEUE_SIZE) int queueSize, PerthreadManager perthreadManager, RegistryShutdownHub shutdownHub, ThunkCreator thunkCreator) { if (!threadPoolEnabled) return new NonParallelExecutor(); LinkedBlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<Runnable>(queueSize); final ThreadPoolExecutor executorService = new ThreadPoolExecutor(coreSize, maxSize, keepAliveMillis, TimeUnit.MILLISECONDS, workQueue); shutdownHub.addRegistryShutdownListener(new Runnable() { @Override public void run() { executorService.shutdown(); } }); return new ParallelExecutorImpl(executorService, thunkCreator, perthreadManager); }
public static ParallelExecutor buildDeferredExecution(@Symbol(IOCSymbols.THREAD_POOL_CORE_SIZE) int coreSize, @Symbol(IOCSymbols.THREAD_POOL_MAX_SIZE) int maxSize, @Symbol(IOCSymbols.THREAD_POOL_KEEP_ALIVE) @IntermediateType(TimeInterval.class) int keepAliveMillis, @Symbol(IOCSymbols.THREAD_POOL_ENABLED) boolean threadPoolEnabled, @Symbol(IOCSymbols.THREAD_POOL_QUEUE_SIZE) int queueSize, PerthreadManager perthreadManager, RegistryShutdownHub shutdownHub, ThunkCreator thunkCreator) { if (!threadPoolEnabled) return new NonParallelExecutor(); LinkedBlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<Runnable>(queueSize); final ThreadPoolExecutor executorService = new ThreadPoolExecutor(coreSize, maxSize, keepAliveMillis, TimeUnit.MILLISECONDS, workQueue); shutdownHub.addRegistryShutdownListener(new Runnable() { @Override public void run() { executorService.shutdown(); } }); return new ParallelExecutorImpl(executorService, thunkCreator, perthreadManager); }