Author: ivol37 at gmail.com
Date: Mon Dec 13 09:28:25 2010
New Revision: 488
Log:
[AMDATU-199] Added checks to prevent issue 199 to happen
Modified:
trunk/amdatu-authorization/login-gadget/src/main/java/org/amdatu/authorization/login/gadget/service/LoginGadgetImpl.java
trunk/amdatu-example/course-gadget/src/main/java/org/amdatu/example/course/gadget/service/CourseGadgetServiceImpl.java
trunk/amdatu-example/friends-gadget/src/main/java/org/amdatu/example/friend/sgadget/service/FriendsGadgetServiceImpl.java
trunk/amdatu-semanticweb/sparqlendpoint/src/main/java/org/amdatu/semanticweb/sparqlendpoint/service/SPARQLEndpointServiceImpl.java
Modified:
trunk/amdatu-authorization/login-gadget/src/main/java/org/amdatu/authorization/login/gadget/service/LoginGadgetImpl.java
==============================================================================
---
trunk/amdatu-authorization/login-gadget/src/main/java/org/amdatu/authorization/login/gadget/service/LoginGadgetImpl.java
(original)
+++
trunk/amdatu-authorization/login-gadget/src/main/java/org/amdatu/authorization/login/gadget/service/LoginGadgetImpl.java
Mon Dec 13 09:28:25 2010
@@ -61,7 +61,13 @@
// Create our own http context service which registers static
resources and JSPs automatically
m_httpContextComponent =
m_httpContextServiceFactory.create(m_bundleContext, this);
- if (m_hostname != null && m_portnr != null) {
+ if (m_hostname == null || m_portnr == null) {
+ // FIXME: Because of a bug in the Felix dependency manager,
update() is not invoked when the bundle
+ // is stopped/started. Hence m_hostname and m_portnr will be null.
To prevent serious problems as
+ // described in issue
http://jira.amdatu.org/jira/browse/AMDATU-199 we implement this check for now.
+ // For the bug description, see
http://jira.amdatu.org/jira/browse/AMDATU-174
+ // and https://issues.apache.org/jira/browse/FELIX-2696
+ } else {
// Register the gadget with the Gadget management service. Note
that we can do this as
// many times as we want, since the gadget URL is the unique
identifier
String gadgetSpecUrl =
@@ -71,10 +77,7 @@
m_gadgetManagement.addGadget(gadgetDef);
m_logService.log(LogService.LOG_INFO, "Login gadget registered on
URL '" + gadgetSpecUrl + "'");
}
- else {
- m_logService.log(LogService.LOG_ERROR, "Login gadget could not be
registered, hostname=" + m_hostname
- + ", portnr=" + m_portnr);
- }
+
m_logService.log(LogService.LOG_INFO, getClass().getName() + " service
started");
}
Modified:
trunk/amdatu-example/course-gadget/src/main/java/org/amdatu/example/course/gadget/service/CourseGadgetServiceImpl.java
==============================================================================
---
trunk/amdatu-example/course-gadget/src/main/java/org/amdatu/example/course/gadget/service/CourseGadgetServiceImpl.java
(original)
+++
trunk/amdatu-example/course-gadget/src/main/java/org/amdatu/example/course/gadget/service/CourseGadgetServiceImpl.java
Mon Dec 13 09:28:25 2010
@@ -76,9 +76,11 @@
m_httpContextComponent =
m_httpContextFactoryService.create(m_bundleContext, this);
if (m_hostname == null || m_portnr == null) {
- // FIXME: For some reason update() is only invoked the very first
time this service is created. When
- // you stop/start the bundle, updated() will not be invoked (at
all!) and so hostname and portnr remain
- // null.
+ // FIXME: Because of a bug in the Felix dependency manager,
update() is not invoked when the bundle
+ // is stopped/started. Hence m_hostname and m_portnr will be null.
To prevent serious problems as
+ // described in issue
http://jira.amdatu.org/jira/browse/AMDATU-199 we implement this check for now.
+ // For the bug description, see
http://jira.amdatu.org/jira/browse/AMDATU-174
+ // and https://issues.apache.org/jira/browse/FELIX-2696
} else {
GadgetDefinition gadgetDef =
new GadgetDefinition("http://" + m_hostname + ":" + m_portnr +
"/" + Activator.RESOURCE_ID
@@ -95,9 +97,8 @@
// Register the service consumer in our own oAuth server such that
our own oAuth server
// can also handle oAuth of this gadget
registerConsumer();
-
- m_logService.log(LogService.LOG_INFO, getClass().getName() + "
service initialized");
}
+ m_logService.log(LogService.LOG_INFO, getClass().getName() + " service
initialized");
}
/**
Modified:
trunk/amdatu-example/friends-gadget/src/main/java/org/amdatu/example/friend/sgadget/service/FriendsGadgetServiceImpl.java
==============================================================================
---
trunk/amdatu-example/friends-gadget/src/main/java/org/amdatu/example/friend/sgadget/service/FriendsGadgetServiceImpl.java
(original)
+++
trunk/amdatu-example/friends-gadget/src/main/java/org/amdatu/example/friend/sgadget/service/FriendsGadgetServiceImpl.java
Mon Dec 13 09:28:25 2010
@@ -21,12 +21,12 @@
import java.net.URL;
import java.util.Dictionary;
-import org.amdatu.opensocial.gadgetmanagement.GadgetManagement;
import org.amdatu.example.friends.gadget.osgi.Activator;
-import org.amdatu.web.httpcontext.HttpContextServiceFactory;
-import org.amdatu.web.httpcontext.ResourceProvider;
+import org.amdatu.opensocial.gadgetmanagement.GadgetManagement;
import org.amdatu.opensocial.shindig.GadgetCategory;
import org.amdatu.opensocial.shindig.GadgetDefinition;
+import org.amdatu.web.httpcontext.HttpContextServiceFactory;
+import org.amdatu.web.httpcontext.ResourceProvider;
import org.apache.felix.dm.Component;
import org.osgi.framework.BundleContext;
import org.osgi.service.cm.ConfigurationException;
@@ -63,12 +63,18 @@
// Create our own http context service
m_httpContextComponent =
m_httpContextFactoryService.create(m_bundleContext, this);
- GadgetDefinition gadgetDef = new GadgetDefinition("http://" +
m_hostname + ":" + m_portnr + "/" + Activator.RESOURCE_ID +
"/static/xml/FriendsGadget.xml",
+ if (m_hostname == null || m_portnr == null) {
+ // FIXME: Because of a bug in the Felix dependency manager,
update() is not invoked when the bundle
+ // is stopped/started. Hence m_hostname and m_portnr will be null.
To prevent serious problems as
+ // described in issue
http://jira.amdatu.org/jira/browse/AMDATU-199 we implement this check for now.
+ // For the bug description, see
http://jira.amdatu.org/jira/browse/AMDATU-174
+ // and https://issues.apache.org/jira/browse/FELIX-2696
+ } else {
+ GadgetDefinition gadgetDef = new GadgetDefinition("http://" +
m_hostname + ":" + m_portnr + "/" + Activator.RESOURCE_ID +
"/static/xml/FriendsGadget.xml",
GadgetCategory.AMDATU_EXAMPLES, false);
-
- gadgetDef.setServiceName("friends");
-
- m_gadgetManagement.addGadget(gadgetDef);
+ gadgetDef.setServiceName("friends");
+ m_gadgetManagement.addGadget(gadgetDef);
+ }
m_logService.log(LogService.LOG_INFO, getClass().getName() + " service
initialized");
}
Modified:
trunk/amdatu-semanticweb/sparqlendpoint/src/main/java/org/amdatu/semanticweb/sparqlendpoint/service/SPARQLEndpointServiceImpl.java
==============================================================================
---
trunk/amdatu-semanticweb/sparqlendpoint/src/main/java/org/amdatu/semanticweb/sparqlendpoint/service/SPARQLEndpointServiceImpl.java
(original)
+++
trunk/amdatu-semanticweb/sparqlendpoint/src/main/java/org/amdatu/semanticweb/sparqlendpoint/service/SPARQLEndpointServiceImpl.java
Mon Dec 13 09:28:25 2010
@@ -77,11 +77,19 @@
// Create our own http context service which registers static
resources and JSPs automatically
m_httpContextComponent =
m_httpContextServiceFactory.create(m_bundleContext, this);
- // Register the gadget with the Gadget management service. Note that
we can do this as
- // many times as we want, since the gadget URL is the unique identifier
- GadgetDefinition gadgetDef = new GadgetDefinition("http://" +
m_hostname + ":" + m_portnr + "/" + Activator.RESOURCE_ID +
"/jsp/SPARQLEndpointGadget.jsp",
+ if (m_hostname == null || m_portnr == null) {
+ // FIXME: Because of a bug in the Felix dependency manager,
update() is not invoked when the bundle
+ // is stopped/started. Hence m_hostname and m_portnr will be null.
To prevent serious problems as
+ // described in issue
http://jira.amdatu.org/jira/browse/AMDATU-199 we implement this check for now.
+ // For the bug description, see
http://jira.amdatu.org/jira/browse/AMDATU-174
+ // and https://issues.apache.org/jira/browse/FELIX-2696
+ } else {
+ // Register the gadget with the Gadget management service. Note
that we can do this as
+ // many times as we want, since the gadget URL is the unique
identifier
+ GadgetDefinition gadgetDef = new GadgetDefinition("http://" +
m_hostname + ":" + m_portnr + "/" + Activator.RESOURCE_ID +
"/jsp/SPARQLEndpointGadget.jsp",
GadgetCategory.AMDATU_PLATFORM, true);
- m_gadgetManagement.addGadget(gadgetDef);
+ m_gadgetManagement.addGadget(gadgetDef);
+ }
m_logService.log(LogService.LOG_INFO, getClass().getName() + " service
initialized");
}
@@ -99,8 +107,8 @@
@Consumes("application/x-www-form-urlencoded")
@Produces({MediaType.APPLICATION_JSON})
public Response executeSPARQLQuery(@FormParam("query") final String query,
- @DefaultValue("1") @QueryParam("startIndex") final int startIndex,
- @DefaultValue("0") @QueryParam("endIndex") final int
endIndexParam) {
+ @DefaultValue("1") @QueryParam("startIndex") final int startIndex,
+ @DefaultValue("0") @QueryParam("endIndex") final int endIndexParam) {
m_logService.log(LogService.LOG_DEBUG, "Executing SPARQL query: " +
query);
final int endIndex = endIndexParam > 0 ? endIndexParam : MAX_ROW_COUNT;
JSONObject jsonObject = m_sesameService.executeSPARQLQuery(query, new
SPARQLQueryHandler<JSONObject>() {