Hi, Simon. "In SCA, the default service name for a class with no @Service annotation is the unqualified name of the class. In your example, the class is named rocku.java.infoshare.services.**FeedImpl, so the service will be named FeedImpl. "
I changed the service name to "FeedImpl" and I got a warning: Service not found for component service: Component = FeedComponent Service = FeedImpl I remember that in the store example, the service names are always the interface name. So is that true the the default service name for a class with no @Service annotation is the unqualified name of the class? When it comes to my problem, I find it weird that the code runs OK today. I paste the problematic code in this post which didn't run correctly 4 days ago, and the feed works fine! I can't figure out why. On Thu, Aug 18, 2011 at 4:19 PM, Simon Nash <[email protected]> wrote: > Tianlong Wu wrote: > >> I checked the example of blog-feed and fixed my problem. >> Actually the code was right. It is the composite file that had sth. >> wrong. In my composite file, I exposed service with the component: >> <component name="FeedComponent"> >> <implementation.java class="rocku.java.infoshare.**services.FeedImpl" >> /> >> <service name="Collection"> >> <t:binding.rss /> >> </service> >> </component> >> while in the blog-feed example, the RSS service was promoted: >> <service name="BlogRSSAPIs" promote="BlogRSS"> >> <tuscany:binding.rss >> uri="http://localhost:8090/**BlogRSSAPIs<http://localhost:8090/BlogRSSAPIs> >> "/> >> </service> >> >> <component name="BlogRSS"> >> <implementation.java class="com.tuscanyscatours.**blog.feed.impl.** >> RSSBlogFeedImpl"/> >> </component> >> >> I changed my composite file adding a promoted service and everything is >> OK. >> So what's the difference between this two kind of service? >> >> You don't need to use promotion. I modified the blog-feed sample to > expose a service without using promotion and confirmed that it works OK. > To make your non-promoted service work, you need to fix the service name > in your composite. > > In SCA, the default service name for a class with no @Service annotation > is the unqualified name of the class. In your example, the class is > named rocku.java.infoshare.services.**FeedImpl, so the service will be > named FeedImpl. You need to use this name when configuring your composite, > as follows: > > > <component name="FeedComponent"> > <implementation.java class="rocku.java.infoshare.**services.FeedImpl" > /> > <service name="FeedImpl"> > > <t:binding.rss /> > </service> > </component> > > The reason it works with promotion is that promotion allows you to > omit the service name if there is only one service in the component. > So when you write > promote="FeedComponent" > you are actually promoting the service named FeedComponent/FeedImpl > because this is the only service in FeedComponent. > > It's not a good idea to use promotion in a top-level deployment composite > as the blog-feed sample does. This is because SCA 1.1 and Tuscany 2.0 > don't support this use of promotion to reconfigure a component deployed > into the domain. It works in Tuscany 1.x and is used by many of the > Tuscany 1.x samples, but this is for historical reasons. Promotion is > still used in SCA 1.1 and Tuscany 2.0 to reconfigure a service that's > part of an implementation composite. > > Simon > > On Tue, Aug 16, 2011 at 3:37 PM, Simon Nash <[email protected] <mailto: >> [email protected]>> wrote: >> >> Tianlong Wu wrote: >> >> hello, >> I was trying to build a rss feed service using tuscany. >> I implemented the interface >> org.apache.tuscany.sca.__**binding.rss.collection.__**Collection >> like this: >> public class FeedImpl implements Collection { >> >> public SyndEntry get(String id) throws NotFoundException { >> // TODO Auto-generated method stub >> SyndPerson author = new SyndPersonImpl( ); >> author.setEmail("editor@__exam**ple.org<http://example.org> >> <mailto:[email protected]> <mailto:[email protected] >> >> <mailto:[email protected]>>")**; >> >> author.setName("Example Person"); >> SyndEntry entry = new SyndEntryImpl( ); >> entry.setTitle("First Entry Title"); >> >> entry.setLink("http://www.__ex**ample.org/item1<http://example.org/item1> >> <http://www.example.org/item1>**"); >> SyndContent description = new SyndContentImpl( ); >> description.setValue("News about the Example project"); >> description.setType("text"); >> entry.setDescription(__**description); >> entry.setAuthors(Collections._**_singletonList(author)); >> return entry; >> } >> >> public SyndFeed getFeed() { >> // TODO Auto-generated method stub >> SyndPerson author = new SyndPersonImpl( ); >> author.setEmail("editor@__exam**ple.org<http://example.org> >> <mailto:[email protected]> <mailto:[email protected] >> >> <mailto:[email protected]>>")**; >> >> author.setName("Example Person"); >> SyndFeed feed = new SyndFeedImpl( ); >> feed.setTitle("Example Feed Output from ROME"); >> feed.setDescription("The Example Organization web site"); >> feed.setAuthors(Collections.__**singletonList(author)); >> feed.setLink("http://www.__exa**mple.org/<http://example.org/> >> <http://www.example.org/>"); >> feed.setPublishedDate(new Date( )); >> >> List<SyndEntry> entries = new ArrayList<SyndEntry>(); >> >> try { >> entries.add(this.get("")); >> } catch (Exception e) { >> // TODO: handle exception >> } >> feed.setEntries(entries); >> return feed; >> } >> >> public SyndFeed query(String queryString) { >> // TODO Auto-generated method stub >> >> return getFeed(); >> } >> } >> and in my composite file there is: >> <component name="FeedComponent"> >> <implementation.java >> class="rocku.java.infoshare.__**services.FeedImpl" /> >> <service name="Collection"> >> <t:binding.rss /> >> </service> >> </component> >> >> The application run successfully. But when I open the >> >> URL(http://localhost:8080/__**FeedComponent<http://localhost:8080/__FeedComponent> >> >> <http://localhost:8080/**FeedComponent<http://localhost:8080/FeedComponent> >> >) >> in my browser, it outputs the following error: >> HTTP ERROR: 500 >> >> Invalid rss_2.0 feed, missing channel title >> RequestURI=/FeedComponent >> >> Caused by: >> >> com.sun.syndication.io >> <http://com.sun.syndication.io**>.__FeedException: Invalid rss_2.0 >> >> feed, missing channel title >> ...... >> >> I found the JIRA page: >> >> https://issues.apache.org/__**jira/browse/TUSCANY-3111<https://issues.apache.org/__jira/browse/TUSCANY-3111> >> >> <https://issues.apache.org/**jira/browse/TUSCANY-3111<https://issues.apache.org/jira/browse/TUSCANY-3111>>. >> It says that >> adding a description to the feed would fix the problem. But I >> explicitly set the title and >> description in my code. >> >> Thanks for your time. >> >> The Tuscany travel sample contains an example of creating an RSS feed. >> See the contributions/blog-feed and launchers/blog-feed directories >> for details of how to do this successfully. The travel sample isn't >> part of the Tuscany binary distribution, so you'll need to download it >> separately from this page: >> >> http://tuscany.apache.org/sca-**__java-travel-sample-1x-__** >> releases.html<http://tuscany.apache.org/sca-__java-travel-sample-1x-__releases.html> >> >> <http://tuscany.apache.org/**sca-java-travel-sample-1x-**releases.html<http://tuscany.apache.org/sca-java-travel-sample-1x-releases.html> >> > >> >> Simon >> >> >> -- ******************************** >> __*********************** >> Tianlong Wu >> >> Computer Science and Technology Dept. >> Harbin Institute of Technology >> NO.92 Xidazhi Street,150001 >> Harbin, Heilongjiang Province, P.R.China >> >> >> >> >> >> -- >> ******************************************************* >> Tianlong Wu >> >> Computer Science and Technology Dept. >> Harbin Institute of Technology >> NO.92 Xidazhi Street,150001 >> Harbin, Heilongjiang Province, P.R.China >> > > -- ***************************************************** Tianlong Wu Computer Science and Technology Dept. Harbin Institute of Technology NO.92 Xidazhi Street,150001 Harbin, Heilongjiang Province, P.R.China
