de.uplanet.util
Class Safely

java.lang.Object
  extended by de.uplanet.util.Safely

@Scriptable
public final class Safely
extends java.lang.Object

Helper for closing uninstantiated objects, database connections, statements, result sets,...

Version:
$Revision: 74032 $

Constructor Summary
Safely()
           
 
Method Summary
static javax.naming.directory.DirContext close(javax.naming.directory.DirContext p_closee)
          Safely close a javax.naming.directory.DirContext.
static javax.naming.directory.DirContext close(javax.naming.directory.DirContext p_closee, org.slf4j.Logger p_log)
          Safely close a javax.naming.directory.DirContext.
static javax.imageio.stream.ImageInputStream close(javax.imageio.stream.ImageInputStream p_closee)
          Safely close an javax.imageio.stream.ImageInputStream.
static javax.imageio.stream.ImageInputStream close(javax.imageio.stream.ImageInputStream p_closee, org.slf4j.Logger p_log)
          Safely close an javax.imageio.stream.ImageInputStreamt.
static
<T extends ICloseable>
T
close(T p_closee)
          Safely close a de.uplanet.util.ICloseable.
static
<T extends java.io.Closeable>
T
close(T p_closee)
          Safely close a java.io.Closeable.
static
<T extends java.net.ServerSocket>
T
close(T p_closee)
          Safely close a java.net.ServerSocket.
static
<T extends java.net.Socket>
T
close(T p_closee)
          Safely close a java.net.Socket.
static
<T extends java.nio.channels.Selector>
T
close(T p_closee)
          Safely close a java.nio.channels.Selector.
static
<T extends java.sql.Connection>
T
close(T p_closee)
          Safely close a java.sql.Connection.
static
<T extends java.sql.ResultSet>
T
close(T p_closee)
          Safely close a java.sql.ResultSet.
static
<T extends java.sql.Statement>
T
close(T p_closee)
          Safely close a java.sql.Statement.
static
<T extends java.util.zip.ZipFile>
T
close(T p_closee)
          Safely close a java.util.zip.ZipFile.
static
<T extends ICloseable>
T
close(T p_closee, org.slf4j.Logger p_log)
          Safely close a de.uplanet.util.ICloseable and log any errors.
static
<T extends java.io.Closeable>
T
close(T p_closee, org.slf4j.Logger p_log)
          Safely close a java.io.Closeable and log any errors.
static
<T extends java.net.ServerSocket>
T
close(T p_closee, org.slf4j.Logger p_log)
          Safely close a java.net.ServerSocket and log any errors.
static
<T extends java.net.Socket>
T
close(T p_closee, org.slf4j.Logger p_log)
          Safely close a java.net.Socket and log any errors.
static
<T extends java.nio.channels.Selector>
T
close(T p_closee, org.slf4j.Logger p_log)
          Safely close a java.nio.channels.Selector and log any errors.
static
<T extends java.sql.Connection>
T
close(T p_closee, org.slf4j.Logger p_log)
          Safely close a java.sql.Connection and log any errors.
static
<T extends java.sql.ResultSet>
T
close(T p_closee, org.slf4j.Logger p_log)
          Safely close a java.sql.ResultSet and log any errors.
static
<T extends java.sql.Statement>
T
close(T p_closee, org.slf4j.Logger p_log)
          Safely close a java.sql.Statement and log any errors.
static
<T extends java.util.zip.ZipFile>
T
close(T p_closee, org.slf4j.Logger p_log)
          Safely close a java.util.zip.ZipFile and log any errors.
static
<T extends java.io.Closeable>
T
close(T p_closee, java.io.PrintStream p_ps)
          Safely close a java.io.Closeable and log any errors.
static void commit(java.sql.Connection p_conn)
          Safely call commit on a database connection.
static void commit(java.sql.Connection p_conn, org.slf4j.Logger p_log)
          Safely call commit on a database connection.
static void rollback(java.sql.Connection p_conn)
          Safely call rollback on a database connection.
static void rollback(java.sql.Connection p_conn, org.slf4j.Logger p_log)
          Safely call rollback on a database connection.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Safely

public Safely()
Method Detail

close

public static <T extends java.sql.Connection> T close(T p_closee)
Safely close a java.sql.Connection.

Parameters:
p_closee - The connection to be closed or null.
Returns:
null.

close

public static <T extends java.sql.Connection> T close(T p_closee,
                                                      org.slf4j.Logger p_log)
Safely close a java.sql.Connection and log any errors.

Parameters:
p_closee - The connection to be closed or null.
p_log - The logging object used.
Returns:
null.

close

public static <T extends java.sql.Statement> T close(T p_closee)
Safely close a java.sql.Statement.

Parameters:
p_closee - The statement to be closed or null.
Returns:
null.

close

public static <T extends java.sql.Statement> T close(T p_closee,
                                                     org.slf4j.Logger p_log)
Safely close a java.sql.Statement and log any errors.

Parameters:
p_closee - The statement to be closed or null.
p_log - The logging object used.
Returns:
null.

close

public static <T extends java.sql.ResultSet> T close(T p_closee)
Safely close a java.sql.ResultSet.

Parameters:
p_closee - The result set to be closed or null.
Returns:
null.

close

