public class Factory extends Object implements HandlerListener
Setup
considering their corresponding Media
pointing to an XML file. This way it
is possible to create new featurable instances related to their Setup
by sharing the same resources.
Any featurable created by the factory from a Media
must have a public constructor with a single argument
typed
(or sub type) of Setup
.
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.
Destroyed Featurable
can be cached to avoid Featurable
creation if has Recycler
and
Recyclable
Feature
s.
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 |
---|---|
<O extends Featurable> |
create(Media media)
Create a
Featurable from its Media using a generic way. |
<O extends Featurable> |
create(Media media,
Class<O> type)
Create a featurable from its
Media using a generic way. |
Setup |
getSetup(Media media)
Get a setup reference from its media.
|
void |
notifyHandlableAdded(Featurable featurable)
Notify when a featurable has been added.
|
void |
notifyHandlableRemoved(Featurable featurable)
Notify when a featurable has been removed.
|
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 Featurable> O create(Media media)
Featurable
from its Media
using a generic way. The concerned class to instantiate and
its constructor must be public, and can have the following parameter: (Setup
).
Automatically add IdentifiableModel
if feature does not have Identifiable
feature.
Destroyed Featurable
can be cached to avoid Featurable
creation if has Recycler
and
Recyclable
Feature
s. If cache associated to media is available, it is
Recyclable.recycle()
and then returned.
O
- The featurable type.media
- The featurable media.LionEngineException
- If Media
is null
or Setup
not found.public <O extends Featurable> O create(Media media, Class<O> type)
Media
using a generic way. The concerned class to instantiate and its
constructor must be public, and can have the following parameter: (Setup
).
Automatically add IdentifiableModel
if feature does not have Identifiable
feature.
Destroyed Featurable
can be cached to avoid Featurable
creation if has Recycler
and
Recyclable
Feature
s. If cache associated to media is available, it is
Recyclable.recycle()
and then returned.
O
- The featurable type.media
- The featurable media.type
- The specific class to use (override the one in the media).LionEngineException
- If Media
is null
or Setup
not found.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.public void notifyHandlableAdded(Featurable featurable)
HandlerListener
notifyHandlableAdded
in interface HandlerListener
featurable
- The added featurable.public void notifyHandlableRemoved(Featurable featurable)
HandlerListener
notifyHandlableRemoved
in interface HandlerListener
featurable
- The removed featurable.Copyright © 2017 Byron 3D Games Studio. All rights reserved.