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 2011/03/26 12:02:37 UTC
svn commit: r1085687 - in /commons/sandbox/runtime/trunk/src/main:
java/org/apache/commons/runtime/ java/org/apache/commons/runtime/io/
java/org/apache/commons/runtime/net/ native/include/acr/ native/shared/
Author: mturk
Date: Sat Mar 26 11:02:36 2011
New Revision: 1085687
URL: http://svn.apache.org/viewvc?rev=1085687&view=rev
Log:
Add more of the old code
Added:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Callback.java (with props)
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Container.java (with props)
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Sizeof.java (with props)
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Local.java (with props)
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/LocalStrings.properties (with props)
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Local.java (with props)
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalStrings.properties (with props)
Modified:
commons/sandbox/runtime/trunk/src/main/native/include/acr/error.h
commons/sandbox/runtime/trunk/src/main/native/shared/error.c
Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Callback.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Callback.java?rev=1085687&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Callback.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Callback.java Sat Mar 26 11:02:36 2011
@@ -0,0 +1,57 @@
+/* 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;
+
+/**
+ * Callback interface.
+ * <p>
+ * Callbacks are called from the native code when a native operation
+ * requires the state introspection from the Java code. The Callback
+ * implementation receives the {@code opaque} data object that was
+ * registered during the callback initialisation stage.
+ * </p>
+ * <p>
+ * Native callback management code uses {@code WeakReference} for both
+ * the opaque data and callback object itself. This means that garbage
+ * collection may destroy those objects if they are referenced only
+ * by the native code. If this behaviour is not desirable make sure
+ * you hold the references to those objects.
+ * </p>
+ *
+ * @since Runtime 1.0
+ */
+public interface Callback
+{
+ /**
+ * Handler method executed from Native code.
+ * <p>
+ * If {@code handler} returns {@code zero} the operation continues.
+ * If negative value is returned the operation breaks. If positive
+ * value is returned the native part will decide what to do with this
+ * value and it depends on the implementation of the callback itself.
+ * </p>
+ *
+ * @param data Data passed to the callback at register time or
+ * newly created object by the native.
+ * @param status Native provided status call that informs about
+ * the callback reason.
+ * @return Continuation state that defines
+ * if the operation should continue or not.
+ */
+ public int handler(Object data, int status);
+
+}
Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Callback.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Container.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Container.java?rev=1085687&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Container.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Container.java Sat Mar 26 11:02:36 2011
@@ -0,0 +1,40 @@
+/*
+ * 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;
+
+/**
+ * The base class for all classes offerering
+ * detach method to it's child objects.
+ */
+public interface Container<T>
+{
+
+ /**
+ * Detach {@code data} from it's container.
+ * <p>
+ * Called from the object that was created by {@code this}
+ * object informing it that it should destroy the reference
+ * to the {@code data} object.
+ * </p>
+ *
+ * @param data Object to detach.
+ */
+ public void detach(T data);
+
+}
Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Container.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Sizeof.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Sizeof.java?rev=1085687&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Sizeof.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Sizeof.java Sat Mar 26 11:02:36 2011
@@ -0,0 +1,69 @@
+/* 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;
+
+/**
+ * Primitive native types size info.
+ *
+ * @since Runtime 1.0
+ *
+ */
+public final class Sizeof
+{
+
+ private Sizeof()
+ {
+ // No class instance
+ }
+
+
+ static {
+
+ INT = Platform.SIZEOF_INT;
+ LONG = Platform.SIZEOF_LONG;
+ SIZE_T = Platform.SIZEOF_SIZE_T;
+ POINTER = Platform.SIZEOF_POINTER;
+ WCHAR = Platform.SIZEOF_WCHAR;
+ }
+
+ /**
+ * Size of the native platform {@code int} type in bytes.
+ */
+ public static final int INT;
+
+ /**
+ * Size of the native platform {@code long} type in bytes.
+ */
+ public static final int LONG;
+
+ /**
+ * Size of the native platform {@code size_t} type in bytes.
+ */
+ public static final int SIZE_T;
+
+ /**
+ * Size of the native platform {@code pointer} type in bytes.
+ */
+ public static final int POINTER;
+
+ /**
+ * Size of the native platform {@code wchar_t} type in bytes.
+ */
+ public static final int WCHAR;
+
+}
+
Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Sizeof.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Local.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Local.java?rev=1085687&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Local.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Local.java Sat Mar 26 11:02:36 2011
@@ -0,0 +1,33 @@
+/*
+ * 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 org.apache.commons.runtime.util.StringManager;
+
+/** Io package private constants
+ */
+class Local
+{
+
+ public static final String Package = "org.apache.commons.runtime.io";
+ public static final StringManager sm;
+
+ static {
+ sm = StringManager.getManager(Package);
+ }
+}
Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Local.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/LocalStrings.properties
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/LocalStrings.properties?rev=1085687&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/LocalStrings.properties (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/LocalStrings.properties Sat Mar 26 11:02:36 2011
@@ -0,0 +1,17 @@
+# 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.
+
+file.EEXIST=File already exsts and CREATE and EXCL FileOpenMode was given
+symlink.EEXIST=Symbolic link exists and points to a different path
Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/LocalStrings.properties
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Local.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Local.java?rev=1085687&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Local.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Local.java Sat Mar 26 11:02:36 2011
@@ -0,0 +1,33 @@
+/*
+ * 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.net;
+import org.apache.commons.runtime.util.StringManager;
+
+/** Net package private constants
+ */
+class Local
+{
+
+ public static final String Package = "org.apache.commons.runtime.net";
+ public static final StringManager sm;
+
+ static {
+ sm = StringManager.getManager(Package);
+ }
+}
Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Local.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalStrings.properties
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalStrings.properties?rev=1085687&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalStrings.properties (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalStrings.properties Sat Mar 26 11:02:36 2011
@@ -0,0 +1,14 @@
+# 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.
Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalStrings.properties
------------------------------------------------------------------------------
svn:eol-style = native
Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr/error.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr/error.h?rev=1085687&r1=1085686&r2=1085687&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr/error.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr/error.h Sat Mar 26 11:02:36 2011
@@ -268,6 +268,8 @@ enum {
#define ACR_EISNULL (ACR_OS_START_ERROR + 100)
#define ACR_EINVALSIZ (ACR_OS_START_ERROR + 101)
#define ACR_ERDONLY (ACR_OS_START_ERROR + 102)
+#define ACR_ECLASSNOTFOUND (ACR_OS_START_ERROR + 103)
+#define ACR_ENOJNIENV (ACR_OS_START_ERROR + 104)
/**
* @defgroup ACR_STATUS_IS Status Value Tests
Modified: commons/sandbox/runtime/trunk/src/main/native/shared/error.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/error.c?rev=1085687&r1=1085686&r2=1085687&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/error.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/error.c Sat Mar 26 11:02:36 2011
@@ -17,6 +17,7 @@
#include "acr/error.h"
#include "acr/debug.h"
#include "acr/jniapi.h"
+#include "acr/string.h"
#include "acr/port.h"
static const char *_throw_classes[] = {
@@ -277,6 +278,12 @@ static const char *_private_error_desc(i
return "The given argument is null";
case ACR_EINVALSIZ:
return "The given argument size is invalid";
+ case ACR_ERDONLY:
+ return "The specified resource is read-only";
+ case ACR_ECLASSNOTFOUND:
+ return "The specified Java Class was not found";
+ case ACR_ENOJNIENV:
+ return "JNI Environment was not provided";
default:
return "Error string not specified yet";
}
@@ -552,8 +559,7 @@ AcrThrow(JNI_STDENV, const char *clazz,
}
if ((*_E)->ExceptionCheck(_E)) {
/* We already have a pending exception. */
- ACR_DEBUG_TRACE("Exception is already in the queue.", 0);
- ACR_DEBUG_TRACE("Throwing class '%s'", clazz);
+ ACR_DEBUG_TRACE("Exception is already in the queue. Throwing '%s'", clazz);
if (msg) {
ACR_DEBUG_TRACE("%s", msg);
}
@@ -626,4 +632,3 @@ AcrThrowException(JNI_STDENV, int cls, i
clazz = _throw_classes[0];
AcrThrow(_E, clazz, 0);
}
-