Search in sources :

Example 6 with Result

use of com.sun.enterprise.util.Result in project Payara by payara.

the class DomainXmlVerifier method checkDuplicate.

private void checkDuplicate(Collection<? extends Dom> beans) {
    if (beans == null || beans.size() <= 1) {
        return;
    }
    WeakHashMap keyBeanMap = new WeakHashMap();
    ArrayList<String> keys = new ArrayList<String>(beans.size());
    for (Dom b : beans) {
        String key = b.getKey();
        keyBeanMap.put(key, b);
        keys.add(key);
    }
    WeakHashMap<String, Class<ConfigBeanProxy>> errorKeyBeanMap = new WeakHashMap<String, Class<ConfigBeanProxy>>();
    String[] strKeys = keys.toArray(new String[beans.size()]);
    for (int i = 0; i < strKeys.length; i++) {
        boolean foundDuplicate = false;
        for (int j = i + 1; j < strKeys.length; j++) {
            // we have a duplicate. So output that error
            if ((strKeys[i].equals(strKeys[j]))) {
                foundDuplicate = true;
                errorKeyBeanMap.put(strKeys[i], ((Dom) keyBeanMap.get(strKeys[i])).getProxyType());
                error = true;
                break;
            }
        }
    }
    for (Map.Entry e : errorKeyBeanMap.entrySet()) {
        Result result = new Result(strings.get("VerifyDupKey", e.getKey(), e.getValue()));
        output(result);
    }
}
Also used : Dom(org.jvnet.hk2.config.Dom) ArrayList(java.util.ArrayList) Result(com.sun.enterprise.util.Result) ConfigBeanProxy(org.jvnet.hk2.config.ConfigBeanProxy) Map(java.util.Map) WeakHashMap(java.util.WeakHashMap) WeakHashMap(java.util.WeakHashMap)

Example 7 with Result

use of com.sun.enterprise.util.Result in project Payara by payara.

the class GrizzlyService method createNetworkProxy.

/*
     * Creates a new NetworkProxy for a particular HttpListner
     * @param listener NetworkListener
     * @param networkConfig HttpService
     */
public synchronized Future<Result<Thread>> createNetworkProxy(NetworkListener listener) {
    if (!Boolean.valueOf(listener.getEnabled())) {
        // in case the listener will be enabled
        addChangeListener(listener);
        LOGGER.log(Level.INFO, KernelLoggerInfo.grizzlyPortDisabled, new Object[] { listener.getName(), listener.getPort() });
        return null;
    }
    // create the proxy for the port.
    GrizzlyProxy proxy = new GrizzlyProxy(this, listener);
    Future<Result<Thread>> future = null;
    try {
        proxy.initialize();
        if (!isLightWeightListener(listener)) {
            final NetworkConfig networkConfig = listener.getParent(NetworkListeners.class).getParent(NetworkConfig.class);
            // attach all virtual servers to this port
            for (VirtualServer vs : networkConfig.getParent(Config.class).getHttpService().getVirtualServer()) {
                List<String> vsListeners = StringUtils.parseStringList(vs.getNetworkListeners(), " ,");
                if (vsListeners == null || vsListeners.isEmpty() || vsListeners.contains(listener.getName())) {
                    if (!hosts.contains(vs.getId())) {
                        hosts.add(vs.getId());
                    }
                }
            }
            addChangeListener(listener);
            addChangeListener(listener.findThreadPool());
            addChangeListener(listener.findTransport());
            final Protocol protocol = listener.findHttpProtocol();
            if (protocol != null) {
                addChangeListener(protocol);
                addChangeListener(protocol.getHttp());
                addChangeListener(protocol.getHttp().getFileCache());
                addChangeListener(protocol.getSsl());
            }
        }
        future = proxy.start();
        // add the new proxy to our list of proxies.
        proxies.add(proxy);
    } catch (Throwable e) {
        final Future<Result<Thread>> errorFuture = Futures.createReadyFuture(new Result<Thread>(e));
        future = errorFuture;
    } finally {
        if (future == null) {
            final FutureImpl<Result<Thread>> errorFuture = Futures.<Result<Thread>>createUnsafeFuture();
            errorFuture.result(new Result<Thread>(new IllegalStateException("Unexpected error")));
            future = errorFuture;
        }
        futures.add(future);
    }
    return future;
}
Also used : NetworkConfig(org.glassfish.grizzly.config.dom.NetworkConfig) VirtualServer(com.sun.enterprise.config.serverbeans.VirtualServer) Result(com.sun.enterprise.util.Result) NetworkListeners(org.glassfish.grizzly.config.dom.NetworkListeners) Future(java.util.concurrent.Future) Protocol(org.glassfish.grizzly.config.dom.Protocol)

Aggregations

Result (com.sun.enterprise.util.Result)7 ArrayList (java.util.ArrayList)3 Future (java.util.concurrent.Future)3 VirtualServer (com.sun.enterprise.config.serverbeans.VirtualServer)2 Map (java.util.Map)2 ExecutionException (java.util.concurrent.ExecutionException)2 TimeoutException (java.util.concurrent.TimeoutException)2 NetworkListener (org.glassfish.grizzly.config.dom.NetworkListener)2 Config (com.sun.enterprise.config.serverbeans.Config)1 HttpService (com.sun.enterprise.config.serverbeans.HttpService)1 SystemProperty (com.sun.enterprise.config.serverbeans.SystemProperty)1 JmsHost (com.sun.enterprise.connectors.jms.config.JmsHost)1 Application (com.sun.enterprise.deployment.Application)1 StringUtils (com.sun.enterprise.util.StringUtils)1 DummyNetworkListener (com.sun.enterprise.v3.services.impl.DummyNetworkListener)1 GrizzlyService (com.sun.enterprise.v3.services.impl.GrizzlyService)1 GrizzlyMonitoring (com.sun.enterprise.v3.services.impl.monitor.GrizzlyMonitoring)1 IOException (java.io.IOException)1 InvocationHandler (java.lang.reflect.InvocationHandler)1 Method (java.lang.reflect.Method)1