-
Notifications
You must be signed in to change notification settings - Fork 612
Service Plugin
Ruben de Laat edited this page Oct 14, 2015
·
4 revisions
Service plugins can extend the functionality of a BIMserver by listening to notifications and acting upon them. For example a ClashDetection Service plugin could create a ClashDetection report as [ExtendedData] when a user checks in a new revision.
Have a look here for an easier implementation of services.
For this plugin you do not need implement any specific methods as long as you subclass [ServicePlugin]. You can register your services by calling the [register] method:
public void register(ServerDescriptor serverDescriptor, ServiceDescriptor serviceDescriptor, NotificationInterface notificationInterface) {
}
It's best to register your services in the init method. You have to provide a [ServerDescriptor] and [ServiceDescriptor], here are examples for those:
ServerDescriptor serverDescriptor = StoreFactory.eINSTANCE.createServerDescriptor();
serverDescriptor.setTitle("Clashdetection");
ServiceDescriptor clashDetection = StoreFactory.eINSTANCE.createServiceDescriptor();
clashDetection.setName("Clashdetection");
clashDetection.setDescription("Clashdetection");
clashDetection.setNotificationProtocol(AccessMethod.INTERNAL);
clashDetection.setReadRevision(true);
clashDetection.setWriteExtendedData(true);
clashDetection.setTrigger(Trigger.NEW_REVISION);
Example implementation code:
register(serverDescriptor, clashDetection, new NotificationInterfaceAdapter(){
@Override
public void newLogAction(SLogAction newRevisionNotification, SToken token, String apiUrl) throws UserException, ServerException {
ServiceInterface serviceInterface = getServiceInterface(token);
// Here goes your code
}
}
Example:
public class DemoServicePlugin1 extends ServicePlugin {
private boolean initialized;
@Override
public void init(PluginManager pluginManager) throws PluginException {
super.init(pluginManager);
initialized = true;
}
@Override
public String getDescription() {
return "Demo Service 1";
}
@Override
public String getDefaultName() {
return "Demo Service 1";
}
@Override
public String getVersion() {
return "1.0";
}
@Override
public ObjectDefinition getSettingsDefinition() {
return null;
}
@Override
public boolean isInitialized() {
return initialized;
}
@Override
public String getTitle() {
return "Demo Service 1";
}
@Override
public void register(PluginConfiguration pluginConfiguration) {
ServiceDescriptor serviceDescriptor = StoreFactory.eINSTANCE.createServiceDescriptor();
serviceDescriptor.setProviderName("BIMserver");
serviceDescriptor.setIdentifier(getClass().getName());
serviceDescriptor.setName("Demo Service 1");
serviceDescriptor.setDescription("Demo Service 1");
serviceDescriptor.setNotificationProtocol(AccessMethod.INTERNAL);
serviceDescriptor.setTrigger(Trigger.NEW_REVISION);
registerNewRevisionHandler(serviceDescriptor, new NewRevisionHandler() {
@Override
public void newRevision(BimServerClientInterface bimServerClientInterface, long poid, long roid, long soid, SObjectType settings) throws ServerException, UserException {
try {
Date startDate = new Date();
Long topicId = bimServerClientInterface.getRegistry().registerProgressOnRevisionTopic(SProgressTopicType.RUNNING_SERVICE, poid, roid, "Running Demo Service");
for (int i=0; i<100; i++) {
SLongActionState state = new SLongActionState();
state.setProgress(i);
state.setTitle("Demo Service 1");
state.setState(SActionState.STARTED);
state.setStart(startDate);
bimServerClientInterface.getRegistry().updateProgressTopic(topicId, state);
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
SLongActionState state = new SLongActionState();
state.setProgress(100);
state.setTitle("Demo Service 1");
state.setState(SActionState.FINISHED);
state.setStart(startDate);
state.setEnd(new Date());
bimServerClientInterface.getRegistry().updateProgressTopic(topicId, state);
bimServerClientInterface.getRegistry().unregisterProgressTopic(topicId);
} catch (PublicInterfaceNotFoundException e1) {
e1.printStackTrace();
}
}
});
}
}
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