Author: [email protected]
Date: Tue Mar 29 16:51:45 2011
New Revision: 918

Log:
AMDATU-283 cleanup old resource/context code

Modified:
   
branches/AMDATU-283-dev/amdatu-example/oauth/src/main/java/org/amdatu/example/oauth/osgi/Activator.java
   
branches/AMDATU-283-dev/amdatu-example/oauth/src/main/java/org/amdatu/example/oauth/service/OAuthGadgetsRegistrationServiceImpl.java

Modified: 
branches/AMDATU-283-dev/amdatu-example/oauth/src/main/java/org/amdatu/example/oauth/osgi/Activator.java
==============================================================================
--- 
branches/AMDATU-283-dev/amdatu-example/oauth/src/main/java/org/amdatu/example/oauth/osgi/Activator.java
     (original)
+++ 
branches/AMDATU-283-dev/amdatu-example/oauth/src/main/java/org/amdatu/example/oauth/osgi/Activator.java
     Tue Mar 29 16:51:45 2011
@@ -36,12 +36,13 @@
 
 /**
  * This is the OSGi activator for this bundle.
+ * 
  * @author ivol
  */
 public class Activator extends ServiceDependentActivator {
-    // The resource identifier for this bundle. Resources are only considered 
to be 'ours' when
-    // it is prefixed with this id.
-    public final static String RESOURCE_ID = "examples/oauth";
+
+    public final static String CONTEXTID = "amdatu-examples";
+    public final static String ALIAS = "/examples/oauth";
 
     @Override
     protected Class<?>[] getRequiredServices() {
@@ -54,17 +55,17 @@
         // and HTTP service
 
         // Provide context and alias information for resources
-        Dictionary<String, Object> svcProperties = new Hashtable<String, 
Object>();
-        svcProperties.put(DispatcherService.CONTEXT_ID_KEY, RESOURCE_ID);
-        svcProperties.put(DispatcherService.ALIAS_KEY, "/" + RESOURCE_ID);
+        Dictionary<String, Object> properties = new Hashtable<String, 
Object>();
+        properties.put(DispatcherService.CONTEXT_ID_KEY, CONTEXTID);
+        properties.put(DispatcherService.ALIAS_KEY, ALIAS);
 
         manager.add(createComponent()
-            .setInterface(ResourceProvider.class.getName(), svcProperties)
+            .setInterface(ResourceProvider.class.getName(), properties)
             .setImplementation(OAuthGadgetsRegistrationServiceImpl.class)
-            
.add(createServiceDependency().setService(LogService.class).setRequired(true))
             
.add(createServiceDependency().setService(GadgetManagement.class).setRequired(true))
             
.add(createServiceDependency().setService(OAuthServiceConsumerRegistry.class).setRequired(true))
-            
.add(createServiceDependency().setService(HttpService.class).setRequired(true)));
+            
.add(createServiceDependency().setService(HttpService.class).setRequired(true))
+            
.add(createServiceDependency().setService(LogService.class).setRequired(false)));
 
         manager.add(createComponent()
             .setInterface(DummyInterface.class.getName(), null)

Modified: 
branches/AMDATU-283-dev/amdatu-example/oauth/src/main/java/org/amdatu/example/oauth/service/OAuthGadgetsRegistrationServiceImpl.java
==============================================================================
--- 
branches/AMDATU-283-dev/amdatu-example/oauth/src/main/java/org/amdatu/example/oauth/service/OAuthGadgetsRegistrationServiceImpl.java
        (original)
+++ 
branches/AMDATU-283-dev/amdatu-example/oauth/src/main/java/org/amdatu/example/oauth/service/OAuthGadgetsRegistrationServiceImpl.java
        Tue Mar 29 16:51:45 2011
@@ -16,8 +16,6 @@
  */
 package org.amdatu.example.oauth.service;
 
-import static org.amdatu.example.oauth.osgi.Activator.RESOURCE_ID;
-
 import java.net.URL;
 import java.util.Map;
 
@@ -41,6 +39,7 @@
  * @author ivol
  */
 public class OAuthGadgetsRegistrationServiceImpl implements ResourceProvider {
+
     // oAuth properties of this gadget as service consumer
     private final static String CONSUMER_CALLBACK_URL = 
"/gadgets/oauthcallback";
     private final static String CONSUMER_KEY = "example.amdatu.org";
@@ -56,16 +55,14 @@
     // Instance variables, injected by the OSGi framework
     private BundleContext m_bundleContext;
 
-    // Other instance variables
-    private Component m_httpContextComponent;
-
     /**
      * The init() method is invoked by the Felix dependency manager.
      */
     public void init() {
 
-        String gadgetUrl = "/" + RESOURCE_ID + "/jsp/3leggedOAuthGadget.jspf";
-        GadgetDefinition gadgetDef = new GadgetDefinition(gadgetUrl, 
ExampleGadgetRepositoryService.AMDATU_EXAMPLE_CATEGORY, false);
+        String gadgetUrl = Activator.ALIAS + "/jsp/3leggedOAuthGadget.jspf";
+        GadgetDefinition gadgetDef =
+            new GadgetDefinition(gadgetUrl, 
ExampleGadgetRepositoryService.AMDATU_EXAMPLE_CATEGORY, false);
 
         // Set oAuth parameters
         gadgetDef.setServiceName(SERVICE_NAME);
@@ -86,24 +83,17 @@
      * The destroy() method is invoked by the Felix dependency manager.
      */
     public void destroy() {
-        // Stop our private HTTP Context service
-        m_httpContextComponent.stop();
-
         m_logService.log(LogService.LOG_INFO, getClass().getName() + " service 
destroyed");
     }
 
     public URL getResource(String name) {
-        final String pathPrefix = "/" + Activator.RESOURCE_ID + "/";
-        if(name != null && name.startsWith(pathPrefix)){
-            return 
m_bundleContext.getBundle().getResource(name.substring(pathPrefix.length()));   
         
+        final String pathPrefix = Activator.ALIAS + "/";
+        if (name != null && name.startsWith(pathPrefix)) {
+            return 
m_bundleContext.getBundle().getResource(name.substring(pathPrefix.length()));
         }
         return null;
     }
 
-    public String getResourceId() {
-        return RESOURCE_ID;
-    }
-
     private void registerConsumer() {
         try {
             if (m_consumerRegistry.getConsumer(CONSUMER_KEY) == null) {
_______________________________________________
Amdatu-commits mailing list
[email protected]
http://lists.amdatu.org/mailman/listinfo/amdatu-commits

Reply via email to