Skip to content

Commit 3eb4848

Browse files
author
vikajkr
committed
F: Provide serializable dtos
1 parent 6c9b7e3 commit 3eb4848

File tree

11 files changed

+212
-55
lines changed

11 files changed

+212
-55
lines changed

build/com.kuebler.osgi.ds/ds.target

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<?pde version="3.8"?><target name="ds" sequenceNumber="3">
2+
<?pde version="3.8"?><target name="ds" sequenceNumber="6">
33
<locations>
44
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
55
<unit id="osgi.promise.source" version="6.0.0.201505202027"/>
6+
<unit id="org.apache.felix.fileinstall" version="3.5.4"/>
67
<unit id="osgi.promise" version="6.0.0.201505202027"/>
8+
<unit id="org.apache.felix.fileinstall.source" version="3.5.4"/>
79
<repository location="http://depth.openseamap.org/p2"/>
810
</location>
911
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
12+
<unit id="org.eclipse.zest.sdk.feature.group" version="1.7.0.201606061308"/>
13+
<unit id="org.eclipse.gef.sdk.feature.group" version="3.11.0.201606061308"/>
14+
<unit id="org.eclipse.ecf.core.feature.group" version="3.13.1.v20160405-1820"/>
15+
<unit id="org.eclipse.ecf.remoteservice.sdk.feature.feature.group" version="3.13.1.v20160405-1820"/>
16+
<repository location="http://download.eclipse.org/releases/neon"/>
17+
</location>
18+
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
1019
<unit id="org.eclipse.platform.ide" version="4.6.0.I20160606-1100"/>
20+
<unit id="org.eclipse.equinox.sdk.feature.group" version="3.12.0.v20160606-1311"/>
1121
<unit id="org.eclipse.rcp.feature.group" version="4.6.0.v20160606-1342"/>
1222
<repository location="http://download.eclipse.org/eclipse/updates/4.6"/>
1323
</location>
14-
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
15-
<unit id="org.eclipse.gef.sdk.feature.group" version="3.11.0.201606061308"/>
16-
<unit id="org.eclipse.zest.sdk.feature.group" version="1.7.0.201606061308"/>
17-
<repository location="http://download.eclipse.org/releases/neon"/>
18-
</location>
1924
</locations>
2025
</target>

