On 11/03/2013 23:47, Danny Coward wrote:
> Hi Mark,
>
> Yes, 6.2 is going to need changing :( The javadoc I think is clear, but,
> I did not update 6.2 when we made the last change to the
> ServerApplicationConfig class in the *Configuration refactoring. My bad
> and thanks for catching it.
>
> The reason it doesn't work to scan for ServerEndpointConfigs is that
> they have to carry the basic endpoint path and class information. Up to
> the last refactoring, the only way to put this in was to the information
> in the no-arg constructor, meaning you had to make a subclass of
> subclass ServerEndpointConfig just to put the path in. And if the
> container were supposed to scan for them an instantiated them, who would
> put in the path information ?
>
> Here is the context that summarizes the issues better:
> http://java.net/projects/websocket-spec/lists/jsr356-experts/archive/2013-02/message/39
>
>
> The consequence of this is that a programmatic endpoint requires the
> developer to provide an ServerEndpointConfig to deploy it. (The
> annotated endpoints have all their config in them, so that's easy thank
> goodness).
>
> So explicitly, and referring to the PFD javadoc for
> ServerApplicationConfig, the SCI needs to do two scans: one for subtypes
> of Endpoint, and one for classes annotated @ServerEndpoint.
>
> So ServerApplicationConfigs are going to look something like this:-
>
> public class MyAppConfig implements ServerApplicationConfig {
> public Set<ServerEndpointConfig> getEndpointConfigs(Set<Class<?
> extends Endpoint>> endpointClasses) {
> // for each endpointClass you want to deploy, create a
> ServerEndpointConfig instance
> // e.g. ServerEndpointConfig sec =
> ServerEndpointConfig.Builder.create(MyEndpoint.class, "/foo").build();
> return serverEndpointConfigInstances;
> }
>
> Set<Class<?>> getAnnotatedEndpointClasses(Set<Class<?>> scanned) {
> // for each scanned annotated endpoint class, return it if you
> want it deployed.
> return annotatedEndpointClasses;
> }
>
> }
>
> HTH,
It does. Many thanks.
Mark
>
> - Danny
>
>
>
>
> On 3/7/13 3:06 AM, Mark Thomas wrote:
>> I think it would help if section 6.2 clarified exactly what the SCI is
>> expected to scan for. My understanding is that the list is:
>> - Implementations of ServerApplicationConfig
>> - Classes annotated with ServerEndpoint
>> - Implementations of ServerEndpointConfig
>>
>> As a follow up to this, would it make more sense to pass a set of
>> ServerEndpointConfig instances to the ServerApplicationConfig instances?
>>
>> The reason for raising this is that I originally thought that the SCI
>> needed to scan for Endpoint implementations but I quickly came to the
>> conclusion that this was incorrect since there is no way to identify the
>> path to use in order to create the necessary ServerEndpointConfig if no
>> ServerApplicationConfigs are defined.
>>
>> I do wonder if I have understood this last bit correctly. An alternative
>> option would be to scan for implementations of ServerEndpointConfig and
>> Endpoint passing the endpoints to the ServerApplicationConfig instances
>> if any are found and using the ServerEndpointConfigs if no
>> ServerApplicationConfig are present but that seems a little to
>> complicated not to be mention explicitly in the spec since it would be
>> rather unexpected for users.
>>
>> Mark
>
>