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 2013/02/27 16:59:44 UTC
svn commit: r1450821 [4/5] - in /felix/trunk/ipojo/handler/jmx: ./ doc/
jmx-handler-it/ jmx-handler-it/src/ jmx-handler-it/src/it/
jmx-handler-it/src/it/jmx-it/ jmx-handler-it/src/it/jmx-it/src/
jmx-handler-it/src/it/jmx-it/src/main/ jmx-handler-it/src...
Added: felix/trunk/ipojo/handler/jmx/jmx-handler/doc/ipojo-jmx-handler_files/shCore.js
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/jmx/jmx-handler/doc/ipojo-jmx-handler_files/shCore.js?rev=1450821&view=auto
==============================================================================
--- felix/trunk/ipojo/handler/jmx/jmx-handler/doc/ipojo-jmx-handler_files/shCore.js (added)
+++ felix/trunk/ipojo/handler/jmx/jmx-handler/doc/ipojo-jmx-handler_files/shCore.js Wed Feb 27 15:59:42 2013
@@ -0,0 +1,622 @@
+/**
+ * Code Syntax Highlighter.
+ * Version 1.3.0
+ * Copyright (C) 2004 Alex Gorbatchev.
+ * http://www.dreamprojections.com/syntaxhighlighter/
+ *
+ * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+//
+// create namespaces
+//
+var dp = {
+ sh : // dp.sh
+ {
+ Utils : {}, // dp.sh.Utils
+ Brushes : {}, // dp.sh.Brushes
+ Strings : {},
+ Version : '1.3.0'
+ }
+};
+
+dp.sh.Strings = {
+ AboutDialog : '<html><head><title>About...</title></head><body class="dp-about"><table cellspacing="0"><tr><td class="copy"><p class="title">dp.SyntaxHighlighter</div><div class="para">Version: {V}</p><p><a href="http://www.dreamprojections.com/syntaxhighlighter/?ref=about" target="_blank">http://www.dreamprojections.com/SyntaxHighlighter</a></p>©2004-2005 Alex Gorbatchev. All right reserved.</td></tr><tr><td class="footer"><input type="button" class="close" value="OK" onClick="window.close()"/></td></tr></table></body></html>',
+
+ // tools
+ ExpandCode : '+ expand code',
+ ViewPlain : 'view plain',
+ Print : 'print',
+ CopyToClipboard : 'copy to clipboard',
+ About : '?',
+
+ CopiedToClipboard : 'The code is in your clipboard now.'
+};
+
+dp.SyntaxHighlighter = dp.sh;
+
+//
+// Dialog and toolbar functions
+//
+
+dp.sh.Utils.Expand = function(sender)
+{
+ var table = sender;
+ var span = sender;
+
+ // find the span in which the text label and pipe contained so we can hide it
+ while(span != null && span.tagName != 'SPAN')
+ span = span.parentNode;
+
+ // find the table
+ while(table != null && table.tagName != 'TABLE')
+ table = table.parentNode;
+
+ // remove the 'expand code' button
+ span.parentNode.removeChild(span);
+
+ table.tBodies[0].className = 'show';
+ table.parentNode.style.height = '100%'; // containing div isn't getting updated properly when the TBODY is shown
+}
+
+// opens a new windows and puts the original unformatted source code inside.
+dp.sh.Utils.ViewSource = function(sender)
+{
+ var code = sender.parentNode.originalCode;
+ var wnd = window.open('', '_blank', 'width=750, height=400, location=0, resizable=1, menubar=0, scrollbars=1');
+
+ code = code.replace(/</g, '<');
+
+ wnd.document.write('<pre>' + code + '</pre>');
+ wnd.document.close();
+}
+
+// copies the original source code in to the clipboard (IE only)
+dp.sh.Utils.ToClipboard = function(sender)
+{
+ var code = sender.parentNode.originalCode;
+
+ // This works only for IE. There's a way to make it work with Mozilla as well,
+ // but it requires security settings changed on the client, which isn't by
+ // default, so 99% of users won't have it working anyways.
+ if(window.clipboardData)
+ {
+ window.clipboardData.setData('text', code);
+
+ alert(dp.sh.Strings.CopiedToClipboard);
+ }
+}
+
+// creates an invisible iframe, puts the original source code inside and prints it
+dp.sh.Utils.PrintSource = function(sender)
+{
+ var td = sender.parentNode;
+ var code = td.processedCode;
+ var iframe = document.createElement('IFRAME');
+ var doc = null;
+ var wnd =
+
+ // this hides the iframe
+ iframe.style.cssText = 'position:absolute; width:0px; height:0px; left:-5px; top:-5px;';
+
+ td.appendChild(iframe);
+
+ doc = iframe.contentWindow.document;
+ code = code.replace(/</g, '<');
+
+ doc.open();
+ doc.write('<pre>' + code + '</pre>');
+ doc.close();
+
+ iframe.contentWindow.focus();
+ iframe.contentWindow.print();
+
+ td.removeChild(iframe);
+}
+
+dp.sh.Utils.About = function()
+{
+ var wnd = window.open('', '_blank', 'dialog,width=320,height=150,scrollbars=0');
+ var doc = wnd.document;
+
+ var styles = document.getElementsByTagName('style');
+ var links = document.getElementsByTagName('link');
+
+ doc.write(dp.sh.Strings.AboutDialog.replace('{V}', dp.sh.Version));
+
+ // copy over ALL the styles from the parent page
+ for(var i = 0; i < styles.length; i++)
+ doc.write('<style>' + styles[i].innerHTML + '</style>');
+
+ for(var i = 0; i < links.length; i++)
+ if(links[i].rel.toLowerCase() == 'stylesheet')
+ doc.write('<link type="text/css" rel="stylesheet" href="' + links[i].href + '"></link>');
+
+ doc.close();
+ wnd.focus();
+}
+
+//
+// Match object
+//
+dp.sh.Match = function(value, index, css)
+{
+ this.value = value;
+ this.index = index;
+ this.length = value.length;
+ this.css = css;
+}
+
+//
+// Highlighter object
+//
+dp.sh.Highlighter = function()
+{
+ this.addGutter = true;
+ this.addControls = true;
+ this.collapse = false;
+ this.tabsToSpaces = true;
+}
+
+// static callback for the match sorting
+dp.sh.Highlighter.SortCallback = function(m1, m2)
+{
+ // sort matches by index first
+ if(m1.index < m2.index)
+ return -1;
+ else if(m1.index > m2.index)
+ return 1;
+ else
+ {
+ // if index is the same, sort by length
+ if(m1.length < m2.length)
+ return -1;
+ else if(m1.length > m2.length)
+ return 1;
+ }
+ return 0;
+}
+
+// gets a list of all matches for a given regular expression
+dp.sh.Highlighter.prototype.GetMatches = function(regex, css)
+{
+ var index = 0;
+ var match = null;
+
+ while((match = regex.exec(this.code)) != null)
+ {
+ this.matches[this.matches.length] = new dp.sh.Match(match[0], match.index, css);
+ }
+}
+
+dp.sh.Highlighter.prototype.AddBit = function(str, css)
+{
+ var span = document.createElement('span');
+
+ str = str.replace(/&/g, '&');
+ str = str.replace(/ /g, ' ');
+ str = str.replace(/</g, '<');
+ str = str.replace(/\n/gm, ' <br>');
+
+ // when adding a piece of code, check to see if it has line breaks in it
+ // and if it does, wrap individual line breaks with span tags
+ if(css != null)
+ {
+ var regex = new RegExp('<br>', 'gi');
+
+ if(regex.test(str))
+ {
+ var lines = str.split(' <br>');
+
+ str = '';
+
+ for(var i = 0; i < lines.length; i++)
+ {
+ span = document.createElement('SPAN');
+ span.className = css;
+ span.innerHTML = lines[i];
+
+ this.div.appendChild(span);
+
+ // don't add a <BR> for the last line
+ if(i + 1 < lines.length)
+ this.div.appendChild(document.createElement('BR'));
+ }
+ }
+ else
+ {
+ span.className = css;
+ span.innerHTML = str;
+ this.div.appendChild(span);
+ }
+ }
+ else
+ {
+ span.innerHTML = str;
+ this.div.appendChild(span);
+ }
+}
+
+// checks if one match is inside any other match
+dp.sh.Highlighter.prototype.IsInside = function(match)
+{
+ if(match == null || match.length == 0)
+ return;
+
+ for(var i = 0; i < this.matches.length; i++)
+ {
+ var c = this.matches[i];
+
+ if(c == null)
+ continue;
+
+ if((match.index > c.index) && (match.index <= c.index + c.length))
+ return true;
+ }
+
+ return false;
+}
+
+dp.sh.Highlighter.prototype.ProcessRegexList = function()
+{
+ for(var i = 0; i < this.regexList.length; i++)
+ this.GetMatches(this.regexList[i].regex, this.regexList[i].css);
+}
+
+dp.sh.Highlighter.prototype.ProcessSmartTabs = function(code)
+{
+ var lines = code.split('\n');
+ var result = '';
+ var tabSize = 4;
+ var tab = '\t';
+
+ // This function inserts specified amount of spaces in the string
+ // where a tab is while removing that given tab.
+ function InsertSpaces(line, pos, count)
+ {
+ var left = line.substr(0, pos);
+ var right = line.substr(pos + 1, line.length); // pos + 1 will get rid of the tab
+ var spaces = '';
+
+ for(var i = 0; i < count; i++)
+ spaces += ' ';
+
+ return left + spaces + right;
+ }
+
+ // This function process one line for 'smart tabs'
+ function ProcessLine(line, tabSize)
+ {
+ if(line.indexOf(tab) == -1)
+ return line;
+
+ var pos = 0;
+
+ while((pos = line.indexOf(tab)) != -1)
+ {
+ // This is pretty much all there is to the 'smart tabs' logic.
+ // Based on the position within the line and size of a tab,
+ // calculate the amount of spaces we need to insert.
+ var spaces = tabSize - pos % tabSize;
+
+ line = InsertSpaces(line, pos, spaces);
+ }
+
+ return line;
+ }
+
+ // Go through all the lines and do the 'smart tabs' magic.
+ for(var i = 0; i < lines.length; i++)
+ result += ProcessLine(lines[i], tabSize) + '\n';
+
+ return result;
+}
+
+dp.sh.Highlighter.prototype.SwitchToTable = function()
+{
+ // thanks to Lachlan Donald from SitePoint.com for this <br/> tag fix.
+ var html = this.div.innerHTML.replace(/<(br)\/?>/gi, '\n');
+ var lines = html.split('\n');
+ var row = null;
+ var cell = null;
+ var tBody = null;
+ var html = '';
+ var pipe = ' | ';
+
+ // creates an anchor to a utility
+ function UtilHref(util, text)
+ {
+ return '<a href="#" onclick="dp.sh.Utils.' + util + '(this); return false;">' + text + '</a>';
+ }
+
+ tBody = document.createElement('TBODY'); // can be created and all others go to tBodies collection.
+
+ this.table.appendChild(tBody);
+
+ if(this.addGutter == true)
+ {
+ row = tBody.insertRow(-1);
+ cell = row.insertCell(-1);
+ cell.className = 'tools-corner';
+ }
+
+ if(this.addControls == true)
+ {
+ var tHead = document.createElement('THEAD'); // controls will be placed in here
+ this.table.appendChild(tHead);
+
+ row = tHead.insertRow(-1);
+
+ // add corner if there's a gutter
+ if(this.addGutter == true)
+ {
+ cell = row.insertCell(-1);
+ cell.className = 'tools-corner';
+ }
+
+ cell = row.insertCell(-1);
+
+ // preserve some variables for the controls
+ cell.originalCode = this.originalCode;
+ cell.processedCode = this.code;
+ cell.className = 'tools';
+
+ if(this.collapse == true)
+ {
+ tBody.className = 'hide';
+ cell.innerHTML += '<span><b>' + UtilHref('Expand', dp.sh.Strings.ExpandCode) + '</b>' + pipe + '</span>';
+ }
+
+ cell.innerHTML += UtilHref('ViewSource', dp.sh.Strings.ViewPlain) + pipe + UtilHref('PrintSource', dp.sh.Strings.Print);
+
+ // IE has this clipboard object which is easy enough to use
+ if(window.clipboardData)
+ cell.innerHTML += pipe + UtilHref('ToClipboard', dp.sh.Strings.CopyToClipboard);
+
+ cell.innerHTML += pipe + UtilHref('About', dp.sh.Strings.About);
+ }
+
+ for(var i = 0, lineIndex = this.firstLine; i < lines.length - 1; i++, lineIndex++)
+ {
+ row = tBody.insertRow(-1);
+
+ if(this.addGutter == true)
+ {
+ cell = row.insertCell(-1);
+ cell.className = 'gutter';
+ cell.innerHTML = lineIndex;
+ }
+
+ cell = row.insertCell(-1);
+ cell.className = 'line' + (i % 2 + 1); // uses .line1 and .line2 css styles for alternating lines
+ cell.innerHTML = lines[i];
+ }
+
+ this.div.innerHTML = '';
+}
+
+dp.sh.Highlighter.prototype.Highlight = function(code)
+{
+ function Trim(str)
+ {
+ return str.replace(/^\s*(.*?)[\s\n]*$/g, '$1');
+ }
+
+ function Chop(str)
+ {
+ return str.replace(/\n*$/, '').replace(/^\n*/, '');
+ }
+
+ function Unindent(str)
+ {
+ var lines = str.split('\n');
+ var indents = new Array();
+ var regex = new RegExp('^\\s*', 'g');
+ var min = 1000;
+
+ // go through every line and check for common number of indents
+ for(var i = 0; i < lines.length && min > 0; i++)
+ {
+ if(Trim(lines[i]).length == 0)
+ continue;
+
+ var matches = regex.exec(lines[i]);
+
+ if(matches != null && matches.length > 0)
+ min = Math.min(matches[0].length, min);
+ }
+
+ // trim minimum common number of white space from the begining of every line
+ if(min > 0)
+ for(var i = 0; i < lines.length; i++)
+ lines[i] = lines[i].substr(min);
+
+ return lines.join('\n');
+ }
+
+ // This function returns a portions of the string from pos1 to pos2 inclusive
+ function Copy(string, pos1, pos2)
+ {
+ return string.substr(pos1, pos2 - pos1);
+ }
+
+ var pos = 0;
+
+ this.originalCode = code;
+ this.code = Chop(Unindent(code));
+ this.div = document.createElement('DIV');
+ this.table = document.createElement('TABLE');
+ this.matches = new Array();
+
+ if(this.CssClass != null)
+ this.table.className = this.CssClass;
+
+ // replace tabs with spaces
+ if(this.tabsToSpaces == true)
+ this.code = this.ProcessSmartTabs(this.code);
+
+ this.table.border = 0;
+ this.table.cellSpacing = 0;
+ this.table.cellPadding = 0;
+
+ this.ProcessRegexList();
+
+ // if no matches found, add entire code as plain text
+ if(this.matches.length == 0)
+ {
+ this.AddBit(this.code, null);
+ this.SwitchToTable();
+ return;
+ }
+
+ // sort the matches
+ this.matches = this.matches.sort(dp.sh.Highlighter.SortCallback);
+
+ // The following loop checks to see if any of the matches are inside
+ // of other matches. This process would get rid of highligting strings
+ // inside comments, keywords inside strings and so on.
+ for(var i = 0; i < this.matches.length; i++)
+ if(this.IsInside(this.matches[i]))
+ this.matches[i] = null;
+
+ // Finally, go through the final list of matches and pull the all
+ // together adding everything in between that isn't a match.
+ for(var i = 0; i < this.matches.length; i++)
+ {
+ var match = this.matches[i];
+
+ if(match == null || match.length == 0)
+ continue;
+
+ this.AddBit(Copy(this.code, pos, match.index), null);
+ this.AddBit(match.value, match.css);
+
+ pos = match.index + match.length;
+ }
+
+ this.AddBit(this.code.substr(pos), null);
+
+ this.SwitchToTable();
+}
+
+dp.sh.Highlighter.prototype.GetKeywords = function(str)
+{
+ return '\\b' + str.replace(/ /g, '\\b|\\b') + '\\b';
+}
+
+// highlightes all elements identified by name and gets source code from specified property
+dp.sh.HighlightAll = function(name, showGutter /* optional */, showControls /* optional */, collapseAll /* optional */, firstLine /* optional */)
+{
+ function FindValue()
+ {
+ var a = arguments;
+
+ for(var i = 0; i < a.length; i++)
+ {
+ if(a[i] == null)
+ continue;
+
+ if(typeof(a[i]) == 'string' && a[i] != '')
+ return a[i] + '';
+
+ if(typeof(a[i]) == 'object' && a[i].value != '')
+ return a[i].value + '';
+ }
+
+ return null;
+ }
+
+ function IsOptionSet(value, list)
+ {
+ for(var i = 0; i < list.length; i++)
+ if(list[i] == value)
+ return true;
+
+ return false;
+ }
+
+ function GetOptionValue(name, list, defaultValue)
+ {
+ var regex = new RegExp('^' + name + '\\[(\\w+)\\]$', 'gi');
+ var matches = null;
+
+ for(var i = 0; i < list.length; i++)
+ if((matches = regex.exec(list[i])) != null)
+ return matches[1];
+
+ return defaultValue;
+ }
+
+ var elements = document.getElementsByName(name);
+ var highlighter = null;
+ var registered = new Object();
+ var propertyName = 'value';
+
+ // if no code blocks found, leave
+ if(elements == null)
+ return;
+
+ // register all brushes
+ for(var brush in dp.sh.Brushes)
+ {
+ var aliases = dp.sh.Brushes[brush].Aliases;
+
+ if(aliases == null)
+ continue;
+
+ for(var i = 0; i < aliases.length; i++)
+ registered[aliases[i]] = brush;
+ }
+
+ for(var i = 0; i < elements.length; i++)
+ {
+ var element = elements[i];
+ var options = FindValue(
+ element.attributes['class'], element.className,
+ element.attributes['language'], element.language
+ );
+ var language = '';
+
+ if(options == null)
+ continue;
+
+ options = options.split(':');
+
+ language = options[0].toLowerCase();
+
+ if(registered[language] == null)
+ continue;
+
+ // instantiate a brush
+ highlighter = new dp.sh.Brushes[registered[language]]();
+
+ // hide the original element
+ element.style.display = 'none';
+
+ highlighter.addGutter = (showGutter == null) ? !IsOptionSet('nogutter', options) : showGutter;
+ highlighter.addControls = (showControls == null) ? !IsOptionSet('nocontrols', options) : showControls;
+ highlighter.collapse = (collapseAll == null) ? IsOptionSet('collapse', options) : collapseAll;
+
+ // first line idea comes from Andrew Collington, thanks!
+ highlighter.firstLine = (firstLine == null) ? parseInt(GetOptionValue('firstline', options, 1)) : firstLine;
+
+ highlighter.Highlight(element[propertyName]);
+
+ // place the result table inside a div
+ var div = document.createElement('DIV');
+
+ div.className = 'dp-highlighter';
+ div.appendChild(highlighter.table);
+
+ element.parentNode.insertBefore(div, element);
+ }
+}
Added: felix/trunk/ipojo/handler/jmx/jmx-handler/doc/ipojo-jmx-handler_files/site.css
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/jmx/jmx-handler/doc/ipojo-jmx-handler_files/site.css?rev=1450821&view=auto
==============================================================================
--- felix/trunk/ipojo/handler/jmx/jmx-handler/doc/ipojo-jmx-handler_files/site.css (added)
+++ felix/trunk/ipojo/handler/jmx/jmx-handler/doc/ipojo-jmx-handler_files/site.css Wed Feb 27 15:59:42 2013
@@ -0,0 +1,25 @@
+/* @override http://felix.apache.org/site/media.data/site.css */
+
+body { background-color: #ffffff; color: #3b3b3b; font-family: Tahoma, Arial, sans-serif; font-size: 10pt; line-height: 140% }
+h1, h2, h3, h4, h5, h6 { font-weight: normal; color: #000000; line-height: 100%; margin-top: 0px}
+h1 { font-size: 200% }
+h2 { font-size: 175% }
+h3 { font-size: 150% }
+h4 { font-size: 140% }
+h5 { font-size: 130% }
+h6 { font-size: 120% }
+a { color: #1980af }
+a:visited { color: #1980af }
+a:hover { color: #1faae9 }
+.title { position: absolute; left: 1px; right: 1px; top:25px; height: 81px; background: url(http://felix.apache.org/site/media.data/gradient.png) repeat-x; background-position: bottom; }
+.logo { position: absolute; width: 15em; height: 81px; text-align: center; }
+.header { text-align: right; margin-right: 20pt; margin-top: 30pt;}
+.menu { border-top: 10px solid #f9bb00; position: absolute; top: 107px; left: 1px; width: 15em; bottom: 0px; padding: 0px; background-color: #fcfcfc }
+.menu ul { background-color: #fdf5d9; list-style: none; padding-left: 4em; margin-top: 0px; padding-top: 2em; padding-bottom: 2em; margin-left: 0px; color: #4a4a43}
+.menu a { text-decoration: none; color: #4a4a43 }
+.main { position: absolute; border-top: 10px solid #cde0ea; top: 107px; left: 15em; right: 1px; margin-left: 2px; padding-right: 4em; padding-left: 1em; padding-top: 1em;}
+.code { background-color: #eeeeee; border: solid 1px black; padding: 0.5em }
+.code-keyword { color: #880000 }
+.code-quote { color: #008800 }
+.code-object { color: #0000dd }
+.code-java { margin: 0em }
\ No newline at end of file
Added: felix/trunk/ipojo/handler/jmx/jmx-handler/doc/ipojo-jmx-handler_files/superfish.js
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/jmx/jmx-handler/doc/ipojo-jmx-handler_files/superfish.js?rev=1450821&view=auto
==============================================================================
--- felix/trunk/ipojo/handler/jmx/jmx-handler/doc/ipojo-jmx-handler_files/superfish.js (added)
+++ felix/trunk/ipojo/handler/jmx/jmx-handler/doc/ipojo-jmx-handler_files/superfish.js Wed Feb 27 15:59:42 2013
@@ -0,0 +1,121 @@
+
+/*
+ * Superfish v1.4.8 - jQuery menu widget
+ * Copyright (c) 2008 Joel Birch
+ *
+ * Dual licensed under the MIT and GPL licenses:
+ * http://www.opensource.org/licenses/mit-license.php
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
+ */
+
+;(function($){
+ $.fn.superfish = function(op){
+
+ var sf = $.fn.superfish,
+ c = sf.c,
+ $arrow = $(['<span class="',c.arrowClass,'"> »</span>'].join('')),
+ over = function(){
+ var $$ = $(this), menu = getMenu($$);
+ clearTimeout(menu.sfTimer);
+ $$.showSuperfishUl().siblings().hideSuperfishUl();
+ },
+ out = function(){
+ var $$ = $(this), menu = getMenu($$), o = sf.op;
+ clearTimeout(menu.sfTimer);
+ menu.sfTimer=setTimeout(function(){
+ o.retainPath=($.inArray($$[0],o.$path)>-1);
+ $$.hideSuperfishUl();
+ if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);}
+ },o.delay);
+ },
+ getMenu = function($menu){
+ var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0];
+ sf.op = sf.o[menu.serial];
+ return menu;
+ },
+ addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); };
+
+ return this.each(function() {
+ var s = this.serial = sf.o.length;
+ var o = $.extend({},sf.defaults,op);
+ o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){
+ $(this).addClass([o.hoverClass,c.bcClass].join(' '))
+ .filter('li:has(ul)').removeClass(o.pathClass);
+ });
+ sf.o[s] = sf.op = o;
+
+ $('li:has(ul)',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() {
+ if (o.autoArrows) addArrow( $('>a:first-child',this) );
+ })
+ .not('.'+c.bcClass)
+ .hideSuperfishUl();
+
+ var $a = $('a',this);
+ $a.each(function(i){
+ var $li = $a.eq(i).parents('li');
+ $a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);});
+ });
+ o.onInit.call(this);
+
+ }).each(function() {
+ var menuClasses = [c.menuClass];
+ if (sf.op.dropShadows && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);
+ $(this).addClass(menuClasses.join(' '));
+ });
+ };
+
+ var sf = $.fn.superfish;
+ sf.o = [];
+ sf.op = {};
+ sf.IE7fix = function(){
+ var o = sf.op;
+ if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined)
+ this.toggleClass(sf.c.shadowClass+'-off');
+ };
+ sf.c = {
+ bcClass : 'sf-breadcrumb',
+ menuClass : 'sf-js-enabled',
+ anchorClass : 'sf-with-ul',
+ arrowClass : 'sf-sub-indicator',
+ shadowClass : 'sf-shadow'
+ };
+ sf.defaults = {
+ hoverClass : 'sfHover',
+ pathClass : 'overideThisToUse',
+ pathLevels : 1,
+ delay : 800,
+ animation : {opacity:'show'},
+ speed : 'normal',
+ autoArrows : true,
+ dropShadows : true,
+ disableHI : false, // true disables hoverIntent detection
+ onInit : function(){}, // callback functions
+ onBeforeShow: function(){},
+ onShow : function(){},
+ onHide : function(){}
+ };
+ $.fn.extend({
+ hideSuperfishUl : function(){
+ var o = sf.op,
+ not = (o.retainPath===true) ? o.$path : '';
+ o.retainPath = false;
+ var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass)
+ .find('>ul').hide().css('visibility','hidden');
+ o.onHide.call($ul);
+ return this;
+ },
+ showSuperfishUl : function(){
+ var o = sf.op,
+ sh = sf.c.shadowClass+'-off',
+ $ul = this.addClass(o.hoverClass)
+ .find('>ul:hidden').css('visibility','visible');
+ sf.IE7fix.call($ul);
+ o.onBeforeShow.call($ul);
+ $ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); });
+ return this;
+ }
+ });
+
+})(jQuery);
Added: felix/trunk/ipojo/handler/jmx/jmx-handler/doc/ipojo-jmx-handler_files/supersubs.js
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/jmx/jmx-handler/doc/ipojo-jmx-handler_files/supersubs.js?rev=1450821&view=auto
==============================================================================
--- felix/trunk/ipojo/handler/jmx/jmx-handler/doc/ipojo-jmx-handler_files/supersubs.js (added)
+++ felix/trunk/ipojo/handler/jmx/jmx-handler/doc/ipojo-jmx-handler_files/supersubs.js Wed Feb 27 15:59:42 2013
@@ -0,0 +1,90 @@
+
+/*
+ * Supersubs v0.2b - jQuery plugin
+ * Copyright (c) 2008 Joel Birch
+ *
+ * Dual licensed under the MIT and GPL licenses:
+ * http://www.opensource.org/licenses/mit-license.php
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ *
+ * This plugin automatically adjusts submenu widths of suckerfish-style menus to that of
+ * their longest list item children. If you use this, please expect bugs and report them
+ * to the jQuery Google Group with the word 'Superfish' in the subject line.
+ *
+ */
+
+;(function($){ // $ will refer to jQuery within this closure
+
+ $.fn.supersubs = function(options){
+ var opts = $.extend({}, $.fn.supersubs.defaults, options);
+ // return original object to support chaining
+ return this.each(function() {
+ // cache selections
+ var $$ = $(this);
+ // support metadata
+ var o = $.meta ? $.extend({}, opts, $$.data()) : opts;
+ // get the font size of menu.
+ // .css('fontSize') returns various results cross-browser, so measure an em dash instead
+ var fontsize = $('<li id="menu-fontsize">—</li>').css({
+ 'padding' : 0,
+ 'position' : 'absolute',
+ 'top' : '-999em',
+ 'width' : 'auto'
+ }).appendTo($$).width(); //clientWidth is faster, but was incorrect here
+ // remove em dash
+ $('#menu-fontsize').remove();
+ // cache all ul elements
+ $ULs = $$.find('ul');
+ // loop through each ul in menu
+ $ULs.each(function(i) {
+ // cache this ul
+ var $ul = $ULs.eq(i);
+ // get all (li) children of this ul
+ var $LIs = $ul.children();
+ // get all anchor grand-children
+ var $As = $LIs.children('a');
+ // force content to one line and save current float property
+ var liFloat = $LIs.css('white-space','nowrap').css('float');
+ // remove width restrictions and floats so elements remain vertically stacked
+ var emWidth = $ul.add($LIs).add($As).css({
+ 'float' : 'none',
+ 'width' : 'auto'
+ })
+ // this ul will now be shrink-wrapped to longest li due to position:absolute
+ // so save its width as ems. Clientwidth is 2 times faster than .width() - thanks Dan Switzer
+ .end().end()[0].clientWidth / fontsize;
+ // add more width to ensure lines don't turn over at certain sizes in various browsers
+ emWidth += o.extraWidth;
+ // restrict to at least minWidth and at most maxWidth
+ if (emWidth > o.maxWidth) { emWidth = o.maxWidth; }
+ else if (emWidth < o.minWidth) { emWidth = o.minWidth; }
+ emWidth += 'em';
+ // set ul to width in ems
+ $ul.css('width',emWidth);
+ // restore li floats to avoid IE bugs
+ // set li width to full width of this ul
+ // revert white-space to normal
+ $LIs.css({
+ 'float' : liFloat,
+ 'width' : '100%',
+ 'white-space' : 'normal'
+ })
+ // update offset position of descendant ul to reflect new width of parent
+ .each(function(){
+ var $childUl = $('>ul',this);
+ var offsetDirection = $childUl.css('left')!==undefined ? 'left' : 'right';
+ $childUl.css(offsetDirection,emWidth);
+ });
+ });
+
+ });
+ };
+ // expose defaults
+ $.fn.supersubs.defaults = {
+ minWidth : 9, // requires em unit.
+ maxWidth : 25, // requires em unit.
+ extraWidth : 0 // extra width can ensure lines don't sometimes turn over due to slight browser differences in how they round-off values
+ };
+
+})(jQuery); // plugin code ends
Added: felix/trunk/ipojo/handler/jmx/jmx-handler/metadata.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/jmx/jmx-handler/metadata.xml?rev=1450821&view=auto
==============================================================================
--- felix/trunk/ipojo/handler/jmx/jmx-handler/metadata.xml (added)
+++ felix/trunk/ipojo/handler/jmx/jmx-handler/metadata.xml Wed Feb 27 15:59:42 2013
@@ -0,0 +1,22 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<ipojo>
+<handler classname="org.apache.felix.ipojo.handlers.jmx.MBeanHandler" name="config" namespace="org.apache.felix.ipojo.handlers.jmx" />
+<handler classname="org.apache.felix.ipojo.handlers.jmx.MBeanHandler" name="JMXBean" namespace="org.apache.felix.ipojo.handlers.jmx" />
+</ipojo>
\ No newline at end of file
Added: felix/trunk/ipojo/handler/jmx/jmx-handler/obr.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/jmx/jmx-handler/obr.xml?rev=1450821&view=auto
==============================================================================
--- felix/trunk/ipojo/handler/jmx/jmx-handler/obr.xml (added)
+++ felix/trunk/ipojo/handler/jmx/jmx-handler/obr.xml Wed Feb 27 15:59:42 2013
@@ -0,0 +1,30 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<obr>
+ <capability name="ipojo.handler">
+ <p n="name" v="config"/>
+ <p n="namespace" v="org.apache.felix.ipojo.handlers.jmx"/>
+ <p n="type" v="primitive"/>
+ </capability>
+ <capability name="ipojo.handler">
+ <p n="name" v="JMXBean"/>
+ <p n="namespace" v="org.apache.felix.ipojo.handlers.jmx"/>
+ <p n="type" v="primitive"/>
+ </capability>
+</obr>
\ No newline at end of file
Added: felix/trunk/ipojo/handler/jmx/jmx-handler/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/jmx/jmx-handler/pom.xml?rev=1450821&view=auto
==============================================================================
--- felix/trunk/ipojo/handler/jmx/jmx-handler/pom.xml (added)
+++ felix/trunk/ipojo/handler/jmx/jmx-handler/pom.xml Wed Feb 27 15:59:42 2013
@@ -0,0 +1,125 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>felix-parent</artifactId>
+ <version>1.2.1</version>
+ <relativePath>../../pom/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>bundle</packaging>
+ <name>Apache Felix iPOJO JMX Handler</name>
+ <artifactId>org.apache.felix.ipojo.handler.jmx</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+
+ <description>
+ iPOJO extension to expose instances as MBean inside a MBean Server.
+ </description>
+ <url>http://felix.apache.org/site/ipojo-jmx-handler.html</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.ipojo</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>4.0.0</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <version>1.4.3</version>
+ <configuration>
+ <instructions>
+ <Private-Package> org.apache.felix.ipojo.handlers.jmx
+ </Private-Package>
+ <Bundle-Name>${project.name}</Bundle-Name>
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+ <Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
+ <Bundle-Description> iPOJO JMX Handler </Bundle-Description>
+ <Bundle-DocURL>
+ http://felix.apache.org/site/ipojo-jmx-handler.html
+ </Bundle-DocURL>
+ <Include-Resource>
+ META-INF/LICENSE=LICENSE,
+ META-INF/NOTICE=NOTICE,
+ META-INF/DEPENDENCIES=DEPENDENCIES
+ </Include-Resource>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-ipojo-plugin</artifactId>
+ <version>${project.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>ipojo-bundle</goal>
+ </goals>
+ <configuration>
+ <metadata>metadata.xml</metadata>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>rat-maven-plugin</artifactId>
+ <configuration>
+ <excludeSubProjects>false</excludeSubProjects>
+ <useEclipseDefaultExcludes>true</useEclipseDefaultExcludes>
+ <useMavenDefaultExcludes>true</useMavenDefaultExcludes>
+ <excludes>
+ <param>doc/**/*</param>
+ <param>maven-eclipse.xml</param>
+ <param>.checkstyle</param>
+ <param>.externalToolBuilders/*</param>
+ <param>LICENSE.asm</param>
+ </excludes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <enableRulesSummary>false</enableRulesSummary>
+ <violationSeverity>warning</violationSeverity>
+ <configLocation>http://felix.apache.org/ipojo/dev/checkstyle_ipojo.xml</configLocation>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: felix/trunk/ipojo/handler/jmx/jmx-handler/src/main/java/org/apache/felix/ipojo/handlers/jmx/DynamicMBeanImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/jmx/jmx-handler/src/main/java/org/apache/felix/ipojo/handlers/jmx/DynamicMBeanImpl.java?rev=1450821&view=auto
==============================================================================
--- felix/trunk/ipojo/handler/jmx/jmx-handler/src/main/java/org/apache/felix/ipojo/handlers/jmx/DynamicMBeanImpl.java (added)
+++ felix/trunk/ipojo/handler/jmx/jmx-handler/src/main/java/org/apache/felix/ipojo/handlers/jmx/DynamicMBeanImpl.java Wed Feb 27 15:59:42 2013
@@ -0,0 +1,408 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.handlers.jmx;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.management.Attribute;
+import javax.management.AttributeChangeNotification;
+import javax.management.AttributeList;
+import javax.management.AttributeNotFoundException;
+import javax.management.DynamicMBean;
+import javax.management.InvalidAttributeValueException;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanException;
+import javax.management.MBeanInfo;
+import javax.management.MBeanNotificationInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.Notification;
+import javax.management.NotificationBroadcasterSupport;
+import javax.management.ReflectionException;
+import javax.management.RuntimeOperationsException;
+
+import org.apache.felix.ipojo.InstanceManager;
+import org.apache.felix.ipojo.parser.MethodMetadata;
+import org.apache.felix.ipojo.util.Callback;
+import org.apache.felix.ipojo.util.Logger;
+
+/**
+ * This class implements iPOJO DynamicMBean. it builds the dynamic MBean
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class DynamicMBeanImpl extends NotificationBroadcasterSupport implements
+ DynamicMBean {
+
+ /**
+ * The instance manager. Used to store the InstanceManager instance.
+ */
+ protected final InstanceManager m_instanceManager;
+
+ /**
+ * The JmxConfigDFieldMap. Stors the data extracted from metadata.xml.
+ */
+ private JmxConfigFieldMap m_configMap;
+
+ /**
+ * The MBeanInfo. The class storing the MBean Informations.
+ */
+ private MBeanInfo m_mBeanInfo;
+
+ /**
+ * The class name. Constant storing the name of the class.
+ */
+ private String m_className = this.getClass().getName();
+
+ /**
+ * The sequence number. Used to calculate unique id to notification.
+ */
+ private int m_sequenceNumber;
+
+ /**
+ * Constructor.
+ *
+ * @param properties the data extracted from metadat.xml file
+ * @param instanceManager the InstanceManager instance
+ */
+ public DynamicMBeanImpl(JmxConfigFieldMap properties,
+ InstanceManager instanceManager) {
+ m_configMap = properties;
+ m_instanceManager = instanceManager;
+ this.buildMBeanInfo();
+ }
+
+ /**
+ * Gets the value of the required attribute.
+ *
+ * @param arg0 the name of required attribute
+ * @throws AttributeNotFoundException if the attribute doesn't exist
+ * @throws MBeanException if something bad occures
+ * @throws ReflectionException if something bad occures
+ * @return the object attribute
+ */
+ public Object getAttribute(String arg0) throws AttributeNotFoundException,
+ MBeanException, ReflectionException {
+ PropertyField attribute = m_configMap.getPropertyFromName(arg0);
+
+ if (attribute == null) {
+ throw new AttributeNotFoundException(arg0 + " not found");
+ } else {
+ return attribute.getValue();
+ }
+ }
+
+ /**
+ * Gets values of required attributes.
+ *
+ * @param attributeNames the names of the required attributes
+ * @return return the list of the attribute
+ */
+ public AttributeList getAttributes(String[] attributeNames) {
+
+ if (attributeNames == null) {
+ throw new IllegalArgumentException(
+ "attributeNames[] cannot be null");
+ }
+
+ AttributeList resultList = new AttributeList();
+ for (int i = 0; i < attributeNames.length; i++) {
+ PropertyField propertyField = (PropertyField) m_configMap
+ .getPropertyFromField((String) attributeNames[i]);
+
+ if (propertyField != null) {
+ resultList.add(new Attribute(attributeNames[i], propertyField
+ .getValue()));
+ }
+ }
+ return resultList;
+ }
+
+ /**
+ * Returns the MBean Class builded.
+ *
+ * @return return MBeanInfo class constructed by buildMBeanInfo
+ */
+ public MBeanInfo getMBeanInfo() {
+ return m_mBeanInfo;
+ }
+
+ /**
+ * Invokes the required method on the targeted POJO.
+ *
+ * @param operationName the name of the method called
+ * @param params the parameters given to the method
+ * @param signature the determine which method called
+ * @return the object return by the method
+ * @throws MBeanException if something bad occures
+ * @throws ReflectionException if something bad occures
+ */
+ public Object invoke(String operationName, Object[] params,
+ String[] signature) throws MBeanException, ReflectionException {
+
+ MethodField method = m_configMap.getMethodFromName(operationName,
+ signature);
+ if (method != null) {
+ MethodMetadata methodCall = method.getMethod();
+ Callback mc = new Callback(methodCall, m_instanceManager);
+ try {
+ return mc.call(params);
+ } catch (NoSuchMethodException e) {
+ throw new ReflectionException(e);
+ } catch (IllegalAccessException e) {
+ throw new ReflectionException(e);
+ } catch (InvocationTargetException e) {
+ throw new MBeanException(e);
+ }
+ } else {
+ throw new ReflectionException(new NoSuchMethodException(
+ operationName), "Cannot find the operation " + operationName
+ + " in " + m_className);
+ }
+ }
+
+ /**
+ * Changes specified attribute value.
+ *
+ * @param attribute the attribute with new value to be changed
+ * @throws AttributeNotFoundException if the required attribute was not found
+ * @throws InvalidAttributeValueException if the value is inccorrect type
+ * @throws MBeanException if something bad occures
+ * @throws ReflectionException if something bad occures
+ */
+ public void setAttribute(Attribute attribute)
+ throws AttributeNotFoundException, InvalidAttributeValueException,
+ MBeanException, ReflectionException {
+
+ // Check attribute is not null to avoid NullPointerException later on
+ if (attribute == null) {
+ throw new RuntimeOperationsException(new IllegalArgumentException(
+ "Attribute cannot be null"), "Cannot invoke a setter of "
+ + m_className + " with null attribute");
+ }
+ String name = attribute.getName();
+ Object value = attribute.getValue();
+
+ if (name == null) {
+ throw new RuntimeOperationsException(new IllegalArgumentException(
+ "Attribute name cannot be null"),
+ "Cannot invoke the setter of " + m_className
+ + " with null attribute name");
+ }
+ // Check for a recognized attribute name and call the corresponding
+ // setter
+ //
+
+ PropertyField propertyField = (PropertyField) m_configMap
+ .getPropertyFromName(name);
+ if (propertyField == null) {
+ // unrecognized attribute name:
+ throw new AttributeNotFoundException("Attribute " + name
+ + " not found in " + m_className);
+ }
+ if (!propertyField.isWritable()) {
+ throw new InvalidAttributeValueException("Attribute " + name
+ + " can not be set");
+ }
+
+ if (value == null) {
+ try {
+ m_instanceManager.onSet(null, propertyField.getField(), null);
+ } catch (Exception e) {
+ throw new InvalidAttributeValueException(
+ "Cannot set attribute " + name + " to null");
+ }
+ } else { // if non null value, make sure it is assignable to the
+ // attribute
+// if (true /* TODO type.class.isAssignableFrom(value.getClass()) */) {
+ // propertyField.setValue(value);
+ // setValue(attributeField.getField(),null);
+ m_instanceManager.onSet(null, propertyField.getField(), value);
+// } else {
+// throw new InvalidAttributeValueException(
+// "Cannot set attribute " + name + " to a "
+// + value.getClass().getName()
+// + " object, String expected");
+// }
+ }
+
+ }
+
+ /**
+ * Changes all the attributes value.
+ *
+ * @param attributes the list of attribute value to be changed
+ * @return the list of new attribute
+ */
+ public AttributeList setAttributes(AttributeList attributes) {
+
+ // Check attributes is not null to avoid NullPointerException later on
+ if (attributes == null) {
+ throw new RuntimeOperationsException(new IllegalArgumentException(
+ "AttributeList attributes cannot be null"),
+ "Cannot invoke a setter of " + m_className);
+ }
+ AttributeList resultList = new AttributeList();
+
+ // if attributeNames is empty, nothing more to do
+ if (attributes.isEmpty()) {
+ return resultList;
+ }
+
+ // for each attribute, try to set it and add to the result list if
+ // successful
+ for (Iterator i = attributes.iterator(); i.hasNext();) {
+ Attribute attr = (Attribute) i.next();
+ try {
+ setAttribute(attr);
+ String name = attr.getName();
+ Object value = getAttribute(name);
+ resultList.add(new Attribute(name, value));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ return resultList;
+ }
+
+ /**
+ * Builds the MBean information on initialization. This
+ * value doesn't change further.
+ */
+ private void buildMBeanInfo() {
+
+ // generate infos for attributes
+ MBeanAttributeInfo[] dAttributes = null;
+
+ if (m_configMap == null) {
+ return;
+ }
+
+ String dDescription = m_configMap.getDecription();
+
+ if (m_configMap.getProperties() != null) {
+ List < MBeanAttributeInfo > lAttributes = null;
+ lAttributes = new ArrayList < MBeanAttributeInfo >();
+
+ Iterator < PropertyField > iterator = m_configMap.getProperties()
+ .iterator();
+ while (iterator.hasNext()) {
+ PropertyField propertyField = iterator.next();
+ lAttributes.add(new MBeanAttributeInfo(propertyField.getName(),
+ propertyField.getType(), propertyField.getDescription(),
+ propertyField.isReadable(), propertyField.isWritable(),
+ false));
+ }
+ dAttributes = lAttributes
+ .toArray(new MBeanAttributeInfo[lAttributes.size()]);
+ }
+
+ MBeanOperationInfo[] dOperations = null;
+ if (m_configMap.getMethods() != null) {
+
+ List < MBeanOperationInfo > lOperations = new ArrayList < MBeanOperationInfo >();
+
+ Iterator < MethodField[] > iterator = m_configMap.getMethods()
+ .iterator();
+ while (iterator.hasNext()) {
+ MethodField[] method = iterator.next();
+ for (int i = 0; i < method.length; i++) {
+ lOperations.add(new MBeanOperationInfo(method[i].getName(),
+ method[i].getDescription(), method[i].getParams(),
+ method[i].getReturnType(), MBeanOperationInfo.UNKNOWN));
+ }
+ dOperations = lOperations
+ .toArray(new MBeanOperationInfo[lOperations.size()]);
+ }
+ }
+
+ MBeanNotificationInfo[] dNotification = new MBeanNotificationInfo[0];
+ if (m_configMap.getMethods() != null) {
+
+ List < MBeanNotificationInfo > lNotifications = new ArrayList < MBeanNotificationInfo >();
+
+ Iterator < NotificationField > iterator = m_configMap
+ .getNotifications().iterator();
+ while (iterator.hasNext()) {
+ NotificationField notification = iterator
+ .next();
+ lNotifications.add(notification.getNotificationInfo());
+ }
+ dNotification = lNotifications
+ .toArray(new MBeanNotificationInfo[lNotifications.size()]);
+ }
+
+ m_mBeanInfo = new MBeanInfo(this.m_className, dDescription,
+ dAttributes, null, // No constructor
+ dOperations, dNotification);
+ }
+
+ /**
+ * Gets the notification informations (use by JMX).
+ *
+ * @return the structure which describe the notifications
+ */
+ public MBeanNotificationInfo[] getNotificationInfo() {
+ MBeanNotificationInfo[] dNotification = new MBeanNotificationInfo[0];
+ if (m_configMap.getMethods() != null) {
+
+ List < MBeanNotificationInfo > lNotifications = new ArrayList < MBeanNotificationInfo >();
+
+ Iterator < NotificationField > iterator = m_configMap
+ .getNotifications().iterator();
+ while (iterator.hasNext()) {
+ NotificationField notification = iterator
+ .next();
+ lNotifications.add(notification.getNotificationInfo());
+ }
+ dNotification = lNotifications
+ .toArray(new MBeanNotificationInfo[lNotifications.size()]);
+ }
+ return dNotification;
+ }
+
+ /**
+ * Sends a notification to a subscriber.
+ *
+ * @param msg the msg to send
+ * @param attributeName the name of the attribute
+ * @param attributeType the type of the attribute
+ * @param oldValue the old value of the attribute
+ * @param newValue the new value of the attribute
+ */
+ public void sendNotification(String msg, String attributeName,
+ String attributeType, Object oldValue, Object newValue) {
+
+ long timeStamp = System.currentTimeMillis();
+
+ if ((newValue == null && oldValue == null)
+ || (newValue != null && newValue.equals(oldValue))) {
+ return;
+ }
+ m_sequenceNumber++;
+ Notification notification = new AttributeChangeNotification(this,
+ m_sequenceNumber, timeStamp, msg, attributeName, attributeType,
+ oldValue, newValue);
+ sendNotification(notification);
+ m_instanceManager.getFactory().getLogger().log(Logger.INFO,
+ "Notification sent");
+ }
+}
Added: felix/trunk/ipojo/handler/jmx/jmx-handler/src/main/java/org/apache/felix/ipojo/handlers/jmx/DynamicMBeanWRegisterImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/jmx/jmx-handler/src/main/java/org/apache/felix/ipojo/handlers/jmx/DynamicMBeanWRegisterImpl.java?rev=1450821&view=auto
==============================================================================
--- felix/trunk/ipojo/handler/jmx/jmx-handler/src/main/java/org/apache/felix/ipojo/handlers/jmx/DynamicMBeanWRegisterImpl.java (added)
+++ felix/trunk/ipojo/handler/jmx/jmx-handler/src/main/java/org/apache/felix/ipojo/handlers/jmx/DynamicMBeanWRegisterImpl.java Wed Feb 27 15:59:42 2013
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.handlers.jmx;
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.management.MBeanRegistration;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.felix.ipojo.InstanceManager;
+import org.apache.felix.ipojo.parser.MethodMetadata;
+import org.apache.felix.ipojo.util.Callback;
+
+/**
+ * This class implements a 'wide' iPOJO DynamicMBean that can perform actions
+ * before and after its registration and deregistration.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class DynamicMBeanWRegisterImpl extends DynamicMBeanImpl implements
+ MBeanRegistration {
+
+ /**
+ * The preRegister method of MBeanRegistration interface.
+ */
+ private MethodMetadata m_preRegisterMeth;
+ /**
+ * The postRegister method of MBeanRegistration interface.
+ */
+ private MethodMetadata m_postRegisterMeth;
+ /**
+ * The preDeregister method of MBeanRegistration interface.
+ */
+ private MethodMetadata m_preDeregisterMeth;
+ /**
+ * The postDeregister method of MBeanRegistration interface.
+ */
+ private MethodMetadata m_postDeregisterMeth;
+ /**
+ * The effective name of the MBean.
+ */
+ private ObjectName m_objName;
+
+ /**
+ * Constructs a new DynamicMBeanWRegisterImpl.
+ *
+ * @param properties the data extracted from the metadata.xml
+ * @param instanceManager the instance manager
+ * @param preRegisterMeth the method to call before MBean registration
+ * @param postRegisterMeth the method to call after MBean registration
+ * @param preDeregisterMeth the method to call before MBean deregistration
+ * @param postDeregisterMeth the method to call after MBean registration
+ */
+ public DynamicMBeanWRegisterImpl(JmxConfigFieldMap properties,
+ InstanceManager instanceManager, MethodMetadata preRegisterMeth,
+ MethodMetadata postRegisterMeth, MethodMetadata preDeregisterMeth,
+ MethodMetadata postDeregisterMeth) {
+ super(properties, instanceManager);
+
+ m_preRegisterMeth = preRegisterMeth;
+ m_postRegisterMeth = postRegisterMeth;
+ m_preDeregisterMeth = preDeregisterMeth;
+ m_postDeregisterMeth = postDeregisterMeth;
+ }
+
+ /**
+ * Returns the MBean name used to register it.
+ *
+ * @return the MBean name used to register it.
+ */
+ public ObjectName getObjectName() {
+ return m_objName;
+ }
+
+ /**
+ * This method is executed before the MBean registration.
+ *
+ * @param server the server on which the MBean will be registered
+ * @param name the name of the MBean to expose
+ * @throws Exception This exception will be caught by the MBean server and re-thrown as an MBeanRegistrationException.
+ * @return the name with which the MBean will be registered
+ */
+ public ObjectName preRegister(MBeanServer server, ObjectName name)
+ throws Exception {
+ m_objName = (ObjectName) callMethod(m_preRegisterMeth,
+ MBeanHandler.PRE_REGISTER_METH_NAME, new Object[] { server, name });
+ return m_objName;
+ }
+
+ /**
+ * This method is executed after the MBean registration.
+ *
+ * @param registrationDone indicates whether or not the MBean has been successfully registered in the MBean server.
+ */
+ public void postRegister(Boolean registrationDone) {
+ callMethod(m_postRegisterMeth, MBeanHandler.POST_REGISTER_METH_NAME,
+ new Object[] { registrationDone });
+ }
+
+ /**
+ * This method is before after the MBean deregistration.
+ *
+ * @throws Exception This exception will be caught by the MBean server and re-thrown as an MBeanRegistrationException.
+ */
+ public void preDeregister() throws Exception {
+ callMethod(m_preDeregisterMeth, MBeanHandler.PRE_DEREGISTER_METH_NAME,
+ null);
+ }
+
+ /**
+ * This method is executed after the MBean deregistration.
+ */
+ public void postDeregister() {
+ callMethod(m_postDeregisterMeth,
+ MBeanHandler.POST_DEREGISTER_METH_NAME, null);
+ }
+
+ /**
+ * Private method used to execute a given callback.
+ *
+ * @param methodMetadata the metadata description of the callback
+ * @param methodName the name of the callback
+ * @param params the parameters of the callback
+ * @return the object eventually returned by the callback, or null if nothing's returned
+ */
+ private Object callMethod(MethodMetadata methodMetadata, String methodName,
+ Object[] params) {
+ Callback mc = new Callback(methodMetadata, m_instanceManager);
+ try {
+ if ((params == null) || (params.length == 0)) {
+ return mc.call();
+ } else {
+ return mc.call(params);
+ }
+ } catch (NoSuchMethodException e) {
+ // should never happen : method exists
+ System.err.println("No such method : " + methodName);
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ System.err.println("Illegal Access Exception");
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ System.err.println("Invocation Target Exception");
+ e.printStackTrace();
+ }
+ return null;
+ }
+}
Added: felix/trunk/ipojo/handler/jmx/jmx-handler/src/main/java/org/apache/felix/ipojo/handlers/jmx/JMXHandlerDescription.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/jmx/jmx-handler/src/main/java/org/apache/felix/ipojo/handlers/jmx/JMXHandlerDescription.java?rev=1450821&view=auto
==============================================================================
--- felix/trunk/ipojo/handler/jmx/jmx-handler/src/main/java/org/apache/felix/ipojo/handlers/jmx/JMXHandlerDescription.java (added)
+++ felix/trunk/ipojo/handler/jmx/jmx-handler/src/main/java/org/apache/felix/ipojo/handlers/jmx/JMXHandlerDescription.java Wed Feb 27 15:59:42 2013
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.handlers.jmx;
+
+import org.apache.felix.ipojo.architecture.HandlerDescription;
+import org.apache.felix.ipojo.metadata.Attribute;
+import org.apache.felix.ipojo.metadata.Element;
+
+/**
+ * Description of the JMX handler.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class JMXHandlerDescription extends HandlerDescription {
+
+ /**
+ * The referenced handler.
+ */
+ private MBeanHandler m_handler;
+
+ /**
+ * Constructs a new handler description for the given handler.
+ *
+ * @param handler the handler to describe
+ */
+ public JMXHandlerDescription(MBeanHandler handler) {
+ super(handler);
+ m_handler = handler;
+ }
+
+ /**
+ * Gets handler information.
+ *
+ * @return the handler information.
+ */
+ public Element getHandlerInfo() {
+ Element elem = super.getHandlerInfo();
+ elem.addAttribute(new Attribute("registered", Boolean
+ .toString(m_handler.isRegistered())));
+ elem.addAttribute(new Attribute("objectName", m_handler
+ .getUsedObjectName()));
+ if (m_handler.isUsesMOSGi()) {
+ String foundStr = null;
+
+ if (m_handler.isMOSGiExists()) {
+ foundStr = "found";
+ } else {
+ foundStr = "not_found";
+ }
+ elem.addAttribute(new Attribute("mosgi", foundStr));
+ }
+
+ return elem;
+ }
+}
Added: felix/trunk/ipojo/handler/jmx/jmx-handler/src/main/java/org/apache/felix/ipojo/handlers/jmx/JmxConfigFieldMap.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/jmx/jmx-handler/src/main/java/org/apache/felix/ipojo/handlers/jmx/JmxConfigFieldMap.java?rev=1450821&view=auto
==============================================================================
--- felix/trunk/ipojo/handler/jmx/jmx-handler/src/main/java/org/apache/felix/ipojo/handlers/jmx/JmxConfigFieldMap.java (added)
+++ felix/trunk/ipojo/handler/jmx/jmx-handler/src/main/java/org/apache/felix/ipojo/handlers/jmx/JmxConfigFieldMap.java Wed Feb 27 15:59:42 2013
@@ -0,0 +1,297 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.ipojo.handlers.jmx;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * JmxConfigFieldMap : use to store the informations needed to build the Dynamic
+ * MBean.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class JmxConfigFieldMap {
+
+ /**
+ * The exposed attributes.
+ */
+ private Map < String, PropertyField > m_properties = new HashMap < String, PropertyField >();
+ /**
+ * The exposed methods.
+ */
+ private Map < String, MethodField[] > m_methods = new HashMap < String, MethodField[] >();
+ /**
+ * The allowed notifications.
+ */
+ private Map < String, NotificationField > m_notifications = new HashMap < String, NotificationField >();
+ /**
+ * The description of the Mbean.
+ */
+ private String m_description;
+
+ /**
+ * Constructor.
+ */
+ public JmxConfigFieldMap() {
+
+ }
+
+ /**
+ * Gets the description of the MBean.
+ *
+ * @return the description of the MBean
+ */
+ public String getDecription() {
+ return m_description;
+ }
+
+ /**
+ * Sets the description of the MBean.
+ *
+ * @param description a String which describes the Mbean
+ */
+ public void setDescription(String description) {
+ this.m_description = description;
+ }
+
+ /**
+ * Adds a new attribute exposed in the Mbean.
+ *
+ * @param name the name of the new property
+ * @param propertyField the field which describes the property
+ */
+ public void addPropertyFromName(String name, PropertyField propertyField) {
+ m_properties.put(name, propertyField);
+ }
+
+ /**
+ * Gets all of the properties exposed.
+ *
+ * @return the collection of all properties
+ */
+ public Collection < PropertyField > getProperties() {
+ if (m_properties != null) {
+ return m_properties.values();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Gets the property by the name.
+ *
+ * @param name the name of the required property
+ * @return the field required or null if is not found
+ */
+ public PropertyField getPropertyFromName(String name) {
+ PropertyField prop = m_properties.get(name);
+ return prop;
+ }
+
+ /**
+ * Gets the property by the field.
+ *
+ * @param field the required field
+ * @return the property by the field
+ */
+ public PropertyField getPropertyFromField(String field) {
+ PropertyField property = null;
+ Iterator < PropertyField > it = m_properties.values().iterator();
+ while (it.hasNext()) {
+ PropertyField p = it.next();
+ if (p.getField().compareTo(field) == 0) {
+ if (property != null) {
+ System.err.println("a field already exists");
+ } else {
+ property = p;
+ }
+ }
+ }
+ return property;
+ }
+
+ /**
+ * Adds a new method descriptor from its name.
+ *
+ * @param name the name of the method
+ * @param methodField the description of the method
+ */
+ public void addMethodFromName(String name, MethodField methodField) {
+ MethodField[] mf;
+ if (!m_methods.containsKey(name)) {
+ mf = new MethodField[1];
+ mf[0] = methodField;
+ } else {
+ MethodField[] temp = m_methods.get(name);
+ mf = new MethodField[temp.length + 1];
+ for (int i = 0; i < temp.length; i++) {
+ mf[i] = temp[i];
+ }
+ mf[temp.length] = methodField;
+ }
+ m_methods.put(name, mf);
+ }
+
+ /**
+ * Adds new methods descriptors from one name. (the method must have the same name but different signature).
+ *
+ * @param name the name of the method
+ * @param methodsField the description of the methods
+ */
+ public void addMethodFromName(String name, MethodField[] methodsField) {
+ MethodField[] mf;
+ if (!m_methods.containsKey(name)) {
+ mf = methodsField;
+ } else {
+ MethodField[] temp = m_methods.get(name);
+ mf = new MethodField[temp.length + methodsField.length];
+ for (int i = 0; i < temp.length; i++) {
+ mf[i] = temp[i];
+ }
+ for (int i = 0; i < methodsField.length; i++) {
+ mf[i + temp.length] = methodsField[i];
+ }
+ }
+ m_methods.put(name, mf);
+ }
+
+ /**
+ * Adds a method from name and erases the older if exists.
+ *
+ * @param name the name of the method
+ * @param methodField the method to be added
+ */
+ public void overrideMethodFromName(String name, MethodField methodField) {
+ MethodField[] mf = new MethodField[1];
+ mf[0] = methodField;
+ m_methods.put(name, mf);
+ }
+
+ /**
+ * Add methods from name and erases the olders if exists.
+ *
+ * @param name the name of the method
+ * @param methodsField the array of methods to be added
+ */
+ public void overrideMethodFromName(String name, MethodField[] methodsField) {
+ m_methods.put(name, methodsField);
+ }
+
+ /**
+ * Returns the method(s) with the given name.
+ *
+ * @param name the name of the methods
+ * @return the list of methods with the given name
+ */
+ public MethodField[] getMethodFromName(String name) {
+ MethodField[] prop = m_methods.get(name);
+ return prop;
+ }
+
+ /**
+ * Gets the method with the good signature.
+ *
+ * @param operationName the name of the method requiered
+ * @param signature the required signature
+ * @return the method which the same signature or null if not found
+ */
+ public MethodField getMethodFromName(String operationName,
+ String[] signature) {
+ MethodField[] methods = m_methods.get(operationName);
+ for (int i = 0; i < methods.length; i++) {
+ if (isSameSignature(signature, methods[i].getSignature())) {
+ return methods[i];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Compares two method signature.
+ *
+ * @param sig1 the first signature
+ * @param sig2 the second signature
+ * @return true if the signature are similar false otherwise
+ */
+ private boolean isSameSignature(String[] sig1, String[] sig2) {
+ if (sig1.length != sig2.length) {
+ return false;
+ } else {
+ for (int i = 0; i < sig1.length; i++) {
+ if (!sig1[i].equals(sig2[i])) {
+ return false;
+ }
+ }
+
+ }
+ return true;
+ }
+
+ /**
+ * Returns all methods store.
+ *
+ * @return the collection of methodField[]
+ */
+ public Collection < MethodField[] > getMethods() {
+ if (m_methods != null) {
+ return m_methods.values();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Adds a notification.
+ *
+ * @param name the name of the notification
+ * @param notificationField the field involved with the notification.
+ */
+ public void addNotificationFromName(String name,
+ NotificationField notificationField) {
+ m_notifications.put(name, notificationField);
+ }
+
+ /**
+ * Returns the notification with the given name.
+ *
+ * @param name the name of the notification to return
+ * @return the notification if it exists, {@code null} otherwise
+ */
+ public NotificationField getNotificationFromName(String name) {
+ NotificationField prop = m_notifications.get(name);
+ return prop;
+ }
+
+ /**
+ * Gets all notifications defined.
+ *
+ * @return the collection of NotificationField
+ */
+ public Collection < NotificationField > getNotifications() {
+ if (m_notifications != null) {
+ return m_notifications.values();
+ } else {
+ return null;
+ }
+ }
+}