bundles/com.kuebler.osgi.ds.equinox/META-INF/MANIFEST.MF

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@ Bundle-ManifestVersion: 2
33
Bundle-Name: Service Component Runtime Equinox
44
Bundle-SymbolicName: com.kuebler.osgi.ds.equinox
55
Bundle-Version: 0.0.1.qualifier
6-
Import-Package: org.apache.felix.scr;version="1.6.0",
7-
org.eclipse.equinox.internal.ds,
8-
org.osgi.framework;version="[1.8.0,2.0.0)",
9-
org.osgi.framework.dto;version="[1.8.0,2.0.0)",
10-
org.osgi.framework.dto.serial,
11-
org.osgi.service.component;version="1.2.2",
12-
org.osgi.service.component.annotations;version="[1.2.0,1.3.0)",
13-
org.osgi.service.component.runtime.dto.serial;version="1.3.0",
14-
org.osgi.service.component.runtime.serial;version="[1.0.0,2.0.0)",
15-
org.osgi.util.promise;version="[1.0.0,2.0.0)"
16-
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
17-
Service-Component: OSGI-INF/com.kuebler.osgi.ds.equinox.EquinoxSCR.xml
186
Bundle-ActivationPolicy: lazy
7+
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
8+
Service-Component: OSGI-INF/com.kuebler.osgi.ds.equinox.EquinoxAppConfigurator.xml,
9+
OSGI-INF/com.kuebler.osgi.ds.equinox.EquinoxSCR.xml
10+
Import-Package: org.apache.felix.scr;version="1.6.0",
11+
org.eclipse.equinox.internal.ds,
12+
org.osgi.framework;version="[1.8.0,2.0.0)",
13+
org.osgi.framework.dto;version="[1.8.0,2.0.0)",
14+
org.osgi.framework.dto.serial,
15+
org.osgi.service.cm;version="1.5.0",
16+
org.osgi.service.component;version="1.2.2",
17+
org.osgi.service.component.annotations;version="[1.2.0,1.3.0)",
18+
org.osgi.service.component.runtime.dto.serial;version="1.3.0",
19+
org.osgi.service.component.runtime.serial;version="[1.0.0,2.0.0)",
20+
org.osgi.util.promise;version="[1.0.0,2.0.0)"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<!--Generated by DS Annotation Builder [src/com/kuebler/osgi/ds/equinox/EquinoxAppConfigurator.java]-->
3+
<scr:component name="com.kuebler.osgi.ds.equinox.EquinoxAppConfigurator" activate="activate" xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
4+
<reference name="ConfigAdmin" interface="org.osgi.service.cm.ConfigurationAdmin" cardinality="1..1" policy="dynamic" bind="bindConfigAdmin" unbind="unbindConfigAdmin"/>
5+
<implementation class="com.kuebler.osgi.ds.equinox.EquinoxAppConfigurator"/>
6+
</scr:component>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.kuebler.osgi.ds.equinox;
2+
3+
import java.io.IOException;
4+
import java.util.Dictionary;
5+
import java.util.Properties;
6+
import java.util.concurrent.atomic.AtomicReference;
7+
8+
import org.osgi.service.cm.Configuration;
9+
import org.osgi.service.cm.ConfigurationAdmin;
10+
import org.osgi.service.component.annotations.Activate;
11+
import org.osgi.service.component.annotations.Component;
12+
import org.osgi.service.component.annotations.Reference;
13+
import org.osgi.service.component.annotations.ReferenceCardinality;
14+
import org.osgi.service.component.annotations.ReferencePolicy;
15+
16+
/**
17+
*
18+
* Add additional information to augment a property for the application being debugged
19+
*
20+
*/
21+
@Component
22+
public class EquinoxAppConfigurator {
23+
24+
@Activate
25+
public void activate() throws IOException {
26+
ConfigurationAdmin configurationAdmin = _configAdmin.get();
27+
Configuration configuration = configurationAdmin.getConfiguration(EquinoxSCR.class.getName());
28+
Dictionary<String, Object> properties = configuration.getProperties();
29+
Properties properties2 = System.getProperties();
30+
configuration.update(properties);
31+
}
32+
33+
34+
private AtomicReference<ConfigurationAdmin> _configAdmin = new AtomicReference<ConfigurationAdmin>();
35+
36+
/**
37+
* OSGi bind method
38+
* @param name
39+
*/
40+
@Reference(cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC)
41+
public void bindConfigAdmin(ConfigurationAdmin configAdmin) {
42+
_configAdmin.set(configAdmin);
43+
}
44+
45+
/**
46+
* OSGi unbind method
47+
* @param name
48+
*/
49+
public void unbindConfigAdmin(ConfigurationAdmin name) {
50+
_configAdmin.compareAndSet(name, null);
51+
}}

