Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed to the Apache Software Foundation (ASF) under one or more
   * contributor license agreements.  See the NOTICE file distributed with
   * this work for additional information regarding copyright ownership.
   * The ASF licenses this file to You under the Apache License, Version 2.0
   * (the "License"); you may not use this file except in compliance with
   * the License.  You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package javax.websocket.server;
 
 import java.util.List;
 
Provides configuration information for WebSocket endpoints published to a server. Applications may provide their own implementation or use ServerEndpointConfig.Builder.
 
 public interface ServerEndpointConfig extends EndpointConfig {
 
     Class<?> getEndpointClass();

    
Returns the path at which this WebSocket server endpoint has been registered. It may be a path or a level 0 URI template.
 
     String getPath();
 
 
 
 
 
     public final class Builder {
 
         public static Builder create(
                 Class<?> endpointClassString path) {
             return new Builder(endpointClasspath);
         }
 
 
         private final Class<?> endpointClass;
         private final String path;
         private List<Class<? extends Encoder>> encoders =
                 Collections.emptyList();
         private List<Class<? extends Decoder>> decoders =
                 Collections.emptyList();
         private List<Stringsubprotocols = Collections.emptyList();
         private List<Extensionextensions = Collections.emptyList();
         private Configurator configurator =
                 Configurator.fetchContainerDefaultConfigurator();
 
 
         private Builder(Class<?> endpointClass,
                 String path) {
             this. = endpointClass;
             this. = path;
         }
 
         public ServerEndpointConfig build() {
             return new DefaultServerEndpointConfig(,
                     );
         }
 
 
         public Builder encoders(
                 List<Class<? extends Encoder>> encoders) {
             if (encoders == null || encoders.size() == 0) {
                 this. = Collections.emptyList();
             } else {
                 this. = Collections.unmodifiableList(encoders);
             }
             return this;
         }
 
 
         public Builder decoders(
                 List<Class<? extends Decoder>> decoders) {
             if (decoders == null || decoders.size() == 0) {
                 this. = Collections.emptyList();
             } else {
                this. = Collections.unmodifiableList(decoders);
            }
            return this;
        }
        public Builder subprotocols(
                List<Stringsubprotocols) {
            if (subprotocols == null || subprotocols.size() == 0) {
                this. = Collections.emptyList();
            } else {
                this. = Collections.unmodifiableList(subprotocols);
            }
            return this;
        }
        public Builder extensions(
                List<Extensionextensions) {
            if (extensions == null || extensions.size() == 0) {
                this. = Collections.emptyList();
            } else {
                this. = Collections.unmodifiableList(extensions);
            }
            return this;
        }
        public Builder configurator(Configurator serverEndpointConfigurator) {
            if (serverEndpointConfigurator == null) {
                this. = Configurator.fetchContainerDefaultConfigurator();
            } else {
                this. = serverEndpointConfigurator;
            }
            return this;
        }
    }
    public class Configurator {
        private static volatile Configurator defaultImpl = null;
        private static final Object defaultImplLock = new Object();
        private static final String DEFAULT_IMPL_CLASSNAME =
                "org.apache.tomcat.websocket.server.DefaultServerEndpointConfigurator";
            if ( == null) {
                synchronized () {
                    if ( == null) {
                         = loadDefault();
                    }
                }
            }
            return ;
        }
        private static Configurator loadDefault() {
            Configurator result = null;
            ServiceLoader<ConfiguratorserviceLoader =
                    ServiceLoader.load(Configurator.class);
            Iterator<Configuratoriter = serviceLoader.iterator();
            while (result == null && iter.hasNext()) {
                result = iter.next();
            }
            // Fall-back. Also used by unit tests
            if (result == null) {
                try {
                    @SuppressWarnings("unchecked")
                    Class<Configuratorclazz =
                            (Class<Configurator>) Class.forName(
                                    );
                    result = clazz.newInstance();
                } catch (ClassNotFoundException e) {
                    // No options left. Just return null.
                } catch (InstantiationException e) {
                    // No options left. Just return null.
                } catch (IllegalAccessException e) {
                    // No options left. Just return null.
                }
            }
            return result;
        }
        public String getNegotiatedSubprotocol(List<Stringsupported,
                List<Stringrequested) {
            return fetchContainerDefaultConfigurator().getNegotiatedSubprotocol(supportedrequested);
        }
        public List<ExtensiongetNegotiatedExtensions(List<Extensioninstalled,
                List<Extensionrequested) {
            return fetchContainerDefaultConfigurator().getNegotiatedExtensions(installedrequested);
        }
        public boolean checkOrigin(String originHeaderValue) {
            return fetchContainerDefaultConfigurator().checkOrigin(originHeaderValue);
        }
        public void modifyHandshake(ServerEndpointConfig sec,
                HandshakeRequest requestHandshakeResponse response) {
            fetchContainerDefaultConfigurator().modifyHandshake(secrequestresponse);
        }
        public <T extends Object> T getEndpointInstance(Class<T> clazz)
                throws InstantiationException {
                    clazz);
        }
    }
New to GrepCode? Check out our FAQ X