Solid - probably ought to be a constructor that doesn't add defaults
too.....and maybe a note about thread safety on add.

On 7 February 2011 04:29, Peter Firmstone <j...@zeus.net.au> wrote:

> Dan Creswell wrote:
>
>>
>>  Sorry, what you meant was the builder generates a default array or Set of
>>> Entry classes required to support the platform, additional Entry classes
>>> the
>>> client needs can be added, then it builds the array to pass as a
>>> parameter
>>> to the lookup service.
>>>
>>>
>>>
>>>
>> Yep.
>>
>>
>>
>>
>
> How's this?
>
> Cheers,
>
> Peter.
>
>
> /*
> * 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 org.apache.river.api.lookup;
>
> import java.util.HashSet;
> import java.util.Set;
> import net.jini.lookup.entry.Address;
> import net.jini.lookup.entry.Comment;
> import net.jini.lookup.entry.Location;
> import net.jini.lookup.entry.Name;
> import net.jini.lookup.entry.ServiceInfo;
> import net.jini.lookup.entry.Status;
> import net.jini.lookup.entry.UIDescriptor;
>
> /**
> * A little builder utility class that creates an array of Entry classes to
> * be used as a parameter for StreamServiceRegistrar.  All the platform
> * Entry's are included.
> *
> * Suggested by Dan Creswell.
> * @author peter
> */
> public class DefaultEntries {
>   private final Set<Class> entrys;
>   public DefaultEntries() {
>       entrys = new HashSet<Class>(16);
>       add(Comment.class);
>       add(Location.class);
>       add(Name.class);
>       add(ServiceInfo.class);
>       add(Status.class);
>       add(UIDescriptor.class);
>       add(Address.class);
>   }
>   public DefaultEntries add(Class cl){
>       entrys.add(cl);
>       return this;
>   }
>   public Class[] getEntries(){
>       return entrys.toArray(new Class[entrys.size()]);
>   }
>
> }
>
>

Reply via email to