-
November 22nd, 2010, 01:12 PM
#1
How does lightstreamer do the filter?
Dear Lightstreamer supporter.
I have a question when I read our company's codes about lightstreamer.
I am not clear how does the lightstreamer do the filter.
I just know that we will assemble a query in the front end and send it to the medataprovider.
We have a class named FilterChainAdapter.java, it extends the class LiteralBasedProvider.
In FilterChainAdapter, I notice that we overwrite two method:
@Override
public boolean isSelectorAllowed(String user, String item, String selector) {
LOGGER.debug("START XmlQueryDataProvider.isSelectorAllowed(..)");
try {
for(AbstractFilterManager filterManager : runnable) {
/*
the runnable is a list, we store several filter manager classes in it.
In this method, we just loop each the filter manager, and execute its constructFilterChain method.
*/
filterManager.constructFilterChain(user,item,selec tor, runnable);
}
} catch (Exception e) {
LOGGER.error("Exception in XmlQueryDataProvider:isSelectorAllowed ", e);
}
return true;
}
@Override
public synchronized boolean isSelected(String user, String item, String selector, ItemEvent event) {
/*
this method was called by each filter manager. But I am not clear its purpose.
*/
LOGGER.debug("START XmlQueryDataProvider.isSelected(..)");
if (!StringUtils.hasText(selector)) {
LOGGER.warn("No query string selector found. Update refused. " +
"You should be using LiteralBasedProfile or you have forgot to add the XML query.");
return false;
}
if(runnable.isEmpty()) {
LOGGER.error("There are no runnable FilterManagers...error");
return false;
}
LOGGER.debug("Running Filter Managers....");
try {
for(AbstractFilterManager filterManager : runnable) {
if(!filterManager.accepts(user, event)){
LOGGER.debug("Filter Rejected Event!" + event.getValueAsString("key"));
return false;
}
}
} catch (Exception e) {
e.printStackTrace();
LOGGER.error("Exception in XmlQueryDataProvider", e);
}
return true;
}
After execute these two methods, the result was filtered automatically. Without entering the subscribe method again that we defined in our data adapter class. So I am very puzzled about this.
Any one can explain this to me?? I am very urgent in my current project.
Thank you very much.
Gary
Similar Threads
-
By mnenchev in forum General
Replies: 5
Last Post: September 8th, 2009, 03:07 PM
-
By jamesclinton in forum Client SDKs
Replies: 2
Last Post: April 16th, 2007, 12:54 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
All times are GMT +1. The time now is 11:52 AM.
Bookmarks