I dunno, it just seems to fit so well here, I didn't even have to change
the documentation.
/** Generic service creation method that attempts to start the
* services defined by the provided <code>ServiceDescriptor[]</code>
* argument.
* @param descs The <code>ServiceDescriptor[]</code> that contains
* the descriptors for the services to start.
* @param config The associated <code>Configuration</code> object
* used to customize the service creation process.
* @return Returns a <code>Result[]</code> that is the same length as
* <code>descs</code>, which contains the details for each
* service creation attempt.
* @throws Exception If there was a problem creating the service.
* @see Result
* @see ServiceDescriptor
* @see net.jini.config.Configuration
*/
private static Result[] create(final ServiceDescriptor[] descs,
final Configuration config)
throws Exception
{
logger.entering(ServiceStarter.class.getName(), "create",
new Object[] {descs, config});
ArrayList proxies = new ArrayList();
Object result = null;
Exception problem = null;
ServiceDescriptor desc = null;
for (int i=0; i < descs.length; i++) {
desc = descs[i];
result = null;
problem = null;
try {
if (desc != null) {
result = desc.create(config);
if (result instanceof Starter) ((Starter)
result).start();
}
} catch (Exception e) {
problem = e;
} finally {
proxies.add(new Result(desc, result, problem));
}
}
logger.exiting(ServiceStarter.class.getName(), "create", proxies);
return (Result[])proxies.toArray(new Result[proxies.size()]);
}
Gregg Wonderly wrote:
Looking around briefly, it seems that there is a not so great set of
returned values from ServiceDescriptor.create() with activation
returning the RMI GID. So a little more work to wrap everything into
something implementing an interface with lifecycle management in it
would be required.
Gregg
On 3/15/2013 9:18 PM, Peter Firmstone wrote:
I'd like to add a start() method to OutriggerImpl, so I can delay any
threads from being started until after construction is complete.
This is required for safe publication to comply with the JMM.
Before doing so, I'd like to know how people are using Outrigger, so
I can minimise unintended consequences / breakages.
Comments, opinions and thoughts?
Regards,
Peter.