1 25 26 package com.rift.coad.lib.interceptor; 28 29 import com.rift.coad.lib.security.ThreadsPermissionContainer; 31 import com.rift.coad.lib.security.user.UserSessionManager; 32 import com.rift.coad.lib.security.user.UserStoreManager; 33 34 41 public class InterceptorFactory { 42 43 private static InterceptorFactory singleton = null; 45 private ClientInterceptor clientInterceptor = null; 46 private ServerInterceptor serverInterceptor = null; 47 48 51 private InterceptorFactory(ThreadsPermissionContainer permissionContainer, 52 UserSessionManager userSessionManager, UserStoreManager 53 userStoreManger) { 54 serverInterceptor = new ServerInterceptor(permissionContainer, 55 userSessionManager, userStoreManger); 56 clientInterceptor = new ClientInterceptor(permissionContainer); 57 } 58 59 60 68 public static synchronized InterceptorFactory init( 69 ThreadsPermissionContainer permissionContainer, UserSessionManager 70 userSessionManager, UserStoreManager userStoreManger) throws 71 InterceptorException { 72 if (singleton == null) { 73 return singleton = new InterceptorFactory(permissionContainer, 74 userSessionManager,userStoreManger); 75 } 76 throw new InterceptorException("The interceptor factory has already " + 77 "been initialized."); 78 } 79 80 81 88 protected static synchronized InterceptorFactory getInstance() throws 89 InterceptorException { 90 if (singleton == null) { 91 throw new InterceptorException("The interceptor factory has not " + 92 "been initialized."); 93 } 94 return singleton; 95 } 96 97 98 104 protected ClientInterceptor getClientInterceptor() throws 105 InterceptorException { 106 return clientInterceptor; 107 } 108 109 110 116 protected ServerInterceptor getServerInterceptor() throws 117 InterceptorException { 118 return serverInterceptor; 119 } 120 } 121 | Popular Tags |