@Scope(ScopeConstants.PERTHREAD) public class InternalRequestGlobalsImpl implements InternalRequestGlobals { private Throwable classLoaderException; public Throwable getClassLoaderException() { return classLoaderException; } public void storeClassLoaderException(Throwable classLoaderException) { if (this.classLoaderException == null) this.classLoaderException = classLoaderException; } }
@Scope(ScopeConstants.PERTHREAD) public class DateUtilitiesImpl implements DateUtilities { private static final TimeZone tz = TimeZone.getTimeZone("UTC"); private DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); { df.setTimeZone(tz); } public String formatISO8601(Date date) { assert date != null; return df.format(date); } }
@Scope(ScopeConstants.PERTHREAD) public class ThreadLocaleImpl implements ThreadLocale { private Locale locale = Locale.getDefault(); @Override public Locale getLocale() { return locale; } @Override public void setLocale(Locale locale) { assert locale != null; this.locale = locale; } }
@Scope(ScopeConstants.PERTHREAD) public class ThreadLocaleImpl implements ThreadLocale { private Locale locale = Locale.getDefault(); @Override public Locale getLocale() { return locale; } @Override public void setLocale(Locale locale) { assert locale != null; this.locale = locale; } }
@Scope(ScopeConstants.PERTHREAD) public class JSSupportImpl implements JSSupport { private final JSLocator jsLocator; private final StringBuffer scriptBuffer; public JSSupportImpl(JSLocator jsLocator, Logger logger) { this.jsLocator = jsLocator; scriptBuffer = new StringBuffer(); } public void addScript(String script) { scriptBuffer.append(script); } public String store() { if ( scriptBuffer.length() == 0 ) { return null; } scriptBuffer.insert(0,"function jsOnLoad() {"); scriptBuffer.append("}"); return jsLocator.store(scriptBuffer.toString()); } }
@Scope("magic") public Runnable buildUnknownScope() { return null; } }
@Scope(ScopeConstants.PERTHREAD) public StringBuilder buildScopeRequiresAProxyAndNoInterfaceIsProvided() { return null; } }
@Scope("onread") public String getAnnotationOnRead() { return null; }
@Scope("threaded") public FoeService buildBarney() { return null; }
@Scope(ScopeConstants.PERTHREAD) @PreventServiceDecoration public class ExceptionTrackerImpl implements ExceptionTracker { private final Set<Throwable> exceptions = CollectionFactory.newSet(); @Override public boolean exceptionLogged(Throwable exception) { boolean result = exceptions.contains(exception); exceptions.add(exception); return result; } }
@Scope("onwrite") public void setAnnotationOnWrite(String value) { }
@Scope("onwrite") public void setAnnotationOnRead(String value) { }
@Scope(ScopeConstants.PERTHREAD) @PreventServiceDecoration public class ExceptionTrackerImpl implements ExceptionTracker { private final Set<Throwable> exceptions = CollectionFactory.newSet(); @Override public boolean exceptionLogged(Throwable exception) { boolean result = exceptions.contains(exception); exceptions.add(exception); return result; } }
@Scope(ScopeConstants.PERTHREAD) public static EntityManagerManager buildEntityManagerManager(final EntityManagerSource entityManagerSource, final PerthreadManager perthreadManager, final Logger logger) { final EntityManagerManagerImpl service = new EntityManagerManagerImpl(entityManagerSource, logger); perthreadManager.addThreadCleanupListener(service); return service; }
/** * The session manager manages sessions on a per-thread/per-request basis. Any active transaction will be rolled * back at {@linkplain org.apache.tapestry5.ioc.Registry#cleanupThread() thread cleanup time}. The thread is * cleaned up automatically in a Tapestry web application. */ @Scope(ScopeConstants.PERTHREAD) public static HibernateSessionManager buildHibernateSessionManager(HibernateSessionSource sessionSource, PerthreadManager perthreadManager) { HibernateSessionManagerImpl service = new HibernateSessionManagerImpl(sessionSource); perthreadManager.addThreadCleanupListener(service); return service; }
@Scope(ScopeConstants.PERTHREAD) public static EntityManagerManager buildEntityManagerManager(final EntityManagerSource entityManagerSource, final PerthreadManager perthreadManager, final Logger logger) { final EntityManagerManagerImpl service = new EntityManagerManagerImpl(entityManagerSource, logger); perthreadManager.addThreadCleanupListener(service); return service; }
/** * The session manager manages sessions on a per-thread/per-request basis. Any active transaction will be rolled * back at {@linkplain org.apache.tapestry5.ioc.Registry#cleanupThread() thread cleanup time}. The thread is * cleaned up automatically in a Tapestry web application. */ @Scope(ScopeConstants.PERTHREAD) public static HibernateSessionManager buildHibernateSessionManager(HibernateSessionSource sessionSource, PerthreadManager perthreadManager) { HibernateSessionManagerImpl service = new HibernateSessionManagerImpl(sessionSource); perthreadManager.addThreadCleanupListener(service); return service; }
@Scope(ScopeConstants.PERTHREAD) public Environment buildEnvironment(PerthreadManager perthreadManager) { final EnvironmentImpl service = new EnvironmentImpl(); perthreadManager.addThreadCleanupCallback(new Runnable() { public void run() { service.threadDidCleanup(); } }); return service; }
@Scope(ScopeConstants.PERTHREAD) public StringHolder buildStringHolder(@Autobuild StringHolderImpl impl) { return impl; } }
@Scope(ScopeConstants.PERTHREAD) public static MongoDB buildMongoDB(Logger logger, final MongoDBSource mongoDBSource, PerthreadManager perthreadManager, @Symbol(MongoDBSymbols.DEFAULT_DB_NAME) String defaultDbName, @Symbol(MongoDBSymbols.CONSISTENT_REQUEST) boolean consistentRequest, @Symbol(MongoDBSymbols.SECURE_MODE) boolean secureMode, @Symbol(MongoDBSymbols.DB_USERNAME) String dbUsername, @Symbol(MongoDBSymbols.DB_PASSWORD) String dbPassword) { final MongoDBImpl mongoDB = new MongoDBImpl(logger, mongoDBSource, defaultDbName, consistentRequest, secureMode, dbUsername, dbPassword); perthreadManager.addThreadCleanupListener(mongoDB); return mongoDB; }