-
Notifications
You must be signed in to change notification settings - Fork 616
Writing a service, the easy way
hlg edited this page Dec 16, 2024
·
11 revisions
This page has a description how to write internal services, but as most internal services seem to either checkin an updated revision, or add extended data, some convenience classes have been written that make it a lot easier to write an internal service. This page describes how to use those classes.
Make sure to create a plugin.xml
These services are triggered by a new revision, and add extended data to the revision.
First subclass "AbstractAddExtendedDataService", which can be found in the package "org.bimserver.plugins.services" in the "Shared" project.
- Create a constructor and call the super constructor with 2 arguments, name and description.
- Implement newRevision
- (Optional) Implement getProgressType If you want to report progress-data, the default is UNKNOWN
- (Optional) Implement getSettingsDefinition to tell BIMserver you require certain user-defined settings
Full code:
package org.bimserver.demoplugins.service;
import org.apache.commons.io.IOUtils;
import org.bimserver.interfaces.objects.SObjectType;
import org.bimserver.plugins.services.AbstractAddExtendedDataService;
import org.bimserver.plugins.services.BimServerClientInterface;
public class HtmlService extends AbstractAddExtendedDataService {
// A unique namespace, this is used by other software to determine the type of file you uploaded as extended data
private static final String NAMESPACE = "htmldemo";
// Constructor, make sure it is a no-arg constructor
public HtmlService() {
// Give a sensible name and description for the service
super("HTML Demo Service", "HTML Demo Service", NAMESPACE);
}
// This is the method that gets called when there is a new revision, have a look at the [documentation](https://github.com/opensourceBIM/BIMserver/blob/master/Shared/src/org/bimserver/plugins/services/AbstractService.java#L92) for the details
@Override
public void newRevision(RunningService runningService, BimServerClientInterface bimServerClientInterface, long poid, long roid, String userToken, long soid, SObjectType settings) throws Exception {
byte[] bytes = IOUtils.toByteArray(getPluginContext().getResourceAsInputStream("data/example.html"));
addExtendedData(bytes, "example.html", "HTML Demo Results", "text/html", bimServerClientInterface, roid, NAMESPACE);
}
// (Optional) Method to let BIMserver know whether you are going to provide progress-data, only required to implement if progress will be KNOWN
@Override
public ProgressType getProgressType() {
return ProgressType.KNOWN;
}
}
TODO
TODO
Get Started
- Quick Guide
- Requirements Version 1.2
- Requirements Version 1.3
- Requirements Version 1.4
- Requirements Version 1.4 > 2015-09-12
- Requirements Version 1.5
- Download
- JAR Starter
- Setup
Deployment
- Ubuntu installation 1.3
- Windows installation
- Security
- Memory Usage
- More memory
- Performance statistics
- Large databases
Developers
- Service Interfaces
- Common functions
- Data Model
- Low Level Calls
- Endpoints
Clients
BIMServer Developers
- Plugins in 1.5
- Plugin Development
- Eclipse
- Eclipse Modeling Framework
- Embedding
- Terminology
- Database/Versioning
- IFC STEP Encoding
- Communication
- Global changes in 1.5
- Writing a service
- Services/Notifications
- BIMserver 1.5 Developers
- Extended data
- Extended data schema
- Object IDM
New developments
- New remote service interface
- Plugins new
- Deprecated
- New query language
- Visual query language
- Reorganizing BIMserver JavaScript API
General