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/01/29 11:22:39 UTC

svn commit: r1655577 [2/2] - in /felix/sandbox/http-rfc189/base: ./ src/main/java/org/apache/felix/http/base/internal/ src/main/java/org/apache/felix/http/base/internal/handler/ src/main/java/org/apache/felix/http/base/internal/runtime/ src/main/java/o...

Propchange: felix/sandbox/http-rfc189/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ResourceTracker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/sandbox/http-rfc189/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ResourceTracker.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: felix/sandbox/http-rfc189/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ResourceTracker.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/sandbox/http-rfc189/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ServletContextHelperTracker.java
URL: http://svn.apache.org/viewvc/felix/sandbox/http-rfc189/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ServletContextHelperTracker.java?rev=1655577&view=auto
==============================================================================
--- felix/sandbox/http-rfc189/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ServletContextHelperTracker.java (added)
+++ felix/sandbox/http-rfc189/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ServletContextHelperTracker.java Thu Jan 29 10:22:38 2015
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.felix.http.base.internal.whiteboard.tracker;
+
+import org.apache.felix.http.base.internal.whiteboard.ExtenderManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.http.context.ServletContextHelper;
+import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
+
+public final class ServletContextHelperTracker extends AbstractTracker<ServletContextHelper>
+{
+    private final ExtenderManager manager;
+
+    private static org.osgi.framework.Filter createFilter(final BundleContext btx)
+    {
+        try
+        {
+            return btx.createFilter(String.format("(&(objectClass=%s)(%s=*)(%s=*))",
+                    ServletContextHelperTracker.class.getName(),
+                    HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME,
+                    HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH));
+        }
+        catch ( final InvalidSyntaxException ise)
+        {
+            // we can safely ignore it as the above filter is a constant
+        }
+        return null; // we never get here - and if we get an NPE which is fine
+    }
+
+    public ServletContextHelperTracker(final BundleContext context, ExtenderManager manager)
+    {
+        super(context, createFilter(context));
+        this.manager = manager;
+    }
+
+    @Override
+    protected void added(ServletContextHelper service, ServiceReference ref)
+    {
+        this.manager.add(service, ref);
+    }
+
+    @Override
+    protected void modified(ServletContextHelper service, ServiceReference ref)
+    {
+        removed(service, ref);
+        added(service, ref);
+    }
+
+    @Override
+    protected void removed(ServletContextHelper service, ServiceReference ref)
+    {
+        this.manager.remove(service);
+    }
+}

Propchange: felix/sandbox/http-rfc189/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ServletContextHelperTracker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/sandbox/http-rfc189/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ServletContextHelperTracker.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: felix/sandbox/http-rfc189/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ServletContextHelperTracker.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/sandbox/http-rfc189/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ServletTracker.java
URL: http://svn.apache.org/viewvc/felix/sandbox/http-rfc189/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ServletTracker.java?rev=1655577&view=auto
==============================================================================
--- felix/sandbox/http-rfc189/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ServletTracker.java (added)
+++ felix/sandbox/http-rfc189/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ServletTracker.java Thu Jan 29 10:22:38 2015
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.felix.http.base.internal.whiteboard.tracker;
+
+import javax.servlet.Servlet;
+
+import org.apache.felix.http.base.internal.whiteboard.ExtenderManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
+
+public final class ServletTracker extends AbstractTracker<Servlet>
+{
+    private final ExtenderManager manager;
+
+    private static org.osgi.framework.Filter createFilter(final BundleContext btx)
+    {
+        try
+        {
+            return btx.createFilter(String.format("(&(objectClass=%s)(%s=*))",
+                    Servlet.class.getName(),
+                    HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN));
+        }
+        catch ( final InvalidSyntaxException ise)
+        {
+            // we can safely ignore it as the above filter is a constant
+        }
+        return null; // we never get here - and if we get an NPE which is fine
+    }
+
+    public ServletTracker(final BundleContext context, final ExtenderManager manager)
+    {
+        super(context, createFilter(context));
+        this.manager = manager;
+    }
+
+    @Override
+    protected void added(Servlet service, ServiceReference ref)
+    {
+        this.manager.add(service, ref);
+    }
+
+    @Override
+    protected void modified(Servlet service, ServiceReference ref)
+    {
+        removed(service, ref);
+        added(service, ref);
+    }
+
+    @Override
+    protected void removed(Servlet service, ServiceReference ref)
+    {
+        this.manager.removeServlet(ref);
+    }
+}

