org.springbyexample.httpclient.solr
Class SolrOxmClient<T>

java.lang.Object
  extended by org.springbyexample.httpclient.solr.SolrOxmClient<T>
All Implemented Interfaces:
DisposableBean, InitializingBean

public class SolrOxmClient<T>
extends Object
implements InitializingBean, DisposableBean

Specialized client for processing requests with Solr that are marshalled and unmarshalled.

Author:
David Winterfeldt

Field Summary
protected  String baseUrl
           
protected static String COMMIT_ELEMENT_NAME
           
protected static String DELETE_ELEMENT_NAME
           
protected static String DELETE_ID_ELEMENT_NAME
           
protected static String DELETE_QUERY_ELEMENT_NAME
           
protected  Marshaller marshaller
           
protected static String OPTIMIZE_ELEMENT_NAME
           
protected  HttpClientTemplate postTemplate
           
protected static String ROLLBACK_REQUEST
           
static String SEARCH_QUERY_PARAM
           
protected static String SELECT_URL_SUFFIX
           
protected  HttpClientOxmTemplate<List<T>> selectTemplate
           
protected  Unmarshaller unmarshaller
           
protected static String UPDATE_URL_SUFFIX
           
protected  HttpClientOxmTemplate<List<T>> updateTemplate
           
 
Constructor Summary
SolrOxmClient()
           
 
Method Summary
 void afterPropertiesSet()
          Initializes HttpClientTemplates.
 void commit()
          Commits pending transactions.
 void commit(SolrRequestAttributes attrs)
          Commits pending transactions using specified attributes.
protected  void delete(String query, boolean commit)
          Deletes.
 void deleteById(String id)
          Deletes a record based on an id and automatically commits the delete.
 void deleteById(String id, boolean commit)
          Deletes a record based on an id.
 void deleteByQuery(String query)
          Deletes an id and automatically commits the delete.
 void deleteByQuery(String query, boolean commit)
          Deletes an id and automatically commits the delete.
 void destroy()
          Calls destroy on HttpClientTemplates.
 String getBaseUrl()
          Gets base url (ex: http://localhost:8983/solr).
 Marshaller getMarshaller()
          Gets marshaller.
protected  String getSelectUrl()
          Gets Solr select url.
 Unmarshaller getUnmarshaller()
          Gets unmarshaller.
protected  String getUpdateUrl()
          Gets Solr update url.
 void optimize()
          Optimize.
 void optimize(SolrRequestAttributes attrs)
          Optimize using specified attributes.
 void rollback()
          Rollback pending transactions.
 List<T> search(Map<String,String> hParams)
          Search.
 List<T> search(String query)
          Search.
 List<T> search(String query, Map<String,String> hParams)
          Search.
 void setBaseUrl(String baseUrl)
          Sets base url (ex: http://localhost:8983/solr).
 void setMarshaller(Marshaller marshaller)
          Sets marshaller.
 void setUnmarshaller(Unmarshaller unmarshaller)
          Sets unmarshaller.
 void update(List<T> lBeans)
          Updates a list of beans and automatically commits the updates.
 void update(List<T> lBeans, boolean commit)
          Updates a list of beans.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEARCH_QUERY_PARAM

public static final String SEARCH_QUERY_PARAM
See Also:
Constant Field Values

SELECT_URL_SUFFIX

protected static final String SELECT_URL_SUFFIX
See Also:
Constant Field Values

UPDATE_URL_SUFFIX

protected static final String UPDATE_URL_SUFFIX
See Also:
Constant Field Values

DELETE_ELEMENT_NAME

protected static final String DELETE_ELEMENT_NAME
See Also:
Constant Field Values

DELETE_ID_ELEMENT_NAME

protected static final String DELETE_ID_ELEMENT_NAME
See Also:
Constant Field Values

DELETE_QUERY_ELEMENT_NAME

protected static final String DELETE_QUERY_ELEMENT_NAME
See Also:
Constant Field Values

COMMIT_ELEMENT_NAME

protected static final String COMMIT_ELEMENT_NAME
See Also:
Constant Field Values

ROLLBACK_REQUEST

protected static final String ROLLBACK_REQUEST
See Also:
Constant Field Values

OPTIMIZE_ELEMENT_NAME

protected static final String OPTIMIZE_ELEMENT_NAME
See Also:
Constant Field Values

selectTemplate

protected HttpClientOxmTemplate<List<T>> selectTemplate

updateTemplate

protected HttpClientOxmTemplate<List<T>> updateTemplate

postTemplate

protected HttpClientTemplate postTemplate

baseUrl

protected String baseUrl

marshaller

protected Marshaller marshaller

unmarshaller

protected Unmarshaller unmarshaller
Constructor Detail

SolrOxmClient

public SolrOxmClient()
Method Detail

getBaseUrl

public String getBaseUrl()
Gets base url (ex: http://localhost:8983/solr).


setBaseUrl

public void setBaseUrl(String baseUrl)
Sets base url (ex: http://localhost:8983/solr).


getSelectUrl

protected String getSelectUrl()
Gets Solr select url.


getUpdateUrl

protected String getUpdateUrl()
Gets Solr update url.


getMarshaller

public Marshaller getMarshaller()
Gets marshaller.


setMarshaller

public void setMarshaller(Marshaller marshaller)
Sets marshaller.


getUnmarshaller

public Unmarshaller getUnmarshaller()
Gets unmarshaller.


setUnmarshaller

public void setUnmarshaller(Unmarshaller unmarshaller)
Sets unmarshaller.


afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception

Initializes HttpClientTemplates.

Implementation of InitializingBean.

Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

destroy

public void destroy()
             throws Exception

Calls destroy on HttpClientTemplates.

Implementation of DisposableBean.

Specified by:
destroy in interface DisposableBean
Throws:
Exception

search

public List<T> search(String query)
Search.

Parameters:
query - Search query.

search

public List<T> search(String query,
                      Map<String,String> hParams)
Search.

Parameters:
query - Search query.
hParams - Map of query parameters.

search

public List<T> search(Map<String,String> hParams)
Search.

Parameters:
hParams - Map of query parameters.

update

public void update(List<T> lBeans)
Updates a list of beans and automatically commits the updates.

Parameters:
lBeans - List of beans to create or update.

update

public void update(List<T> lBeans,
                   boolean commit)
Updates a list of beans.

Parameters:
lBeans - List of beans to create or update.
commit - Whether or not to commit the request.

deleteById

public void deleteById(String id)
Deletes a record based on an id and automatically commits the delete.

Parameters:
id - ID to delete.

deleteById

public void deleteById(String id,
                       boolean commit)
Deletes a record based on an id.

Parameters:
id - ID to delete.
commit - Whether or not to commit the request.

deleteByQuery

public void deleteByQuery(String query)
Deletes an id and automatically commits the delete.

Parameters:
query - ID to delete.

deleteByQuery

public void deleteByQuery(String query,
                          boolean commit)
Deletes an id and automatically commits the delete.

Parameters:
query - ID to delete.
commit - Whether or not to commit the request.

delete

protected void delete(String query,
                      boolean commit)
Deletes.

Parameters:
query - Query should either be an id element or query element.
commit - Whether or not to commit the request.

commit

public void commit()
Commits pending transactions.


commit

public void commit(SolrRequestAttributes attrs)
Commits pending transactions using specified attributes.


rollback

public void rollback()
Rollback pending transactions.


optimize

public void optimize()
Optimize.


optimize

public void optimize(SolrRequestAttributes attrs)
Optimize using specified attributes.



Copyright © 2008-2009 Spring by Example. All Rights Reserved.