You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by lh...@apache.org on 2009/05/21 15:48:27 UTC
svn commit: r777115 - in
/incubator/jsecurity/trunk/core/src/main/java/org/apache/ki:
mgt/SessionsSecurityManager.java session/mgt/DefaultSessionManager.java
session/mgt/eis/SessionDAOAware.java
Author: lhazlewood
Date: Thu May 21 13:48:27 2009
New Revision: 777115
URL: http://svn.apache.org/viewvc?rev=777115&view=rev
Log:
Added SessionDAOAware interface to allow passthrough configuration of SessionDAOs on the DefaultSecurityManager (to the underlying DefaultSessionManager)
Added:
incubator/jsecurity/trunk/core/src/main/java/org/apache/ki/session/mgt/eis/SessionDAOAware.java
Modified:
incubator/jsecurity/trunk/core/src/main/java/org/apache/ki/mgt/SessionsSecurityManager.java
incubator/jsecurity/trunk/core/src/main/java/org/apache/ki/session/mgt/DefaultSessionManager.java
Modified: incubator/jsecurity/trunk/core/src/main/java/org/apache/ki/mgt/SessionsSecurityManager.java
URL: http://svn.apache.org/viewvc/incubator/jsecurity/trunk/core/src/main/java/org/apache/ki/mgt/SessionsSecurityManager.java?rev=777115&r1=777114&r2=777115&view=diff
==============================================================================
--- incubator/jsecurity/trunk/core/src/main/java/org/apache/ki/mgt/SessionsSecurityManager.java (original)
+++ incubator/jsecurity/trunk/core/src/main/java/org/apache/ki/mgt/SessionsSecurityManager.java Thu May 21 13:48:27 2009
@@ -25,6 +25,8 @@
import org.apache.ki.session.SessionListener;
import org.apache.ki.session.SessionListenerRegistrar;
import org.apache.ki.session.mgt.*;
+import org.apache.ki.session.mgt.eis.SessionDAO;
+import org.apache.ki.session.mgt.eis.SessionDAOAware;
import org.apache.ki.util.LifecycleUtils;
import java.io.Serializable;
@@ -49,7 +51,8 @@
* @author Les Hazlewood
* @since 0.9
*/
-public abstract class SessionsSecurityManager extends AuthorizingSecurityManager implements SessionListenerRegistrar {
+public abstract class SessionsSecurityManager extends AuthorizingSecurityManager
+ implements SessionListenerRegistrar, SessionFactoryAware, SessionDAOAware {
/**
* The internal delegate <code>SessionManager</code> used by this security manager that manages all the
@@ -121,6 +124,18 @@
}
}
+ public void setSessionDAO(SessionDAO sessionDAO) {
+ SessionManager sm = getSessionManager();
+ if (sm instanceof SessionDAOAware) {
+ ((SessionDAOAware) sm).setSessionDAO(sessionDAO);
+ } else {
+ String msg = "The underlying session manager is null or does not implement the " +
+ SessionDAO.class.getName() + " interface, which is required if the underlying " +
+ "instance is to receive the sessionDAO argument.";
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
/**
* Ensures the internal delegate <code>SessionManager</code> is injected with the newly set
* {@link #setCacheManager CacheManager} so it may use it for its internal caching needs.
Modified: incubator/jsecurity/trunk/core/src/main/java/org/apache/ki/session/mgt/DefaultSessionManager.java
URL: http://svn.apache.org/viewvc/incubator/jsecurity/trunk/core/src/main/java/org/apache/ki/session/mgt/DefaultSessionManager.java?rev=777115&r1=777114&r2=777115&view=diff
==============================================================================
--- incubator/jsecurity/trunk/core/src/main/java/org/apache/ki/session/mgt/DefaultSessionManager.java (original)
+++ incubator/jsecurity/trunk/core/src/main/java/org/apache/ki/session/mgt/DefaultSessionManager.java Thu May 21 13:48:27 2009
@@ -24,6 +24,7 @@
import org.apache.ki.session.Session;
import org.apache.ki.session.mgt.eis.MemorySessionDAO;
import org.apache.ki.session.mgt.eis.SessionDAO;
+import org.apache.ki.session.mgt.eis.SessionDAOAware;
import org.apache.ki.util.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -42,7 +43,7 @@
* @since 0.1
*/
public class DefaultSessionManager extends AbstractValidatingSessionManager
- implements CacheManagerAware, SessionFactoryAware {
+ implements CacheManagerAware, SessionFactoryAware, SessionDAOAware {
//TODO - complete JavaDoc
@@ -126,7 +127,7 @@
* delegates and calls
* <code>this.{@link SessionDAO sessionDAO}.{@link SessionDAO#create(org.apache.ki.session.Session) create}(session);<code>
*
- * @param session
+ * @param session the Session instance to persist to the underlying EIS.
*/
protected void create(Session session) {
if (log.isDebugEnabled()) {
Added: incubator/jsecurity/trunk/core/src/main/java/org/apache/ki/session/mgt/eis/SessionDAOAware.java
URL: http://svn.apache.org/viewvc/incubator/jsecurity/trunk/core/src/main/java/org/apache/ki/session/mgt/eis/SessionDAOAware.java?rev=777115&view=auto
==============================================================================
--- incubator/jsecurity/trunk/core/src/main/java/org/apache/ki/session/mgt/eis/SessionDAOAware.java (added)
+++ incubator/jsecurity/trunk/core/src/main/java/org/apache/ki/session/mgt/eis/SessionDAOAware.java Thu May 21 13:48:27 2009
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ki.session.mgt.eis;
+
+/**
+ * Allows interested components to receive a configured {@link SessionDAO} instance.
+ *
+ * @author Les Hazlewood
+ * @since 1.0
+ */
+public interface SessionDAOAware {
+
+ /**
+ * Sets the {@link SessionDAO} to use for {@link org.apache.ki.session.Session Session} CRUD operations.
+ *
+ * @param sessionDAO the {@link SessionDAO} to use for {@link org.apache.ki.session.Session Session} CRUD operations.
+ */
+ void setSessionDAO(SessionDAO sessionDAO);
+}