Refactoring Database Access in Marauroa: Difference between revisions
Content deleted Content added
imported>Madmetzger |
imported>Kymara |
||
| (34 intermediate revisions by 2 users not shown) | |||
Line 18:
<!-- OUTDATED [[Image:Marauroa.server.game.db.png]] -->
== Concept FAQ ==
Line 37 ⟶ 36:
Imagine you want to subclass the CharacterDAO with your class SomeGameCharacterDAO:
<source lang="java">
public class SomeGameCharacterDAO extends CharacterDAO {
...
</source>
You simply register it as
<source lang="java">
DAORegistry.get().register(CharacterDAO.class, new SomeGameCharacterDAO());
</source>
Note: In the register call the first parameter is the parent class you want to replace.
Line 47 ⟶ 49:
=== What are those database adapters for? ===
They are a thin layer of database abstraction. This allows us to not only support MySQL but also database systems
=== Why is there a method getLastInsertId? ===
Line 81 ⟶ 82:
The following diff shows the complete list of changes that were required to port JMaPacman. I think it may help you to get a feeling on how to adjust your own code.
<!--
Don't use syntax highlighting here because it does not work well with the diff characters and bold formation
<source lang="java">
-->
public class MaPacmanRPRuleProcessor implements IRPRuleProcessor
{
Line 163 ⟶ 167:
}
}
[[Category:Marauroa]]
| |||