001: /*
002: * CoadunationLib: The coaduntion implementation library.
003: * Copyright (C) 2006 Rift IT Contracting
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2.1 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
018: *
019: * InterceptorFactory.java
020: *
021: * This class is responsible for returning interceptors constructed with
022: * reference to the coadunation internals. So that incoming threads can be
023: * boot strapped appropriatly.
024: */
025:
026: // package path
027: package com.rift.coad.lib.interceptor;
028:
029: // coadunation imports
030: import com.rift.coad.lib.security.ThreadsPermissionContainer;
031: import com.rift.coad.lib.security.user.UserSessionManager;
032: import com.rift.coad.lib.security.user.UserStoreManager;
033:
034: /**
035: * This class is responsible for returning interceptors constructed with
036: * reference to the coadunation internals. So that incoming threads can be
037: * boot strapped appropriatly.
038: *
039: * @author Brett Chaldecott
040: */
041: public class InterceptorFactory {
042:
043: // private member variables
044: private static InterceptorFactory singleton = null;
045: private ClientInterceptor clientInterceptor = null;
046: private ServerInterceptor serverInterceptor = null;
047:
048: /**
049: * Creates a new instance of InterceptorFactory
050: */
051: private InterceptorFactory(
052: ThreadsPermissionContainer permissionContainer,
053: UserSessionManager userSessionManager,
054: UserStoreManager userStoreManger) {
055: serverInterceptor = new ServerInterceptor(permissionContainer,
056: userSessionManager, userStoreManger);
057: clientInterceptor = new ClientInterceptor(permissionContainer);
058: }
059:
060: /**
061: * This method instanciates the rmi interceptor factory
062: *
063: *
064: * @return The reference to the RMI interceptor factory.
065: * @param permissionContainer The reference to the permission container.
066: * @exception InterceptorException
067: */
068: public static synchronized InterceptorFactory init(
069: ThreadsPermissionContainer permissionContainer,
070: UserSessionManager userSessionManager,
071: UserStoreManager userStoreManger)
072: throws InterceptorException {
073: if (singleton == null) {
074: return singleton = new InterceptorFactory(
075: permissionContainer, userSessionManager,
076: userStoreManger);
077: }
078: throw new InterceptorException(
079: "The interceptor factory has already "
080: + "been initialized.");
081: }
082:
083: /**
084: * This method returns a reference to the rmi interceptor factory singleton.
085: *
086: *
087: * @return The reference to the RMI interceptor factory.
088: * @exception InterceptorException
089: */
090: protected static synchronized InterceptorFactory getInstance()
091: throws InterceptorException {
092: if (singleton == null) {
093: throw new InterceptorException(
094: "The interceptor factory has not "
095: + "been initialized.");
096: }
097: return singleton;
098: }
099:
100: /**
101: * This method returns a reference to the client interceptor.
102: *
103: * @return A reference to the client intercpetor.
104: * @exception InterceptorException
105: */
106: protected ClientInterceptor getClientInterceptor()
107: throws InterceptorException {
108: return clientInterceptor;
109: }
110:
111: /**
112: * This method returns a reference to the server interceptor.
113: *
114: * @return A reference to the server interceptor.
115: * @exception InterceptorException
116: */
117: protected ServerInterceptor getServerInterceptor()
118: throws InterceptorException {
119: return serverInterceptor;
120: }
121: }
|