MCPcopy Index your code
hub / github.com/Zhuinden/service-tree

github.com/Zhuinden/service-tree @1.6.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.6.1 ↗ · + Follow
318 symbols 965 edges 79 files 104 documented · 33% updated 8y ago1.6.1 · 2017-06-03★ 33
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Service Tree

It's a tree that holds a Map<String, Object> in each of its nodes. Therefore, it allows you to store your services in it, each node identified by a particular key.

The service-tree is therefore a hierarchical service locator, independent from the Android platform.

This is a key difference to square/Mortar, which utilizes context.getSystemService() to create the hierarchy and inheritance.

You can also traverse the tree, either from top to bottom, or in reverse order from bottom to up.

Each Node is constructed with serviceTree.createNode(), and services can be bound to it using node.bindService(String, Object).

The first level is created with createRootNode(), the following levels are created by createChildNode().

Root nodes inherit root services, and child nodes inherit services from their parent node.

Creating a hierarchy

Singleton / Application

You can instantiate the ServiceTree as a singleton in a custom application class, and register root services with serviceTree.registerRootService(String, Object). These services are accessible by all root nodes, and children.

Activity

Activities are direct children of the root, so you can use serviceTree.createRootNode(String nodeTag);.

Fragment

Fragments are tricky, but they are children of the Activity. Their node can be created with serviceTree.createChildNode(Node parentNode, String childNodeTag);

Accessing services

The services you bind to a node can be accessed with node.getService(String serviceName).

While you're binding to a new node, you can also access the inherited services with node.getService(String serviceName).

Using Service Tree

In order to use Service Tree, you need to add jitpack to your project root gradle:

buildscript {
    repositories {
        // ...
        maven { url "https://jitpack.io" }
    }
    // ...
}
allprojects {
    repositories {
        // ...
        maven { url "https://jitpack.io" }
    }
    // ...
}

and add the compile dependency to your module level gradle.

compile 'com.github.Zhuinden:service-tree:1.6.1'

License

Copyright 2017 Gabor Varadi

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Method 241
Class 51
Interface 22
Enum 4

Languages

Java100%

Modules by API surface

service-tree/src/main/java/com/zhuinden/servicetree/ServiceTree.java67 symbols
service-tree/src/test/java/com/zhuinden/servicetree/TraversalTest.java19 symbols
service-tree/src/test/java/com/zhuinden/servicetree/ServiceTreeTest.java19 symbols
service-tree-view-example/src/main/java/com/zhuinden/servicetreeviewexample/MainActivity.java12 symbols
service-tree-fragment-example/src/main/java/com/zhuinden/servicetreefragmentexample/MainActivity.java11 symbols
service-tree-conductor-example/src/main/java/com/zhuinden/servicetreeconductorexample/MainActivity.java8 symbols
service-tree-simple-stack-example/src/main/java/com/zhuinden/servicetreenavigatorexample/MainActivity.java7 symbols
service-tree-fragment-example/src/main/java/com/zhuinden/servicetreefragmentexample/FirstFragment.java6 symbols
service-tree-conductor-example/src/main/java/com/zhuinden/servicetreeconductorexample/FirstController.java6 symbols
service-tree/src/test/java/com/zhuinden/servicetree/TestKey.java5 symbols
service-tree-view-example/src/main/java/com/zhuinden/servicetreeviewexample/FirstView.java5 symbols
service-tree-simple-stack-example/src/main/java/com/zhuinden/servicetreenavigatorexample/SecondKey.java5 symbols

For agents

$ claude mcp add service-tree \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page