Search in sources :

Example 11 with NSBundle

use of com.webobjects.foundation.NSBundle in project wonder-slim by undur.

the class ERXResourceManager method _initFrameworkProjectBundles.

private void _initFrameworkProjectBundles() {
    NSBundle aBundle = null;
    NSArray aFrameworkBundleList = NSBundle.frameworkBundles();
    for (Enumeration aBundleEnumerator = aFrameworkBundleList.objectEnumerator(); aBundleEnumerator.hasMoreElements(); _erxCachedBundleForFrameworkNamed(aBundle.name())) {
        aBundle = (NSBundle) aBundleEnumerator.nextElement();
    }
}
Also used : NSBundle(com.webobjects.foundation.NSBundle) Enumeration(java.util.Enumeration) NSArray(com.webobjects.foundation.NSArray)

Example 12 with NSBundle

use of com.webobjects.foundation.NSBundle in project wonder-slim by undur.

the class ERXResourceManager method _locateBundleForFrameworkNamed.

private static WODeployedBundle _locateBundleForFrameworkNamed(String aFrameworkName) {
    WODeployedBundle aBundle = null;
    aBundle = ERXDeployedBundle.deployedBundleForFrameworkNamed(aFrameworkName);
    if (aBundle == null) {
        NSBundle nsBundle = NSBundle.bundleForName(aFrameworkName);
        if (nsBundle != null) {
            aBundle = _bundleWithNSBundle(nsBundle);
        }
    }
    return aBundle;
}
Also used : WODeployedBundle(com.webobjects.appserver._private.WODeployedBundle) NSBundle(com.webobjects.foundation.NSBundle)

Example 13 with NSBundle

use of com.webobjects.foundation.NSBundle in project wonder-slim by undur.

the class ERXDeployedBundle method deployedBundleForFrameworkNamed.

public static synchronized WODeployedBundle deployedBundleForFrameworkNamed(String aFrameworkName) {
    WODeployedBundle aBundle = null;
    NSArray bundleArray = TheBundles.allValues();
    int baCount = TheBundles.count();
    NSBundle nsBundle = NSBundle.bundleForName(aFrameworkName);
    if (nsBundle == null)
        nsBundle = NSBundle.bundleWithPath(aFrameworkName);
    if (nsBundle != null) {
        int i = 0;
        do {
            if (i >= baCount)
                break;
            WODeployedBundle aFrameworkBundle = (WODeployedBundle) bundleArray.objectAtIndex(i);
            if (nsBundle.equals(aFrameworkBundle.nsBundle())) {
                aBundle = aFrameworkBundle;
                WODeployedBundle dBundle = aBundle.projectBundle();
                if (dBundle != null)
                    aBundle = dBundle;
                break;
            }
            i++;
        } while (true);
    }
    return aBundle;
}
Also used : WODeployedBundle(com.webobjects.appserver._private.WODeployedBundle) NSBundle(com.webobjects.foundation.NSBundle) NSArray(com.webobjects.foundation.NSArray)

Example 14 with NSBundle

use of com.webobjects.foundation.NSBundle in project wonder-slim by undur.

the class WOExceptionPage method sourceFileContainingError.

/**
 * @return The source file where the exception originated (from the last line of the stack trace).
 */
private Path sourceFileContainingError() {
    String nameOfThrowingClass = firstLineOfTrace().packageClassPath();
    NSBundle bundle = bundleForClassName(nameOfThrowingClass);
    if (bundle == null) {
        return null;
    }
    String path = null;
    if (NSBundle.mainBundle().getClass().getName().contains("NSMavenProjectBundle")) {
        // FIXME: We should probably be referencing the real class once that exists again // Hugi 2021-05-21
        path = bundle.bundlePath() + pathModifier + "/src/main/java/" + nameOfThrowingClass.replace(".", "/") + ".java";
    } else {
        path = bundle.bundlePath() + pathModifier + "/Sources/" + nameOfThrowingClass.replace(".", "/") + ".java";
    }
    return Paths.get(path);
}
Also used : NSBundle(com.webobjects.foundation.NSBundle)

Example 15 with NSBundle

use of com.webobjects.foundation.NSBundle in project wonder-slim by undur.

the class ERXLocalizer method frameworkSearchPath.

public static NSArray<String> frameworkSearchPath() {
    if (frameworkSearchPath == null) {
        frameworkSearchPath = ERXProperties.arrayForKey("er.extensions.ERXLocalizer.frameworkSearchPath");
        if (frameworkSearchPath == null) {
            NSMutableArray<String> defaultValue = new NSMutableArray<>();
            for (Enumeration<NSBundle> e = NSBundle.frameworkBundles().objectEnumerator(); e.hasMoreElements(); ) {
                NSBundle bundle = e.nextElement();
                String name = bundle.name();
                // Check the Properties and Add it Automatically
                String propertyName = "er.extensions." + name + ".hasLocalization";
                boolean hasLocalization = ERXProperties.booleanForKeyWithDefault(propertyName, true);
                if (name.equals("ERCoreBusinessLogic") || name.equals("ERDirectToWeb") || name.equals("ERExtensions")) {
                // || name.startsWith("Java")
                // do nothing yet, because will add later
                } else if (hasLocalization) {
                    defaultValue.addObject(name);
                }
            }
            if (NSBundle.bundleForName("ERCoreBusinessLogic") != null)
                defaultValue.addObject("ERCoreBusinessLogic");
            if (NSBundle.bundleForName("ERDirectToWeb") != null)
                defaultValue.addObject("ERDirectToWeb");
            if (NSBundle.bundleForName("ERExtensions") != null)
                defaultValue.addObject("ERExtensions");
            defaultValue.insertObjectAtIndex("app", 0);
            frameworkSearchPath = defaultValue;
        }
        if (log.isDebugEnabled())
            log.debug("FrameworkSearchPath: {}", frameworkSearchPath.componentsJoinedByString(" / "));
    }
    return frameworkSearchPath;
}
Also used : NSBundle(com.webobjects.foundation.NSBundle) NSMutableArray(com.webobjects.foundation.NSMutableArray)

Aggregations

NSBundle (com.webobjects.foundation.NSBundle)17 NSArray (com.webobjects.foundation.NSArray)5 IOException (java.io.IOException)5 Enumeration (java.util.Enumeration)5 File (java.io.File)4 NSMutableArray (com.webobjects.foundation.NSMutableArray)3 URL (java.net.URL)3 WOApplication (com.webobjects.appserver.WOApplication)2 WODeployedBundle (com.webobjects.appserver._private.WODeployedBundle)2 NSDictionary (com.webobjects.foundation.NSDictionary)2 MalformedURLException (java.net.MalformedURLException)2 JarFile (java.util.jar.JarFile)2 NSForwardException (com.webobjects.foundation.NSForwardException)1 NSMutableDictionary (com.webobjects.foundation.NSMutableDictionary)1 NSNotification (com.webobjects.foundation.NSNotification)1 NSProperties (com.webobjects.foundation.NSProperties)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStream (java.io.InputStream)1 UncheckedIOException (java.io.UncheckedIOException)1 Field (java.lang.reflect.Field)1