Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.7.2)

E13403-10


oracle.ide.persistence
Interface Storage


public interface Storage

Provides access to a persistent storage area.

Since:
11.1.1.2

Method Summary
 void allowOpen()
          Allows the storage to be opened again.
 void close()
          Close the storage.
 void deleteNameSpace(java.lang.String name)
          Delete a namespace from this storage.
 NameSpace getNameSpace(java.lang.String name)
          Get a namespace from this storage.
 NameSpace getNameSpace(java.lang.String name, int type)
          Get a namespace from this storage.
 NameSpace getNameSpace(java.lang.String name, SecondaryKeyProvider provider)
          Get a namespace from this storage.
 java.lang.String getRelativePath(java.net.URL url)
          Get a path relative to this storage.
 java.net.URL getURL(java.lang.String relativePath)
          Get the URL for a relative path in the storage.
 boolean isOpen()
          Determine whether this storage is open.
 void lockClosed()
          Locks this storage closed.
 void open()
          Open the storage.
<T> T
runWhileClosed(java.util.concurrent.Callable<T> c)
          Run a task while the storage is closed.
 void runWhileClosed(java.lang.Runnable r)
          Run a task while the storage is closed.
<T> T
runWhileOpen(java.util.concurrent.Callable<T> c)
          Runs a task while the storage is open.
 void runWhileOpen(java.lang.Runnable r)
          Runs a task while the storage is open.

 

Method Detail

getRelativePath

java.lang.String getRelativePath(@NotNull
                                 java.net.URL url)
Get a path relative to this storage. This can be used to avoid storing abosolute paths in the storage, which helps make the storage files portable between machines. The storage must be open when this method is called.
Parameters:
url - the URL to make relative
Returns:
the relative path
Throws:
java.lang.IllegalStateException - if the storage is not open
See Also:
getURL(String)

getURL

java.net.URL getURL(@NotNull
                    java.lang.String relativePath)
Get the URL for a relative path in the storage. The storage must be open when this method is called.
Parameters:
relativePath - the relative path
Returns:
the URL
Throws:
java.lang.IllegalStateException - if the storage is not open
See Also:
getRelativePath(URL)

getNameSpace

NameSpace getNameSpace(@NotNull
                       java.lang.String name)
Get a namespace from this storage. The storage must be open when this method is called.
Parameters:
name - the name of the namespace
Returns:
the namespace
Throws:
java.lang.IllegalStateException - if the storage is not open

getNameSpace

NameSpace getNameSpace(@NotNull
                       java.lang.String name,
                       int type)
Get a namespace from this storage. The storage must be open when this method is called.
Parameters:
name - the name of the namespace
type - the type of namespace, either NameSpace.NSTYPE_NORMAL or NameSpace.NSTYPE_PACKED
Returns:
the namespace
Throws:
java.lang.IllegalStateException - if the storage is not open

getNameSpace

NameSpace getNameSpace(@NotNull
                       java.lang.String name,
                       @NotNull
                       SecondaryKeyProvider provider)
Get a namespace from this storage. The storage must be open when this method is called.
Parameters:
name - the name of the namespace
provider - the secondary key provider for the namespace
Returns:
the namespace
Throws:
java.lang.IllegalStateException - if the storage is not open

deleteNameSpace

void deleteNameSpace(@NotNull
                     java.lang.String name)
Delete a namespace from this storage. The storage must be open when this method is called.
Parameters:
name - the name of the namespace
Throws:
java.lang.IllegalStateException - if the storage is not open

isOpen

boolean isOpen()
Determine whether this storage is open.
Returns:
true if the storage is open, false otherwise

open

void open()
Open the storage. Calls to this method must be paired with a call to close(). It is strongly recommended that runWhileOpen(Runnable) or runWhileOpen(Callable) be used instead of this method.
See Also:
close(), runWhileOpen(Runnable), runWhileOpen(Callable)

close

void close()
Close the storage. Calls to this method must be paired with a call to open(). It is strongly recommended that runWhileOpen(Runnable) or runWhileOpen(Callable) be used instead of this method.
See Also:
open(), runWhileOpen(Runnable), runWhileOpen(Callable)

runWhileOpen

void runWhileOpen(@NotNull
                  java.lang.Runnable r)
Runs a task while the storage is open. This takes care of opening and closing the storage, even if the task throws an exception.
Parameters:
r - the task to run

runWhileOpen

<T> T runWhileOpen(@NotNull
                   java.util.concurrent.Callable<T> c)
               throws java.lang.Exception
Runs a task while the storage is open. This takes care of opening and closing the storage, even if the task throws an exception.
Type Parameters:
T - the type of value returned by the task
Parameters:
c - the task to run
Returns:
the return value of the task
Throws:
java.lang.Exception - if the task throws an exception

lockClosed

void lockClosed()
Locks this storage closed. This will block until the storage is not open. The storage will not be allowed to open again until allowOpen() is called. Great care must be taken when calling this method to avoid deadlock. This method should never be called while holding onto any other locks, such as Node locks. Doing so would cause deadlock with other threads that use the storage.

The calling thread must not call anything that requires the storage in between the calls to lockClosed and allowOpen. Doing so would cause deadlock.

The caller must ensure that for every call to this method, there is a corresponding call to allowOpen(). Failure to do so would result in the storage being locked permanently, blocking all future operations that need to use it. Typically, a caller should use a try/finally block to make sure that allowOpen() is always called.

This method is useful for situations where the storage file must be deleted or replaced while JDeveloper is running.

It is strongly recommended that runWhileClosed(Runnable) or runWhileClosed(Callable) be used instead of this method.

See Also:
allowOpen(), runWhileClosed(Runnable), runWhileClosed(Callable)

allowOpen

void allowOpen()
Allows the storage to be opened again. This must be paired with a call to lockClosed().

It is strongly recommended that runWhileClosed(Runnable) or runWhileClosed(Callable) be used instead of this method.

See Also:
lockClosed(), runWhileClosed(Runnable), runWhileClosed(Callable)

runWhileClosed

void runWhileClosed(@NotNull
                    java.lang.Runnable r)
Run a task while the storage is closed. This will block until the storage is no longer in use.
Parameters:
r - the task to run

runWhileClosed

<T> T runWhileClosed(@NotNull
                     java.util.concurrent.Callable<T> c)
                 throws java.lang.Exception
Run a task while the storage is closed. This will block until the storage is no longer in use.
Type Parameters:
T - the type of value returned by the task
Parameters:
c - the task to run
Returns:
the return value of the task
Throws:
java.lang.Exception - if the task throws an exception

Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.7.2)

E13403-10


Copyright © 1997, 2013, Oracle. All rights reserved.