Skip to content

Commit

Permalink
fixed bnd plugin and scripting project, renamed some bundles...
Browse files Browse the repository at this point in the history
  • Loading branch information
Sophos-Elias-Vasylenko committed Oct 28, 2015
1 parent 977a4dd commit dad4606
Show file tree
Hide file tree
Showing 56 changed files with 2,078 additions and 148 deletions.
5 changes: 2 additions & 3 deletions cnf/build.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ Bundle-Version: ${modabi-version}.${tstamp}
# -baseline: *
-releaserepo: Release

modabi-bnd-plugin: ${workspace}/uk.co.strangeskies.modabi.bnd/generated/uk.co.strangeskies.modabi.bnd.${1}.jar
modabi-bnd-plugin: ${build}/release/uk.co.strangeskies.modabi.bnd.${1}/uk.co.strangeskies.modabi.bnd.${1}-${modabi-version}.jar

pluginpath.modabi: \
${modabi-bnd-plugin;core},\
${modabi-bnd-plugin;xml},\
${modabi-bnd-plugin;xml}

-pluginpath.base: \
${build}/cache/biz.aQute.repository.aether.jar; \
Expand Down
2 changes: 1 addition & 1 deletion cnf/local/index.xml.sha
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8de8e8866152096f0c4ea5ddd6ed1d633b4d1a6edfbd823245cb57f6639732fd
00d32998f75fb42424a40b7de9e81e4dc9be2ca6a9fc3f2d3bec406919d62140
2 changes: 1 addition & 1 deletion uk.co.strangeskies.modabi.benchmarks/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ Bundle-Description: \
uk.co.strangeskies.modabi.core.api;version=project,\
org.apache.commons.lang3

-runvm: -XX:MaxJavaStackTraceDepth=1000000
-runvm: -XX:MaxJavaStackTraceDepth=1000000
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" ?>
<schema xmlns="http://modabi.strangeskies.co.uk/2014-01-01/"
name="BenchmarkSchema">

<dependencies>
<dependency>BaseSchema</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
Expand All @@ -45,7 +43,6 @@
import org.osgi.service.log.LogService;

import uk.co.strangeskies.modabi.SchemaManager;
import uk.co.strangeskies.modabi.io.structured.DataInterface;
import uk.co.strangeskies.utilities.ContextClassLoaderRunner;

@Component
Expand Down
29 changes: 27 additions & 2 deletions uk.co.strangeskies.modabi.bnd/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,33 @@ Bundle-Description: \
${ss;reflection},\
uk.co.strangeskies.modabi.core.api;version=project,\
uk.co.strangeskies.modabi.core.provider;version=project,\
uk.co.strangeskies.modabi.io.xml.provider;version=project,\
uk.co.strangeskies.modabi.io.xml;version=project,\
biz.aQute.bndlib

Export-Package: uk.co.strangeskies.modabi.bnd
-sub: *.bnd

dependencies.wrapped: \
uk.co.strangeskies.modabi,\
uk.co.strangeskies.modabi.declarative,\
uk.co.strangeskies.modabi.impl,\
uk.co.strangeskies.modabi.impl.processing,\
uk.co.strangeskies.modabi.impl.schema,\
uk.co.strangeskies.modabi.impl.schema.building,\
uk.co.strangeskies.modabi.impl.schema.utilities,\
uk.co.strangeskies.modabi.io,\
uk.co.strangeskies.modabi.io.structured,\
uk.co.strangeskies.modabi.io.xml,\
uk.co.strangeskies.modabi.processing,\
uk.co.strangeskies.modabi.processing.providers,\
uk.co.strangeskies.modabi.schema,\
uk.co.strangeskies.modabi.schema.building,\
uk.co.strangeskies.mathematics,\
uk.co.strangeskies.reflection,\
uk.co.strangeskies.utilities,\
uk.co.strangeskies.utilities.collection.computingmap,\
uk.co.strangeskies.utilities.collection,\
uk.co.strangeskies.utilities.collection,\
uk.co.strangeskies.utilities.factory,\
uk.co.strangeskies.utilities.function,\
uk.co.strangeskies.utilities.text,\
uk.co.strangeskies.utilities.tuple
30 changes: 0 additions & 30 deletions uk.co.strangeskies.modabi.bnd/core.bnd

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@
*/
package uk.co.strangeskies.modabi.bnd.xml;

import aQute.bnd.annotation.plugin.BndPlugin;
import aQute.bnd.service.AnalyzerPlugin;
import uk.co.strangeskies.modabi.bnd.ModabiRegistration;
import uk.co.strangeskies.modabi.impl.SchemaManagerImpl;
import uk.co.strangeskies.modabi.io.xml.XmlInterface;

