]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - internal/jetty/JettyServiceFactory.java
1 package org
.argeo
.cms
.servlet
.internal
.jetty
;
3 import java
.util
.Dictionary
;
5 import org
.argeo
.api
.cms
.CmsConstants
;
6 import org
.argeo
.api
.cms
.CmsLog
;
7 import org
.eclipse
.equinox
.http
.jetty
.JettyConfigurator
;
8 import org
.osgi
.framework
.FrameworkUtil
;
9 import org
.osgi
.service
.cm
.ConfigurationException
;
10 import org
.osgi
.service
.cm
.ManagedServiceFactory
;
12 public class JettyServiceFactory
implements ManagedServiceFactory
{
13 private final CmsLog log
= CmsLog
.getLog(JettyServiceFactory
.class);
20 public String
getName() {
21 return "Jetty Service Factory";
25 public void updated(String pid
, Dictionary
<String
, ?
> properties
) throws ConfigurationException
{
26 // Explicitly configures Jetty so that the default server is not started by the
27 // activator of the Equinox Jetty bundle.
29 // if (!webServerConfig.isEmpty()) {
30 // webServerConfig.put("customizer.class", KernelConstants.CMS_JETTY_CUSTOMIZER_CLASS);
32 // // TODO centralise with Jetty extender
33 // Object webSocketEnabled = webServerConfig.get(InternalHttpConstants.WEBSOCKET_ENABLED);
34 // if (webSocketEnabled != null && webSocketEnabled.toString().equals("true")) {
35 // bc.registerService(ServerEndpointConfig.Configurator.class, new CmsWebSocketConfigurator(), null);
36 // webServerConfig.put(InternalHttpConstants.WEBSOCKET_ENABLED, "true");
42 tryGettyJetty
: while (tryCount
> 0) {
44 // FIXME deal with multiple ids
45 JettyConfigurator
.startServer(CmsConstants
.DEFAULT
, properties
);
46 // Explicitly starts Jetty OSGi HTTP bundle, so that it gets triggered if OSGi
47 // configuration is not cleaned
48 FrameworkUtil
.getBundle(JettyConfigurator
.class).start();
50 } catch (IllegalStateException e
) {
51 // Jetty may not be ready
54 } catch (Exception e1
) {
60 } catch (Exception e
) {
61 log
.error("Cannot start default Jetty server with config " + properties
, e
);
67 public void deleted(String pid
) {
72 JettyConfigurator
.stopServer(CmsConstants
.DEFAULT
);
73 } catch (Exception e
) {
74 log
.error("Cannot stop default Jetty server.", e
);