You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by js...@apache.org on 2006/01/16 00:36:20 UTC
svn commit: r369280 -
/geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/
Author: jstrachan
Date: Sun Jan 15 15:36:05 2006
New Revision: 369280
URL: http://svn.apache.org/viewcvs?rev=369280&view=rev
Log:
A spike for a simple API for working with stateful session bean state from OpenEJB, ServiceMix or Tuscany; its very simple to use & has all thats required from the perspective of the client; we should be able to layer this on pretty much any implementation technology like WADI et al
Added:
geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/Locator.java
geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/NoSuchSessionException.java
geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/Server.java
geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/Session.java
geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionAlreadyExistsException.java
geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionDestroyedException.java
geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionException.java
geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionLocation.java
geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionNotLocalException.java
geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionNotMovableException.java
geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/WriteLockTimedOutException.java
Modified:
geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/package.html
Added: geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/Locator.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/Locator.java?rev=369280&view=auto
==============================================================================
--- geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/Locator.java (added)
+++ geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/Locator.java Sun Jan 15 15:36:05 2006
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.geronimo.session;
+
+/**
+ * This is the main API to locating where sessions are located, to create
+ * new sessions and to view the available servers. There is a single Locator per
+ * local {@link Server}.
+ *
+ * @version $Revision: $
+ */
+public interface Locator {
+
+ /**
+ * Finds the session location which could be local or remote
+ */
+ public SessionLocation getSessionLocation(String clientID);
+
+ Session createSession(String sessionId) throws SessionAlreadyExistsException;
+
+ public Server[] getRemoteServers();
+
+ public Server getLocalServer();
+}
Added: geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/NoSuchSessionException.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/NoSuchSessionException.java?rev=369280&view=auto
==============================================================================
--- geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/NoSuchSessionException.java (added)
+++ geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/NoSuchSessionException.java Sun Jan 15 15:36:05 2006
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.geronimo.session;
+
+/**
+ * An attempt was made to access an exception which does not exist.
+ *
+ * @version $Revision: $
+ */
+public class NoSuchSessionException extends SessionException {
+
+ private static final long serialVersionUID = 4002448240048003002L;
+
+ public NoSuchSessionException(String sessionId) {
+ super("No such session ID: " + sessionId, sessionId);
+ }
+}
Added: geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/Server.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/Server.java?rev=369280&view=auto
==============================================================================
--- geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/Server.java (added)
+++ geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/Server.java Sun Jan 15 15:36:05 2006
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.geronimo.session;
+
+/**
+ * Represents a logical server which is either the local server or a remote
+ * server.
+ *
+ * @version $Revision: $
+ */
+public interface Server {
+
+ /**
+ * Returns the unique name of this server
+ */
+ String getName();
+
+ /**
+ * Returns the addresses on which you can communicate with the server which is
+ * required for redirecting or proxying requests for remote sessions
+ */
+ String[] getAddresses(String protocol);
+
+ /**
+ * Configures the available addresses that can be used to connect to this server
+ */
+ void setAddresses(String string, String[] strings);
+
+ /**
+ * Is this the local in-JVM server or a remote server
+ */
+ public boolean isLocalServer();
+
+}
Added: geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/Session.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/Session.java?rev=369280&view=auto
==============================================================================
--- geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/Session.java (added)
+++ geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/Session.java Sun Jan 15 15:36:05 2006
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.geronimo.session;
+
+/**
+ * The state for a stateful session client which always exists in the local JVM; it is never remote.
+ *
+ * There is only one instance of this object in the system for a given session
+ * ID; even when using buddy groups to replicate session state there will only
+ * be one Session; the others are just backups of the serialized state (a
+ * byte[]) and not an actual usable Session object.
+ *
+ * @version $Revision: $
+ */
+public interface Session {
+
+ /**
+ * Returns the Id of the session.
+ */
+ public String getSessionId();
+
+ /**
+ * Releases the session so that its changed state can be replicated to its
+ * buddies (once a write lock can be acquired as there may be concurrent
+ * access to this session).
+ *
+ */
+ public void release();
+
+ /**
+ * Creates the state for the given key.
+ */
+ public void addState(String key, Object value);
+
+ /**
+ * This method assumes that the client will update the state object and so
+ * if you are using a state backup mechanism then this method call marks the
+ * entry as modified.
+ */
+ public Object getState(String key);
+
+ /**
+ * Removes the state entry for the given key (such as if an EJB stateful
+ * session bean is destroyed)
+ */
+ public Object removeState(String key);
+}
Added: geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionAlreadyExistsException.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionAlreadyExistsException.java?rev=369280&view=auto
==============================================================================
--- geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionAlreadyExistsException.java (added)
+++ geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionAlreadyExistsException.java Sun Jan 15 15:36:05 2006
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.geronimo.session;
+
+/**
+ * An attempt was made to create a new session which was already created by another
+ * process or thread.
+ *
+ * @version $Revision: $
+ */
+public class SessionAlreadyExistsException extends SessionException {
+
+ private static final long serialVersionUID = 7152083589480056760L;
+
+ public SessionAlreadyExistsException(String sessionId) {
+ super("The session already exists for ID: " + sessionId, sessionId);
+ }
+}
Added: geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionDestroyedException.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionDestroyedException.java?rev=369280&view=auto
==============================================================================
--- geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionDestroyedException.java (added)
+++ geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionDestroyedException.java Sun Jan 15 15:36:05 2006
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.geronimo.session;
+
+/**
+ * An attempt was made to use a session that has already been destroyed.
+ *
+ * @version $Revision: $
+ */
+public class SessionDestroyedException extends RuntimeException {
+
+ private static final long serialVersionUID = 7834900446243654015L;
+
+ private final String sessionId;
+
+ public SessionDestroyedException(String sessionId) {
+ super("The session is already destroyed: " + sessionId);
+ this.sessionId = sessionId;
+ }
+
+ public String getSessionId() {
+ return sessionId;
+ }
+
+}
Added: geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionException.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionException.java?rev=369280&view=auto
==============================================================================
--- geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionException.java (added)
+++ geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionException.java Sun Jan 15 15:36:05 2006
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.geronimo.session;
+
+/**
+ * An exception occurred working with a given session.
+ *
+ * @version $Revision: $
+ */
+public class SessionException extends Exception {
+
+ private static final long serialVersionUID = 1880705415197036320L;
+
+ private final String sessionId;
+
+ public SessionException(String message, String sessionId) {
+ super(message);
+ this.sessionId = sessionId;
+ }
+
+ /**
+ * Returns the Session Id that causes the exception
+ */
+ public String getSessionId() {
+ return sessionId;
+ }
+}
Added: geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionLocation.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionLocation.java?rev=369280&view=auto
==============================================================================
--- geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionLocation.java (added)
+++ geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionLocation.java Sun Jan 15 15:36:05 2006
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.geronimo.session;
+
+/**
+ * Represents the location of a session which could be local or remote.
+ *
+ * @version $Revision: $
+ */
+public interface SessionLocation {
+
+ /**
+ * Is the session local to this JVM so that it can be used directly or
+ * must the user redirect, proxy or move.
+ */
+ boolean isLocal();
+
+ /**
+ * Is this session movable.
+ */
+ boolean isMovable();
+
+ /**
+ * Returns the session ID.
+ */
+ String getSessionId();
+
+ /**
+ * Returns the server (JVM) where this session is currently located so that
+ * you can redirector proxy to the actual server where the session is hosted
+ * or maybe use some server metadata to make a decision if its worth moving
+ * it.
+ */
+ Server getServer();
+
+ /**
+ * Acquires the current session handle; you must release it when you have
+ * done.
+ *
+ * NOTE this session object is not thread safe
+ *
+ * @see Session#release()
+ */
+ Session getSession() throws SessionNotLocalException;
+
+ /**
+ * Moves the remote session to this JVM and acquires the current session;
+ * you must release it when you have done.
+ *
+ * NOTE this session object is not thread safe
+ *
+ * @see Session#release()
+ */
+ Session moveLocally() throws NoSuchSessionException, WriteLockTimedOutException, SessionNotLocalException,
+ SessionNotMovableException;
+
+ /**
+ * Destroys the session from the system
+ */
+ void destroy() throws SessionNotLocalException;
+
+}
Added: geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionNotLocalException.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionNotLocalException.java?rev=369280&view=auto
==============================================================================
--- geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionNotLocalException.java (added)
+++ geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionNotLocalException.java Sun Jan 15 15:36:05 2006
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.geronimo.session;
+
+/**
+ * An attempt was mode to use local access to a session which is remote.
+ *
+ * @version $Revision: $
+ */
+public class SessionNotLocalException extends SessionException {
+
+ private static final long serialVersionUID = -53844606425457569L;
+
+ public SessionNotLocalException(String sessionId) {
+ super("The session is not local: " + sessionId, sessionId);
+ }
+
+}
Added: geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionNotMovableException.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionNotMovableException.java?rev=369280&view=auto
==============================================================================
--- geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionNotMovableException.java (added)
+++ geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/SessionNotMovableException.java Sun Jan 15 15:36:05 2006
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.geronimo.session;
+
+/**
+ * The Session is not movable.
+ *
+ * @version $Revision: $
+ */
+public class SessionNotMovableException extends SessionException {
+
+ private static final long serialVersionUID = -4266816494370986532L;
+
+ public SessionNotMovableException(String sessionId) {
+ super("The session is not movable for ID: " + sessionId, sessionId);
+ }
+
+}
Added: geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/WriteLockTimedOutException.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/WriteLockTimedOutException.java?rev=369280&view=auto
==============================================================================
--- geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/WriteLockTimedOutException.java (added)
+++ geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/WriteLockTimedOutException.java Sun Jan 15 15:36:05 2006
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.geronimo.session;
+
+/**
+ * The remote lock timed out while trying to move the session
+ *
+ * @version $Revision: $
+ */
+public class WriteLockTimedOutException extends SessionException {
+
+ private static final long serialVersionUID = 7717527292815502849L;
+
+ public WriteLockTimedOutException(String sessionId) {
+ super("The remote write lock timed out for session ID: " + sessionId, sessionId);
+ }
+}
Modified: geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/package.html
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/package.html?rev=369280&r1=369279&r2=369280&view=diff
==============================================================================
--- geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/package.html (original)
+++ geronimo/trunk/modules/session/src/java/org/apache/geronimo/session/package.html Sun Jan 15 15:36:05 2006
@@ -4,8 +4,6 @@
</head>
<body>
-<h1>Geronimo :: Session</h1>
-
<p>
This library provides a simple API for working with stateful session state so that it is easy to
integrate different state management technologies into projects like OpenEJB, ServiceMix or Tuscany while also