Skip to content

Commit

Permalink
support loading 1.4.0 SCR components
Browse files Browse the repository at this point in the history
refs #397
  • Loading branch information
tomsontom committed May 4, 2020
1 parent 8e85a9f commit 627fc18
Show file tree
Hide file tree
Showing 13 changed files with 146 additions and 26 deletions.
1 change: 1 addition & 0 deletions modules/core/org.eclipse.fx.core/.gitignore
@@ -1,2 +1,3 @@
/target
/bin
/scr-1.4.0.xsd
18 changes: 18 additions & 0 deletions modules/core/org.eclipse.fx.core/bind-info.xjb
@@ -0,0 +1,18 @@
<bindings xmlns="http://java.sun.com/xml/ns/jaxb"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="2.1">
<bindings schemaLocation="scr-1.4.0.xsd" version="1.4.0">
<!-- Customise the package name -->
<schemaBindings>
<package name="org.eclipse.fx.core.internal.sm"/>
</schemaBindings>

<!-- rename the value element -->
<bindings node="//xs:complexType[@name='Tproperty']">
<bindings node=".//xs:attribute[@name='value']">
<property name="ValueAttribute"/>
</bindings>
</bindings>
</bindings>
</bindings>
24 changes: 0 additions & 24 deletions modules/core/org.eclipse.fx.core/src/main/java/Dummy.java

This file was deleted.

Expand Up @@ -41,6 +41,7 @@
import org.eclipse.fx.core.internal.sm.Component11;
import org.eclipse.fx.core.internal.sm.Component12;
import org.eclipse.fx.core.internal.sm.Component13;
import org.eclipse.fx.core.internal.sm.Component14;
import org.eclipse.fx.core.internal.sm.Properties;
import org.eclipse.fx.core.internal.sm.Property;
import org.eclipse.fx.core.internal.sm.Reference;
Expand Down Expand Up @@ -366,8 +367,10 @@ private Component handle(URL resource) {
jaxbContext = JAXBContext.newInstance(Component11.class);
} else if( data.contains("http://www.osgi.org/xmlns/scr/v1.2.0") ) { //$NON-NLS-1$
jaxbContext = JAXBContext.newInstance(Component12.class);
} else {
} else if( data.contains("http://www.osgi.org/xmlns/scr/v1.3.0") ) { //$NON-NLS-1$
jaxbContext = JAXBContext.newInstance(Component13.class);
} else {
jaxbContext = JAXBContext.newInstance(Component14.class);
}

Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
Expand Down
Expand Up @@ -11,9 +11,13 @@
package org.eclipse.fx.core.internal.sm;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.xml.bind.annotation.XmlAnyAttribute;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.namespace.QName;

