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 2005/06/12 14:29:37 UTC
svn commit: r190262 - in /directory/network/trunk/src:
java/org/apache/mina/common/CloseFuture.java
java/org/apache/mina/common/ConnectFuture.java
java/org/apache/mina/common/IoFuture.java
java/org/apache/mina/common/WriteFuture.java
test/org/apache/mina/common/FutureTest.java
Author: trustin
Date: Sun Jun 12 05:29:37 2005
New Revision: 190262
URL: http://svn.apache.org/viewcvs?rev=190262&view=rev
Log:
Added more JavaDocs to IoFutures.
Modified:
directory/network/trunk/src/java/org/apache/mina/common/CloseFuture.java
directory/network/trunk/src/java/org/apache/mina/common/ConnectFuture.java
directory/network/trunk/src/java/org/apache/mina/common/IoFuture.java
directory/network/trunk/src/java/org/apache/mina/common/WriteFuture.java
directory/network/trunk/src/test/org/apache/mina/common/FutureTest.java
Modified: directory/network/trunk/src/java/org/apache/mina/common/CloseFuture.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/CloseFuture.java?rev=190262&r1=190261&r2=190262&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/CloseFuture.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/CloseFuture.java Sun Jun 12 05:29:37 2005
@@ -1,7 +1,34 @@
+/*
+ * @(#) $Id$
+ *
+ * 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.
+ *
+ */
package org.apache.mina.common;
+/**
+ * An {@link IoFuture} for asynchronous close requests.
+ *
+ * @author The Apache Directory Project
+ * @version $Rev$, $Date$
+ */
public class CloseFuture extends IoFuture
{
+ /**
+ * Returns <tt>true</tt> if the close request is finished and the session is closed.
+ */
public boolean isClosed()
{
if( isReady() )
@@ -14,6 +41,10 @@
}
}
+ /**
+ * This method is invoked by MINA internally. Please do not call this method
+ * directly.
+ */
public void setClosed( boolean closed )
{
setValue( closed? Boolean.TRUE : Boolean.FALSE );
Modified: directory/network/trunk/src/java/org/apache/mina/common/ConnectFuture.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/ConnectFuture.java?rev=190262&r1=190261&r2=190262&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/ConnectFuture.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/ConnectFuture.java Sun Jun 12 05:29:37 2005
@@ -1,11 +1,41 @@
+/*
+ * @(#) $Id$
+ *
+ * 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.
+ *
+ */
package org.apache.mina.common;
import java.io.IOException;
import org.apache.mina.util.ExceptionUtil;
+/**
+ * An {@link IoFuture} for asynchronous connect requests.
+ *
+ * @author The Apache Directory Project
+ * @version $Rev$, $Date$
+ */
public class ConnectFuture extends IoFuture
{
+ /**
+ * Returns {@link IoSession} which is the result of connect operation.
+ *
+ * @return <tt>null</tt> if the connect operation is not finished yet
+ * @throws IOException if connection attempt failed by an exception
+ */
public IoSession getSession() throws IOException
{
Object v = getValue();
@@ -19,17 +49,28 @@
return ( IoSession ) v;
}
}
-
+
+ /**
+ * Returns <tt>true</tt> if the connect operation is finished successfully.
+ */
public boolean isConnected()
{
return getValue() instanceof IoSession;
}
+ /**
+ * This method is invoked by MINA internally. Please do not call this method
+ * directly.
+ */
public void setSession( IoSession session )
{
setValue( session );
}
+ /**
+ * This method is invoked by MINA internally. Please do not call this method
+ * directly.
+ */
public void setException( Throwable exception )
{
setValue( exception );
Modified: directory/network/trunk/src/java/org/apache/mina/common/IoFuture.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/IoFuture.java?rev=190262&r1=190261&r2=190262&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/IoFuture.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/IoFuture.java Sun Jun 12 05:29:37 2005
@@ -1,15 +1,45 @@
+/*
+ * @(#) $Id$
+ *
+ * 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.
+ *
+ */
package org.apache.mina.common;
+/**
+ * Represents the result of an ashynchronous I/O operation.
+ *
+ * @author The Apache Directory Project
+ * @version $Rev$, $Date$
+ */
public class IoFuture
{
private Object result;
private boolean ready;
+ /**
+ * Creates a new instance.
+ */
protected IoFuture()
{
}
+ /**
+ * Wait for the asynchronous operation to end.
+ */
public synchronized void join()
{
while( !ready )
@@ -24,6 +54,11 @@
}
}
+ /**
+ * Wait for the asynchronous operation to end with the specified timeout.
+ *
+ * @return <tt>true</tt> if the operation is finished.
+ */
public synchronized boolean join( long timeoutInMillis )
{
long startTime = ( timeoutInMillis <= 0 ) ? 0 : System
@@ -61,11 +96,17 @@
}
}
+ /**
+ * Returns if the asynchronous operation is finished.
+ */
public synchronized boolean isReady()
{
return ready;
}
+ /**
+ * Sets the result of the asynchronous operation, and mark it as finished.
+ */
protected synchronized void setValue( Object newValue )
{
result = newValue;
@@ -73,6 +114,9 @@
notifyAll();
}
+ /**
+ * Returns the result of the asynchronous operation.
+ */
protected synchronized Object getValue()
{
return result;
Modified: directory/network/trunk/src/java/org/apache/mina/common/WriteFuture.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/WriteFuture.java?rev=190262&r1=190261&r2=190262&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/WriteFuture.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/WriteFuture.java Sun Jun 12 05:29:37 2005
@@ -1,7 +1,34 @@
+/*
+ * @(#) $Id$
+ *
+ * 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.
+ *
+ */
package org.apache.mina.common;
+/**
+ * An {@link IoFuture} for asynchronous write requests.
+ *
+ * @author The Apache Directory Project
+ * @version $Rev$, $Date$
+ */
public class WriteFuture extends IoFuture
{
+ /**
+ * Returns <tt>true</tt> if the write operation is finished successfully.
+ */
public boolean isWritten()
{
if( isReady() )
@@ -13,7 +40,11 @@
return false;
}
}
-
+
+ /**
+ * This method is invoked by MINA internally. Please do not call this method
+ * directly.
+ */
public void setWritten( boolean written )
{
setValue( written? Boolean.TRUE : Boolean.FALSE );
Modified: directory/network/trunk/src/test/org/apache/mina/common/FutureTest.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/test/org/apache/mina/common/FutureTest.java?rev=190262&r1=190261&r2=190262&view=diff
==============================================================================
--- directory/network/trunk/src/test/org/apache/mina/common/FutureTest.java (original)
+++ directory/network/trunk/src/test/org/apache/mina/common/FutureTest.java Sun Jun 12 05:29:37 2005
@@ -1,3 +1,21 @@
+/*
+ * @(#) $Id$
+ *
+ * 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.
+ *
+ */
package org.apache.mina.common;
import java.io.IOException;
@@ -5,6 +23,12 @@
import junit.framework.TestCase;
+/**
+ * Tests {@link IoFuture}s.
+ *
+ * @author Trustin Lee (trustin@apache.org)
+ * @version $Rev$, $Date$
+ */
public class FutureTest extends TestCase
{