public class Factory extends Object
Setup
considering their corresponding Media
pointing to an XML file. This way it
is possible to create new object instances related to their Setup
by sharing the same resources.
Any object created by the factory from a Media
must have the following public constructor:
The factory uses the ClassLoader.getSystemClassLoader()
, but it is possible to set a custom one with
setClassLoader(ClassLoader)
. Should be used in an OSGI environment for example.
Modifier and Type | Field and Description |
---|---|
static String |
FILE_DATA_DOT_EXTENSION
Data file extension with dot as prefix.
|
static String |
FILE_DATA_EXTENSION
Data file extension.
|
Constructor and Description |
---|
Factory(Services services)
Create a factory.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear all loaded setup and their configuration.
|
<O extends ObjectGame> |
create(Media media)
Create an object from its
Media using a generic way. |
<O extends ObjectGame> |
create(Media media,
Class<O> type)
Create an object from its
Media using a generic way. |
Setup |
getSetup(Media media)
Get a setup reference from its media.
|
void |
setClassLoader(ClassLoader classLoader)
Set an external class loader.
|
public static final String FILE_DATA_EXTENSION
public static final String FILE_DATA_DOT_EXTENSION
public Factory(Services services)
services
- The services reference.public <O extends ObjectGame> O create(Media media)
Media
using a generic way. The concerned classes to instantiate and its
constructor must be public, and must have the following parameters: (Setup
, Services
).O
- The object type.media
- The object media.LionEngineException
- If Media
is null
, Setup
not found, or Services
missing service.ObjectGame.ObjectGame(Setup, Services)
public <O extends ObjectGame> O create(Media media, Class<O> type)
Media
using a generic way. The concerned classes to instantiate and its
constructor must be public, and must have the following parameters: (Setup
, Services
).O
- The object type.media
- The object media.type
- The specific class to use (override the one in the media).LionEngineException
- If Media
is null
, Setup
not found, or Services
missing service.ObjectGame.ObjectGame(Setup, Services)
public void clear()
public void setClassLoader(ClassLoader classLoader)
classLoader
- The external class loader.public Setup getSetup(Media media)
media
- The setup media.LionEngineException
- If no setup found for the media.Copyright © 2016 Byron 3D Games Studio. All rights reserved.