You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2015/03/01 14:55:12 UTC
svn commit: r1663103 - in /felix/trunk/http/jetty: ./
src/main/java/org/apache/felix/http/jetty/internal/ src/main/resources/
src/test/java/org/apache/felix/http/jetty/internal/
Author: cziegeler
Date: Sun Mar 1 13:55:12 2015
New Revision: 1663103
URL: http://svn.apache.org/r1663103
Log:
FELIX-4813 : Metatype information might contain wrong default values
Removed:
felix/trunk/http/jetty/src/main/resources/
Modified:
felix/trunk/http/jetty/pom.xml
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyActivator.java
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
felix/trunk/http/jetty/src/test/java/org/apache/felix/http/jetty/internal/JettyServiceTest.java
Modified: felix/trunk/http/jetty/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/pom.xml?rev=1663103&r1=1663102&r2=1663103&view=diff
==============================================================================
--- felix/trunk/http/jetty/pom.xml (original)
+++ felix/trunk/http/jetty/pom.xml Sun Mar 1 13:55:12 2015
@@ -70,9 +70,13 @@
org.ietf.jgss;resolution:=optional,
org.mortbay.log;resolution:=optional;version="[6.1,7)",
org.mortbay.util.ajax;resolution:=optional;version="[6.1,7)",
+ org.osgi.service.metatype;version="[1.1,2)";resolution:=optional,
org.osgi.service.useradmin;resolution:=optional,
*
</Import-Package>
+ <DynamicImport-Package>
+ org.osgi.service.metatype;version="[1.1,2)"
+ </DynamicImport-Package>
</instructions>
<!-- Skip Baselining due to Jetty API -->
<skip>true</skip>
@@ -85,7 +89,7 @@
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
- <version>6.0.0</version>
+ <version>5.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -146,12 +150,12 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.http.api</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>2.3.2</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.http.base</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>2.4.0</version>
</dependency>
</dependencies>
Modified: felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyActivator.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyActivator.java?rev=1663103&r1=1663102&r2=1663103&view=diff
==============================================================================
--- felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyActivator.java (original)
+++ felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyActivator.java Sun Mar 1 13:55:12 2015
@@ -16,22 +16,59 @@
*/
package org.apache.felix.http.jetty.internal;
+import java.util.Dictionary;
+import java.util.Hashtable;
+
import org.apache.felix.http.base.internal.AbstractHttpActivator;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceRegistration;
public final class JettyActivator extends AbstractHttpActivator
{
private JettyService jetty;
+ private ServiceRegistration<?> metatypeReg;
+
+ @Override
protected void doStart() throws Exception
{
super.doStart();
+ final Dictionary<String, Object> properties = new Hashtable<String, Object>();
+ properties.put(Constants.SERVICE_DESCRIPTION, "Metatype provider for Jetty Http Service");
+ properties.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
+ properties.put("metatype.pid", JettyService.PID);
+
+ metatypeReg = this.getBundleContext().registerService("org.osgi.service.metatype.MetaTypeProvider",
+ new ServiceFactory()
+ {
+
+ @Override
+ public Object getService(final Bundle bundle, final ServiceRegistration registration)
+ {
+ return new ConfigMetaTypeProvider(getBundleContext().getBundle());
+ }
+
+ @Override
+ public void ungetService(Bundle bundle, ServiceRegistration registration, Object service)
+ {
+ // nothing to do
+ }
+ }, properties);
this.jetty = new JettyService(getBundleContext(), getDispatcherServlet(), getEventDispatcher(), getHttpServiceController());
this.jetty.start();
}
+ @Override
protected void doStop() throws Exception
{
this.jetty.stop();
+ if ( metatypeReg != null )
+ {
+ metatypeReg.unregister();
+ metatypeReg = null;
+ }
super.doStop();
}
}
Modified: felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java?rev=1663103&r1=1663102&r2=1663103&view=diff
==============================================================================
--- felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java (original)
+++ felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java Sun Mar 1 13:55:12 2015
@@ -33,54 +33,54 @@ import org.osgi.framework.BundleContext;
public final class JettyConfig
{
/** Felix specific property to set the interface to listen on. Applies to both HTTP and HTTP */
- private static final String FELIX_HOST = "org.apache.felix.http.host";
+ public static final String FELIX_HOST = "org.apache.felix.http.host";
/** Standard OSGi port property for HTTP service */
- private static final String HTTP_PORT = "org.osgi.service.http.port";
+ public static final String HTTP_PORT = "org.osgi.service.http.port";
/** Standard OSGi port property for HTTPS service */
- private static final String HTTPS_PORT = "org.osgi.service.http.port.secure";
+ public static final String HTTPS_PORT = "org.osgi.service.http.port.secure";
/** Felix specific property to set http reaching timeout limit */
public static final String HTTP_TIMEOUT = "org.apache.felix.http.timeout";
/** Felix specific property to enable debug messages */
- private static final String FELIX_HTTP_DEBUG = "org.apache.felix.http.debug";
- private static final String HTTP_DEBUG = "org.apache.felix.http.jetty.debug";
+ public static final String FELIX_HTTP_DEBUG = "org.apache.felix.http.debug";
+ public static final String HTTP_DEBUG = "org.apache.felix.http.jetty.debug";
/** Felix specific property to override the keystore file location. */
- private static final String FELIX_KEYSTORE = "org.apache.felix.https.keystore";
+ public static final String FELIX_KEYSTORE = "org.apache.felix.https.keystore";
private static final String OSCAR_KEYSTORE = "org.ungoverned.osgi.bundle.https.keystore";
/** Felix specific property to override the keystore password. */
- private static final String FELIX_KEYSTORE_PASSWORD = "org.apache.felix.https.keystore.password";
+ public static final String FELIX_KEYSTORE_PASSWORD = "org.apache.felix.https.keystore.password";
private static final String OSCAR_KEYSTORE_PASSWORD = "org.ungoverned.osgi.bundle.https.password";
/** Felix specific property to override the keystore key password. */
- private static final String FELIX_KEYSTORE_KEY_PASSWORD = "org.apache.felix.https.keystore.key.password";
+ public static final String FELIX_KEYSTORE_KEY_PASSWORD = "org.apache.felix.https.keystore.key.password";
private static final String OSCAR_KEYSTORE_KEY_PASSWORD = "org.ungoverned.osgi.bundle.https.key.password";
/** Felix specific property to override the type of keystore (JKS). */
- private static final String FELIX_KEYSTORE_TYPE = "org.apache.felix.https.keystore.type";
+ public static final String FELIX_KEYSTORE_TYPE = "org.apache.felix.https.keystore.type";
/** Felix specific property to control whether to enable HTTPS. */
- private static final String FELIX_HTTPS_ENABLE = "org.apache.felix.https.enable";
+ public static final String FELIX_HTTPS_ENABLE = "org.apache.felix.https.enable";
private static final String OSCAR_HTTPS_ENABLE = "org.ungoverned.osgi.bundle.https.enable";
/** Felix specific property to control whether to enable HTTP. */
- private static final String FELIX_HTTP_ENABLE = "org.apache.felix.http.enable";
+ public static final String FELIX_HTTP_ENABLE = "org.apache.felix.http.enable";
/** Felix specific property to override the truststore file location. */
- private static final String FELIX_TRUSTSTORE = "org.apache.felix.https.truststore";
+ public static final String FELIX_TRUSTSTORE = "org.apache.felix.https.truststore";
/** Felix specific property to override the truststore password. */
- private static final String FELIX_TRUSTSTORE_PASSWORD = "org.apache.felix.https.truststore.password";
+ public static final String FELIX_TRUSTSTORE_PASSWORD = "org.apache.felix.https.truststore.password";
/** Felix specific property to override the type of truststore (JKS). */
- private static final String FELIX_TRUSTSTORE_TYPE = "org.apache.felix.https.truststore.type";
+ public static final String FELIX_TRUSTSTORE_TYPE = "org.apache.felix.https.truststore.type";
/** Felix specific property to control whether to want or require HTTPS client certificates. Valid values are "none", "wants", "needs". Default is "none". */
- private static final String FELIX_HTTPS_CLIENT_CERT = "org.apache.felix.https.clientcertificate";
+ public static final String FELIX_HTTPS_CLIENT_CERT = "org.apache.felix.https.clientcertificate";
/** Felix specific property to configure the session timeout in minutes (same session-timout in web.xml). Default is servlet container specific */
public static final String FELIX_SESSION_TIMEOUT = "org.apache.felix.http.session.timeout";
Modified: felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java?rev=1663103&r1=1663102&r2=1663103&view=diff
==============================================================================
--- felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java (original)
+++ felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java Sun Mar 1 13:55:12 2015
@@ -70,7 +70,6 @@ import org.osgi.framework.ServiceRegistr
import org.osgi.service.cm.ManagedService;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventAdmin;
-import org.osgi.service.http.runtime.HttpServiceRuntimeConstants;
import org.osgi.util.tracker.BundleTracker;
import org.osgi.util.tracker.BundleTrackerCustomizer;
import org.osgi.util.tracker.ServiceTracker;
@@ -79,7 +78,9 @@ import org.osgi.util.tracker.ServiceTrac
public final class JettyService extends AbstractLifeCycle.AbstractLifeCycleListener implements BundleTrackerCustomizer, ServiceTrackerCustomizer
{
/** PID for configuration of the HTTP service. */
- private static final String PID = "org.apache.felix.http";
+ public static final String PID = "org.apache.felix.http";
+ /** Endpoint service registration property from RFC 189 */
+ private static final String REG_PROPERTY_ENDPOINTS = "osgi.http.service.endpoints";
private static final String HEADER_WEB_CONTEXT_PATH = "Web-ContextPath";
private static final String HEADER_ACTIVATION_POLICY = "Bundle-ActivationPolicy";
@@ -598,7 +599,7 @@ public final class JettyService extends
}
}
}
- props.put(HttpServiceRuntimeConstants.HTTP_SERVICE_ENDPOINT_ATTRIBUTE,
+ props.put(REG_PROPERTY_ENDPOINTS,
endpoints.toArray(new String[endpoints.size()]));
}
Modified: felix/trunk/http/jetty/src/test/java/org/apache/felix/http/jetty/internal/JettyServiceTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/test/java/org/apache/felix/http/jetty/internal/JettyServiceTest.java?rev=1663103&r1=1663102&r2=1663103&view=diff
==============================================================================
--- felix/trunk/http/jetty/src/test/java/org/apache/felix/http/jetty/internal/JettyServiceTest.java (original)
+++ felix/trunk/http/jetty/src/test/java/org/apache/felix/http/jetty/internal/JettyServiceTest.java Sun Mar 1 13:55:12 2015
@@ -48,16 +48,9 @@ import org.apache.felix.http.base.intern
import org.apache.felix.http.jetty.internal.JettyService.Deployment;
import org.eclipse.jetty.servlet.FilterHolder;
import org.eclipse.jetty.servlet.ServletHolder;
-import org.mockito.Matchers;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceFactory;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
import org.osgi.framework.Version;
-import org.osgi.service.http.context.ServletContextHelper;
-import org.osgi.service.http.runtime.HttpServiceRuntime;
public class JettyServiceTest extends TestCase
{
@@ -92,19 +85,6 @@ public class JettyServiceTest extends Te
when(mockBundle.getSymbolicName()).thenReturn("main");
when(mockBundle.getVersion()).thenReturn(new Version("1.0.0"));
when(mockBundle.getHeaders()).thenReturn(new Hashtable<String, String>());
- final ServiceReference ref = mock(ServiceReference.class);
- when(ref.getProperty(Constants.SERVICE_ID)).thenReturn(1L);
- final ServiceRegistration reg = mock(ServiceRegistration.class);
- when(reg.getReference()).thenReturn(ref);
- when(mockBundleContext.registerService((Class<ServletContextHelper>)Matchers.isNotNull(),
- (ServiceFactory<ServletContextHelper>)Matchers.any(ServiceFactory.class),
- Matchers.any(Dictionary.class))).thenReturn(reg);
- when(mockBundleContext.registerService(Matchers.<String[]>any(),
- Matchers.any(ServiceFactory.class),
- Matchers.any(Dictionary.class))).thenReturn(reg);
- when(mockBundleContext.registerService((Class<HttpServiceRuntime>)Matchers.isNotNull(),
- Matchers.any(HttpServiceRuntime.class),
- Matchers.any(Dictionary.class))).thenReturn(reg);
httpServiceController = new HttpServiceController(mockBundleContext);
dispatcherServlet = new DispatcherServlet(httpServiceController);
@@ -158,13 +138,11 @@ public class JettyServiceTest extends Te
//Add a Filter to test whether the osgi-bundlecontext is available at init
webAppBundleContext.addServlet(new ServletHolder(new Servlet()
{
- @Override
public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException
{
// Do Nothing
}
- @Override
public void init(ServletConfig config) throws ServletException
{
ServletContext context = config.getServletContext();
@@ -174,19 +152,16 @@ public class JettyServiceTest extends Te
testLatch.countDown();
}
- @Override
public String getServletInfo()
{
return null;
}
- @Override
public ServletConfig getServletConfig()
{
return null;
}
- @Override
public void destroy()
{
// Do Nothing
@@ -195,7 +170,6 @@ public class JettyServiceTest extends Te
webAppBundleContext.addFilter(new FilterHolder(new Filter()
{
- @Override
public void init(FilterConfig filterConfig) throws ServletException
{
ServletContext context = filterConfig.getServletContext();
@@ -205,13 +179,11 @@ public class JettyServiceTest extends Te
testLatch.countDown();
}
- @Override
public void doFilter(ServletRequest arg0, ServletResponse response, FilterChain chain) throws IOException, ServletException
{
// Do Nothing
}
- @Override
public void destroy()
{
// Do Nothing
@@ -228,4 +200,4 @@ public class JettyServiceTest extends Te
fail("Test Was not asserted");
}
}
-}
\ No newline at end of file
+}