Propchange: felix/sandbox/http-rfc189/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ServletTracker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/sandbox/http-rfc189/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ServletTracker.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: felix/sandbox/http-rfc189/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ServletTracker.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: felix/sandbox/http-rfc189/base/src/test/java/org/apache/felix/http/base/internal/handler/FilterHandlerTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/http-rfc189/base/src/test/java/org/apache/felix/http/base/internal/handler/FilterHandlerTest.java?rev=1655577&r1=1655576&r2=1655577&view=diff
==============================================================================
--- felix/sandbox/http-rfc189/base/src/test/java/org/apache/felix/http/base/internal/handler/FilterHandlerTest.java (original)
+++ felix/sandbox/http-rfc189/base/src/test/java/org/apache/felix/http/base/internal/handler/FilterHandlerTest.java Thu Jan 29 10:22:38 2015
@@ -33,7 +33,7 @@ import javax.servlet.FilterConfig;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.felix.http.api.FilterInfo;
+import org.apache.felix.http.base.internal.runtime.FilterInfo;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -41,6 +41,7 @@ public class FilterHandlerTest extends A
 {
     private Filter filter;
 
+    @Override
     @Before
     public void setUp()
     {
@@ -220,6 +221,7 @@ public class FilterHandlerTest extends A
         verify(this.filter).init(any(FilterConfig.class));
     }
 
+    @Override
     protected AbstractHandler createHandler()
     {
         return createHandler(0, "dummy");

Modified: felix/sandbox/http-rfc189/base/src/test/java/org/apache/felix/http/base/internal/handler/HandlerMappingTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/http-rfc189/base/src/test/java/org/apache/felix/http/base/internal/handler/HandlerMappingTest.java?rev=1655577&r1=1655576&r2=1655577&view=diff
==============================================================================
--- felix/sandbox/http-rfc189/base/src/test/java/org/apache/felix/http/base/internal/handler/HandlerMappingTest.java (original)
+++ felix/sandbox/http-rfc189/base/src/test/java/org/apache/felix/http/base/internal/handler/HandlerMappingTest.java Thu Jan 29 10:22:38 2015
@@ -33,15 +33,15 @@ import java.util.regex.Pattern;
 import javax.servlet.Filter;
 import javax.servlet.Servlet;
 
-import org.apache.felix.http.api.FilterInfo;
-import org.apache.felix.http.api.ServletInfo;
 import org.apache.felix.http.base.internal.context.ExtServletContext;
 import org.apache.felix.http.base.internal.handler.HandlerMapping.PatternComparator;
+import org.apache.felix.http.base.internal.runtime.FilterInfo;
+import org.apache.felix.http.base.internal.runtime.ServletInfo;
 import org.junit.Test;
 
 /**
  * Test cases for {@link HandlerMapping}.
- * 
+ *
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
 public class HandlerMappingTest

Modified: felix/sandbox/http-rfc189/base/src/test/java/org/apache/felix/http/base/internal/handler/ServletHandlerTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/http-rfc189/base/src/test/java/org/apache/felix/http/base/internal/handler/ServletHandlerTest.java?rev=1655577&r1=1655576&r2=1655577&view=diff
==============================================================================
--- felix/sandbox/http-rfc189/base/src/test/java/org/apache/felix/http/base/internal/handler/ServletHandlerTest.java (original)
+++ felix/sandbox/http-rfc189/base/src/test/java/org/apache/felix/http/base/internal/handler/ServletHandlerTest.java Thu Jan 29 10:22:38 2015
@@ -32,7 +32,7 @@ import javax.servlet.ServletConfig;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.felix.http.api.ServletInfo;
+import org.apache.felix.http.base.internal.runtime.ServletInfo;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -40,6 +40,7 @@ public class ServletHandlerTest extends
 {
     private Servlet servlet;
 
+    @Override
     @Before
     public void setUp()
     {
@@ -197,6 +198,7 @@ public class ServletHandlerTest extends
         verify(this.servlet).init(any(ServletConfig.class));
     }
 
+    @Override
     protected AbstractHandler createHandler()
     {
         return createHandler("/dummy");