You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cl...@apache.org on 2010/07/12 19:40:19 UTC
svn commit: r963383 - in /felix/trunk/ipojo/webconsole-plugin/src/main:
java/org/apache/felix/ipojo/webconsole/IPOJOPlugin.java
resources/res/handlers.html resources/res/ui/factory.js
resources/res/ui/handler.js resources/res/ui/ipojo.js
Author: clement
Date: Mon Jul 12 17:40:19 2010
New Revision: 963383
URL: http://svn.apache.org/viewvc?rev=963383&view=rev
Log:
Add the handler list support.
Added:
felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/handlers.html
felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/handler.js
- copied, changed from r963381, felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/factory.js
Modified:
felix/trunk/ipojo/webconsole-plugin/src/main/java/org/apache/felix/ipojo/webconsole/IPOJOPlugin.java
felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/factory.js
felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/ipojo.js
Modified: felix/trunk/ipojo/webconsole-plugin/src/main/java/org/apache/felix/ipojo/webconsole/IPOJOPlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/webconsole-plugin/src/main/java/org/apache/felix/ipojo/webconsole/IPOJOPlugin.java?rev=963383&r1=963382&r2=963383&view=diff
==============================================================================
--- felix/trunk/ipojo/webconsole-plugin/src/main/java/org/apache/felix/ipojo/webconsole/IPOJOPlugin.java (original)
+++ felix/trunk/ipojo/webconsole-plugin/src/main/java/org/apache/felix/ipojo/webconsole/IPOJOPlugin.java Mon Jul 12 17:40:19 2010
@@ -37,6 +37,8 @@ public class IPOJOPlugin extends Abstrac
private final String INSTANCES;
private final String FACTORIES;
+ private final String HANDLERS;
+
/**
* Label used by the web console.
@@ -74,7 +76,7 @@ public class IPOJOPlugin extends Abstrac
public IPOJOPlugin() {
INSTANCES = readTemplateFile(this.getClass(), "/res/instances.html" );
FACTORIES = readTemplateFile(this.getClass(), "/res/factories.html" );
-
+ HANDLERS = readTemplateFile(this.getClass(), "/res/handlers.html" );
}
private final String readTemplateFile(final Class clazz, final String templateFile)
@@ -132,7 +134,9 @@ public class IPOJOPlugin extends Abstrac
response.getWriter().print( INSTANCES );
} else if (view.equals("factories")) {
response.getWriter().print( FACTORIES );
- }
+ } else if (view.equals("handlers")) {
+ response.getWriter().print( HANDLERS );
+ }
}
private void renderAllInstances(PrintWriter pw) {
@@ -164,7 +168,7 @@ public class IPOJOPlugin extends Abstrac
JSONObject resp = new JSONObject();
resp.put("count", m_factories.size());
resp.put("valid_count", getValidFactoriesCount());
- resp.put("invalid_count", getValidFactoriesCount());
+ resp.put("invalid_count", getInvalidFactoriesCount());
JSONArray factories = new JSONArray();
for (Factory factory : m_factories) {
@@ -192,6 +196,43 @@ public class IPOJOPlugin extends Abstrac
}
}
+ private void renderAllHandlers(PrintWriter pw) {
+ try {
+ JSONObject resp = new JSONObject();
+ resp.put("count", m_handlers.size());
+ resp.put("valid_count", getValidHandlersCount());
+ resp.put("invalid_count", getInvalidHandlersCount());
+
+ JSONArray factories = new JSONArray();
+ for (HandlerFactory factory : m_handlers) {
+ String version = factory.getVersion();
+ String name = factory.getHandlerName();
+
+ String state = getFactoryState(factory.getState());
+ String bundle = factory.getBundleContext().getBundle().getSymbolicName()
+ + " (" + factory.getBundleContext().getBundle().getBundleId() + ")";
+ JSONObject fact = new JSONObject();
+ fact.put("name", name);
+ if (version != null) {
+ fact.put("version", version);
+ }
+ fact.put("bundle", bundle);
+ fact.put("state", state);
+ fact.put("type", factory.getType());
+ if (! factory.getMissingHandlers().isEmpty()) {
+ fact.put("missing", factory.getMissingHandlers().toString());
+ }
+ factories.put(fact);
+ }
+ resp.put("data", factories);
+
+ pw.print(resp.toString());
+ } catch (JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
@Override
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
@@ -222,8 +263,7 @@ public class IPOJOPlugin extends Abstrac
}
if (reqInfo.handlers) {
- //TODO
- return;
+ this.renderAllHandlers(response.getWriter());
}
// nothing more to do
return;
@@ -287,6 +327,26 @@ public class IPOJOPlugin extends Abstrac
return i;
}
+ private int getValidHandlersCount() {
+ int i = 0;
+ for (Factory a : m_handlers) { // Cannot be null, an empty list is returned.
+ if (a.getState() == Factory.VALID) {
+ i ++;
+ }
+ }
+ return i;
+ }
+
+ private int getInvalidHandlersCount() {
+ int i = 0;
+ for (Factory a : m_handlers) { // Cannot be null, an empty list is returned.
+ if (a.getState() == Factory.INVALID) {
+ i ++;
+ }
+ }
+ return i;
+ }
+
/**
* Gets the instance state as a String.
* @param state the state.
Added: felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/handlers.html
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/handlers.html?rev=963383&view=auto
==============================================================================
--- felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/handlers.html (added)
+++ felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/handlers.html Mon Jul 12 17:40:19 2010
@@ -0,0 +1,47 @@
+<script type="text/javascript" src="${pluginRoot}/res/ui/handler.js"></script>
+
+
+<!-- status line -->
+<p class="statline"> </p>
+
+<!-- top header -->
+<form method="post" enctype="multipart/form-data" action="">
+ <div class="ui-widget-header ui-corner-top buttonGroup">
+ <button class="instancesButton" type="button">Instances</button>
+ <button class="factoriesButton" type="button">Factories</button>
+ <button class="handlersButton" type="button">Handlers</button>
+ </div>
+</form>
+
+<table id="plugin_table" class="tablesorter nicetable noauto">
+ <thead>
+ <tr>
+ <th class="col_Name">Handler Name</th>
+ <th class="col_Type">Handler Type</th>
+ <th class="col_Bundle">Bundle</th>
+ <th class="col_State">State</th>
+ <th class="col_Missing">Missing Handlers</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr><!-- template -->
+ <td class="name"> </td>
+ <td class="type"> </td>
+ <td class="bundle"> </td>
+ <td class="state"> </td>
+ <td class="missing"> </td>
+ </tr>
+ </tbody>
+</table>
+
+<!-- bottom header -->
+<form method="post" enctype="multipart/form-data" action="">
+ <div class="ui-widget-header ui-corner-bottom buttonGroup">
+ <button class="instancesButton" type="button">Instances</button>
+ <button class="factoriesButton" type="button">Factories</button>
+ <button class="handlersButton" type="button">Handlers</button>
+ </div>
+</form>
+
+<!-- status line -->
+<p class="statline"> </p>
Modified: felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/factory.js
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/factory.js?rev=963383&r1=963382&r2=963383&view=diff
==============================================================================
--- felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/factory.js (original)
+++ felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/factory.js Mon Jul 12 17:40:19 2010
@@ -57,7 +57,7 @@ function loadInstancesData() {
}
function loadHandlersData() {
- console.log("Load handlers data");
+ window.location=window.location.pathname + "?view=handlers"
}
var tableBody = false;
Copied: felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/handler.js (from r963381, felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/factory.js)
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/handler.js?p2=felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/handler.js&p1=felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/factory.js&r1=963381&r2=963383&rev=963383&view=diff
==============================================================================
--- felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/factory.js (original)
+++ felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/handler.js Mon Jul 12 17:40:19 2010
@@ -14,50 +14,57 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-function renderFactoriesData(factories) {
- $(".statline").html(getFactoriesStatLine(factories));
+function renderHandlersData(handlers) {
+ $(".statline").html(getHandlersStatLine(handlers));
tableBody.empty();
- for ( var idx in factories.data ) {
- factoriesEntry( factories.data[idx] );
+ for ( var idx in handlers.data ) {
+ handlersEntry( handlers.data[idx] );
}
$("#plugin_table").trigger("update");
}
-function getFactoriesStatLine(factories) {
- return factories.count + " factories in total, "
- + factories.valid_count + " valid factories, "
- + factories.invalid_count + " invalid factories.";
+function getHandlersStatLine(handlers) {
+ return handlers.count + " handlers in total, "
+ + handlers.valid_count + " valid handlers, "
+ + handlers.invalid_count + " invalid handlers.";
}
-function factoriesEntry(factory) {
- var name = factory.name;
- var state = factory.state;
- var bundle = factory.bundle;
+function handlersEntry(handler) {
+ var name = handler.name;
+ var state = handler.state;
+ var bundle = handler.bundle;
+ var type = handler.type;
- console.log("Create entry : " + factory);
+ console.log("Create entry : " + handler);
- var _ = tableEntryTemplate.clone().appendTo(tableBody).attr('id', 'factory-' + factory.name);
+ var _ = tableEntryTemplate.clone().appendTo(tableBody).attr('id', 'handler-' + handler.name);
- _.find('td.name').html('<a href="' + window.location.pathname + '/factories/' + name + '">' + name + '</a>');
+ _.find('td.name').text(name);
+ _.find('td.type').text(type);
_.find('td.bundle').text(bundle);
_.find('td.state').text(state);
+ if (handler.missing) {
+ _.find('td.missing').html(handler.missing);
+ } else {
+ _.find('td.missing').html('<i>No missing handlers</i>');
+ }
+
}
-function loadFactoriesData() {
- console.log("Load factories data");
- $.get(pluginRoot + "/factories.json", null, function(data) {
- renderFactoriesData(data);
+function loadHandlersData() {
+ console.log("Load handlers data");
+ $.get(pluginRoot + "/handlers.json", null, function(data) {
+ renderHandlersData(data);
}, "json");
}
function loadInstancesData() {
- console.log("Go to instances");
window.location=window.location.pathname + "?view=instances"
}
-function loadHandlersData() {
- console.log("Load handlers data");
+function loadFactoriesData() {
+ window.location=window.location.pathname + "?view=factories"
}
var tableBody = false;
@@ -67,7 +74,7 @@ $(document).ready(function(){
tableBody = $('#plugin_table tbody');
tableEntryTemplate = tableBody.find('tr').clone();
- loadFactoriesData();
+ loadHandlersData();
$(".instancesButton").click(loadInstancesData);
$(".factoriesButton").click(loadFactoriesData);
Modified: felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/ipojo.js
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/ipojo.js?rev=963383&r1=963382&r2=963383&view=diff
==============================================================================
--- felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/ipojo.js (original)
+++ felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/ipojo.js Mon Jul 12 17:40:19 2010
@@ -54,7 +54,7 @@ function loadFactoriesData() {
}
function loadHandlersData() {
- console.log("Load handlers data");
+ window.location=window.location.pathname + "?view=handlers"
}
var tableBody = false;