You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsrf-commits@ws.apache.org by jr...@apache.org on 2005/07/28 18:46:40 UTC
svn commit: r225815 -
/webservices/wsrf/trunk/src/site/content/xdocs/tutorial/mod_home.xml
Author: jruzzi
Date: Thu Jul 28 09:46:33 2005
New Revision: 225815
URL: http://svn.apache.org/viewcvs?rev=225815&view=rev
Log:
changed to init
Modified:
webservices/wsrf/trunk/src/site/content/xdocs/tutorial/mod_home.xml
Modified: webservices/wsrf/trunk/src/site/content/xdocs/tutorial/mod_home.xml
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/site/content/xdocs/tutorial/mod_home.xml?rev=225815&r1=225814&r2=225815&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/site/content/xdocs/tutorial/mod_home.xml (original)
+++ webservices/wsrf/trunk/src/site/content/xdocs/tutorial/mod_home.xml Thu Jul 28 09:46:33 2005
@@ -8,53 +8,31 @@
<body>
<section>
<title>Introduction</title>
- <p>In this step of the tutorial, the generated Home class (<code>FilesystemHome</code>) is modified to include a <code>getInstance</code> method.
+ <p>In this step of the tutorial, the generated Home class (<code>FilesystemHome</code>) is modified to include an <code>init</code> method.
The Home is used to lookup the resource instance. It can act as a factory for creating instances upon request, or build all instances. It is meant
to be the entry point for locating a resource instance.
</p>
</section>
<section>
- <title>Modify the Home Class</title>
+ <title>Modify the FileSytem Home Class</title>
<p>Open <code>WORK_DIR/generated/filesystem/src/java/org/apache/ws/resource/example/filesystem/FilesystemHome.java</code> and
- replace the <code>public Resource getInstance( ResourceContext resourceContext )</code> method with the following method:</p>
- <source><![CDATA[ public Resource getInstance( ResourceContext resourceContext )
- throws ResourceException,
- ResourceContextException,
- ResourceUnknownException
+ replace the <code>public void init()</code> method with the following method. You will also need to copy the instance variables below.</p>
+ <source><![CDATA[
+ private static final String LVOL1_ID = "/dev/vg00/lvol1";
+ private static final String LVOL2_ID = "/dev/vg00/lvol2";
+
+ /**
+ * Create and add two resource instances.
+ *
+ * @throws Exception on error
+ */
+ public void init() throws Exception
{
- ResourceKey key = resourceContext.getResourceKey();
- FilesystemResource resource = null;
- try
- {
- resource = (FilesystemResource)find( key );
- }
- catch ( ResourceException re )
- {
- Object id = key.getValue();
- /**
- * Determine if the passed-in key is, in fact, something we expect.
- */
- if ( id.equals( "/dev/vg00/lvol1" ) || id.equals( "/dev/vg00/lvol2" ) )
- {
- try
- {
- resource = (FilesystemResource)createInstance( key);
- EndpointReference epr = getEndpointReference(resourceContext.getBaseURL( ) + "/" + getServiceName().getLocalPart() , key, SPEC_NAMESPACE_SET.getAddressingNamespace());
- resource.setEndpointReference(epr);
- }
- catch ( Exception e )
- {
- throw new ResourceException( e );
- }
- add( key, resource );
- }
- else
- {
- throw new ResourceUnknownException( id,
- resourceContext.getServiceName() );
- }
- }
- return resource;
+ super.init();
+ FilesystemResource lvol1Resource = (FilesystemResource) createInstance( LVOL1_ID );
+ add( lvol1Resource );
+ FilesystemResource lvol2Resource = (FilesystemResource) createInstance( LVOL2_ID );
+ add( lvol2Resource );
}]]></source>
<p>
<img src="images/back.gif" alt="go to the previous step"/>