Permalink
Browse files

Core: remove unused code and cleanup (#261).

See ticket 261.
  • Loading branch information...
1 parent e647c31 commit 6433c2306f29a1e07baa5cc55c8599c72f4cdad6 @jri committed Jul 1, 2012
@@ -209,7 +209,7 @@ public void preUpdateHook(Topic topic, Properties newProperties) {
} */
@Override
- public void introduceTopicTypeHook(TopicType topicType, ClientState clientState) {
+ public void introduceTopicType(TopicType topicType, ClientState clientState) {
// ### TODO: explain
if (topicType.getUri().equals("dm4.core.meta_meta_type")) {
return;
@@ -737,7 +737,7 @@ private Topic fetchChildTopic(AssociationDefinition assocDef, TopicModel newChil
long childTopicId = newChildTopic.getId();
if (childTopicId != -1) {
// Note: the child topic's composite must be fetched. It needs to be passed to the
- // POST_UPDATE_TOPIC hook as part of the "old model" (when the child topic is updated).
+ // POST_UPDATE_TOPIC hook as part of the "old model" (when the child topic is updated). ### FIXDOC
return fetchChildTopic(assocDef, childTopicId, true); // fetchComposite=true
} else {
return null;
@@ -26,7 +26,6 @@
import de.deepamehta.core.service.DeepaMehtaService;
import de.deepamehta.core.service.Directive;
import de.deepamehta.core.service.Directives;
-import de.deepamehta.core.service.Hook; // ### TODO: drop this
import de.deepamehta.core.service.Listener;
import de.deepamehta.core.service.Migration;
import de.deepamehta.core.service.ObjectFactory;
@@ -146,11 +145,6 @@ public AttachedTopic getTopic(String key, SimpleValue value, boolean fetchCompos
ResultSet<Topic> topics = JSONHelper.toTopicSet(getTopicType(typeUri, clientState).getRelatedTopics(
"dm4.core.instantiation", "dm4.core.type", "dm4.core.instance", null, fetchComposite, false,
maxResultSize, clientState)); // othersTopicTypeUri=null
- /*
- for (Topic topic : topics) {
- triggerHook(Hook.PROVIDE_TOPIC_PROPERTIES, topic);
- }
- */
tx.success();
return topics;
} catch (Exception e) {
@@ -555,30 +549,6 @@ public void runPluginMigration(Plugin plugin, int migrationNr, boolean isCleanIn
plugin.setMigrationNr(migrationNr);
}
- /**
- * Triggers a hook for all installed plugins.
- *
- * ### TODO: drop this method.
- */
- @Override
- public Map<String, Object> triggerHook(final Hook hook, final Object... params) {
- final Map resultMap = new HashMap();
- new PluginCache.Iterator() {
- @Override
- void body(Plugin plugin) {
- try {
- Object result = triggerHook(plugin, hook, params);
- if (result != null) {
- resultMap.put(plugin.getUri(), result);
- }
- } catch (Exception e) {
- throw new RuntimeException("Triggering hook " + hook + " of " + plugin + " failed", e);
- }
- }
- };
- return resultMap;
- }
-
// === Listeners ===
@@ -858,18 +828,6 @@ void associateDataType(String typeUri, String dataTypeUri) {
// === Plugins ===
- /**
- * ### TODO: drop this method
- *
- * @throws NoSuchMethodException
- * @throws IllegalAccessException
- * @throws InvocationTargetException
- */
- private Object triggerHook(Plugin plugin, Hook hook, Object... params) throws Exception {
- Method hookMethod = plugin.getClass().getMethod(hook.getMethodName(), hook.getParamClasses());
- return hookMethod.invoke(plugin, params);
- }
-
private boolean isDeepaMehtaPlugin(Bundle bundle) {
String packages = (String) bundle.getHeaders().get("Import-Package");
// Note: packages might be null. Not all bundles import packges.
@@ -11,6 +11,20 @@
+/**
+ * Events fired by the DeepaMehta core.
+ * Plugins can listen to these events by implementing the respective listener interfaces.
+ *
+ * There are 2 types of events:
+ * - regular events: are fired (usually) by the core and then delivered to all registered listeners (plugins).
+ * - internal plugin events: are fired by a plugin and then delivered only to itself. There are 4 internal events:
+ * - POST_INSTALL_PLUGIN
+ * - INTRODUCE_TOPIC_TYPE (has a double nature)
+ * - SERVICE_ARRIVED
+ * - SERVICE_GONE
+ *
+ * @see de.deepamehta.core.service.listener
+ */
public enum CoreEvent {
PRE_CREATE_TOPIC(PreCreateTopicListener.class,
@@ -28,38 +42,33 @@
POST_DELETE_ASSOCIATION(PostDeleteAssociationListener.class,
"postDeleteAssociation", Association.class, Directives.class),
- POST_RETYPE_ASSOCIATION(PostRetypeAssociationListener.class,
- "postRetypeAssociation", Association.class, String.class, Directives.class),
- // ### TODO: remove this hook. Retype is special case of update.
+ POST_RETYPE_ASSOCIATION(PostRetypeAssociationListener.class, // ### TODO: remove this event. Retype is special
+ "postRetypeAssociation", Association.class, String.class, Directives.class), // case of update.
PRE_SEND_TOPIC(PreSendTopicListener.class,
"preSendTopic", Topic.class, ClientState.class),
PRE_SEND_TOPIC_TYPE(PreSendTopicTypeListener.class,
"preSendTopicType", TopicType.class, ClientState.class),
- POST_INSTALL_PLUGIN(PostInstallPluginListener.class,
+ POST_INSTALL_PLUGIN(PostInstallPluginListener.class, // ### TODO: remove this event. Use migration 1 instead.
"postInstallPlugin"),
- // Note: this is an internal plugin event. It is fired for a specific plugin only.
- // (see {@link de.deepamehta.core.service.Plugin#initializePlugin}).
- // ### TODO: remove this event. Use migration 1 instead.
+ // Note: this is an internal plugin event (see {@link Plugin#installPluginInDB}).
ALL_PLUGINS_READY(AllPluginsReadyListener.class,
"allPluginsReady"),
INTRODUCE_TOPIC_TYPE(IntroduceTopicTypeListener.class,
"introduceTopicType", TopicType.class, ClientState.class),
- // Note: besides regular triggering (see {@link #createTopicType})
- // this hook is triggered by the plugin itself
- // (see {@link de.deepamehta.core.service.Plugin#introduceTypesToPlugin}).
+ // Note: besides regular firing (see {@link EmbeddedService#createTopicType})
+ // this is an internal plugin event (see {@link Plugin#introduceTypesToPlugin}).
SERVICE_ARRIVED(ServiceArrivedListener.class,
"serviceArrived", PluginService.class),
- // Note: this hook is triggered only by the plugin itself
- // (see {@link de.deepamehta.core.service.Plugin#createServiceTracker}).
+ // Note: this is an internal plugin event (see {@link Plugin#createServiceTracker}).
SERVICE_GONE(ServiceGoneListener.class,
- "serviceGone", PluginService.class);
- // Note: this hook is triggered only by the plugin itself
- // (see {@link de.deepamehta.core.service.Plugin#createServiceTracker}).
+ "serviceGone", PluginService.class)
+ // Note: this is an internal plugin event (see {@link Plugin#createServiceTracker}).
+ ;
public final Class listenerInterface;
public final String handlerMethodName;
@@ -24,7 +24,7 @@
* <p>
* The responsibility of the DeepaMehta core service is to orchestrate the control flow and allow plugins to hook in.
* The main duties of the DeepaMehta core service are to provide access to the storage layer and to trigger hooks of
- * the registered plugins.
+ * the registered plugins. ### FIXDOC
* <p>
* The DeepaMehta core service is a realization of the <i>Inversion of Control</i> pattern.
* <p>
@@ -144,8 +144,6 @@ Association getAssociation(String assocTypeUri, long topic1Id, long topic2Id,
void runPluginMigration(Plugin plugin, int migrationNr, boolean isCleanInstall);
- Map<String, Object> triggerHook(Hook hook, Object... params);
-
// === Listeners ===
@@ -170,7 +168,7 @@ Association getAssociation(String assocTypeUri, long topic1Id, long topic2Id,
/**
* Checks if all DeepaMehta plugin bundles are registered at core.
- * Triggers the ALL_PLUGINS_READY hook if so.
+ * Fires the {@link CoreEvent.ALL_PLUGINS_READY} event if so.
* <p>
* Called from the Plugin class.
* Not meant to be called by a plugin developer.
@@ -1,69 +0,0 @@
-package de.deepamehta.core.service;
-
-import de.deepamehta.core.Association;
-import de.deepamehta.core.Topic;
-import de.deepamehta.core.TopicType;
-import de.deepamehta.core.model.TopicModel;
-
-
-
-public enum Hook {
-
- DUMMY("dummy");
-
- // Note: this hook is triggered only by the plugin itself
- // (see {@link de.deepamehta.core.service.Plugin#initializePlugin}).
- // It is declared here for documentation purpose only.
- // ### TODO: remove this hook. Use migration 1 instead.
- // ### POST_INSTALL_PLUGIN("postInstallPluginHook"),
- // ### ALL_PLUGINS_READY("allPluginsReadyHook"),
-
- // Note: this hook is triggered only by the plugin itself
- // (see {@link de.deepamehta.core.service.Plugin#createServiceTracker}).
- // It is declared here for documentation purpose only.
- // ### SERVICE_ARRIVED("serviceArrived", PluginService.class),
- // Note: this hook is triggered only by the plugin itself
- // (see {@link de.deepamehta.core.service.Plugin#createServiceTracker}).
- // It is declared here for documentation purpose only.
- // ### SERVICE_GONE("serviceGone", PluginService.class),
-
- // ### PRE_CREATE_TOPIC("preCreateHook", TopicModel.class, ClientState.class),
- // ### POST_CREATE_TOPIC("postCreateHook", Topic.class, ClientState.class, Directives.class),
-
- // ### PRE_UPDATE_TOPIC("preUpdateHook", Topic.class, TopicModel.class, Directives.class),
- // ### POST_UPDATE_TOPIC("postUpdateHook", Topic.class, TopicModel.class, TopicModel.class,
- // ### ClientState.class, Directives.class),
-
- // ### PRE_DELETE_ASSOCIATION("preDeleteAssociationHook", Association.class, Directives.class),
- // ### POST_DELETE_ASSOCIATION("postDeleteAssociationHook", Association.class, Directives.class),
-
- // ### PRE_SEND_TOPIC("preSendTopicHook", Topic.class, ClientState.class),
- // ### PRE_SEND_TOPIC_TYPE("preSendTopicTypeHook", TopicType.class, ClientState.class),
-
- // ### TODO: remove this hook. Retype is special case of update.
- // ### POST_RETYPE_ASSOCIATION("postRetypeAssociationHook", Association.class, String.class, Directives.class),
-
- // Note: besides regular triggering (see {@link #createTopicType})
- // this hook is triggered by the plugin itself
- // (see {@link de.deepamehta.core.service.Plugin#introduceTypesToPlugin}).
- // ### MODIFY_TOPIC_TYPE("modifyTopicTypeHook", TopicType.class, ClientState.class),
-
- // ### TODO: remove this hook. Let the plugin provide a REST API instead.
- // ### EXECUTE_COMMAND("executeCommandHook", String.class, CommandParams.class, ClientState.class);
-
- private final String methodName;
- private final Class[] paramClasses;
-
- private Hook(String methodName, Class... paramClasses) {
- this.methodName = methodName;
- this.paramClasses = paramClasses;
- }
-
- public String getMethodName() {
- return methodName;
- }
-
- public Class[] getParamClasses() {
- return paramClasses;
- }
-}
Oops, something went wrong.

0 comments on commit 6433c23

Please sign in to comment.