@BndPlugin(name = "modabi-xml")
public class ModabiXmlRegistration extends ModabiRegistration
implements AnalyzerPlugin {
public ModabiXmlRegistration() {
Expand Down
8 changes: 7 additions & 1 deletion uk.co.strangeskies.modabi.bnd/xml.bnd
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Private-Package: \
${dependencies.wrapped},\
uk.co.strangeskies.modabi.bnd.xml,\
uk.co.strangeskies.modabi.io.xml
uk.co.strangeskies.modabi.bnd

Import-Package: \
java.net,\
java.util,\
*
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

import uk.co.strangeskies.modabi.schema.ComplexNode;
import uk.co.strangeskies.modabi.schema.Model;
import uk.co.strangeskies.utilities.collection.multimap.MultiHashMap;
import uk.co.strangeskies.utilities.collection.multimap.MultiMap;
import uk.co.strangeskies.utilities.collection.MultiHashMap;
import uk.co.strangeskies.utilities.collection.MultiMap;

public class Bindings {
public final Models models;
Expand All @@ -41,9 +41,8 @@ public Bindings() {

public <T> void add(ComplexNode<?> element, T data) {
models.addAll(element.source().baseModel());
bindings.addToAll(
element.source().baseModel().stream().map(n -> n.effective().getName())
.collect(Collectors.toSet()), data);
bindings.addToAll(element.source().baseModel().stream()
.map(n -> n.effective().getName()).collect(Collectors.toSet()), data);
}

public <T> void add(Model<T> model, T data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

import uk.co.strangeskies.modabi.schema.DataType;
import uk.co.strangeskies.modabi.schema.DataNode;
import uk.co.strangeskies.utilities.collection.multimap.MultiHashMap;
import uk.co.strangeskies.utilities.collection.multimap.MultiMap;
import uk.co.strangeskies.utilities.collection.MultiHashMap;
import uk.co.strangeskies.utilities.collection.MultiMap;

public class DataTypes extends QualifiedNamedSet<DataType<?>> {
private final MultiMap<QualifiedName, DataType<?>, LinkedHashSet<DataType<?>>> derivedTypes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ default GeneratedSchema generateDataTypes(
<T> DataType<T> buildDataType(
Function<DataTypeConfigurator<Object>, DataTypeConfigurator<T>> build);

default <T> DataType<T> buildDataType(String name,
Function<DataTypeConfigurator<Object>, DataTypeConfigurator<T>> build) {
return buildDataType(m -> build.apply(
m.name(new QualifiedName(name, getQualifiedName().getNamespace()))));
}

<T> Model<T> buildModel(
Function<ModelConfigurator<Object>, ModelConfigurator<T>> build);

default <T> Model<T> buildModel(String name,
Function<ModelConfigurator<Object>, ModelConfigurator<T>> build) {
return buildModel(m -> build.apply(
m.name(new QualifiedName(name, getQualifiedName().getNamespace()))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@

import uk.co.strangeskies.modabi.schema.Model;
import uk.co.strangeskies.reflection.TypeToken;
import uk.co.strangeskies.utilities.collection.multimap.MultiHashMap;
import uk.co.strangeskies.utilities.collection.multimap.MultiMap;
import uk.co.strangeskies.utilities.collection.MultiHashMap;
import uk.co.strangeskies.utilities.collection.MultiMap;

public class Models extends QualifiedNamedSet<Model<?>> {
private final MultiMap<QualifiedName, Model<?>, LinkedHashSet<Model<?>>> derivedModels;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import java.util.Map;
import java.util.function.Function;

import uk.co.strangeskies.utilities.collection.decorator.SetDecorator;
import uk.co.strangeskies.utilities.function.collection.SetTransformationView;
import uk.co.strangeskies.utilities.collection.SetDecorator;
import uk.co.strangeskies.utilities.function.SetTransformationView;

public class QualifiedNamedSet<T> extends /* @ReadOnly */SetDecorator<T> {
private final Function<T, QualifiedName> qualifiedNamingFunction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
import uk.co.strangeskies.modabi.schema.building.ModelBuilder;
import uk.co.strangeskies.reflection.TypeToken;
import uk.co.strangeskies.reflection.TypeToken.Infer;
import uk.co.strangeskies.utilities.collection.multimap.MultiHashMap;
import uk.co.strangeskies.utilities.collection.multimap.MultiMap;
import uk.co.strangeskies.utilities.collection.MultiHashMap;
import uk.co.strangeskies.utilities.collection.MultiMap;

@Component(immediate = true)
public class SchemaManagerImpl implements SchemaManager {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ChoiceNodeImpl extends SchemaNodeImpl<ChoiceNode, ChoiceNode.Effective>
private static class Effective
extends SchemaNodeImpl.Effective<ChoiceNode, ChoiceNode.Effective>
implements ChoiceNode.Effective {
private final boolean mandatory;
private final Boolean mandatory;

private final TypeToken<?> preInputClass;
private final TypeToken<?> postInputClass;
Expand All @@ -53,24 +53,31 @@ else if (!nextInputClass.isAssignableFrom(preInputClass))
TypeToken<?> postInputClass = overrideMerge
.getOverride(ChildNode::getPostInputType)
.validate(TypeToken::isAssignableTo).tryGet();
if (!isAbstract())
if (postInputClass == null)
if (!isAbstract()) {
if (postInputClass == null) {
for (ChildNode.Effective<?, ?> child : children()) {
TypeToken<?> nextOutputClass = child.getPostInputType();
if (postInputClass != null)
if (nextOutputClass.isAssignableFrom(postInputClass))

if (postInputClass != null) {
if (nextOutputClass.isAssignableFrom(postInputClass)) {
postInputClass = nextOutputClass;
else if (!postInputClass.isAssignableFrom(nextOutputClass))
} else if (!postInputClass.isAssignableFrom(nextOutputClass)) {
postInputClass = TypeToken.over(Object.class);
}
}
}
else
for (ChildNode.Effective<?, ?> child : children())
if (!postInputClass.isAssignableFrom(child.getPostInputType()))
} else {
for (ChildNode.Effective<?, ?> child : children()) {
if (!postInputClass.isAssignableFrom(child.getPostInputType())) {
throw new SchemaException();
}
}
}
}
this.postInputClass = postInputClass;

mandatory = overrideMerge.getOverride(ChoiceNode::isMandatory)
.orDefault(false).get();
.validate((o, p) -> o || !p).orDefault(false).get();
}

@Override
Expand Down
8 changes: 4 additions & 4 deletions uk.co.strangeskies.modabi.core.test/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Test-Cases: ${test-cases}
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.command)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.runtime)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.shell)',\
osgi.identity;filter:='(osgi.identity=uk.co.strangeskies.modabi.io.json.provider)',\
osgi.identity;filter:='(osgi.identity=uk.co.strangeskies.modabi.io.xml.provider)',\
osgi.identity;filter:='(osgi.identity=uk.co.strangeskies.modabi.io.json)',\
osgi.identity;filter:='(osgi.identity=uk.co.strangeskies.modabi.io.xml)',\
osgi.identity;filter:='(osgi.identity=biz.aQute.tester)',\
osgi.identity;filter:='(osgi.identity=uk.co.strangeskies.modabi.core.provider)',\
osgi.identity;filter:='(osgi.identity=uk.co.strangeskies.modabi.core.api)'
Expand All @@ -53,8 +53,8 @@ Test-Cases: ${test-cases}
uk.co.strangeskies.mathematics;version='[1.0.13,1.0.14)',\
uk.co.strangeskies.modabi.core.api;version=snapshot,\
uk.co.strangeskies.modabi.core.provider;version=snapshot,\
uk.co.strangeskies.modabi.io.json.provider;version=snapshot,\
uk.co.strangeskies.modabi.io.xml.provider;version=snapshot,\
uk.co.strangeskies.modabi.io.json;version=snapshot,\
uk.co.strangeskies.modabi.io.xml;version=snapshot,\
uk.co.strangeskies.reflection;version='[1.0.13,1.0.14)',\
uk.co.strangeskies.utilities;version='[1.0.13,1.0.14)',\
uk.co.strangeskies.utilities.osgi.consolelog;version='[1.0.13,1.0.14)'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,22 @@ private <T> T getService(Class<T> clazz) {
}
}

@Test
public void abstractChoiceNodeTest() {
SchemaManager schemaManager = getService(SchemaManager.class);
schemaManager.generateSchema(new QualifiedName("choiceNodeTest"))
.buildModel("choiceNodeTestModel",
m -> m.isAbstract(true).addChild(c -> c.choice().isAbstract(true)));
}

@Test
public void schemaManagerServiceTest() {
System.out.println("TEST1");
Assert.assertNotNull(getService(SchemaManager.class));
}

@Test
public void schemaUnbindingTest() {
new ContextClassLoaderRunner(getClass().getClassLoader()).run(() -> {
System.out.println("TEST2");
SchemaManager schemaManager = getService(SchemaManager.class);

System.out.println("Unbinding BaseSchema...");
Expand Down Expand Up @@ -193,7 +199,6 @@ public uk.co.strangeskies.modabi.schema.ChoiceNode.Effective effective() {

@Test
public void manualSchemaCreationTest() {
System.out.println("TEST3");
SchemaManager schemaManager = getService(SchemaManager.class);

GeneratedSchema generatedSchema = schemaManager.generateSchema(
Expand Down
Loading

0 comments on commit dad4606

Please sign in to comment.