You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by tr...@apache.org on 2004/10/11 15:45:06 UTC
svn commit: rev 54584 - incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/session
Author: trustin
Date: Mon Oct 11 06:45:05 2004
New Revision: 54584
Added:
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/session/AbstractSession.java (contents, props changed)
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/session/TcpSession.java (contents, props changed)
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/session/UdpSession.java (contents, props changed)
Log:
Added Session implementations.
Added: incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/session/AbstractSession.java
==============================================================================
--- (empty file)
+++ incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/session/AbstractSession.java Mon Oct 11 06:45:05 2004
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2004 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.
+ *
+ */
+/*
+ * @(#) $Id$
+ */
+package org.apache.seda.session;
+
+import org.apache.seda.Session;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+
+/**
+ * A simplistic {@link Session} which implements basic attribute methods.
+ *
+ * @author Trustin Lee (trustin@gmail.com)
+ * @version $Rev$, $Date$
+ */
+public abstract class AbstractSession implements Session {
+ private final Map attributes = new HashMap();
+
+ /**
+ * Creates a new instance.
+ */
+ public AbstractSession() {
+ }
+
+ public Set getAttributeNames() {
+ synchronized (attributes) {
+ return new HashSet(attributes.keySet());
+ }
+ }
+
+ public Object getAttribute(String key) {
+ return attributes.get(key);
+ }
+
+ public Object setAttribute(String key, Object value) {
+ synchronized (attributes) {
+ return attributes.put(key, value);
+ }
+ }
+}
Added: incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/session/TcpSession.java
==============================================================================
--- (empty file)
+++ incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/session/TcpSession.java Mon Oct 11 06:45:05 2004
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2004 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.
+ *
+ */
+/*
+ * @(#) $Id$
+ */
+package org.apache.seda.session;
+
+import java.nio.channels.SocketChannel;
+
+
+/**
+ * Represents TCP/IP communication session.
+ *
+ * @author Trustin Lee (trustin@gmail.com)
+ * @version $Rev$, $Date$
+ */
+public class TcpSession extends AbstractSession implements ByteIoSession,
+ StatefulSession {
+ private final SocketChannel channel;
+
+ /**
+ * Creates a new instance with the specified {@link SocketChannel}.
+ */
+ public TcpSession(SocketChannel channel) {
+ if (channel == null) {
+ throw new NullPointerException();
+ }
+
+ this.channel = channel;
+ }
+
+ public boolean isConnected() {
+ return channel.isConnected();
+ }
+}
Added: incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/session/UdpSession.java
==============================================================================
--- (empty file)
+++ incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/session/UdpSession.java Mon Oct 11 06:45:05 2004
@@ -0,0 +1,31 @@
+/*
+ * @(#) $Id$
+ */
+package org.apache.seda.session;
+
+import java.nio.channels.DatagramChannel;
+
+/**
+ * Represents UDP/IP communication session.
+ *
+ * @author Trustin Lee (trustin@gmail.com)
+ * @version $Rev$, $Date$
+ */
+public class UdpSession extends AbstractSession implements ByteIoSession,
+ StatelessSession {
+
+ private final DatagramChannel channel;
+
+ /**
+ * Creates a new instance with the specified channel.
+ */
+ public UdpSession(DatagramChannel channel) {
+ if (channel == null)
+ throw new NullPointerException();
+ this.channel = channel;
+ }
+
+ public DatagramChannel getChannel() {
+ return channel;
+ }
+}