Web component type with DSL?

12 views
Skip to first unread message

Tomáš Fecko

unread,
Oct 29, 2015, 10:28:59 AM10/29/15
to fabric3
Hi,

is there a way of creating the web component with dsl?
source code:

@Provides
public static Composite createComposite(@Environment String pEnvironment) {
Component component = new Component("WebComponent");
component.setImplementation(new WebImplementation(URI.create("web")));
addReference(component, "CoreUtilsComponent", ICoreUtilsService.class);

return CompositeBuilder.newBuilder(QName.valueOf("{org.librade/1.0}" + "webComposite"))
.environment(Arrays.asList("main", "vm"))
.deployable()
.component(component)
.build();
}

private static void addReference(Component pComponent, String pTargetComponent, Class pReferenceClass) {
Reference<Component> reference = new Reference<>(pReferenceClass.getSimpleName(), Multiplicity.ONE_ONE);
reference.addTarget(new Target(pTargetComponent, pReferenceClass.getSimpleName()));
pComponent.add(reference);
}

sca-contribution.xml:

<?xml version="1.0" encoding="UTF-8"?>
<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:librade="org.librade/1.0" xmlns:f3="urn:fabric3.org" f3:context="">

<import.java package="org.librade.common.*"/>
<import.java package="com.nordlicht.commons.base.*"/>
<import.java package="com.google.*"/>

<deployable composite="librade:webComposite" environments="vm main"/>

</contribution>

but I'm getting this error:

[SEVERE 29.10.2015 15:24:20.980] The following contribution errors were found:

   ERROR: Deployable composite {org.librade/1.0}webComposite not found in librade-gui-web-1.3.0-SNAPSHOT.war

1 error was found 

Tomáš Fecko

unread,
Oct 30, 2015, 11:32:28 AM10/30/15
to fabric3
Hi Jim,

ok, now I remember, that we were talking about this.
I will test that out...

thanx
Tomas

Hi Tomas,
A Web component DSL was not created because we didn't think there was a need for it. Previously configuring web components was required for the following reasons:

1. To set the web URI
2. To set references to be injected into the servlet context.

The web URI can now be configured in sca-configuration.xml and reference injection is handled by one of the following:

1. Servlets can be annotated with @Reference and they will be scanned automatically
2. If web app code (e.g. a UI framework) needs to access an SCA service, it can use the Domain API to lookup a service directly. UI frameworks generally provide extension points for obtaining instances that are used by the framework. These extension points can bridge to SCA components using the Domain API.

Let me know if I've missed a use case that requires direct configuration of a web component. Also, if you need some direct examples of using the domain API, I'm happy to provide them.

Jim

Reply all
Reply to author
Forward
0 new messages