de.netseeker.ejoe.adapter
Class AdapterFactory

java.lang.Object
  extended by de.netseeker.ejoe.adapter.AdapterFactory

public final class AdapterFactory
extends java.lang.Object

The AdapterFactory manages creation and caching of all known (already during runtime requested) SerializeAdapters. This factory is mostly used internally within EJOE with one big exception: If one is using a customized adapter, eg. a configurable adapter like the CastorAdapter, which should be initialized with a valid mapping file, then that adapter instance must get (re-)registered with this factory. To overwrite the default adapter instances use:

 CastorAdapter myCastorAdapterInstance = new CastorAdapter( "PathToTheMappingFile" );
 AdapterFactory.registerAdapter( myCastorAdapterInstance );
 
AdapterFactory will then return myCastorAdapterInstance to all requests for CastorAdapter. To register multiple instances of a special adapter use:
 CastorAdapter myCastorAdapterInstance1 = new CastorAdapter( "PathToTheMappingFile1" );
 CastorAdapter myCastorAdapterInstance2 = new CastorAdapter( "PathToTheMappingFile2" );
 AdapterFactory.registerAdapter( "CastorAdapter1", myCastorAdapterInstance1 );
 AdapterFactory.registerAdapter( "CastorAdapter2", myCastorAdapterInstance2 );
 

Since:
0.3.1
Author:
netseeker

Constructor Summary
AdapterFactory()
           
 
Method Summary
static void clear()
          Removes all adapter registrations
static SerializeAdapter createAdapter(java.lang.String name)
          Returns either a new instance of the requested adapter or returns a already cached one.
static java.lang.String getSupportedContentType(java.lang.String name)
          Returns the supported content type for the given adapter synonym
static void registerAdapter(SerializeAdapter adapter)
          Registers a new adapter to the registry of known adapters while using the class name of the adapter as synonym within the registry
static void registerAdapter(java.lang.String name, SerializeAdapter adapter)
          Registers a new adapter to the registry of known adapters while using the given name as synonym within the registry
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdapterFactory

public AdapterFactory()
Method Detail

createAdapter

public static SerializeAdapter createAdapter(java.lang.String name)
                                      throws IllegalAdapterException
Returns either a new instance of the requested adapter or returns a already cached one.

Parameters:
name - class name or synonym for the SerializeAdapter.
Returns:
the requested SerializeAdapter
Throws:
IllegalAdapterException

registerAdapter

public static void registerAdapter(SerializeAdapter adapter)
Registers a new adapter to the registry of known adapters while using the class name of the adapter as synonym within the registry

Parameters:
adapter -

registerAdapter

public static void registerAdapter(java.lang.String name,
                                   SerializeAdapter adapter)
Registers a new adapter to the registry of known adapters while using the given name as synonym within the registry

Parameters:
name -
adapter -

clear

public static void clear()
Removes all adapter registrations


getSupportedContentType

public static java.lang.String getSupportedContentType(java.lang.String name)
                                                throws IllegalAdapterException
Returns the supported content type for the given adapter synonym

Parameters:
name - the synonym for the adapter
Returns:
the supported content type for the adapter
Throws:
IllegalAdapterException


Copyright © 2005-2007 netseeker. All Rights Reserved.