001: package ru.emdev.EmForge;
002:
003: import java.io.Serializable;
004:
005: import org.apache.commons.logging.Log;
006: import org.apache.commons.logging.LogFactory;
007: import org.hibernate.Session;
008: import org.hibernate.SessionFactory;
009: import org.springframework.context.ApplicationContext;
010: import org.springframework.context.ApplicationContextAware;
011:
012: import ru.emdev.EmForge.security.UserSettingsService;
013: import ru.emdev.EmForge.util.Helper;
014:
015: import com.ecyrd.jspwiki.WikiEngine;
016:
017: /**
018: * Basic implementation of EmForge Context
019: */
020: public class EmForgeContextImpl implements EmForgeContext,
021: ApplicationContextAware, Serializable {
022:
023: private static final long serialVersionUID = 7072162975056293792L;
024: protected final Log logger = LogFactory.getLog(getClass());
025:
026: protected String m_applicationPath;
027: protected String m_appName;
028: protected UserSettingsService m_userService;
029: protected ApplicationContext m_appContext;
030: protected SessionFactory m_sessionFactory;
031: protected String m_appVersion;
032: protected boolean m_registerAllowed;
033:
034: /**
035: * @param i_applicationPath
036: */
037: public void setApplicationPath(String i_applicationPath) {
038:
039: m_applicationPath = i_applicationPath;
040: }
041:
042: /**
043: * @param i_appName
044: */
045: public void setAppName(String i_appName) {
046:
047: m_appName = i_appName;
048: }
049:
050: /**
051: * Sets a reference to user settings bean to retrieve default user settings. Called by Spring Framework.
052: *
053: * @param i_userSettingsService is a user settings bean to set
054: */
055: public void setUserService(UserSettingsService i_userSettingsService) {
056:
057: m_userService = i_userSettingsService;
058: }
059:
060: /**
061: * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
062: */
063: public void setApplicationContext(ApplicationContext i_appContext) {
064:
065: m_appContext = i_appContext;
066: }
067:
068: /**
069: * @param i_sessionFactory
070: */
071: public void setSessionFactory(SessionFactory i_sessionFactory) {
072:
073: m_sessionFactory = i_sessionFactory;
074: }
075:
076: /**
077: * @see ru.emdev.EmForge.EmForgeContext#getApplicationPath()
078: */
079: public String getApplicationPath() {
080:
081: return m_applicationPath;
082: }
083:
084: /**
085: * @see ru.emdev.EmForge.EmForgeContext#getUserService()
086: */
087: public UserSettingsService getUserService() {
088:
089: return m_userService;
090: }
091:
092: /**
093: * @see ru.emdev.EmForge.EmForgeContext#getSession()
094: */
095: public Session getSession() {
096:
097: return m_sessionFactory.getCurrentSession();
098: }
099:
100: WikiEngine m_wikiEngine = null;
101:
102: /**
103: * @see ru.emdev.EmForge.EmForgeContext#getAppName()
104: */
105: public String getAppName() {
106:
107: return m_appName;
108: }
109:
110: /**
111: * @see ru.emdev.EmForge.EmForgeContext#getAppVersion()
112: */
113: public String getAppVersion() {
114:
115: return m_appVersion;
116: }
117:
118: /**
119: * @param i_appVersion
120: */
121: public void setAppVersion(String i_appVersion) {
122:
123: m_appVersion = i_appVersion;
124: }
125:
126: /**
127: * @return
128: */
129: public String getPath() {
130:
131: return Helper.getPath();
132: }
133:
134: /**
135: * @see ru.emdev.EmForge.EmForgeContext#isRegisterAllowed()
136: */
137: public boolean isRegisterAllowed() {
138:
139: return m_registerAllowed;
140: }
141:
142: /**
143: * @param i_registerAllowed
144: */
145: public void setRegisterAllowed(boolean i_registerAllowed) {
146:
147: m_registerAllowed = i_registerAllowed;
148: }
149:
150: }
|