What are "services" for bukkit ?

Discussion in 'Plugin Development' started by Digi, Jan 1, 2012.

Thread Status:
Not open for further replies.
  1. The description of getServicesManager() in javadocs is kinda vague... what are those services and in what cases should anyone use them ?
     
  2. Well, not my fault this site can't find it, I searched getServicesManager and getServicesManager() and it turned up nothing, if you search again now you'll only see this thread :} but anyway, thanks :p
     
  3. Offline

    halley

    In other systems, like Android, this concept is used also. It's more important there, where there's a much stronger security system. Two apps usually don't have permission to access the same database, or call each other's API, so the system offers a compromise: a non-app thing called a service. The service can own the data and database, and offer a more indirect form of API that both apps can reach. For example, the database of all your contact info is managed by a service; now all apps that have the right permissions can access that data if they work through the service.

    In Bukkit, where every plugin is in the same process and no ClassLoader security model is installed, it's too easy for two plugins to directly access each other's methods. Which is why I suspect the services in Bukkit have languished in obscurity.
     
  4. Offline

    desht

    @Sleaker used the Bukkit services interface to create Vault. You could browse Vault's source code to see how it's used. In this case, the services are economy and permissions - Vault provides a single interface with backend "plugin" classes to hook each actual economy or permissions provider plugin.
     
  5. Offline

    Sleaker

    the service manager is designed to allow a plugin to register an interface linked to an implementation of that interface. It allows a plugin to hook the implementation by only importing the interface. Anyone could implement the Permission, Chat, or Economy interface from Vault in their own plugin. Then when they plugin starts up they could register the interface with the server just like Vault does for all the systems that I have coded manually. There is no reason why these implementations need to be in Vault, they could theoretically be implemented directly into an Economy (or Perm/Chat) API (the server would need to have Vault installed though so this is the catch) and they could register it manually instead of letting Vault do all the work for them.
     
Thread Status:
Not open for further replies.

Share This Page