bundles/com.kuebler.osgi.ds.ui/src/org/osgi/ds/ui/ComponentViewer.java

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,10 @@
4747
public class ComponentViewer extends ViewPart {
4848
private ComponentStateFilter componentFilter;
4949
private TreeViewer treeViewer;
50-
private Map<String, ComponentConfigurationDTO[]> scr2dtos;
5150
private ServiceTracker<ServiceComponentRuntime, ServiceComponentRuntime> componentRuntimeTracker;
52-
private ServiceReference<?>[] serviceReferences;
5351
private ServiceComponentRuntime serviceComponentRuntime;
5452

5553
public ComponentViewer() {
56-
scr2dtos = new HashMap<String, ComponentConfigurationDTO[]>();
5754
}
5855

5956
@Override
@@ -122,17 +119,6 @@ public void run() {
122119
getViewSite().setSelectionProvider(treeViewer);
123120
}
124121

125-
// private BundleContext updateTreeViewerContents() {
126-
// BundleContext bundleContext = DSUIActivator.getDefault().getBundle().getBundleContext();
127-
// ServiceReference<ScrService> serviceReference = bundleContext.getServiceReference(ScrService.class);
128-
// try {
129-
// StrippedServiceComponentRuntime service = componentRuntimeTracker.getService();
130-
// } finally {
131-
// bundleContext.ungetService(serviceReference);
132-
// }
133-
// return bundleContext;
134-
// }
135-
136122
@Override
137123
public void setFocus() {
138124
// TODO Auto-generated method stub
@@ -141,11 +127,6 @@ public void setFocus() {
141127

142128
public void setFilterStates(int filter) {
143129
componentFilter.setFilter(filter);
144-
// StrippedServiceComponentRuntime service = componentRuntimeTracker.getService();
145-
// if(service != null) {
146-
// Collection<ComponentConfigurationDTO> allComponentConfigurationDTO = service.getAllComponentConfigurationDTO();
147-
// treeViewer.setInput(allComponentConfigurationDTO);
148-
// }
149130
treeViewer.refresh();
150131
}
151132

@@ -176,20 +157,22 @@ public void setInput(Collection<ComponentConfigurationDTO> componentDescriptionD
176157
public void setEndpointId(String frameworkUUID, String endpointID) {
177158
try {
178159
BundleContext bundleContext = DSUIActivator.getDefault().getBundle().getBundleContext();
179-
ServiceReference<?>[] serviceReferences2 = bundleContext.getServiceReferences("org.osgi.service.component.runtime.ServiceComponentRuntime", null);
180-
for (ServiceReference<?> serviceReference : serviceReferences2) {
181-
if(endpointID.equals(serviceReference.getProperty("endpoint.id")) || frameworkUUID.equals(bundleContext.getProperty(Constants.FRAMEWORK_UUID))) {
182-
serviceComponentRuntime = (ServiceComponentRuntime)bundleContext.getService(serviceReference);
183-
if(serviceComponentRuntime != null) {
184-
Collection<ComponentDescriptionDTO> componentDescriptionDTOs = serviceComponentRuntime.getComponentDescriptionDTOs();
185-
Collection<ComponentConfigurationDTO> componentConfigurationDTOs = new ArrayList<>();
186-
for (ComponentDescriptionDTO componentDescriptionDTO : componentDescriptionDTOs) {
187-
componentConfigurationDTOs.addAll(serviceComponentRuntime.getComponentConfigurationDTOs(componentDescriptionDTO));
160+
ServiceReference<?>[] serviceReferences2 = bundleContext.getServiceReferences("org.osgi.service.component.runtime.serial.ServiceComponentRuntime", null);
161+
if(serviceReferences2 != null) {
162+
for (ServiceReference<?> serviceReference : serviceReferences2) {
163+
if(endpointID.equals(serviceReference.getProperty("endpoint.id")) || (serviceReference.getProperty("endpoint.id") == null && frameworkUUID.equals(bundleContext.getProperty(Constants.FRAMEWORK_UUID)))) {
164+
serviceComponentRuntime = (ServiceComponentRuntime)bundleContext.getService(serviceReference);
165+
if(serviceComponentRuntime != null) {
166+
Collection<ComponentDescriptionDTO> componentDescriptionDTOs = serviceComponentRuntime.getComponentDescriptionDTOs();
167+
Collection<ComponentConfigurationDTO> componentConfigurationDTOs = new ArrayList<>();
168+
for (ComponentDescriptionDTO componentDescriptionDTO : componentDescriptionDTOs) {
169+
componentConfigurationDTOs.addAll(serviceComponentRuntime.getComponentConfigurationDTOs(componentDescriptionDTO));
170+
}
171+
treeViewer.setInput(componentConfigurationDTOs);
172+
treeViewer.refresh(true);
188173
}
189-
treeViewer.setInput(componentConfigurationDTOs);
190-
treeViewer.refresh(true);
174+
191175
}
192-
193176
}
194177
}
195178
} catch (InvalidSyntaxException e) {

bundles/com.kuebler.osgi.ds.ui/src/org/osgi/ds/ui/ComponentVisualizationView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public ComponentVisualizationView() {
8585
red = new Color(Display.getDefault(), new RGB(255, 129, 129));
8686
yellow = new Color(Display.getDefault(), new RGB(250, 255, 125));
8787
green = new Color(Display.getDefault(), new RGB(155, 222, 141));
88-
blue = new Color(Display.getDefault(), new RGB(0, 0, 255));
88+
blue = new Color(Display.getDefault(), new RGB(200, 200, 255));
8989
}
9090

9191
/**
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.osgi.ds.ui;
2+
3+
import java.util.Map;
4+
5+
import org.eclipse.jface.viewers.CellLabelProvider;
6+
import org.eclipse.jface.viewers.ViewerCell;
7+
import org.osgi.service.remoteserviceadmin.EndpointDescription;
8+
9+
final class EndpointCellLabelProvider extends CellLabelProvider {
10+
@Override
11+
public void update(ViewerCell cell) {
12+
Object element = cell.getElement();
13+
if(element instanceof EndpointDescription) {
14+
EndpointDescription endpointDescription = (EndpointDescription) element;
15+
if(cell.getColumnIndex() == 0) {
16+
cell.setText(endpointDescription.getFrameworkUUID());
17+
} else if(cell.getColumnIndex() == 1) {
18+
Map<String, Object> properties = endpointDescription.getProperties();
19+
cell.setText(properties.get("ecf.endpoint.id").toString());
20+
}
21+
22+
}
23+
24+
}
25+
}

bundles/com.kuebler.osgi.ds.ui/src/org/osgi/ds/ui/SCRToolContributor.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,18 @@ private Composite createVersionTable(Composite parent) {
246246
_tableViewer.getTable().setHeaderVisible(true);
247247
_tableViewer.getTable().setLinesVisible(true);
248248

249+
EndpointCellLabelProvider labelProvider = new EndpointCellLabelProvider();
249250
TableViewerColumn tableViewerColumnVersion = new TableViewerColumn(_tableViewer, SWT.RESIZE);
250-
tableViewerColumnVersion.getColumn().setText("Service Component Runtime"); //$NON-NLS-1$
251-
tableViewerColumnVersion.getColumn().setWidth(70);
251+
tableViewerColumnVersion.getColumn().setText("Framework ID"); //$NON-NLS-1$
252+
tableViewerColumnVersion.getColumn().setWidth(240);
253+
tableViewerColumnVersion.setLabelProvider(labelProvider);
254+
TableViewerColumn tableViewerColumnVersion2 = new TableViewerColumn(_tableViewer, SWT.RESIZE);
255+
tableViewerColumnVersion2.getColumn().setText("Server"); //$NON-NLS-1$
256+
tableViewerColumnVersion2.getColumn().setWidth(500);
257+
tableViewerColumnVersion2.setLabelProvider(labelProvider);
252258

253259
_tableViewer.setContentProvider(new ArrayContentProvider());
254-
_tableViewer.setLabelProvider(new LabelProvider());
260+
// _tableViewer.setLabelProvider(new EndpointLabelProvider());
255261

256262
_tableViewer.setInput(serviceTracker.getService().getDiscoveredEndpoints());
257263

@@ -283,6 +289,7 @@ public void doubleClick(DoubleClickEvent event) {
283289
EndpointDescription ed = (EndpointDescription) ((IStructuredSelection)selection).getFirstElement();
284290
String id2 = ed.getId();
285291
((ComponentViewer)getWorkbenchWindow().getActivePage().getActivePart()).setEndpointId(ed.getFrameworkUUID(), id2);
292+
// _toolItem.setText(ed.getFrameworkUUID());
286293
setChosenEndpoint(((IStructuredSelection)selection).getFirstElement());
287294
close();
288295
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright (c) OSGi Alliance (2012, 2014). All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.osgi.framework.dto.serial;
18+
19+
import java.io.Serializable;
20+
21+
import org.osgi.dto.DTO;
22+
23+
/**
24+
* Data Transfer Object for a Bundle.
25+
*
26+
* <p>
27+
* A Bundle can be adapted to provide a {@code BundleDTO} for the Bundle.
28+
*
29+
* @author $Id: aa30709351d8fe70b19c9ea99456ebd15ecab7c3 $
30+
* @NotThreadSafe
31+
*/
32+
public class BundleDTO extends DTO implements Serializable {
33+
/**
34+
*
35+
*/
36+
private static final long serialVersionUID = -7204018170853430526L;
37+
38+
/**
39+
* The bundle's unique identifier.
40+
*
41+
* @see {org.osgi.framework.Bundle}#getBundleId()
42+
*/
43+
public long id;
44+
45+
/**
46+
* The time when the bundle was last modified.
47+
*
48+
* @see {org.osgi.framework.Bundle}#getLastModified()
49+
*/
50+
public long lastModified;
51+
52+
/**
53+
* The bundle's state.
54+
*
55+
* @see {org.osgi.framework.Bundle}#getState()
56+
*/
57+
public int state;
58+
59+
/**
60+
* The bundle's symbolic name.
61+
*
62+
* @see {org.osgi.framework.Bundle}#getSymbolicName()
63+
*/
64+
public String symbolicName;
65+
66+
/**
67+
* The bundle's version.
68+
*
69+
* @see {org.osgi.framework.Bundle}#getVersion()
70+
*/
71+
public String version;
72+
}

bundles/com.kuebler.osgi.service.dto.compatibility/src/org/osgi/framework/dto/serial/ServiceReferenceDTO.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.osgi.framework.dto.serial;
1818

19+
import java.io.Serializable;
1920
import java.util.Map;
2021
import org.osgi.dto.DTO;
2122
import org.osgi.framework.Constants;
@@ -35,8 +36,13 @@
3536
* @author $Id: 2c70b84f28c41fb51c488cb03950a46188ea209f $
3637
* @NotThreadSafe
3738
*/
38-
public class ServiceReferenceDTO extends DTO {
39+
public class ServiceReferenceDTO extends DTO implements Serializable {
3940
/**
41+
*
42+
*/
43+
private static final long serialVersionUID = -2865048979395313666L;
44+
45+
/**
4046
* The id of the service.
4147
*
4248
* @see Constants#SERVICE_ID

0 commit comments

Comments
 (0)