You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by xing007008 <xi...@163.com> on 2008/09/21 04:18:55 UTC

Re: Help required to write JSR 170 connector

That is the right code which i need.
:jumping:

Yamini Kumar, Noida wrote:
> 
> 
> Hi,
> 
> My objective is to standardize the access (read/write or both) to data
> content in data sources like a database (MySQL) and any other content
> repository that is not JSR 170 compliant like Open CMS, live link or
> share point. By standardizing access I mean that the client program will
> no longer call the respository specific API like LAPI or JDBC but rather
> call JCR API methods to achieve common functions like, login, logout,
> read and write. 
> 
>  
> 
> I want to clear my concepts by writing a kind of sample connector for MY
> SQL database which can be accessed by JCR API rather than JDBC. I
> understand that in order to do I need to write a wrapper around JDBC API
> which will perform the desired operations using JDBC (as My SQL
> understand JDBC) but for a developer the entry point will be JCR API.
> 
>  
> 
> I have confusion while writing this wrapper. I have taken an example of
> exportsystemview() of JCR API.
>  
> 
> The client code to access this method in CRX using JCR API is 
> 
>  
> 
> /*
> 
> public class ExportXMLFromCRX {
> 
> public static void main(String[] args) {
> 
>                         String propertyName = "";
> 
>                         Repository repository = null;
> 
>                         Session repSession = null;
> 
>                         FileInputStream fileInputStream = null;
> 
>                         FileOutputStream fileOutputStream = null;
> 
>                         try 
> 
>                         {
> 
>                                     ClientRepositoryFactory factory =
> new ClientRepositoryFactory();
> 
>                                     // This is mandatory for rmi access
> to the CRX
> 
>  
> System.setProperty("java.rmi.server.useCodebaseOnly", "true"); 
> 
>                                     repository =
> factory.getRepository("//localhost:1234/crx");
> 
>                                     if(repository != null)
> 
>                                     {
> 
>                                     userCredentials = new
> SimpleCredentials(userID,password);
> 
> repSession = repository.login(new SimpleCredentials("admin",
> "admin".toCharArray(), "crx.default");
> 
>                                     if(repSession != null)
> 
>                                     {
> 
>                                     File outputFile = new
> File("C:/test1.xml");
> 
>                                     FileOutputStream out = new
> FileOutputStream(outputFile);
> 
>  
> repSession.exportSystemView("/MyRootNode", out, false, false);
> 
>                                     }//end if(repSession != null)
> 
>                                     }// end if(repository != null)
> 
>                         } //end try
> 
>                         catch (Exception Exc)
> 
>                         {
> 
>  
> System.out.println(Exc.getMessage());
> 
>                         }//end catch
> 
>                         finally
> 
>                         {
> 
> repSession.save(); //save to update nodes created in the CRX Session
> 
>                                     repSession.logout(); //duly log-out
> of the CRX session
> 
>                                     }//end try
> 
>                         }// end finally
> 
>             }
> 
> }
> 
> */
> 
>  
> 
> What I want is to have a different implementation of the same method
> which will fetch data from database in an XML format & returns the XML
> the way the above method does
> 
>  
> 
> How should I write a wrapper class for my custom method which fetches
> record from DB and build an XML but exposed as JCR method? If I am able
> to do so then the above client code can be used as it is for my MYSQL
> wrapper code as well. The difference will be that it will no longer
> fetch data from CRX and build XML but will build an XML based on my
> database records.
> 
>  
> 
> Please suggest what are the steps I need to perform to achieve this?
> 
>  
> 
>  
> 
>  
> 
> 
> 
> DISCLAIMER:
> -----------------------------------------------------------------------------------------------------------------------
> The contents of this e-mail and any attachment(s) are confidential and
> intended for the named recipient(s) only. 
> It shall not attach any liability on the originator or HCL or its
> affiliates. Any views or opinions presented in 
> this email are solely those of the author and may not necessarily reflect
> the opinions of HCL or its affiliates. 
> Any form of reproduction, dissemination, copying, disclosure,
> modification, distribution and / or publication of 
> this message without the prior written consent of the author of this
> e-mail is strictly prohibited. If you have 
> received this email in error please delete it and notify the sender
> immediately. Before opening any mail and 
> attachments please check them for viruses and defect.
> -----------------------------------------------------------------------------------------------------------------------
> 
-- 
View this message in context: http://www.nabble.com/Help-required-to-write-JSR-170-connector-tp15667379p19591008.html
Sent from the Jackrabbit - Dev mailing list archive at Nabble.com.