Author: mturk Date: Thu Sep 8 16:25:06 2011 New Revision: 1166777 URL: http://svn.apache.org/viewvc?rev=1166777&view=rev Log: Add NativePointer so classes can directly use the native struct pointers without public api
Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/NativePointer.java (with props) Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/PasswordCallback.java Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/NativePointer.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/NativePointer.java?rev=1166777&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/NativePointer.java (added) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/NativePointer.java Thu Sep 8 16:25:06 2011 @@ -0,0 +1,35 @@ +/* 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.ssl; + +import org.apache.commons.runtime.Callback; + +/** + * Abstract native pointer place holder + */ +abstract class NativePointer +{ + public long pointer; + + /** + * Creates a new object instance + */ + protected NativePointer() + { + } + +} Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/NativePointer.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/PasswordCallback.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/PasswordCallback.java?rev=1166777&r1=1166776&r2=1166777&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/PasswordCallback.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/PasswordCallback.java Thu Sep 8 16:25:06 2011 @@ -21,14 +21,16 @@ import org.apache.commons.runtime.Callba /** * Abstract password prompt handler. */ -public abstract class PasswordCallback implements Callback +public abstract class PasswordCallback + extends NativePointer implements Callback { private String prompt; - private long handler; + // Hide native pointer + private long pointer; private native long new0(); - private native void def0(long handler); - private native void del0(long handler); - private native void set0(long handler, String password); + private native void def0(long pointer); + private native void del0(long pointer); + private native void set0(long pointer, String password); private static Object lock; static { @@ -40,7 +42,7 @@ public abstract class PasswordCallback i */ protected PasswordCallback() { - handler = new0(); + super.pointer = new0(); prompt = Local.sm.get("password.PROMPT"); } @@ -49,7 +51,7 @@ public abstract class PasswordCallback i */ protected PasswordCallback(String prompt) { - handler = new0(); + super.pointer = new0(); this.prompt = prompt; } @@ -58,7 +60,7 @@ public abstract class PasswordCallback i { try { String pass = onPasswordPrompt(prompt); - set0(handler, pass); + set0(super.pointer, pass); return 1; } catch (Exception x) { return 0; @@ -71,7 +73,7 @@ public abstract class PasswordCallback i public final void setDefault() { synchronized(lock) { - def0(handler); + def0(super.pointer); } } @@ -82,7 +84,7 @@ public abstract class PasswordCallback i public final void setPassword(String password) { - set0(handler, password); + set0(super.pointer, password); } /** @@ -104,7 +106,7 @@ public abstract class PasswordCallback i protected final void finalize() throws Throwable { - del0(handler); + del0(super.pointer); } }