You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/11/21 11:31:07 UTC
svn commit: r882876 - in /commons/sandbox/runtime/trunk/src/main:
java/org/apache/commons/runtime/io/Pipe.java native/include/acr_pipe.h
native/os/unix/pipe.c native/os/win32/pipe.c native/shared/clazz.c
Author: mturk
Date: Sat Nov 21 10:31:06 2009
New Revision: 882876
URL: http://svn.apache.org/viewvc?rev=882876&view=rev
Log:
Add Pipe class
Added:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Pipe.java (with props)
commons/sandbox/runtime/trunk/src/main/native/include/acr_pipe.h (with props)
Modified:
commons/sandbox/runtime/trunk/src/main/native/os/unix/pipe.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/pipe.c
commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c
Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Pipe.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Pipe.java?rev=882876&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Pipe.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Pipe.java Sat Nov 21 10:31:06 2009
@@ -0,0 +1,77 @@
+/* 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.commons.runtime.io;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.Flushable;
+import java.io.IOException;
+import java.io.SyncFailedException;
+import java.net.URI;
+import java.util.Enumeration;
+import java.util.EnumSet;
+import java.util.Vector;
+import org.apache.commons.runtime.Descriptor;
+import org.apache.commons.runtime.exception.ClosedDescriptorException;
+import org.apache.commons.runtime.exception.AsyncClosedDescriptorException;
+import org.apache.commons.runtime.exception.InvalidDescriptorException;
+import org.apache.commons.runtime.exception.OverlappingFileLockException;
+import org.apache.commons.runtime.exception.TimeoutException;
+import org.apache.commons.runtime.util.StringManager;
+
+/**
+ * Provides static methods for the creation, copying, deletion,
+ * moving and opening of pipes.
+ * <p>
+ * </p>
+ */
+public final class Pipe
+{
+
+ private Descriptor fd;
+ private String name;
+ private PipeIoMode mode;
+ private int type;
+ private Pipe()
+ {
+ // No instance
+ }
+
+ /**
+ * Create new Pipe instance.
+ * This constructor is called only from native.
+ */
+ private Pipe(Descriptor fd, String name, int type)
+ {
+ this.fd = fd;
+ this.name = name;
+ this.type = type;
+
+ mode = PipeIoMode.valueOf(type & 0xff);
+ }
+
+ /**
+ * Return the {@link Descriptor} accosicated with this pipe.
+ *
+ * @return pipe's Descriptor object
+ */
+ public Descriptor fd()
+ {
+ return fd;
+ }
+
+}
Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Pipe.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/runtime/trunk/src/main/native/include/acr_pipe.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_pipe.h?rev=882876&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_pipe.h (added)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_pipe.h Sat Nov 21 10:31:06 2009
@@ -0,0 +1,50 @@
+/* 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.
+ */
+
+#ifndef _ACR_PIPE_H
+#define _ACR_PIPE_H
+
+#include "acr.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file acr_pipe.h
+ * @brief
+ *
+ * ACR Pipe functions
+ *
+ */
+
+/**
+ * Create new Pipe object.
+ */
+ACR_DECLARE(jobject) ACR_NewPipeObject(JNIEnv *env, int type,
+ jobject desc,
+ const acr_pchar_t *name);
+
+/**
+ * Create new Pipe object array.
+ */
+ACR_DECLARE(jobjectArray) ACR_NewPipeArray(JNIEnv *env, jsize len);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ACR_PIPE_H */
Propchange: commons/sandbox/runtime/trunk/src/main/native/include/acr_pipe.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/pipe.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/pipe.c?rev=882876&r1=882875&r2=882876&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/pipe.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/pipe.c Sat Nov 21 10:31:06 2009
@@ -19,12 +19,59 @@
#include "acr_arch.h"
#include "acr_port.h"
#include "acr_error.h"
+#include "acr_clazz.h"
#include "acr_string.h"
#include "acr_descriptor.h"
#include "acr_file.h"
-#include "acr_port.h"
+#include "acr_pipe.h"
/**
* Posix pipe functions
*
*/
+
+J_DECLARE_CLAZZ = {
+ NULL,
+ NULL,
+ ACR_IO_CLASS_PATH "Pipe"
+};
+
+J_DECLARE_M_ID(0000) = {
+ NULL,
+ "<init>",
+ "(L" ACR_CLASS_PATH "Descriptor;Ljava/lang/String;I)V"
+};
+
+ACR_CLASS_LDEF(io_Pipe)
+{
+ int rv;
+
+ if ((rv = ACR_LoadClass(_E, &_clazzn, 0)) != ACR_SUCCESS)
+ return rv;
+ J_LOAD_METHOD(0000);
+
+ return ACR_SUCCESS;
+}
+
+ACR_CLASS_UDEF(io_Pipe)
+{
+ ACR_UnloadClass(_E, &_clazzn);
+}
+
+ACR_DECLARE(jobject) ACR_NewPipeObject(JNIEnv *_E, int type, jobject desc,
+ const char *pname)
+{
+ jstring name;
+ if ((name = ACR_NewJavaStringA(_E, pname)))
+ return (*_E)->NewObject(_E, _clazzn.i, J4MID(0000), desc, name, type);
+ else
+ return NULL;
+}
+
+ACR_DECLARE(jobjectArray) ACR_NewPipeArray(JNIEnv *_E, jsize len)
+{
+ if (_clazzn.i)
+ return (*_E)->NewObjectArray(_E, len, _clazzn.i, NULL);
+ else
+ return NULL;
+}
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/pipe.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/pipe.c?rev=882876&r1=882875&r2=882876&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/pipe.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/pipe.c Sat Nov 21 10:31:06 2009
@@ -20,17 +20,42 @@
#include "acr_atomics.h"
#include "acr_port.h"
#include "acr_error.h"
+#include "acr_clazz.h"
#include "acr_string.h"
#include "acr_descriptor.h"
#include "acr_file.h"
-#include "acr_port.h"
+#include "acr_pipe.h"
/**
* Windows pipe functions
*
*/
+J_DECLARE_CLAZZ = {
+ NULL,
+ NULL,
+ ACR_IO_CLASS_PATH "Pipe"
+};
+
+J_DECLARE_M_ID(0000) = {
+ NULL,
+ "<init>",
+ "(L" ACR_CLASS_PATH "Descriptor;Ljava/lang/String;I)V"
+};
+
+ACR_CLASS_LDEF(io_Pipe)
+{
+ int rv;
+
+ if ((rv = ACR_LoadClass(_E, &_clazzn, 0)) != ACR_SUCCESS)
+ return rv;
+ J_LOAD_METHOD(0000);
+
+ return ACR_SUCCESS;
+}
+
static acr_atomic32_t pipe_id = 0;
+
static int crate_socketpair(SOCKET *rd, SOCKET *wr, int nonblocking)
{
FD_SET rs;
@@ -173,3 +198,26 @@
closesocket(ls);
return rv;
}
+
+ACR_CLASS_UDEF(io_Pipe)
+{
+ ACR_UnloadClass(_E, &_clazzn);
+}
+
+ACR_DECLARE(jobject) ACR_NewPipeObject(JNIEnv *_E, int type, jobject desc,
+ const wchar_t *pname)
+{
+ jstring name;
+ if ((name = ACR_NewJavaStringW(_E, pname)))
+ return (*_E)->NewObject(_E, _clazzn.i, J4MID(0000), desc, name, type);
+ else
+ return NULL;
+}
+
+ACR_DECLARE(jobjectArray) ACR_NewPipeArray(JNIEnv *_E, jsize len)
+{
+ if (_clazzn.i)
+ return (*_E)->NewObjectArray(_E, len, _clazzn.i, NULL);
+ else
+ return NULL;
+}
Modified: commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c?rev=882876&r1=882875&r2=882876&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c Sat Nov 21 10:31:06 2009
@@ -388,6 +388,7 @@
ACR_CLASS_LDEC(io_FileInfo);
ACR_CLASS_LDEC(io_MemoryMapProvider);
ACR_CLASS_LDEC(io_Path);
+ACR_CLASS_LDEC(io_Pipe);
ACR_DECLARE(int) ACR_LoadRuntimeClasses(JNIEnv *_E)
{
@@ -406,6 +407,7 @@
ACR_CLASS_LRUN(io_FileInfo);
ACR_CLASS_LRUN(io_MemoryMapProvider);
ACR_CLASS_LRUN(io_Path);
+ ACR_CLASS_LRUN(io_Pipe);
#ifdef WIN32
#endif
@@ -430,6 +432,7 @@
ACR_CLASS_URUN(io_FileInfo);
ACR_CLASS_URUN(io_MemoryMapProvider);
ACR_CLASS_URUN(io_Path);
+ ACR_CLASS_URUN(io_Pipe);
#ifdef WIN32
#endif