de.smartics.properties.resource.util
Class AbstractServiceFactory<T>

Package class diagram package AbstractServiceFactory
java.lang.Object
  extended by de.smartics.properties.resource.util.AbstractServiceFactory<T>
Type Parameters:
T - the type of the service to instantiate.
Direct Known Subclasses:
AbstractJndiBackedServiceFactory

public abstract class AbstractServiceFactory<T>
     
     
extends Object

A factory to create instances of a given type using the Java Service API.


Constructor Summary
protected AbstractServiceFactory(InstanceCreator<T> creator)
          Default constructor.
 
Method Summary
 T create()
          Creates an instance of a service in META-INF/services.
 T create(Class<? extends T> defaultType)
          Creates an instance of a service in META-INF/services.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractServiceFactory

protected AbstractServiceFactory(InstanceCreator<T> creator)
Default constructor.

Parameters:
creator - the creator of instances created as defaults by this factory.
Throws:
NullPointerException - if creator is null.
Method Detail

create

public final T create()
               throws ResourceException
Creates an instance of a service in META-INF/services.

Returns:
instance of the desired type.
Throws:
ResourceException - if a type cannot be instantiated.

create

public final T create(Class<? extends T> defaultType)
               throws ResourceException
Creates an instance of a service in META-INF/services.

Parameters:
defaultType - the default type to use if there is no configuration file found in META-INF/services.
Returns:
instance of the desired type.
Throws:
ResourceException - if a type cannot be instantiated.


Copyright © 2012-2013 Kronseder & Reiner GmbH - smartics. All Rights Reserved.