incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r905402 - in /sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal: ContainerServicesImpl.java DefaultPortletContainer.java DummyCCPPProfileServiceImpl.java EventProviderImpl.java
Date Mon, 01 Feb 2010 20:18:24 GMT
Author: cziegeler
Date: Mon Feb  1 20:18:24 2010
New Revision: 905402

URL: http://svn.apache.org/viewvc?rev=905402&view=rev
Log:
CCPPProfileService might be a plain osgi service

Modified:
    sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/ContainerServicesImpl.java
    sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/DefaultPortletContainer.java
    sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/DummyCCPPProfileServiceImpl.java
    sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/EventProviderImpl.java

Modified: sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/ContainerServicesImpl.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/ContainerServicesImpl.java?rev=905402&r1=905401&r2=905402&view=diff
==============================================================================
--- sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/ContainerServicesImpl.java
(original)
+++ sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/ContainerServicesImpl.java
Mon Feb  1 20:18:24 2010
@@ -41,6 +41,8 @@
 import org.apache.sling.portal.container.internal.services.DefaultPortletPreferencesService;
 import org.apache.sling.portal.container.internal.services.DefaultPortletRegistryService;
 import org.apache.sling.portal.container.internal.services.FilterManagerServiceImpl;
+import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
 
 public class ContainerServicesImpl implements SlingContainerServices {
 
@@ -50,7 +52,7 @@
     private final PortalContext context;
     private final EventCoordinationService eventCoordinationService;
     private final PortletRequestContextService portletRequestContextService;
-    private final CCPPProfileService ccppProfileService;
+    private final CCPPProfileService defaultCcppProfileService;
     private final FilterManagerServiceImpl filterManagerService;
     private final PortletURLListenerService portletURLListenerService;
     private final DefaultPortletPreferencesService portletPreferencesService;
@@ -66,10 +68,15 @@
     private final PortletRegistryService registry;
     private final PortletWindowManager windowManager;
 
+    private final ServiceTracker ccppProfileServiceTracker;
+
     /**
      * Default Constructor.
      */
-    public ContainerServicesImpl(PortalContext context, final ContainerInfo info, final SlingRepository
repository)
+    public ContainerServicesImpl(final PortalContext context,
+                                 final ContainerInfo info,
+                                 final BundleContext bundleContext,
+                                 final SlingRepository repository)
     throws Exception {
         boolean noErrors = false;
         try {
@@ -79,7 +86,9 @@
             this.portletRequestContextService = new PortletRequestContextServiceImpl();
             this.filterManagerService = new FilterManagerServiceImpl(this.registry);
             this.portletURLListenerService = new PortletURLListenerImpl();
-            this.ccppProfileService = new DummyCCPPProfileServiceImpl();
+            this.ccppProfileServiceTracker = new ServiceTracker(bundleContext, CCPPProfileService.class.getName(),
null);
+            this.ccppProfileServiceTracker.open();
+            this.defaultCcppProfileService = new DummyCCPPProfileServiceImpl();
             this.portletPreferencesService = new DefaultPortletPreferencesService(repository,
registry);
             this.portletInvokerService = new DefaultPortletInvokerService(registry);
             this.portletEnvironmentService = new PortletEnvironmentServiceImpl();
@@ -101,6 +110,9 @@
         if ( this.filterManagerService != null ) {
             this.filterManagerService.destroy();
         }
+        if ( this.ccppProfileServiceTracker != null ) {
+            this.ccppProfileServiceTracker.close();
+        }
     }
 
     /**
@@ -142,7 +154,11 @@
      * @see org.apache.pluto.container.ContainerServices#getCCPPProfileService()
      */
     public CCPPProfileService getCCPPProfileService() {
-        return ccppProfileService;
+        CCPPProfileService service = (CCPPProfileService)this.ccppProfileServiceTracker.getService();
+        if  ( service == null ) {
+            service = defaultCcppProfileService;
+        }
+        return service;
     }
 
     /**

Modified: sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/DefaultPortletContainer.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/DefaultPortletContainer.java?rev=905402&r1=905401&r2=905402&view=diff
==============================================================================
--- sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/DefaultPortletContainer.java
(original)
+++ sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/DefaultPortletContainer.java
Mon Feb  1 20:18:24 2010
@@ -26,6 +26,9 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
 import org.apache.pluto.container.ContainerInfo;
 import org.apache.pluto.container.ContainerServices;
 import org.apache.pluto.container.PortletContainerException;
@@ -36,6 +39,7 @@
 import org.apache.sling.portal.container.SlingPortletContainer;
 import org.apache.sling.portal.container.SlingPortletWindow;
 import org.apache.sling.portal.container.internal.services.DefaultContainerInfo;
+import org.osgi.framework.BundleContext;
 import org.osgi.service.component.ComponentContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -45,9 +49,9 @@
  * This is an OSGi service which forwards all requests to the real portlet
  * container implementation.
  *
- * @scr.component metatype="false"
- * @scr.service interface="SlingPortletContainer"
  */
+@Component
+@Service(value=SlingPortletContainer.class)
 public class DefaultPortletContainer implements SlingPortletContainer {
 
     /** Our logger. */
@@ -56,7 +60,7 @@
     /** The real portlet container */
     protected SlingPortletContainer portletContainer;
 
-    /** @scr.reference */
+    @Reference
     private SlingRepository repository;
 
     protected String containerName = "sling-portal";
@@ -65,10 +69,14 @@
     protected WindowState[] supportedWindowStates = new WindowState[] {WindowState.MAXIMIZED,
WindowState.MINIMIZED, WindowState.NORMAL};
     protected PortletMode[] supportedPortletModes = new PortletMode[] {PortletMode.VIEW,
PortletMode.EDIT, PortletMode.HELP};
 
+    /** The bundle context. */
+    private BundleContext bundleContext;
+
     /**
      * Deactivate and shutdown the container.
      */
     protected void deactivate(final ComponentContext context) {
+        this.bundleContext = null;
         if (this.portletContainer != null ) {
             try {
                 this.portletContainer.destroy();
@@ -84,6 +92,7 @@
      */
     protected void activate(final ComponentContext context)
     throws PortletContainerException {
+        this.bundleContext = context.getBundleContext();
         try {
             this.initContainer();
         } catch (PortletContainerException pce) {
@@ -107,7 +116,9 @@
                 this.supportedWindowStates,
                 null);
         try {
-            final ContainerServicesImpl containerServices = new ContainerServicesImpl(ctx,
info, this.repository);
+            final ContainerServicesImpl containerServices = new ContainerServicesImpl(ctx,
info,
+                    this.bundleContext,
+                    this.repository);
             this.portletContainer = new PortletContainerImpl(info, containerServices);
 
             if (!portletContainer.isInitialized()) {

Modified: sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/DummyCCPPProfileServiceImpl.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/DummyCCPPProfileServiceImpl.java?rev=905402&r1=905401&r2=905402&view=diff
==============================================================================
--- sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/DummyCCPPProfileServiceImpl.java
(original)
+++ sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/DummyCCPPProfileServiceImpl.java
Mon Feb  1 20:18:24 2010
@@ -22,11 +22,11 @@
 import org.apache.pluto.container.CCPPProfileService;
 
 /**
- *
+ * This is a dummy implementation - TODO!
  */
 public class DummyCCPPProfileServiceImpl implements CCPPProfileService {
 
-	/* (non-Javadoc)
+	/**
 	 * @see org.apache.pluto.spi.CCPPProfileService#getCCPPProfile()
 	 */
 	public Profile getCCPPProfile(HttpServletRequest httpServletRequest) {

Modified: sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/EventProviderImpl.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/EventProviderImpl.java?rev=905402&r1=905401&r2=905402&view=diff
==============================================================================
--- sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/EventProviderImpl.java
(original)
+++ sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/EventProviderImpl.java
Mon Feb  1 20:18:24 2010
@@ -51,19 +51,15 @@
 
     private boolean isDeclaredAsPublishingEvent(QName qname) {
         final List<? extends EventDefinitionReference> events = portletWindow.getPortletDefinition().getSupportedPublishingEvents();
-        if (events != null)
-        {
-            String defaultNamespace = portletWindow.getPortletDefinition().getApplication()
-                                                   .getDefaultNamespace();
+        if (events != null) {
+            final String defaultNamespace = portletWindow.getPortletDefinition().getApplication().getDefaultNamespace();
             for (EventDefinitionReference ref : events)
             {
-                QName name = ref.getQualifiedName(defaultNamespace);
-                if (name == null)
-                {
+                final QName name = ref.getQualifiedName(defaultNamespace);
+                if (name == null) {
                     continue;
                 }
-                if (qname.equals(name))
-                {
+                if (qname.equals(name)) {
                     return true;
                 }
             }
@@ -72,24 +68,17 @@
     }
 
     private boolean isValueInstanceOfDefinedClass(QName qname, Serializable value) {
-        PortletApplicationDefinition app = portletWindow.getPortletDefinition().getApplication();
+        final PortletApplicationDefinition app = portletWindow.getPortletDefinition().getApplication();
         List<? extends EventDefinition> events = app.getEventDefinitions();
-        if (events != null)
-        {
-            for (EventDefinition def : events)
-            {
-                if (def.getQName() != null)
-                {
-                    if (def.getQName().equals(qname))
-                    {
+        if (events != null) {
+            for (EventDefinition def : events) {
+                if (def.getQName() != null) {
+                    if (def.getQName().equals(qname)) {
                         return value.getClass().getName().equals(def.getValueType());
                     }
-                }
-                else
-                {
-                    QName tmp = new QName(app.getDefaultNamespace(), def.getName());
-                    if (tmp.equals(qname))
-                    {
+                } else {
+                    final QName tmp = new QName(app.getDefaultNamespace(), def.getName());
+                    if (tmp.equals(qname)) {
                         return value.getClass().getName().equals(def.getValueType());
                     }
                 }



Mime
View raw message