public class ERXExtensions extends ERXFrameworkPrincipal
Modifier and Type | Class and Description |
---|---|
static class |
ERXExtensions.KeyValueQualifierSQLGenerationSupport
Support class that listens for EOKeyValueQualifiers that have a selector
that was registered and uses their support instead.
|
ERXFrameworkPrincipal.Observer
Modifier and Type | Field and Description |
---|---|
static Logger |
adaptorLogger
logging support for the adaptor channel
|
protected ERXModelGroup |
defaultModelGroup
holds the default model group
|
static String |
eoAdaptorLoggingWillChangeNotification
Notification name, posted before EOAdaptor debug logging will change its setting.
|
static String |
objectsWillChangeInEditingContext
Notification name, posted before object will change in an editing context
|
static Logger |
sharedEOadaptorLogger
logging support for shared object loading
|
initializedFrameworks, launchingFrameworks, log
Constructor and Description |
---|
ERXExtensions() |
Modifier and Type | Method and Description |
---|---|
static boolean |
adaptorLogging()
Returns the current state of EOAdaptor logging.
|
static void |
addObjectToBothSidesOfPotentialRelationshipFromObjectWithKeyPath(com.webobjects.eocontrol.EOEnterpriseObject to,
com.webobjects.eocontrol.EOEnterpriseObject from,
String keyPath)
This method handles 3 different cases
1.
|
static void |
addRandomizeDirectActionURL(StringBuffer daURL)
This method can be used with Direct Action URLs to make sure
that the browser will reload the page.
|
static String |
addSessionIdFormValue(String urlString,
com.webobjects.appserver.WOSession session)
Adds the session ID for a given session to a given URL.
|
static boolean |
booleanFlagOnSessionForKeyWithDefault(com.webobjects.appserver.WOSession s,
String key,
boolean defaultValue)
Retrieves a value from the session's dictionary and evaluates
that object using the
booleanValue method of
ERXValueUtilities . |
void |
bundleDidLoad(com.webobjects.foundation.NSNotification n) |
static void |
configureAdaptorContext()
This method is called by the delegate when the configuration
file is changed.
|
void |
configureAdaptorContext(com.webobjects.foundation.NSNotification n)
This method is called every time the configuration file
is changed.
|
static void |
configureAdaptorContextRapidTurnAround(Object anObserver)
Configures the passed in observer to register a call back
when the configuration file is changed.
|
com.webobjects.eoaccess.EOModelGroup |
defaultModelGroup()
Delegate method for the
EOModelGroup class delegate. |
void |
didFinishInitialization()
Overridden by subclasses to finalize framework initialization.
|
void |
finishInitialization()
This method is called when the application has finished
launching.
|
static void |
forceGC(int maxLoop)
Forces the garbage collector to run.
|
static void |
freeProcessResources(Process p)
Deprecated.
|
static void |
initApp(Class applicationSubclass,
String[] args)
Initializes your WOApplication programmatically (for use in test cases and main methods) with
the assumption that the current directory is your main bundle URL.
|
static void |
initApp(String mainBundleName,
Class applicationSubclass,
String[] args)
Initializes your WOApplication programmatically (for use in test cases and main methods).
|
static void |
initApp(String mainBundleName,
URL mainBundleURL,
Class applicationSubclass,
String[] args)
Initializes your WOApplication programmatically (for use in test cases and main methods).
|
static void |
initEOF(File mainBundleFolder,
String[] args)
Initializes Wonder EOF programmatically (for use in test cases and main methods).
|
static void |
initEOF(File mainBundleFile,
String[] args,
boolean assertsBundleExists)
Initializes Wonder EOF programmatically (for use in test cases and main methods).
|
static void |
initEOF(File mainBundleFile,
String[] args,
boolean assertsBundleExists,
boolean assertsBundleIsWOApplicationFolder,
boolean fallbackToUserDirAsBundle)
Initializes Wonder EOF programmatically (for use in test cases and main methods).
|
static void |
initEOF(String[] args)
Initializes Wonder EOF programmatically (for use in test cases and main methods).
|
protected void |
initialize()
Configures the framework.
|
static boolean |
objectImplementsMethod(Object object,
String methodName,
Class[] parameters)
Determines if a given object implements a method given
the name and the array of input parameters.
|
static String |
randomizeDirectActionURL(String daURL)
This method can be used with Direct Action URLs to make sure
that the browser will reload the page.
|
static void |
refreshSharedObjectsWithName(String entityName)
Refreshes all of the shared enterprise objects for a given shared entity,
then notifies the entity's class by calling the static method
sharedEntityDataWasRefreshed() if the shared entity implements it.
|
static void |
refreshSharedObjectsWithNames(NSArray names)
Refreshes all of the objects for an array of entity names.
|
static void |
registerSQLSupportForSelector(com.webobjects.foundation.NSSelector selector,
com.webobjects.eoaccess.EOQualifierSQLGeneration.Support support) |
static String |
resolveUnit(String userInfoUnitString,
com.webobjects.eocontrol.EOEnterpriseObject object,
String prefixKeyPath)
Resolves a given user info unit string for a given object.
|
static void |
setAdaptorLogging(boolean onOff)
Turn EOAdaptor logging on and off.
|
static void |
setBooleanFlagOnSessionForKey(com.webobjects.appserver.WOSession s,
String key,
boolean newValue)
Uses the
setObjectForKey method of the WOSession
class to push a Boolean object onto the session for a given key. |
void |
sharedEditingContextWasInitialized(com.webobjects.foundation.NSNotification n)
This method is called for the following notification
EOSharedEditingContext.DefaultSharedEditingContextWasInitializedNotification |
static String |
userInfoUnit(com.webobjects.eocontrol.EOEnterpriseObject object,
String key)
For a given enterprise object and key path, will return what
the key 'unit' returns from the userInfo dictionary of the
last property of the key path's EOAttribute or EORelationship.
|
static String |
userPreferencesKeyFromContext(String key,
com.webobjects.foundation.NSKeyValueCoding context)
Constructs a unique key based on a context.
|
hasFrameworkInstalled, setUpFrameworkPrincipalClass, sharedInstance, toString
public static final String objectsWillChangeInEditingContext
public static final String eoAdaptorLoggingWillChangeNotification
protected volatile ERXModelGroup defaultModelGroup
public static Logger adaptorLogger
public static Logger sharedEOadaptorLogger
public com.webobjects.eoaccess.EOModelGroup defaultModelGroup()
EOModelGroup
class delegate.protected void initialize()
did*
methods on
ERXGenericRecord
subclasses after an editing context
has been saved. This delegate is also responsible for configuring
ERXValidationFactory
.
This delegate is configured when this framework is loaded.initialize
in class ERXFrameworkPrincipal
public void bundleDidLoad(com.webobjects.foundation.NSNotification n)
public void finishInitialization()
finishInitialization
in class ERXFrameworkPrincipal
public void didFinishInitialization()
ERXFrameworkPrincipal
didFinishInitialization
in class ERXFrameworkPrincipal
public static void registerSQLSupportForSelector(com.webobjects.foundation.NSSelector selector, com.webobjects.eoaccess.EOQualifierSQLGeneration.Support support)
public void configureAdaptorContext(com.webobjects.foundation.NSNotification n)
n
- notification posted when the configuration file
changes.public void sharedEditingContextWasInitialized(com.webobjects.foundation.NSNotification n)
EOSharedEditingContext.DefaultSharedEditingContextWasInitializedNotification
n
- the notification.public static void configureAdaptorContextRapidTurnAround(Object anObserver)
anObserver
- object to register the call back with.public static void configureAdaptorContext()
public static boolean adaptorLogging()
public static void setAdaptorLogging(boolean onOff)
onOff
- public static void forceGC(int maxLoop)
Note: This can be a very costly operation and should only be used in extreme circumstances.
maxLoop
- maximum times to run the garbage
collector. Passing in 0 will cause the
collector to run until all free objects
have been collected.public static void addObjectToBothSidesOfPotentialRelationshipFromObjectWithKeyPath(com.webobjects.eocontrol.EOEnterpriseObject to, com.webobjects.eocontrol.EOEnterpriseObject from, String keyPath)
to
- enterprise object that is having objects added to itfrom
- enterprise object that is providing the objectskeyPath
- that specifies the relationship on the to object
to add the objects to.public static String userInfoUnit(com.webobjects.eocontrol.EOEnterpriseObject object, String key)
For example if the userInfo dictionary or the attribute 'speed' on the entity Car contained the key-value pair unit=mph, then this method would be able to resolve that unit given either of these keypaths:
userInfoUnit(aCar, "speed");
userInfoUnit(aDrive, "toCar.speed");
Units can be very useful for adding meta information to particular
attributes and relationships in models. The ERDirectToWeb framework
adds support for displaying units.object
- to resolve the key-path fromkey
- path off of the objectpublic static String resolveUnit(String userInfoUnitString, com.webobjects.eocontrol.EOEnterpriseObject object, String prefixKeyPath)
userInfoUnit
for
a better description of getting values out of the userInfo
dictionary. This method deals with resolving dynamic userInfo
keys. These keys need to start with the '@@' symbol. For instance
if you have the user info value '@unit' off of an attribute for the
entity Movie, then you can either pass in a Movie object or a
different object with a prefix key path to a movie object.userInfoUnitString
- string to be resolved, needs to start with
'@@'. This keypath will be evaluated against either the object
if no prefixKeyPath is specified or the object returned by
the prefixKeyPath being evaluated against the object passed in.object
- to resolve either the user info unit or the prefixKeyPath.prefixKeyPath
- used as a prefix for the unit resolution.public static void refreshSharedObjectsWithNames(NSArray names)
names
- array of shared entity namespublic static void refreshSharedObjectsWithName(String entityName)
entityName
- name of the shared entitypublic static String randomizeDirectActionURL(String daURL)
daURL
- a url to add the randomization to.public static void addRandomizeDirectActionURL(StringBuffer daURL)
daURL
- a url to add the randomization to.public static String addSessionIdFormValue(String urlString, com.webobjects.appserver.WOSession session)
urlString
- URL string to add session ID form value tosession
- session objectpublic static void setBooleanFlagOnSessionForKey(com.webobjects.appserver.WOSession s, String key, boolean newValue)
setObjectForKey
method of the WOSession
class to push a Boolean object onto the session for a given key.
Note this is not using key value coding, meaning you don't need
to have a boolean instance variable corresponding to the given
key on your session object. This flag can be retrieved using
the method booleanFlagOnSessionForKeyWithDefault
.s
- session object on which to set the boolean flagkey
- to be used in the session's dictionarynewValue
- boolean value to be set on the sessionpublic static boolean booleanFlagOnSessionForKeyWithDefault(com.webobjects.appserver.WOSession s, String key, boolean defaultValue)
booleanValue
method of
ERXValueUtilities
. If there is no object corresponding
to the key passed in, then the default value is returned. The
usual way in which boolean values are set on the session object
is by using the method setBooleanFlagOnSessionForKey
in this class.s
- session object to retrieve the boolean flag fromkey
- that the boolean is stored underdefaultValue
- value to be returned if the object in the
dictionary is nullpublic static String userPreferencesKeyFromContext(String key, com.webobjects.foundation.NSKeyValueCoding context)
key
- preference keycontext
- most likely a d2wContext object@Deprecated public static void freeProcessResources(Process p)
ERXRuntimeUtilities.freeProcessResources(Process)
insteadp
- process to destroypublic static boolean objectImplementsMethod(Object object, String methodName, Class[] parameters)
object
- to determine if it implements a methodmethodName
- name of the methodparameters
- array of parameterspublic static void initApp(Class applicationSubclass, String[] args)
applicationSubclass
- your Application subclassargs
- the commandline arguments for your applicationpublic static void initApp(String mainBundleName, Class applicationSubclass, String[] args)
mainBundleName
- the name of your main bundleapplicationSubclass
- your Application subclassargs
- the commandline arguments for your applicationpublic static void initApp(String mainBundleName, URL mainBundleURL, Class applicationSubclass, String[] args)
mainBundleName
- the name of your main bundle (or null to use mainBundleURL)mainBundleURL
- the URL to your main bundle (ignored if mainBundleName is set)applicationSubclass
- your Application subclassargs
- the commandline arguments for your applicationpublic static void initEOF(String[] args)
This is equivalent to calling initEOF(new File("."), args)
.
args
- the commandline arguments for your applicationIllegalArgumentException
- if the current dir or mainBundleFolder is not a *.woa bundle.public static void initEOF(File mainBundleFolder, String[] args)
This is equivalent to calling initEOF(mainBundleFolder, args, true, true, true)
.
mainBundleFolder
- the folder of your main bundleargs
- the commandline arguments for your applicationIllegalArgumentException
- if the current dir or mainBundleFolder is not a *.woa bundle.public static void initEOF(File mainBundleFile, String[] args, boolean assertsBundleExists)
Initializes Wonder EOF programmatically (for use in test cases and main methods). You do
not need to call this method if you already called initApp. This is lighter-weight than
initApp, and tries to just get enough configured to make EOF work properly. This method is also,
unlike initEOF(String[])
or initEOF(File, String[])
, not so restrictive as to
require the name of the bundle be a *.woa
, and nor does it require *.framework
as the name of the bundle.
It can therefore be useful for, and used with, folder, jar or war
bundles -- whichever bundle is referenced by mainBundleURI
-- so long as it is
bundle-like in content rather than by name. For NSBundle, this usually just requires a Resources folder
within the bundle.
For example, if you're build tool compiles sources and puts Resources under target/classes
you can call this method via ERXExtensions.initEOF(new File(projectDir, "target/classes"), args, true)
.
Note 1:
this will set the system property webobjects.user.dir
to the canonical path of the
given bundle uri if, and only if, the bundle uri points to a directory and is schema is file
.
Note 2:
this will set NSBundle's mainBundle to the referenced bundle loaded via
ERXRuntimeUtilities.loadBundleIfNeeded(File)
if found.
This is equivalent to calling initEOF(mainBundleFolder, args, assertsBundleExists, false, true)
.
mainBundleFile
- the archive file or directory of your main bundleargs
- the commandline arguments for your applicationassertsBundleExists
- ensures that the bundle exists and is loadedcom.webobjects.foundation.NSForwardException
- if the given bundle doesn't satisfy the given assertions or
ERXRuntimeUtilities.loadBundleIfNeeded or ERXApplication.setup fails.initEOF(File, String[], boolean, boolean, boolean)
public static void initEOF(File mainBundleFile, String[] args, boolean assertsBundleExists, boolean assertsBundleIsWOApplicationFolder, boolean fallbackToUserDirAsBundle)
Initializes Wonder EOF programmatically (for use in test cases and main methods). You do
not need to call this method if you already called initApp. This is lighter-weight than
initApp, and tries to just get enough configured to make EOF work properly. This method is also,
unlike initEOF(String[])
or initEOF(File, String[])
, not so restrictive as to
require the name of the bundle be a *.woa
, and nor does it require *.framework
as the name of the bundle.
It can therefore be useful for, and used with, folder, jar or war
bundles -- whichever bundle is referenced by mainBundleURI
-- so long as it is
bundle-like in content rather than by name. For NSBundle, this usually just requires a Resources folder
within the bundle.
For example, if you're build tool compiles sources and puts Resources under target/classes
you can call this method via ERXExtensions.initEOF(new File(projectDir, "target/classes").toURI(), args)
.
Note 1:
this will set the system property webobjects.user.dir
to the canonical path of the
given bundle uri if, and only if, the bundle uri points to a directory and is schema is file
.
Note 2:
this will set NSBundle's mainBundle to the referenced bundle loaded via
ERXRuntimeUtilities.loadBundleIfNeeded(File)
if found.
mainBundleFile
- the archive file or directory of your main bundleargs
- the commandline arguments for your applicationassertsBundleExists
- ensures that the bundle exists and is loadedassertsBundleIsWOApplicationFolder
- ensures that the bundle referenced by mainBundleFile, or the current dir if fallbackToUserDirAsBundle is true, is a *.woa
bundle folder.fallbackToUserDirAsBundle
- falls back to current dir if the mainBundleFile does not existcom.webobjects.foundation.NSForwardException
- if the given bundle doesn't satisfy the given assertions or
ERXRuntimeUtilities.loadBundleIfNeeded or ERXApplication.setup fails.ERXRuntimeUtilities.loadBundleIfNeeded(File)
,
NSBundle._setMainBundle(NSBundle)
,
ERXApplication.setup(String[])
,
bundleDidLoad(NSNotification)
Copyright © 2002 – 2020 Project Wonder.