public static <T extends java.sql.ResultSet> T close(T p_closee,
                                                     org.slf4j.Logger p_log)
Safely close a java.sql.ResultSet and log any errors.

Parameters:
p_closee - The result set to be closed or null.
p_log - The logging object used.
Returns:
null.

close

public static <T extends java.io.Closeable> T close(T p_closee)
Safely close a java.io.Closeable.

Parameters:
p_closee - The closeable object to be closed or null.
Returns:
null.

close

public static <T extends java.io.Closeable> T close(T p_closee,
                                                    org.slf4j.Logger p_log)
Safely close a java.io.Closeable and log any errors.

Parameters:
p_closee - The closeable object to be closed or null.
p_log - The logging object used.
Returns:
null.

close

public static <T extends java.io.Closeable> T close(T p_closee,
                                                    java.io.PrintStream p_ps)
Safely close a java.io.Closeable and log any errors.

Parameters:
p_closee - The closeable object to be closed or null.
p_ps - PrintStream to print the errors to.
Returns:
null.

close

public static <T extends java.nio.channels.Selector> T close(T p_closee)
Safely close a java.nio.channels.Selector.

Parameters:
p_closee - The selector to be closed or null.
Returns:
null.

close

public static <T extends java.nio.channels.Selector> T close(T p_closee,
                                                             org.slf4j.Logger p_log)
Safely close a java.nio.channels.Selector and log any errors.

Parameters:
p_closee - The selector to be closed or null.
p_log - The logging object used.
Returns:
null.

close

public static <T extends java.net.Socket> T close(T p_closee)
Safely close a java.net.Socket.

Parameters:
p_closee - The socket to be closed or null.
Returns:
null.

close

public static <T extends java.net.Socket> T close(T p_closee,
                                                  org.slf4j.Logger p_log)
Safely close a java.net.Socket and log any errors.

Parameters:
p_closee - The socket to be closed or null.
p_log - The logging object used.
Returns:
null.

close

public static <T extends java.net.ServerSocket> T close(T p_closee)
Safely close a java.net.ServerSocket.

Parameters:
p_closee - The server socket to be closed or null.
Returns:
null.

close

public static <T extends java.net.ServerSocket> T close(T p_closee,
                                                        org.slf4j.Logger p_log)
Safely close a java.net.ServerSocket and log any errors.

Parameters:
p_closee - The server socket to be closed or null.
p_log - The logging object used.
Returns:
null.

close

public static <T extends java.util.zip.ZipFile> T close(T p_closee)
Safely close a java.util.zip.ZipFile.

Parameters:
p_closee - The ZipFile to be closed or null.
Returns:
null.

close

public static <T extends java.util.zip.ZipFile> T close(T p_closee,
                                                        org.slf4j.Logger p_log)
Safely close a java.util.zip.ZipFile and log any errors.

Parameters:
p_closee - The ZipFile to be closed or null.
p_log - The logging object used.
Returns:
null.

close

public static <T extends ICloseable> T close(T p_closee)
Safely close a de.uplanet.util.ICloseable.

Parameters:
p_closee - The ZipFile to be closed or null.
Returns:
null.

close

public static <T extends ICloseable> T close(T p_closee,
                                             org.slf4j.Logger p_log)
Safely close a de.uplanet.util.ICloseable and log any errors.

Parameters:
p_closee - The ZipFile to be closed or null.
p_log - The logging object used.
Returns:
null.

close

public static javax.naming.directory.DirContext close(javax.naming.directory.DirContext p_closee)
Safely close a javax.naming.directory.DirContext.

Parameters:
p_closee - The object to be closed or null.
Returns:
null.

close

public static javax.naming.directory.DirContext close(javax.naming.directory.DirContext p_closee,
                                                      org.slf4j.Logger p_log)
Safely close a javax.naming.directory.DirContext.

Parameters:
p_closee - The object to be closed or null.
p_log - The logging object used.
Returns:
null.

close

public static javax.imageio.stream.ImageInputStream close(javax.imageio.stream.ImageInputStream p_closee)
Safely close an javax.imageio.stream.ImageInputStream.

Parameters:
p_closee - The object to be closed or null.
Returns:
null.

close

public static javax.imageio.stream.ImageInputStream close(javax.imageio.stream.ImageInputStream p_closee,
                                                          org.slf4j.Logger p_log)
Safely close an javax.imageio.stream.ImageInputStreamt.

Parameters:
p_closee - The object to be closed or null.
p_log - The logging object used.
Returns:
null.

commit

public static void commit(java.sql.Connection p_conn)
Safely call commit on a database connection.

Parameters:
p_conn - The connection to commit.

commit

public static void commit(java.sql.Connection p_conn,
                          org.slf4j.Logger p_log)
Safely call commit on a database connection.

Parameters:
p_conn - The connection to commit.
p_log - The logging object used.

rollback

public static void rollback(java.sql.Connection p_conn)
Safely call rollback on a database connection.

Parameters:
p_conn - The connection to rollback.

rollback

public static void rollback(java.sql.Connection p_conn,
                            org.slf4j.Logger p_log)
Safely call rollback on a database connection.

Parameters:
p_conn - The connection to rollback.
p_log - The logging object used.


Last updated: 2011-08-11 10-04
Copyright © 2000-2011 United Planet. All Rights Reserved.