@Override public ConnectorService getConnector(String identifier) { Registration registration = connectorsById.get(identifier); if (registration != null) return registration.service; return Register.getComponent(ConnectorService.class, "id", identifier); }
@Override public void start(BundleContext bundleContext) throws Exception { Register.waitFor(PlatformHttp.class, new RegisterWaiter<PlatformHttp>() { @Override public void onAvailable(BundleContext bundleContext, PlatformHttp component) { XOWLConsistencyService service = new XOWLConsistencyService(); bundleContext.registerService(Service.class, service, null); bundleContext.registerService(SecuredService.class, service, null); bundleContext.registerService(HttpApiService.class, service, null); bundleContext.registerService(MeasurableService.class, service, null); bundleContext.registerService(ConsistencyService.class, service, null); } }, bundleContext); }
@Override public Collection<Metric> getMetrics() { Collection<Metric> result = new ArrayList<>(); SecurityService securityService = Register.getComponent(SecurityService.class); if (securityService == null) return result; if (!securityService.checkAction(ACTION_GET_METRICS).isSuccess()) return result; for (MetricProvider provider : Register.getComponents(MeasurableService.class)) { result.addAll(provider.getMetrics()); } return result; }
@Override public Collection<ConnectorService> getConnectors() { return Register.getComponents(ConnectorService.class); }
@Override public Collection<ArtifactSchema> getSchemas() { return Register.getComponents(ArtifactSchema.class); }
@Override public Collection<RemoteCollaboration> getNeighbours() { SecurityService securityService = Register.getComponent(SecurityService.class); if (securityService == null) return Collections.emptyList(); XSPReply reply = securityService.checkAction(ACTION_GET_NEIGHBOURS); if (!reply.isSuccess()) return Collections.emptyList(); return Collections.unmodifiableCollection((Collection) collaborations.values()); }
/** * Executes the startup sequence of the platform */ public void onPlatformStartup() { if (!hasStarted.compareAndSet(false, true)) return; // authenticate as root SecurityService securityService = Register.getComponent(SecurityService.class); if (securityService != null) securityService.authenticate(PlatformUserRoot.INSTANCE); // execute sequence List<ManagedService> services = (List<ManagedService>) Register.getComponents(ManagedService.class); Collections.sort(services, ManagedService.COMPARATOR_STARTUP); for (ManagedService service : services) { service.onLifecycleStart(); } // broadcast the startup event EventService eventService = Register.getComponent(EventService.class); PlatformManagementService platformManagementService = Register.getComponent(PlatformManagementService.class); if (eventService != null) eventService.onEvent(new PlatformStartupEvent(platformManagementService)); }
@Override public void onAvailable(BundleContext bundleContext, PlatformHttp component) { Register.waitFor(HttpService.class, new RegisterWaiter<HttpService>() { @Override public void onAvailable(BundleContext bundleContext, HttpService component) { try { component.registerServlet(PlatformHttp.getUriPrefixApi(), server, null, new XOWLMainHTTPContext(component)); } catch (Exception exception) { Logging.get().error(exception); } } }, bundleContext); } }, bundleContext);
@Override public Collection<ArtifactArchetype> getArchetypes() { return Register.getComponents(ArtifactArchetype.class); }
@Override public Collection<RemoteCollaboration> getNeighbours() { SecurityService securityService = Register.getComponent(SecurityService.class); if (securityService == null) return Collections.emptyList(); XSPReply reply = securityService.checkAction(ACTION_GET_NEIGHBOURS); if (!reply.isSuccess()) return Collections.emptyList(); return Collections.emptyList(); }
/** * Executes the shutdown sequence of the platform */ public void onPlatformShutdown() { if (!hasShutdown.compareAndSet(false, true)) return; // broadcast the shutdown event EventService eventService = Register.getComponent(EventService.class); PlatformManagementService platformManagementService = Register.getComponent(PlatformManagementService.class); if (eventService != null) eventService.onEvent(new PlatformShutdownEvent(platformManagementService)); // authenticate as root SecurityService securityService = Register.getComponent(SecurityService.class); if (securityService != null) securityService.authenticate(PlatformUserRoot.INSTANCE); // execute sequence List<ManagedService> services = (List<ManagedService>) Register.getComponents(ManagedService.class); Collections.sort(services, ManagedService.COMPARATOR_SHUTDOWN); for (ManagedService service : services) { service.onLifecycleStop(); } } }
@Override public void start(BundleContext bundleContext) throws Exception { Register.waitFor(PlatformHttp.class, new RegisterWaiter<PlatformHttp>() { @Override public void onAvailable(BundleContext bundleContext, PlatformHttp component) { XOWLImpactAnalysisService service = new XOWLImpactAnalysisService(); bundleContext.registerService(Service.class, service, null); bundleContext.registerService(SecuredService.class, service, null); bundleContext.registerService(HttpApiService.class, service, null); bundleContext.registerService(ImpactAnalysisService.class, service, null); bundleContext.registerService(JobFactory.class, new XOWLImpactAnalysisJobFactory(), null); } }, bundleContext); }
@Override public Collection<HttpApiService> getServices() { return Register.getComponents(HttpApiService.class); }
@Override public Collection<Addon> getAddons() { SecurityService securityService = Register.getComponent(SecurityService.class); if (securityService == null) return Collections.emptyList(); XSPReply reply = securityService.checkAction(ACTION_GET_ADDONS); if (!reply.isSuccess()) return Collections.emptyList(); return Collections.unmodifiableCollection(addons); }
@Override public MetricSnapshot pollMetric(Metric metric) { SecurityService securityService = Register.getComponent(SecurityService.class); if (securityService == null) return null; if (!securityService.checkAction(ACTION_GET_METRICS).isSuccess()) return null; for (MetricProvider provider : Register.getComponents(MeasurableService.class)) { MetricSnapshot result = provider.pollMetric(metric); if (result != null) return result; } return null; }
@Override public void start(final BundleContext bundleContext) throws Exception { Register.waitFor(PlatformHttp.class, new RegisterWaiter<PlatformHttp>() { @Override public void onAvailable(BundleContext bundleContext, PlatformHttp component) { bundleContext.registerService(DeserializerFactory.class, new DeserializerFactoryForCollaboration(), null); bundleContext.registerService(JobFactory.class, new CollaborationJobFactory(), null); XOWLCollaborationService collaborationService = new XOWLCollaborationService(); bundleContext.registerService(Service.class, collaborationService, null); bundleContext.registerService(SecuredService.class, collaborationService, null); bundleContext.registerService(HttpApiService.class, collaborationService, null); bundleContext.registerService(ManagedService.class, collaborationService, null); bundleContext.registerService(CollaborationService.class, collaborationService, null); bundleContext.registerService(CollaborationLocalService.class, collaborationService, null); bundleContext.registerService(CollaborationNetworkService.class, collaborationService, null); XOWLNetworkProvider networkProvider = new XOWLNetworkProvider(); bundleContext.registerService(CollaborationNetworkServiceProvider.class, networkProvider, null); XOWLPatternProvider patternProvider = new XOWLPatternProvider(); bundleContext.registerService(CollaborationPatternProvider.class, patternProvider, null); } }, bundleContext); }
@Override public Collection<ConnectorDescriptor> getDescriptors() { return Register.getComponents(ConnectorDescriptor.class); }
@Override public List<Job> getQueue() { List<Job> result = new ArrayList<>(); SecurityService securityService = Register.getComponent(SecurityService.class); if (securityService == null) return result; for (Runnable runnable : executorPool.getQueue()) { Job job = (Job) runnable; if (securityService.checkAction(ACTION_GET_JOBS, job).isSuccess()) result.add(job); } return Collections.unmodifiableList(result); }
/** * Resolves the current collaboration network service * * @return The collaboration network service */ private synchronized CollaborationNetworkService getNetworkService() { if (networkService == null) { ConfigurationService configurationService = Register.getComponent(ConfigurationService.class); Configuration configuration = configurationService.getConfigFor(CollaborationService.class.getCanonicalName()); Section configNetwork = configuration.getSection("network"); String identifier = configNetwork.get("service"); for (CollaborationNetworkServiceProvider provider : Register.getComponents(CollaborationNetworkServiceProvider.class)) { networkService = provider.instantiate(identifier, configNetwork); if (networkService != null) break; } } return networkService; }
@Override public void start(final BundleContext bundleContext) throws Exception { Register.waitFor(PlatformHttp.class, new RegisterWaiter<PlatformHttp>() { @Override public void onAvailable(BundleContext bundleContext, PlatformHttp component) { XOWLWebModuleDirectory moduleDirectory = new XOWLWebModuleDirectory(); bundleContext.registerService(Service.class, moduleDirectory, null); bundleContext.registerService(HttpApiService.class, moduleDirectory, null); bundleContext.registerService(WebUIContribution.class, new XOWLMainContribution(), null); bundleContext.registerService(WebModule.class, new XOWLWebModuleCore(), null); bundleContext.registerService(WebModule.class, new XOWLWebModuleCollaboration(), null); bundleContext.registerService(WebModule.class, new XOWLWebModuleAdmin(), null); Register.waitFor(HttpService.class, new RegisterWaiter<HttpService>() { @Override public void onAvailable(BundleContext bundleContext, HttpService component) { try { component.registerResources(PlatformHttp.getUriPrefixWeb(), PlatformHttp.getUriPrefixWeb(), new XOWLHttpContext(component)); } catch (Exception exception) { Logging.get().error(exception); } } }, bundleContext); } }, bundleContext); }