Author: jawi
Date: Sun Jan 18 21:06:33 2015
New Revision: 1652853
URL: http://svn.apache.org/r1652853
Log:
ACE-501 - Fix possible NPE when authentication is enabled:
- add authentication service as required service if authentication
is enabled.
Modified:
ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/servlet/AgentDeploymentServlet.java
Modified:
ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/servlet/AgentDeploymentServlet.java
URL:
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/servlet/AgentDeploymentServlet.java?rev=1652853&r1=1652852&r2=1652853&view=diff
==============================================================================
---
ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/servlet/AgentDeploymentServlet.java
(original)
+++
ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/servlet/AgentDeploymentServlet.java
Sun Jan 18 21:06:33 2015
@@ -44,6 +44,8 @@ import javax.xml.xpath.XPathFactory;
import org.apache.ace.authentication.api.AuthenticationService;
import org.apache.ace.connectionfactory.ConnectionFactory;
+import org.apache.felix.dm.Component;
+import org.apache.felix.dm.DependencyManager;
import org.osgi.framework.Version;
import org.osgi.service.cm.ConfigurationException;
import org.osgi.service.cm.ManagedService;
@@ -68,6 +70,7 @@ public class AgentDeploymentServlet exte
public static final String TEXT_MIMETYPE = "text/plain";
// injected by Dependency Manager
+ private volatile DependencyManager m_dm;
private volatile LogService m_log;
private volatile AuthenticationService m_authService;
private volatile ConnectionFactory m_connectionFactory;
@@ -127,6 +130,17 @@ public class AgentDeploymentServlet exte
}
}
+ /**
+ * Called by Dependency Manager upon initialization of this component.
+ *
+ * @param comp the component to initialize, cannot be <code>null</code>.
+ */
+ protected void init(Component comp) {
+ comp.add(m_dm.createServiceDependency()
+
.setService(AuthenticationService.class).setRequired(m_useAuth).setInstanceBound(true)
+ );
+ }
+
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
try {