Search in sources :

Example 1 with NSSelector

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

the class ERXConfigurationManager method registerForFileNotification.

private void registerForFileNotification(String path, String callbackMethod) {
    try {
        ERXFileNotificationCenter.defaultCenter().addObserver(this, new NSSelector(callbackMethod, ERXUtilities.NotificationClassArray), path);
        log.debug("Registered: {}", path);
    } catch (Exception ex) {
        log.error("An exception occured while registering the observer for the " + "logging configuration file: {} {}", ex.getClass().getName(), ex.getMessage(), ex);
    }
}
Also used : NSSelector(com.webobjects.foundation.NSSelector)

Example 2 with NSSelector

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

the class ERXUtilities method informationForContext.

private static NSMutableDictionary<String, Object> informationForContext(WOContext context) {
    NSMutableDictionary<String, Object> extraInfo = new NSMutableDictionary<>();
    if (context != null) {
        if (context.page() != null) {
            extraInfo.setObjectForKey(context.page().name(), "CurrentPage");
            if (context.component() != null) {
                extraInfo.setObjectForKey(context.component().name(), "CurrentComponent");
                if (context.component().parent() != null) {
                    extraInfo.setObjectForKey(ERXWOContext.componentPath(context), "CurrentComponentHierarchy");
                }
            }
            // If this is a D2W component, get its D2W-related information
            // from ERDirectToWeb.
            NSSelector d2wSelector = new NSSelector("d2wContext");
            if (d2wSelector.implementedByObject(context.page())) {
                try {
                    Class erDirectToWebClazz = Class.forName("er.directtoweb.ERDirectToWeb");
                    NSSelector infoSelector = new NSSelector("informationForContext", new Class[] { WOContext.class });
                    NSDictionary d2wExtraInfo = (NSDictionary) infoSelector.invoke(erDirectToWebClazz, context);
                    extraInfo.addEntriesFromDictionary(d2wExtraInfo);
                } catch (Exception e) {
                }
            }
        }
        if (context.request() != null) {
            extraInfo.setObjectForKey(context.request().uri(), "URL");
            if (context.request().headers() != null) {
                NSMutableDictionary<String, Object> headers = new NSMutableDictionary<>();
                for (Object key : context.request().headerKeys()) {
                    String value = context.request().headerForKey(key);
                    if (value != null) {
                        headers.setObjectForKey(value, key.toString());
                    }
                }
                extraInfo.setObjectForKey(headers, "Headers");
            }
        }
        if (context.hasSession()) {
            if (context.session().statistics() != null) {
                extraInfo.setObjectForKey(context.session().statistics(), "PreviousPageList");
            }
            extraInfo.setObjectForKey(context.session(), "Session");
        }
    }
    return extraInfo;
}
Also used : NSSelector(com.webobjects.foundation.NSSelector) NSDictionary(com.webobjects.foundation.NSDictionary) NSMutableDictionary(com.webobjects.foundation.NSMutableDictionary) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) UncheckedIOException(java.io.UncheckedIOException) NSForwardException(com.webobjects.foundation.NSForwardException)

Aggregations

NSSelector (com.webobjects.foundation.NSSelector)2 NSDictionary (com.webobjects.foundation.NSDictionary)1 NSForwardException (com.webobjects.foundation.NSForwardException)1 NSMutableDictionary (com.webobjects.foundation.NSMutableDictionary)1 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1