/**
* DS Component Model
Expand All @@ -25,6 +29,7 @@ public abstract class Component {
private List<Reference> reference = new ArrayList<>();
private List<Property> property = new ArrayList<>();
private List<Properties> properties = new ArrayList<>();
private Map<QName, String> otherAttributes = new HashMap<>();

/**
* @return the implementation model
Expand Down Expand Up @@ -128,4 +133,13 @@ public List<Properties> getProperties() {
public void setProperties(List<Properties> properties) {
this.properties = properties;
}

@XmlAnyAttribute
public Map<QName, String> getOtherAttributes() {
return this.otherAttributes;
}

public void setOtherAttributes(Map<QName, String> otherAttributes) {
this.otherAttributes = otherAttributes;
}
}
Expand Up @@ -13,7 +13,7 @@
import javax.xml.bind.annotation.XmlRootElement;

/**
* Component in version 1.2.0
* Component in version 1.3.0
*/
@XmlRootElement(name="component",namespace="http://www.osgi.org/xmlns/scr/v1.3.0")
public class Component13 extends Component {
Expand Down
@@ -0,0 +1,21 @@
/*******************************************************************************
* Copyright (c) 2017 BestSolution.at and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
*******************************************************************************/
package org.eclipse.fx.core.internal.sm;

import javax.xml.bind.annotation.XmlRootElement;

/**
* Component in version 1.4.0
*/
@XmlRootElement(name="component",namespace="http://www.osgi.org/xmlns/scr/v1.4.0")
public class Component14 extends Component {
// Nothing
}
Expand Up @@ -10,13 +10,19 @@
*******************************************************************************/
package org.eclipse.fx.core.internal.sm;

import java.util.HashMap;
import java.util.Map;

import javax.xml.bind.annotation.XmlAnyAttribute;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.namespace.QName;

/**
* The implementation model
*/
public class Implementation {
private String clazz;
private Map<QName, String> otherAttributes = new HashMap<>();

/**
* @return the implementation class
Expand All @@ -36,4 +42,12 @@ public void setClazz(String clazz) {
this.clazz = clazz;
}

@XmlAnyAttribute
public Map<QName, String> getOtherAttributes() {
return this.otherAttributes;
}

public void setOtherAttributes(Map<QName, String> otherAttributes) {
this.otherAttributes = otherAttributes;
}
}
Expand Up @@ -10,13 +10,19 @@
*******************************************************************************/
package org.eclipse.fx.core.internal.sm;

import java.util.HashMap;
import java.util.Map;

import javax.xml.bind.annotation.XmlAnyAttribute;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.namespace.QName;

/**
* Properties model
*/
public class Properties {
private String entry;
private Map<QName, String> otherAttributes = new HashMap<>();

/**
* @return the entry path
Expand All @@ -34,4 +40,12 @@ public void setEntry(String entry) {
this.entry = entry;
}

@XmlAnyAttribute
public Map<QName, String> getOtherAttributes() {
return this.otherAttributes;
}

public void setOtherAttributes(Map<QName, String> otherAttributes) {
this.otherAttributes = otherAttributes;
}
}
Expand Up @@ -10,7 +10,12 @@
*******************************************************************************/
package org.eclipse.fx.core.internal.sm;

import java.util.HashMap;
import java.util.Map;

import javax.xml.bind.annotation.XmlAnyAttribute;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.namespace.QName;

/**
* A property model
Expand All @@ -19,6 +24,7 @@ public class Property {
private String name;
private String type;
private String value;
private Map<QName, String> otherAttributes = new HashMap<>();

/**
* @return the name
Expand Down Expand Up @@ -74,4 +80,12 @@ public void setValue(String value) {
this.value = value;
}

@XmlAnyAttribute
public Map<QName, String> getOtherAttributes() {
return this.otherAttributes;
}

public void setOtherAttributes(Map<QName, String> otherAttributes) {
this.otherAttributes = otherAttributes;
}
}
Expand Up @@ -10,14 +10,21 @@
*******************************************************************************/
package org.eclipse.fx.core.internal.sm;

import java.util.HashMap;
import java.util.Map;

import javax.xml.bind.annotation.XmlAnyAttribute;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.namespace.QName;

/**
* The provided interface
*/
public class Provide {

private String iface;

private Map<QName, String> otherAttributes = new HashMap<>();

/**
* @return the interface
Expand All @@ -37,4 +44,12 @@ public void setIface(String iface) {
this.iface = iface;
}

@XmlAnyAttribute
public Map<QName, String> getOtherAttributes() {
return this.otherAttributes;
}

public void setOtherAttributes(Map<QName, String> otherAttributes) {
this.otherAttributes = otherAttributes;
}
}
Expand Up @@ -10,7 +10,12 @@
*******************************************************************************/
package org.eclipse.fx.core.internal.sm;

import java.util.HashMap;
import java.util.Map;

import javax.xml.bind.annotation.XmlAnyAttribute;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.namespace.QName;

/**
* The reference
Expand All @@ -30,6 +35,8 @@ public class Reference {
private String policyOption;

private String unbind;

private Map<QName, String> otherAttributes = new HashMap<>();

/**
* @return the bind method
Expand Down Expand Up @@ -260,4 +267,13 @@ public static ReferenceCardinality fromString(String data) {
}
}
}

@XmlAnyAttribute
public Map<QName, String> getOtherAttributes() {
return this.otherAttributes;
}

public void setOtherAttributes(Map<QName, String> otherAttributes) {
this.otherAttributes = otherAttributes;
}
}
Expand Up @@ -11,13 +11,19 @@
package org.eclipse.fx.core.internal.sm;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.xml.bind.annotation.XmlAnyAttribute;
import javax.xml.namespace.QName;

/**
* The service model
*/
public class Service {
private List<Provide> provide = new ArrayList<>();
private Map<QName, String> otherAttributes = new HashMap<>();

/**
* @return list of provide model elements
Expand All @@ -36,4 +42,12 @@ public void setProvide(List<Provide> provide) {
this.provide = provide;
}

@XmlAnyAttribute
public Map<QName, String> getOtherAttributes() {
return this.otherAttributes;
}

public void setOtherAttributes(Map<QName, String> otherAttributes) {
this.otherAttributes = otherAttributes;
}
}

0 comments on commit 627fc18

Please sign in to comment.