I am trying to learn how to develop using Tuscany along with OSGi bundles to be used as the implementation of SCA components. I am using java on eclipse IDE. I tried to search for online tutorial to get started but I did not get anyone.
I found one link here http://tuscany.apache.org/sca-java-implementationosgi.html
which helps in the general idea, but it does not provide the details. I decided to try without tutorial, and I did something, but it did not work, and I got errors.
So here's what I did:
I created a bundle which contains the following interface:
package com.javaworld.sample.service;
import org.osoa.sca.annotations.Remotable;
#Remotable
public interface HelloService {
public String sayHello();
}
The implementation of the interface works fine and I checked this project alone without Tuscany.
Now, here's the MANIFEST file of this bundle:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: HelloService
Bundle-SymbolicName: com.javaworld.sample.HelloService
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.javaworld.sample.service.impl.HelloServiceActivator
Bundle-Vendor: JAVAWORLD
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Import-Package: org.osgi.framework;version="1.3.0"
Export-Package: com.javaworld.sample.service
In a separate project, I have several components built as SCA, and this is my composite file called store.composite,
<?xml version="1.0" encoding="UTF-8"?>
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
xmlns:s="http://store"
targetNamespace="http://store"
name="store">
<component name="store">
<t:implementation.widget location="ufservices/store.html" />
<service name="Widget">
<t:binding.http uri="http://localhost:8080/store" />
</service>
<reference name="catalog" target="Catalog">
<t:binding.jsonrpc />
</reference>
<reference name="shoppingCart" target="ShoppingCart/Cart">
<t:binding.atom />
</reference>
<reference name="shoppingTotal" target="ShoppingCart/Total">
<t:binding.jsonrpc />
</reference>
<reference name="hellowService" target="HelloWorldService">
<t:binding.jsonrpc />
</reference>
</component>
<component name="Catalog">
<implementation.java class="services.CatalogImpl" />
<property name="currencyCode">USD</property>
<service name="Catalog">
<t:binding.jsonrpc uri="http://localhost:8080/Catalog"/>
</service>
<reference name="currencyConverter" target="CurrencyConverter" />
</component>
<component name="ShoppingCart">
<implementation.java class="services.ShoppingCartImpl" />
<service name="Cart">
<t:binding.atom uri="http://localhost:8080/ShoppingCart/Cart" />
</service>
<service name="Total">
<t:binding.jsonrpc uri="http://localhost:8080/Total"/>
</service>
</component>
<component name="CurrencyConverter">
<implementation.java class="services.CurrencyConverterImpl" />
</component>
<component name="HelloWorldService">
<implementation.osgi xmlns=http://tuscany.apache.org/xmlns/sca/1.0
bundleSymbolicName="com.javaworld.sample.HelloService"
bundleVersion="1.0.0.qualifier">
</implementation.osgi>
</component>
</composite>
You can see at the end of this file that I created a component which refers to osgi implementation of the HelloWorldService bundle.
Below is part of my store component which is an html file:
<html>
<head>
<title>Store</title>
<script type="text/javascript" src="store.js"></script>
<script language="JavaScript">
//#Reference
var hellowService= new tuscany.sca.Reference("hellowService");
function displayHellowService()
{
var h= hellowService.sayHello();
alert(h);
}
</script>
</head>
<body>
<h1>Store</h1>
<div id="store">
<form name="shoppingCartForm">
<input type="button" id="button1" onclick="displayHellowService()"/>
</form>
</div>
</body>
</html>
I also have a launch java file which contains the main method and creates the whole thing.
Finally, below are the errors I get when i run the project.
SEVERE: ContributionReadException occured due to : org.xml.sax.SAXParseException; lineNumber: 51; columnNumber: 36; Open quote is expected for attribute "xmlns" associated with an element type "implementation.osgi".
يول 14, 2013 1:37:52 ص org.apache.tuscany.sca.assembly.xml.CompositeDocumentProcessor
SEVERE: ContributionReadException occured due to : com.ctc.wstx.exc.WstxIOException: Stream closed
Exception in thread "main" org.osoa.sca.ServiceRuntimeException: org.apache.tuscany.sca.contribution.service.ContributionException: org.apache.tuscany.sca.contribution.service.ContributionReadException: com.ctc.wstx.exc.WstxIOException: Stream closed
at org.apache.tuscany.sca.node.impl.NodeImpl.<init>(NodeImpl.java:204)
at org.apache.tuscany.sca.node.impl.NodeFactoryImpl.createSCANodeFromClassLoader(NodeFactoryImpl.java:37)
at org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain.init(DefaultSCADomain.java:178)
at org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain.<init>(DefaultSCADomain.java:100)
at org.apache.tuscany.sca.host.embedded.SCADomain.createNewInstance(SCADomain.java:182)
at org.apache.tuscany.sca.host.embedded.SCADomain.newInstance(SCADomain.java:63)
at launch.Launch.main(Launch.java:8)
Caused by: org.apache.tuscany.sca.contribution.service.ContributionException: org.apache.tuscany.sca.contribution.service.ContributionReadException: com.ctc.wstx.exc.WstxIOException: Stream closed
at org.apache.tuscany.sca.contribution.service.impl.ContributionServiceImpl.addContribution(ContributionServiceImpl.java:421)
at org.apache.tuscany.sca.contribution.service.impl.ContributionServiceImpl.contribute(ContributionServiceImpl.java:198)
at org.apache.tuscany.sca.node.impl.NodeImpl.configureNode(NodeImpl.java:524)
at org.apache.tuscany.sca.node.impl.NodeImpl.<init>(NodeImpl.java:200)
... 6 more
Caused by: org.apache.tuscany.sca.contribution.service.ContributionReadException: com.ctc.wstx.exc.WstxIOException: Stream closed
at org.apache.tuscany.sca.assembly.xml.CompositeDocumentProcessor.read(CompositeDocumentProcessor.java:214)
at org.apache.tuscany.sca.assembly.xml.CompositeDocumentProcessor.read(CompositeDocumentProcessor.java:137)
at org.apache.tuscany.sca.assembly.xml.CompositeDocumentProcessor.read(CompositeDocumentProcessor.java:59)
at org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor.read(ExtensibleURLArtifactProcessor.java:96)
at org.apache.tuscany.sca.contribution.service.impl.ContributionServiceImpl.processReadPhase(ContributionServiceImpl.java:587)
at org.apache.tuscany.sca.contribution.service.impl.ContributionServiceImpl.addContribution(ContributionServiceImpl.java:419)
... 9 more
Caused by: com.ctc.wstx.exc.WstxIOException: Stream closed
at com.ctc.wstx.stax.WstxInputFactory.doCreateSR(WstxInputFactory.java:548)
at com.ctc.wstx.stax.WstxInputFactory.createSR(WstxInputFactory.java:604)
at com.ctc.wstx.stax.WstxInputFactory.createSR(WstxInputFactory.java:619)
at com.ctc.wstx.stax.WstxInputFactory.createXMLStreamReader(WstxInputFactory.java:317)
at org.apache.tuscany.sca.contribution.processor.DefaultValidatingXMLInputFactory.createXMLStreamReader(DefaultValidatingXMLInputFactory.java:226)
at org.apache.tuscany.sca.assembly.xml.CompositeDocumentProcessor.read(CompositeDocumentProcessor.java:181)
... 14 more
Caused by: java.io.IOException: Stream closed
at java.io.BufferedInputStream.getBufIfOpen(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at com.ctc.wstx.io.StreamBootstrapper.ensureLoaded(StreamBootstrapper.java:443)
at com.ctc.wstx.io.StreamBootstrapper.resolveStreamEncoding(StreamBootstrapper.java:267)
at com.ctc.wstx.io.StreamBootstrapper.bootstrapInput(StreamBootstrapper.java:131)
at com.ctc.wstx.stax.WstxInputFactory.doCreateSR(WstxInputFactory.java:543)
... 19 more
Can someone give me a guide to a tutorial or help me to solve the problem. Thanks.
You have XML syntax errors here:
<component name="HelloWorldService">
<implementation.osgi xmlns=http://tuscany.apache.org/xmlns/sca/1.0
bundleSymbolicName="com.javaworld.sample.HelloService"
bundleVersion="1.0.0.qualifier">
</implementation.osgi>
</component>
I can't help you otherwise, but SEVERE: ContributionReadException occured due to : org.xml.sax.SAXParseException; lineNumber: 51; columnNumber: 36; Open quote is expected for attribute "xmlns" associated with an element type "implementation.osgi".
is just XML parsing issues. You can tell by the 'SAXParseException', SAX being Simple API for XML.
The problem is because you are declaring a XML namespace without quotes, change it to:
<implementation.osgi xmlns="http://tuscany.apache.org/xmlns/sca/1.0" />
Note the namespace is enclosed with quotes ("")
Furthermore, let me point you to this tutorial. Even though it is meant for Rational Application Developer, the code will work as well
http://pic.dhe.ibm.com/infocenter/radhelp/v9/topic/com.ibm.sca.tools.doc/tutorials/osgi/sca_osgi_abstract.html
Hope this helps.
Related
I am not a techie but have assumed some responsibilities in someone's absence.
Trying to push below Consent FHIR Resource:
<Consent xmlns="http://hl7.org/fhir">
<id value="123" />
<status value="inactive" />
<scope>
<coding>
<system value="http://terminology.hl7.org/CodeSystem/consentscope" />
<code value="patient-privacy" />
</coding>
</scope>
<category>
<coding>
<system value="http://loinc.org" />
<code value="59284-0" />
</coding>
</category>
<patient>
<reference value="Patient/41" />
<display value="John Stifiles" />
</patient>
<policyRule>
<coding>
<system value="http://terminology.hl7.org/CodeSystem/consentpolicycodes" />
<code value="cric" />
</coding>
</policyRule>
<provision>
<type value="deny" />
<period>
<start value="2021-09-27" />
<end value="2021-09-27" />
</period>
</provision>
</Consent>
This is passed with no errors from inferno.healthit.gov/validator/ but when I run through my integrator (it hits HL7 validator), I get a variety of errors - Encountered unknown member 'Scope' or Encountered unknown member 'Patient', etc.
This is a Consent resource that conforms to FHIR version R4. Inferno runs FHIR R4 as well, so that works.
However, if you try and validate this resource against FHIR STU3, you will get the errors you mentioned, since the Consent resource structure significantly changed from STU3 to R4. Please check your integrator and make sure it runs FHIR R4 as well.
I have an XML fragment and use it in several places in an XML view.
<IconTabFilter text="ABC" key="1" icon="sap-icon://alphabetical-order">
<content>
<Table id="table1" width="auto" items="{path:'/ContactSet',parameters:{expand:'BusinessAddress,HomeAddress,OtherAddress,Photo'},filters:[{path:'Surname',operator:'StartsWith',value1:'A'},{path:'Surname',operator:'StartsWith',value1:'B'},{path:'Surname',operator:'StartsWith',value1:'C'}]}" noDataText=" {worklistView>/tableNoDataText}" busyIndicatorDelay="{worklistView>/tableBusyDelay}" growing="true" growingScrollToLoad="true" updateFinished="onUpdateFinished">
<headerToolbar>
<core:Fragment fragmentName="de.cimt.cimply.AddressBook.view.worklist.tablesHeader" type="XML"/>
</headerToolbar>
<columns>
<core:Fragment fragmentName="de.cimt.cimply.AddressBook.view.worklist.tablesColumns" type="XML"/>
</columns>
<items>
<core:Fragment fragmentName="de.cimt.cimply.AddressBook.view.worklist.tablesRows" type="XML"/>
</items>
</Table>
</content>
</IconTabFilter>
<IconTabSeparator icon="sap-icon://process"/>
<IconTabFilter text="DEF" key="2" icon="sap-icon://alphabetical-order">
<content>
<Table id="table2" width="auto" items="{path:'/ContactSet',parameters:{expand:'BusinessAddress,HomeAddress,OtherAddress,Photo'},filters:[{path:'Surname',operator:'StartsWith',value1:'D'},{path:'Surname',operator:'StartsWith',value1:'E'},{path:'Surname',operator:'StartsWith',value1:'F'}]}" noDataText="{worklistView>/tableNoDataText}" busyIndicatorDelay="{worklistView>/tableBusyDelay}" growing="true" growingScrollToLoad="true" updateFinished="onUpdateFinished">
<headerToolbar>
<core:Fragment fragmentName="de.cimt.cimply.AddressBook.view.worklist.tablesHeader" type="XML"/>
</headerToolbar>
<columns>
<core:Fragment fragmentName="de.cimt.cimply.AddressBook.view.worklist.tablesColumns" type="XML"/>
</columns>
<items>
<core:Fragment fragmentName="de.cimt.cimply.AddressBook.view.worklist.tablesRows" type="XML"/>
</items>
</Table>
</content>
</IconTabFilter>
But the view takes too long to load, especially in WEBIDE.
The reason is it loads similar fragment files several times. Here is an evidence:
The question is how can I improve the performance?
I don't want to repeat the code and I need to put that part of the code in a fragment, but I expected my browser to not load the same file several times.
There is no need to change your code in that case. SAP Web IDE / SCP leverages App Cache Buster concept out of the box, which fetches application resources (e.g. fragments) from the browser cache as long as those resources were not altered before.
See the sample screenshot below:
Given
Code:
<core:Fragment fragmentName="demo.view.fragment.MyFragment" type="XML" />
<core:Fragment fragmentName="demo.view.fragment.MyFragment" type="XML" />
<core:Fragment fragmentName="demo.view.fragment.MyFragment" type="XML" />
<core:Fragment fragmentName="demo.view.fragment.MyFragment" type="XML" />
<core:Fragment fragmentName="demo.view.fragment.MyFragment" type="XML" />
<core:Fragment fragmentName="demo.view.fragment.MyFragment" type="XML" />
URL attribute sap-ui-appCacheBuster=... which Web IDE automatically appends on app launch (describes where sap-ui-cachebuster-info.json is located)
If the devtool is open: Disable cache Unchecked <-- probably that was still activated in your case
Result
As you can see, fragments (and other resources) are loaded fron the disk cache instead of re-fetching them again and again.
Additionally, if the application is bundled for the final production environment, those fragments won't be even requested multiple times as they're typically already included in the bundled file (e.g. Component-preload.js).
If you run your app not in the webide testing environment the fragements should be loaded from cache.
However, you could load your fragment in your controller and use factoryfunctions instead of templates. Something like:
View:
<mvc:View controllerName="test.test.controller.View1" xmlns:mvc="sap.ui.core.mvc" xmlns:core="sap.ui.core" displayBlock="true" xmlns="sap.m">
<Shell id="shell">
<App id="app">
<pages>
<Page id="page" title="{i18n>title}">
<content>
<List items="{ path: '/myList', factory: '.myListFactory' }"/>
</content>
</Page>
</pages>
</App>
</Shell>
in your controller:
onInit: function () {
this.getView().setModel(new JSONModel({
"myList" : [{
"Name": "Test1"
}, {
"Name": "Test2"
}]
}));
},
myListFactory: function (sId) {
if(!this._myListFragment){
this._myListFragment = new sap.ui.xmlfragment("test.test.view.myListFragment", this);
}
return this._myListFragment.clone(sId);
}
fragment:
<core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core">
<StandardListItem icon="sap-icon://warning" title="{Name}" />
I'm interested in defining multiple event-types my app.config file but it doesn't appear to get loaded by default. Is there something that I'm doing wrong? The event type doesn't exist within com.espertech.esper.client.Configuration.
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net" />
<section name="esper-configuration" type="com.espertech.esper.util.EsperSectionHandler,NEsper" />
</configSections>
<esper-configuration>
<engine-settings>
<defaults>
<threading>
<listener-dispatch preserve-order="false" timeout-msec="2000" locking="suspend" />
<insert-into-dispatch preserve-order="false" timeout-msec="3000" locking="suspend" />
<internal-timer enabled="false" msec-resolution="1234567" />
<thread-local style="fast" />
</threading>
<event-meta>
<class-property-resolution style="distinct_case_insensitive" />
</event-meta>
<view-resources>
<share-views enabled="false" />
</view-resources>
<logging>
<execution-path enabled="true" />
</logging>
<variables>
<msec-version-release value="30000" />
</variables>
</defaults>
</engine-settings>
<event-type name="Products" class="ProtoProduct"/>
<event-type name="MarketDepths" class="ProtoDepth"/>
<event-type name="MarketTrades" class="ProtoTrade"/>
<event-type name="Orders" class="ProtoOrder"/>
<event-type name="Positions" class="ProtoPosition"/>
<auto-import import-name="org.mycompany.mypackage.MyUtility"/>
<auto-import import-name="org.mycompany.util.*"/>
</esper-configuration>
The most likely issue is that you haven't used the fully qualified name of the class. In your examples, the classes have no namespace. If your classes are in a namespace add those to the class attribute in your config. If for some reason that isn't the issue, it is most likely that the tips are not visible within the AppDomain. Just make sure they are built into your assembly.
I'm trying to map my Struts actions using wildcards.
Before, I used UrlRewrite Filter by Tuckey. But this question changed my mind.
So here's my problem: My URL's look like the following:
www.example.com/promoties/category-123
www.example.com/promoties/category-123/subcategory-456
In these examples, the words category and subcategory are dummy data used to make the URL more relevant for search engines.
Now I'd like to ignore this dummy data, as I'm just interested in the (last) ID. In the first case 123 in the last case 456.
I've tried the following without success:
<package name="promoties" namespace="/promoties" extends="struts-default">
<action name="([0-9a-zA-Z\-_]+)-{id:([0-9]+)}$" class="CategoryAction">
<result type="tiles">categorydetail</result>
</action>
</package>
Using following options in my struts.xml:
<constant name="struts.enable.SlashesInActionNames" value="true"/>
<constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/>
<constant name="struts.patternMatcher" value="regex" />
Has anyone tried this before? How would I go about doing this in Struts2?
One way is to use simple wild card mapping and regulate the validation of the id component to struts2 validation. Here is an example which has been tested, but without validation.
struts.xml you'll see an action defined for category-* and category-*/subcategory-* in the second we'll just keep the second wild card.
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="true" />
<constant name="struts.ognl.allowStaticMethodAccess" value="true"/>
<constant name="struts.enable.SlashesInActionNames" value="true"/>
<constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/>
<package namespace="" name="default" extends="struts-default">
<action name="category-*" class="test.TestBean">
<param name="id">{1}</param>
<result>/WEB-INF/content/test/results.jsp</result>
</action>
<action name="category-*/subcategory-*" class="test.TestBean">
<param name="id">{2}</param>
<result>/WEB-INF/content/test/results.jsp</result>
</action>
</package>
</struts>
test.TestBean here I used a String but in your case you'll change this to int or Integer. You'll want to validate that we did get an integer using validation xml or simply implementing com.opensymphony.xwork2.Validateable.
package test;
import com.opensymphony.xwork2.ActionSupport;
public class TestBean extends ActionSupport{
//public to avoid get/set to make example shorter
public String id;
}
/WEB-INF/content/test/results.jsp
<%#taglib prefix="s" uri="/struts-tags"%>
<html>
<body>
<h1>Wild Card Value</h1>
id: <s:property value="id"/>
</body>
</html>
Example 1
The url: example.com/category-helloBart produces...
Wild Card Value
id: helloBart
Example 2
The url: example.com/category-helloBart/subcategory-123 produces...
Wild Card Value
id: 123
I wanted to know if there is a way that I can write ELMAH to filter out error logging under the following logic:
If the error is a 404 on favicon.ico OR the error is 404 on /1.xml OR the error is 404 on /2.xml
I have found the way to just do it on the favicon.ico as shown:
<errorFilter>
<test>
<and>
<equal binding="HttpStatusCode" value="404" type="Int32" />
<regex binding="Context.Request.ServerVariables['URL']" pattern="/favicon\.ico(\z|\?)" />
</and>
</test>
</errorFilter>
But for some reason, I cannot understand how to do it for the OR conditions. Any help will be much appreciated.
The following should do the trick or otherwise get you started:
<errorFilter>
<test>
<and>
<equal binding="HttpStatusCode" value="404" type="Int32" />
<or>
<regex binding="Context.Request.ServerVariables['URL']"
pattern="/favicon\.ico(\z|\?)" />
<regex binding="Context.Request.ServerVariables['URL']"
pattern="/[1-2]\.xml(\z|\?)" />
</or>
</and>
</test>
</errorFilter>
Basically, this will filter errors where the HTTP status code is 404 and one of the regular expressions patterns grouped under the or element match the request URL.