|
Project Wonder 5.0 | |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecter.extensions.ERXFrameworkPrincipal
er.extensions.ERXExtensions
public class ERXExtensions
Principal class of the ERExtensions framework. This class will be loaded at runtime when the ERExtensions bundle is loaded (even before the Application constructor is called) This class has a boat-load of stuff in it that will hopefully be finding better homes in the future. This class serves as the initialization point of this framework, look in the static initializer to see all the stuff that is initially setup when this class is loaded. This class also has a boat load of string, array and EOF utilities as well as the factory methods for creating editing contexts with the default delegates set.
Nested Class Summary | |
---|---|
static class |
ERXExtensions.KeyValueQualifierSQLGenerationSupport
Support class that listens for EOKeyValueQualifiers that have a selector that was registered and uses their support instead. |
Nested classes/interfaces inherited from class er.extensions.ERXFrameworkPrincipal |
---|
ERXFrameworkPrincipal.Observer |
Field Summary | |
---|---|
static org.apache.log4j.Logger |
adaptorLogger
logging support for the adaptor channel |
protected ERXModelGroup |
defaultModelGroup
holds the default model group |
static java.lang.String |
eoAdaptorLoggingWillChangeNotification
Notification name, posted before EOAdaptor debug logging will change its setting. |
static java.lang.String |
objectsWillChangeInEditingContext
Notification name, posted before object will change in an editing context |
static org.apache.log4j.Logger |
sharedEOadaptorLogger
logging support for shared object loading |
Fields inherited from class er.extensions.ERXFrameworkPrincipal |
---|
initializedFrameworks, launchingFrameworks, log |
Constructor Summary | |
---|---|
ERXExtensions()
|
Method Summary | |
---|---|
static boolean |
adaptorLogging()
Returns the current state of EOAdaptor logging. |
static void |
addObjectToBothSidesOfPotentialRelationshipFromObjectWithKeyPath(com.webobjects.eocontrol.EOEnterpriseObject to,
com.webobjects.eocontrol.EOEnterpriseObject from,
java.lang.String keyPath)
This method handles 3 different cases 1. |
static void |
addRandomizeDirectActionURL(java.lang.StringBuffer daURL)
This method can be used with Direct Action URLs to make sure that the browser will reload the page. |
static java.lang.String |
addWosidFormValue(java.lang.String url,
com.webobjects.appserver.WOSession s)
Adds the session ID (wosid) for a given session to a given url. |
static boolean |
booleanFlagOnSessionForKeyWithDefault(com.webobjects.appserver.WOSession s,
java.lang.String key,
boolean defaultValue)
Retrieves a value from the session's dictionary and evaulates that object using the booleanValue method of
ERXUtilities . |
void |
bundleDidLoad(com.webobjects.foundation.NSNotification n)
|
static byte[] |
bytesFromFile(java.io.File f)
Returns the byte array for a given file. |
static java.lang.String |
capitalize(java.lang.String s)
Deprecated. ERXStringUtilities.capitalize() |
static java.lang.String |
cleanString(java.lang.String newString,
com.webobjects.foundation.NSArray toBeCleaneds)
Given an initial string and an array of substrings, Removes any occurances of any of the substrings from the initial string. |
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 everytime the configuration file is changed. |
static void |
configureAdaptorContextRapidTurnAround(java.lang.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 |
editingContextDidCreate(com.webobjects.foundation.NSNotification n)
This is needed for WO pre-5.2 when ec's were not retained by their eos. |
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(java.lang.Process p)
Frees all of the resources associated with a given process and then destroys the process. |
static ERXSimpleHTMLFormatter |
htmlFormatter()
|
static void |
initApp(java.lang.Class applicationSubclass,
java.lang.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(java.lang.String mainBundleName,
java.lang.Class applicationSubclass,
java.lang.String[] args)
Initializes your WOApplication programmatically (for use in test cases and main methods). |
static void |
initApp(java.lang.String mainBundleName,
java.net.URL mainBundleURL,
java.lang.Class applicationSubclass,
java.lang.String[] args)
Initializes your WOApplication programmatically (for use in test cases and main methods). |
static void |
initEOF(java.io.File mainBundleFolder,
java.lang.String[] args)
Initializes Wonder EOF programmatically (for use in test cases and main methods). |
static void |
initEOF(java.io.File mainBundleFile,
java.lang.String[] args,
boolean assertsBundleExists)
Initializes Wonder EOF programmatically (for use in test cases and main methods). |
static void |
initEOF(java.io.File mainBundleFile,
java.lang.String[] args,
boolean assertsBundleExists,
boolean assertsBundleIsWOApplicationFolder,
boolean fallbackToUserDirAsBundle)
Initializes Wonder EOF programmatically (for use in test cases and main methods). |
static void |
initEOF(java.lang.String[] args)
Initializes Wonder EOF programmatically (for use in test cases and main methods). |
protected void |
initialize()
Configures the framework. |
static int |
intFromParseableIntegerString(java.lang.String s)
Returns an integer from a parsable string. |
static long |
lastModifiedDateForFileInFramework(java.lang.String fileName,
java.lang.String frameworkName)
Deprecated. use ERXFileUtilities.lastModifiedDateForFileInFramework() |
static boolean |
objectImplementsMethod(java.lang.Object object,
java.lang.String methodName,
java.lang.Class[] parameters)
Determines if a given object implements a method given the name and the array of input parameters. |
static java.lang.String |
plurify(java.lang.String s,
int howMany,
java.lang.String language)
Deprecated. use ERXLocalizer.localizerForLanguage(language).plurifiedString(s, howMany) |
static java.lang.String |
randomizeDirectActionURL(java.lang.String daURL)
This method can be used with Direct Action URLs to make sure that the browser will reload the page. |
static java.lang.Object |
readPropertyListFromFileinFramework(java.lang.String fileName,
java.lang.String aFrameWorkName)
Deprecated. use ERXFileUtilities.readPropertyListFromFileInFramework() |
static java.lang.Object |
readPropertyListFromFileInFramework(java.lang.String fileName,
java.lang.String aFrameWorkName,
com.webobjects.foundation.NSArray languageList)
Deprecated. use ERXFileUtilities.readPropertyListFromFileInFramework() |
static void |
refreshSharedObjectsWithName(java.lang.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(com.webobjects.foundation.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 java.lang.String |
removeHTMLTagsFromString(java.lang.String s)
Removes all of the HTML tags from a given string. |
static java.lang.String |
resolveUnit(java.lang.String userInfoUnitString,
com.webobjects.eocontrol.EOEnterpriseObject object,
java.lang.String prefixKeyPath)
Resolves a given user info unit string for a given object. |
static void |
retainEditingContextForCurrentSession(com.webobjects.eocontrol.EOEditingContext ec)
Retains an editing context for the current session. |
static boolean |
safeDifferent(java.lang.Object v1,
java.lang.Object v2)
A safe different comparison method that first checks to see if either of the objects are null before comparing them with the equals method.Note that if both objects are null then they will be considered equal. |
static boolean |
safeEquals(java.lang.Object v1,
java.lang.Object v2)
A safe comparison method that first checks to see if either of the objects are null before comparing them with the equals method.Note that if both objects are null then they will be considered equal. |
static ERXSession |
session()
Deprecated. use ERXSession.session() instead |
void |
sessionDidTimeOut(com.webobjects.foundation.NSNotification n)
This method is called every time a session times out. |
static void |
sessionDidTimeOut(java.lang.String sessionID)
This method is called when a session times out. |
static void |
setAdaptorLogging(boolean onOff)
Turn EOAdaptor logging on and off. |
static void |
setBooleanFlagOnSessionForKey(com.webobjects.appserver.WOSession s,
java.lang.String key,
boolean newValue)
Uses the setObjectForKey method of the WOSession
class to push a Boolean object onto the session for a given key. |
static void |
setSession(ERXSession session)
Deprecated. use ERXSession.setSession(session) instead |
void |
sharedEditingContextWasInitialized(com.webobjects.foundation.NSNotification n)
This method is called for the following notification EOSharedEditingContext.DefaultSharedEditingContextWasInitializedNotification |
static java.lang.String |
stringFromFile(java.io.File f)
Returns a string from the file using the default encoding. |
static java.lang.String |
stringFromFile(java.io.File f,
java.lang.String encoding)
Returns a string from the file using the specified encoding. |
static boolean |
stringIsParseableInteger(java.lang.String s)
Tests if a given string object can be parsed into an integer. |
static java.lang.String |
substituteStringByStringInString(java.lang.String s1,
java.lang.String s2,
java.lang.String s)
|
static java.lang.String |
userInfoUnit(com.webobjects.eocontrol.EOEnterpriseObject object,
java.lang.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 java.lang.String |
userPreferencesKeyFromContext(java.lang.String key,
com.webobjects.foundation.NSKeyValueCoding context)
Constructs a unique key based on a context. |
Methods inherited from class er.extensions.ERXFrameworkPrincipal |
---|
didFinishInitialization, setUpFrameworkPrincipalClass, sharedInstance, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String objectsWillChangeInEditingContext
public static final java.lang.String eoAdaptorLoggingWillChangeNotification
protected volatile ERXModelGroup defaultModelGroup
public static org.apache.log4j.Logger adaptorLogger
public static org.apache.log4j.Logger sharedEOadaptorLogger
Constructor Detail |
---|
public ERXExtensions()
Method Detail |
---|
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
the ERXCompilerProxy
and 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 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 sessionDidTimeOut(com.webobjects.foundation.NSNotification n)
n
- notification that contains the session ID.public void editingContextDidCreate(com.webobjects.foundation.NSNotification n)
n
- notification posted when an ec is createdpublic void sharedEditingContextWasInitialized(com.webobjects.foundation.NSNotification n)
EOSharedEditingContext.DefaultSharedEditingContextWasInitializedNotification
n
- the notification.public static void configureAdaptorContextRapidTurnAround(java.lang.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 sessionDidTimeOut(java.lang.String sessionID)
sessionID
- of the session that timed outpublic static void retainEditingContextForCurrentSession(com.webobjects.eocontrol.EOEditingContext ec)
ec
- to be retained.public static java.lang.String removeHTMLTagsFromString(java.lang.String s)
ERXSimpleHTMLFormatter
s
- html string
public static void forceGC(int maxLoop)
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 java.lang.String capitalize(java.lang.String s)
s
- string to capitalize
public static java.lang.String plurify(java.lang.String s, int howMany, java.lang.String language)
ERXLocalizer
for more information.
s
- string to pluralizehowMany
- number of itslanguage
- target language
public static boolean safeEquals(java.lang.Object v1, java.lang.Object v2)
equals
method.
v1
- first objectv2
- second object
public static boolean safeDifferent(java.lang.Object v1, java.lang.Object v2)
equals
method.
v1
- first objectv2
- second object
public static boolean stringIsParseableInteger(java.lang.String s)
s
- string to be parsed
public static int intFromParseableIntegerString(java.lang.String s)
s
- string to be parsed.
public static java.lang.String substituteStringByStringInString(java.lang.String s1, java.lang.String s2, java.lang.String s)
public static ERXSimpleHTMLFormatter htmlFormatter()
public static void addObjectToBothSidesOfPotentialRelationshipFromObjectWithKeyPath(com.webobjects.eocontrol.EOEnterpriseObject to, com.webobjects.eocontrol.EOEnterpriseObject from, java.lang.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 byte[] bytesFromFile(java.io.File f) throws java.io.IOException
f
- file to get the bytes from
java.io.IOException
- if things go wrongpublic static java.lang.String stringFromFile(java.io.File f) throws java.io.IOException
f
- file to read
java.io.IOException
public static java.lang.String stringFromFile(java.io.File f, java.lang.String encoding) throws java.io.IOException
f
- file to readencoding
- to be used, null will use the default
java.io.IOException
public static long lastModifiedDateForFileInFramework(java.lang.String fileName, java.lang.String frameworkName)
fileName
- name of the fileframeworkName
- name of the framework, null or "app"
for the application bundle
lastModified
method of the file objectpublic static java.lang.Object readPropertyListFromFileinFramework(java.lang.String fileName, java.lang.String aFrameWorkName)
fileName
- name of the fileaFrameWorkName
- name of the framework, null or
'app' for the application bundle.
public static java.lang.Object readPropertyListFromFileInFramework(java.lang.String fileName, java.lang.String aFrameWorkName, com.webobjects.foundation.NSArray languageList)
fileName
- name of the fileaFrameWorkName
- name of the framework, null or
'app' for the application bundle.languageList
- language list search order
public static java.lang.String userInfoUnit(com.webobjects.eocontrol.EOEnterpriseObject object, java.lang.String key)
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 object
public static java.lang.String resolveUnit(java.lang.String userInfoUnitString, com.webobjects.eocontrol.EOEnterpriseObject object, java.lang.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(com.webobjects.foundation.NSArray names)
names
- array of shared entity namespublic static void refreshSharedObjectsWithName(java.lang.String entityName)
entityName
- name of the shared entitypublic static java.lang.String randomizeDirectActionURL(java.lang.String daURL)
daURL
- a url to add the randomization to.
public static void addRandomizeDirectActionURL(java.lang.StringBuffer daURL)
daURL
- a url to add the randomization to.public static java.lang.String addWosidFormValue(java.lang.String url, com.webobjects.appserver.WOSession s)
url
- to add wosid form value to.
public static java.lang.String cleanString(java.lang.String newString, com.webobjects.foundation.NSArray toBeCleaneds)
newString
- initial string from which to remove other stringstoBeCleaneds
- array of substrings to be removed from the initial string.
public static void setBooleanFlagOnSessionForKey(com.webobjects.appserver.WOSession s, java.lang.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, java.lang.String key, boolean defaultValue)
booleanValue
method of
ERXUtilities
. 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 null
public static void setSession(ERXSession session)
ERXSession
's awake and sleep methods.
session
- that is currently active for this thread.public static ERXSession session()
public static java.lang.String userPreferencesKeyFromContext(java.lang.String key, com.webobjects.foundation.NSKeyValueCoding context)
key
- preference keycontext
- most likely a d2wContext object
public static void freeProcessResources(java.lang.Process p)
p
- process to destroypublic static boolean objectImplementsMethod(java.lang.Object object, java.lang.String methodName, java.lang.Class[] parameters)
object
- to determine if it implements a methodmethodName
- name of the methodparameters
- array of parameters
public static void initApp(java.lang.Class applicationSubclass, java.lang.String[] args)
applicationSubclass
- your Application subclassargs
- the commandline arguments for your applicationpublic static void initApp(java.lang.String mainBundleName, java.lang.Class applicationSubclass, java.lang.String[] args)
mainBundleName
- the name of your main bundleapplicationSubclass
- your Application subclassargs
- the commandline arguments for your applicationpublic static void initApp(java.lang.String mainBundleName, java.net.URL mainBundleURL, java.lang.Class applicationSubclass, java.lang.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(java.lang.String[] args)
This is equivalent to calling initEOF(new File("."), args)
.
args
- the commandline arguments for your application
java.lang.IllegalArgumentException
- if the current dir or mainBundleFolder is not a *.woa bundle.public static void initEOF(java.io.File mainBundleFolder, java.lang.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 application
java.lang.IllegalArgumentException
- if the current dir or mainBundleFolder is not a *.woa bundle.public static void initEOF(java.io.File mainBundleFile, java.lang.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(URI)
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 loaded
com.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(java.io.File mainBundleFile, java.lang.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(URI)
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 exist
com.webobjects.foundation.NSForwardException
- if the given bundle doesn't satisfy the given assertions or
ERXRuntimeUtilities.loadBundleIfNeeded or ERXApplication.setup fails.ERXRuntimeUtilities#loadBundleIfNeeded(URI)
,
NSBundle._setMainBundle(NSBundle)
,
ERXApplication#setup(String[])
,
bundleDidLoad(NSNotification)
|
Last updated: Tue, Feb 21, 2017 05:45 PM CET | |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |