Author: ldywicki Date: Fri Sep 2 14:09:14 2011 New Revision: 1164539 URL: http://svn.apache.org/viewvc?rev=1164539&view=rev Log: Support for tracking NMR exchanges in ServiceMix plugin. Details page for Exchanges
Added: karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/DetailsPage.java karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/ExchangeActionsPanel.java karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/ExchangeModel.java karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/ITrackingExchangeListener.java karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/TrackNmrPage.java karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/TrackingExchangeListener.java karaf/sandbox/webconsole/trunk/servicemix/src/main/resources/org/apache/karaf/webconsole/servicemix/internal/DetailsPage.html karaf/sandbox/webconsole/trunk/servicemix/src/main/resources/org/apache/karaf/webconsole/servicemix/internal/TrackNmrPage.html karaf/sandbox/webconsole/trunk/servicemix/src/main/resources/org/apache/karaf/webconsole/servicemix/internal/message.css Modified: karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/ServiceMixPage.java karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/navigation/ServiceMixConsoleTabProvider.java karaf/sandbox/webconsole/trunk/servicemix/src/main/resources/OSGI-INF/blueprint/servicemix.xml Added: karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/DetailsPage.java URL: http://svn.apache.org/viewvc/karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/DetailsPage.java?rev=1164539&view=auto ============================================================================== --- karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/DetailsPage.java (added) +++ karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/DetailsPage.java Fri Sep 2 14:09:14 2011 @@ -0,0 +1,142 @@ +/* + * 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.karaf.webconsole.servicemix.internal; + +import java.io.InputStream; +import java.io.StringWriter; +import java.util.Arrays; +import java.util.Map; + +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.stream.StreamResult; + +import org.apache.karaf.webconsole.core.page.SinglePage; +import org.apache.karaf.webconsole.core.table.map.MapDataProvider; +import org.apache.karaf.webconsole.core.table.map.MapDataTable; +import org.apache.servicemix.nmr.api.Exchange; +import org.apache.servicemix.nmr.api.Message; +import org.apache.wicket.markup.html.CSSPackageResource; +import org.apache.wicket.markup.html.basic.Label; + +/** + * Exchange details page. + */ +public class DetailsPage extends SinglePage { + + public DetailsPage(Exchange object) { + add(CSSPackageResource.getHeaderContribution(DetailsPage.class, "message.css")); + + Map<String, Object> properties = object.getProperties(); + + class ExLabel extends Label { + public ExLabel(String id, Message m) { + super(id, display(m)); + } + } + + add(new Label("id", object.getId())); + add(new MapDataTable<String, Object>("properties", new MapDataProvider<String, Object>(properties), 20)); + + Message in = object.getIn(false); + if (in != null) { + add(new ExLabel("inBody", in)); + add(new MapDataTable<String, Object>("inHeaders", new MapDataProvider<String, Object>(in.getHeaders()), 20)); + } else { + add(new Label("inBody", "Input message not available")); + add(new Label("inHeaders", "Input message not available")); + } + + Message out = object.getOut(false); + if (out != null) { + add(new ExLabel("outBody", out)); + add(new MapDataTable<String, Object>("outHeaders", new MapDataProvider<String, Object>(out.getHeaders()), 20)); + } else { + add(new Label("outBody", "Output message not available")); + add(new Label("outHeaders", "Output message not available")); + } + + Message fault = object.getFault(false); + if (fault != null) { + add(new ExLabel("faultBody", fault)); + add(new MapDataTable<String, Object>("faultHeaders", new MapDataProvider<String, Object>(fault.getHeaders()), 20)); + } else { + add(new Label("faultBody", "Fault message not available")); + add(new Label("faultHeaders", "Fault message not available")); + } + + Exception exception = object.getError(); + if (exception != null) { + add(new Label("exception", exception.toString())); + } else { + add(new Label("exception", "")); + } + } + + private String display(Message message) { + try { + Object object = message.getBody(); + + if (object instanceof InputStream) { + InputStream is = (InputStream) object; + byte[] data = new byte[is.available()]; + is.mark(0); + is.read(data); + is.reset(); + + // Heuristic to check if this is a string + if (isBinary(data)) { + return Arrays.toString(data); + } else { + return new String(data); + } + } else if (object instanceof Source) { + StringWriter buffer = new StringWriter(); + TransformerFactory factory = TransformerFactory.newInstance(); + Transformer transformer = factory.newTransformer(); + transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); + transformer.setOutputProperty(OutputKeys.METHOD, "xhtml"); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.transform((Source) object, new StreamResult(buffer)); + return buffer.toString(); + } else if (object != null) { + return "[" + object.getClass().getName() + "]" + object.toString(); + } else { + return "- no body -"; + } + } catch (Exception e) { + return "Error while reading message: " + e.getMessage(); + } + } + + private static boolean isBinary(byte[] data) { + if (data.length == 0) { + return true; + } + double prob_bin = 0; + for (int i = 0; i < data.length; i++) { + int j = (int) data[i]; + if (j < 32 || j > 127) { + prob_bin++; + } + } + double pb = prob_bin / data.length; + return pb > 0.5; + } +} Added: karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/ExchangeActionsPanel.java URL: http://svn.apache.org/viewvc/karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/ExchangeActionsPanel.java?rev=1164539&view=auto ============================================================================== --- karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/ExchangeActionsPanel.java (added) +++ karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/ExchangeActionsPanel.java Fri Sep 2 14:09:14 2011 @@ -0,0 +1,55 @@ +/* + * 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.karaf.webconsole.servicemix.internal; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.karaf.webconsole.core.table.ActionsPanel; +import org.apache.servicemix.nmr.api.Exchange; +import org.apache.wicket.RequestCycle; +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.link.Link; +import org.apache.wicket.model.IModel; + +/** + * Actions panel for Exchange. + */ +public class ExchangeActionsPanel extends ActionsPanel<Exchange> { + + public ExchangeActionsPanel(String componentId, IModel<Exchange> model) { + super(componentId, model); + } + + @Override + protected List<Link> getLinks(final Exchange object, String id) { + List<Link> links = new ArrayList<Link>(); + + Link link = new Link(id) { + @Override + public void onClick() { + RequestCycle.get().setResponsePage(new DetailsPage(object)); + } + }; + link.add(new Label("label", "Details")); + + links.add(link); + + return links; + } + +} Added: karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/ExchangeModel.java URL: http://svn.apache.org/viewvc/karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/ExchangeModel.java?rev=1164539&view=auto ============================================================================== --- karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/ExchangeModel.java (added) +++ karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/ExchangeModel.java Fri Sep 2 14:09:14 2011 @@ -0,0 +1,57 @@ +/* + * 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.karaf.webconsole.servicemix.internal; + +import org.apache.servicemix.nmr.api.Exchange; +import org.apache.wicket.model.LoadableDetachableModel; + +/** + * Detachable model of Exchange, prevents it from serialization. In fact exchange + * is serializable but some of fields contains implementations which are not visible + * by our class loader, so it is easier to don't import internal NMR stuff. + */ +public class ExchangeModel extends LoadableDetachableModel<Exchange> { + + /** + * Listener - it keeps references. + */ + private ITrackingExchangeListener listener; + + /** + * Unique exchange id. + */ + private String id; + + public ExchangeModel(ITrackingExchangeListener listener, Exchange object) { + super(object); + + this.listener = listener; + this.id = object.getId(); + } + + @Override + protected Exchange load() { + for (Exchange ex : listener.getExchanges()) { + if (id.equals(ex.getId())) { + return ex; + } + } + + throw new IllegalArgumentException("Exchange is no longer available"); + } + +} Added: karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/ITrackingExchangeListener.java URL: http://svn.apache.org/viewvc/karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/ITrackingExchangeListener.java?rev=1164539&view=auto ============================================================================== --- karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/ITrackingExchangeListener.java (added) +++ karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/ITrackingExchangeListener.java Fri Sep 2 14:09:14 2011 @@ -0,0 +1,32 @@ +/* + * 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.karaf.webconsole.servicemix.internal; + +import java.util.Deque; + +import org.apache.servicemix.nmr.api.Exchange; +import org.apache.servicemix.nmr.api.event.ExchangeListener; + +/** + * Tracking exchange listener is extension of {@link ExchangeListener} which + * allow clients to get list of latest exchanges. + */ +public interface ITrackingExchangeListener extends ExchangeListener { + + Deque<Exchange> getExchanges(); + +} \ No newline at end of file Modified: karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/ServiceMixPage.java URL: http://svn.apache.org/viewvc/karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/ServiceMixPage.java?rev=1164539&r1=1164538&r2=1164539&view=diff ============================================================================== --- karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/ServiceMixPage.java (original) +++ karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/ServiceMixPage.java Fri Sep 2 14:09:14 2011 @@ -1,16 +1,34 @@ +/* + * 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.karaf.webconsole.servicemix.internal; import java.util.ArrayList; +import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Map; -import org.apache.karaf.webconsole.core.page.SinglePage; +import org.apache.karaf.webconsole.core.page.SidebarPage; import org.apache.karaf.webconsole.core.table.OrdinalColumn; import org.apache.karaf.webconsole.core.table.PropertyColumnExt; import org.apache.servicemix.nmr.api.Endpoint; import org.apache.servicemix.nmr.api.EndpointRegistry; import org.apache.servicemix.nmr.api.NMR; +import org.apache.wicket.Page; import org.apache.wicket.extensions.markup.html.repeater.data.table.DefaultDataTable; import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn; import org.apache.wicket.extensions.markup.html.repeater.data.table.ISortableDataProvider; @@ -19,7 +37,10 @@ import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; import org.ops4j.pax.wicket.api.PaxWicketBean; -public class ServiceMixPage extends SinglePage { +/** + * ServiceMix page, it shows list of registered endpoints. + */ +public class ServiceMixPage extends SidebarPage { @PaxWicketBean(name = "nmr") private NMR nmr; @@ -61,4 +82,10 @@ public class ServiceMixPage extends Sing add(new DefaultDataTable<Map<String, Object>>("endpoints", columns, provider, 20)); } + + @Override + protected List<Class<? extends Page>> getSubPages() { + Class<? extends Page>[] pages = new Class[] {TrackNmrPage.class}; + return Arrays.asList(pages); + } } Added: karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/TrackNmrPage.java URL: http://svn.apache.org/viewvc/karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/TrackNmrPage.java?rev=1164539&view=auto ============================================================================== --- karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/TrackNmrPage.java (added) +++ karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/TrackNmrPage.java Fri Sep 2 14:09:14 2011 @@ -0,0 +1,79 @@ +/* + * 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.karaf.webconsole.servicemix.internal; + +import java.util.ArrayList; +import java.util.Iterator; + +import org.apache.karaf.webconsole.core.page.SidebarPage; +import org.apache.karaf.webconsole.core.table.PropertyColumnExt; +import org.apache.servicemix.nmr.api.Exchange; +import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator; +import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn; +import org.apache.wicket.extensions.markup.html.repeater.data.table.DefaultDataTable; +import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn; +import org.apache.wicket.extensions.markup.html.repeater.data.table.ISortableDataProvider; +import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider; +import org.apache.wicket.markup.repeater.Item; +import org.apache.wicket.model.IModel; +import org.apache.wicket.model.Model; +import org.ops4j.pax.wicket.api.PaxWicketBean; + +/** + * Page which shows list of last exchanges. + */ +public class TrackNmrPage extends SidebarPage { + + @PaxWicketBean(name = "tracker") + private ITrackingExchangeListener listener; + + @SuppressWarnings({"unchecked", "rawtypes"}) + public TrackNmrPage() { + IColumn<Exchange>[] columns = new IColumn[] { + new PropertyColumnExt<Exchange>("Id", "id"), + new PropertyColumnExt<Exchange>("Role", "role"), + new PropertyColumnExt<Exchange>("Status", "status"), + new PropertyColumnExt<Exchange>("Pattern", "pattern"), + new PropertyColumnExt<Exchange>("Operation", "operation"), + new AbstractColumn<Exchange>(Model.of("Operations")) { + public void populateItem(Item<ICellPopulator<Exchange>> cellItem, String componentId, IModel<Exchange> rowModel) { + cellItem.add(new ExchangeActionsPanel(componentId, rowModel)); + } + } + }; + + ISortableDataProvider<Exchange> dataProvider = new SortableDataProvider<Exchange>() { + + public Iterator<? extends Exchange> iterator(int first, int count) { + return new ArrayList(listener.getExchanges()).subList(first, first + count).iterator(); + } + + public int size() { + return listener.getExchanges().size(); + } + + public IModel<Exchange> model(Exchange object) { + return new ExchangeModel(listener, object); + } + + }; + + add(new DefaultDataTable<Exchange>("exchanges", columns, dataProvider, 20)); + + } + +} Added: karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/TrackingExchangeListener.java URL: http://svn.apache.org/viewvc/karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/TrackingExchangeListener.java?rev=1164539&view=auto ============================================================================== --- karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/TrackingExchangeListener.java (added) +++ karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/TrackingExchangeListener.java Fri Sep 2 14:09:14 2011 @@ -0,0 +1,64 @@ +/* + * 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.karaf.webconsole.servicemix.internal; + +import java.io.Serializable; +import java.util.Deque; +import java.util.LinkedList; + +import org.apache.servicemix.nmr.api.Exchange; + +/** + * Implementation of tracking listener which keeps last few exchanges. + */ +public class TrackingExchangeListener implements ITrackingExchangeListener, Serializable { + + private final int maxSize; + private Deque<Exchange> exchanges = new LinkedList<Exchange>(); + + public TrackingExchangeListener() { + this(20); + } + + public TrackingExchangeListener(int maxSize) { + this.maxSize = maxSize; + } + + public void exchangeSent(Exchange exchange) { + queue(exchange); + } + + public void exchangeDelivered(Exchange exchange) { + queue(exchange); + } + + public void exchangeFailed(Exchange exchange) { + queue(exchange); + } + + private void queue(Exchange exchange) { + if (exchanges.size() == maxSize) { + exchanges.removeLast(); + } + exchanges.addFirst(exchange); + } + + public Deque<Exchange> getExchanges() { + return exchanges; + } + +} Modified: karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/navigation/ServiceMixConsoleTabProvider.java URL: http://svn.apache.org/viewvc/karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/navigation/ServiceMixConsoleTabProvider.java?rev=1164539&r1=1164538&r2=1164539&view=diff ============================================================================== --- karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/navigation/ServiceMixConsoleTabProvider.java (original) +++ karaf/sandbox/webconsole/trunk/servicemix/src/main/java/org/apache/karaf/webconsole/servicemix/internal/navigation/ServiceMixConsoleTabProvider.java Fri Sep 2 14:09:14 2011 @@ -1,19 +1,44 @@ +/* + * 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.karaf.webconsole.servicemix.internal.navigation; -import java.util.Collections; +import java.util.ArrayList; import java.util.List; import org.apache.karaf.webconsole.core.navigation.ConsoleTabProvider; import org.apache.karaf.webconsole.servicemix.internal.ServiceMixPage; +import org.apache.karaf.webconsole.servicemix.internal.TrackNmrPage; import org.apache.wicket.Page; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.link.BookmarkablePageLink; import org.apache.wicket.markup.html.link.Link; +/** + * ServiceMix tab in console. + */ public class ServiceMixConsoleTabProvider implements ConsoleTabProvider { public List<Link<Page>> getItems(String componentId, String labelId) { - return Collections.emptyList(); + List<Link<Page>> links = new ArrayList<Link<Page>>(); + + Link<Page> link = new BookmarkablePageLink<Page>(componentId, TrackNmrPage.class); + link.add(new Label(labelId, "Track")); + + return links; } public Link<Page> getModuleLink(String componentId, String labelId) { @@ -22,6 +47,4 @@ public class ServiceMixConsoleTabProvide return link; } - - } Modified: karaf/sandbox/webconsole/trunk/servicemix/src/main/resources/OSGI-INF/blueprint/servicemix.xml URL: http://svn.apache.org/viewvc/karaf/sandbox/webconsole/trunk/servicemix/src/main/resources/OSGI-INF/blueprint/servicemix.xml?rev=1164539&r1=1164538&r2=1164539&view=diff ============================================================================== --- karaf/sandbox/webconsole/trunk/servicemix/src/main/resources/OSGI-INF/blueprint/servicemix.xml (original) +++ karaf/sandbox/webconsole/trunk/servicemix/src/main/resources/OSGI-INF/blueprint/servicemix.xml Fri Sep 2 14:09:14 2011 @@ -21,6 +21,15 @@ <bean class="org.apache.karaf.webconsole.servicemix.internal.navigation.ServiceMixConsoleTabProvider" /> </service> + <bean id="tracker" class="org.apache.karaf.webconsole.servicemix.internal.TrackingExchangeListener" /> + + <service ref="tracker"> + <interfaces> + <value>org.apache.servicemix.nmr.api.event.Listener</value> + <value>org.apache.servicemix.nmr.api.event.ExchangeListener</value> + </interfaces> + </service> + <reference id="nmr" interface="org.apache.servicemix.nmr.api.NMR"/> <!-- Added: karaf/sandbox/webconsole/trunk/servicemix/src/main/resources/org/apache/karaf/webconsole/servicemix/internal/DetailsPage.html URL: http://svn.apache.org/viewvc/karaf/sandbox/webconsole/trunk/servicemix/src/main/resources/org/apache/karaf/webconsole/servicemix/internal/DetailsPage.html?rev=1164539&view=auto ============================================================================== --- karaf/sandbox/webconsole/trunk/servicemix/src/main/resources/org/apache/karaf/webconsole/servicemix/internal/DetailsPage.html (added) +++ karaf/sandbox/webconsole/trunk/servicemix/src/main/resources/org/apache/karaf/webconsole/servicemix/internal/DetailsPage.html Fri Sep 2 14:09:14 2011 @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd"> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> + <title>Karaf WebConsole</title> +</head> +<body> + + <wicket:extend> + <h1>Exchange <span wicket:id="id">24319433961</span></h1> + + <h2>Properties</h2> + <table wicket:id="properties" class="dataview" /> + + <h2>Input</h2> + + <h3>Message headers</h3> + <table wicket:id="inHeaders" class="dataview" /> + + <h3>Message body</h3> + <pre class="message" wicket:id="inBody"> + message body + </pre> + + <h2>Output</h2> + + <h3>Message headers</h3> + <table wicket:id="outHeaders" class="dataview" /> + + <h3>Message body</h3> + <pre class="message" wicket:id="outBody"> + message body + </pre> + + <h2>Fault</h2> + + <h3>Fault headers</h3> + <table wicket:id="faultHeaders" class="dataview" /> + + <h3>Fault body</h3> + <pre class="message" wicket:id="faultBody"> + message body + </pre> + + <h2>Exception</h2> + <pre class="message" wicket:id="exception"> + Some stack trace + </pre> + </wicket:extend> + +</body> +</html> \ No newline at end of file Added: karaf/sandbox/webconsole/trunk/servicemix/src/main/resources/org/apache/karaf/webconsole/servicemix/internal/TrackNmrPage.html URL: http://svn.apache.org/viewvc/karaf/sandbox/webconsole/trunk/servicemix/src/main/resources/org/apache/karaf/webconsole/servicemix/internal/TrackNmrPage.html?rev=1164539&view=auto ============================================================================== --- karaf/sandbox/webconsole/trunk/servicemix/src/main/resources/org/apache/karaf/webconsole/servicemix/internal/TrackNmrPage.html (added) +++ karaf/sandbox/webconsole/trunk/servicemix/src/main/resources/org/apache/karaf/webconsole/servicemix/internal/TrackNmrPage.html Fri Sep 2 14:09:14 2011 @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd"> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> + <title>Karaf WebConsole</title> +</head> +<body> + + <wicket:extend> + <h1>Nmr events</h1> + + <table wicket:id="exchanges" class="dataview" /> + </wicket:extend> + +</body> +</html> \ No newline at end of file Added: karaf/sandbox/webconsole/trunk/servicemix/src/main/resources/org/apache/karaf/webconsole/servicemix/internal/message.css URL: http://svn.apache.org/viewvc/karaf/sandbox/webconsole/trunk/servicemix/src/main/resources/org/apache/karaf/webconsole/servicemix/internal/message.css?rev=1164539&view=auto ============================================================================== --- karaf/sandbox/webconsole/trunk/servicemix/src/main/resources/org/apache/karaf/webconsole/servicemix/internal/message.css (added) +++ karaf/sandbox/webconsole/trunk/servicemix/src/main/resources/org/apache/karaf/webconsole/servicemix/internal/message.css Fri Sep 2 14:09:14 2011 @@ -0,0 +1,4 @@ +pre.message { + color: navy; + font-family: monospace; +}