本文整理汇总了Java中org.apache.solr.util.plugin.SolrCoreAware类的典型用法代码示例。如果您正苦于以下问题:Java SolrCoreAware类的具体用法?Java SolrCoreAware怎么用?Java SolrCoreAware使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SolrCoreAware类属于org.apache.solr.util.plugin包,在下文中一共展示了SolrCoreAware类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: inform
import org.apache.solr.util.plugin.SolrCoreAware; //导入依赖的package包/类
/**
* Tell all {@link SolrCoreAware} instances about the SolrCore
*/
public void inform(SolrCore core)
{
this.dataDir = core.getDataDir();
// make a copy to avoid potential deadlock of a callback calling newInstance and trying to
// add something to waitingForCore.
SolrCoreAware[] arr;
while (waitingForCore.size() > 0) {
synchronized (waitingForCore) {
arr = waitingForCore.toArray(new SolrCoreAware[waitingForCore.size()]);
waitingForCore.clear();
}
for( SolrCoreAware aware : arr) {
aware.inform( core );
}
}
// this is the last method to be called in SolrCore before the latch is released.
live = true;
}
示例2: getWrappedHandler
import org.apache.solr.util.plugin.SolrCoreAware; //导入依赖的package包/类
public synchronized SolrRequestHandler getWrappedHandler()
{
if( _handler == null ) {
try {
SolrRequestHandler handler = core.createRequestHandler(_className);
handler.init( _args );
if( handler instanceof SolrCoreAware ) {
((SolrCoreAware)handler).inform( core );
}
_handler = handler;
}
catch( Exception ex ) {
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "lazy loading error", ex );
}
}
return _handler;
}
示例3: newInstance
import org.apache.solr.util.plugin.SolrCoreAware; //导入依赖的package包/类
public <T> T newInstance(String cname, Class<T> expectedType, String ... subpackages) {
Class<? extends T> clazz = findClass(cname, expectedType, subpackages);
if( clazz == null ) {
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,
"Can not find class: "+cname + " in " + classLoader);
}
T obj = null;
try {
obj = clazz.newInstance();
}
catch (Exception e) {
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,
"Error instantiating class: '" + clazz.getName()+"'", e);
}
if (!live) {
if( obj instanceof SolrCoreAware ) {
assertAwareCompatibility( SolrCoreAware.class, obj );
waitingForCore.add( (SolrCoreAware)obj );
}
if (org.apache.solr.util.plugin.ResourceLoaderAware.class.isInstance(obj)) {
log.warn("Class [{}] uses org.apache.solr.util.plugin.ResourceLoaderAware " +
"which is deprecated. Change to org.apache.lucene.analysis.util.ResourceLoaderAware.", cname);
}
if( obj instanceof ResourceLoaderAware ) {
assertAwareCompatibility( ResourceLoaderAware.class, obj );
waitingForResources.add( (ResourceLoaderAware)obj );
}
if (obj instanceof SolrInfoMBean){
//TODO: Assert here?
infoMBeans.add((SolrInfoMBean) obj);
}
}
return obj;
}
示例4: inform
import org.apache.solr.util.plugin.SolrCoreAware; //导入依赖的package包/类
@Override
public void inform(SolrCore core)
{
String path = null;
for( Map.Entry<String, SolrRequestHandler> entry : core.getRequestHandlers().entrySet() ) {
if( entry.getValue() == this ) {
path = entry.getKey();
break;
}
}
if( path == null ) {
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,
"The AdminHandler is not registered with the current core." );
}
if( !path.startsWith( "/" ) ) {
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,
"The AdminHandler needs to be registered to a path. Typically this is '/admin'" );
}
// Remove the parent handler
core.registerRequestHandler(path, null);
if( !path.endsWith( "/" ) ) {
path += "/";
}
StandardHandler[] list = new StandardHandler[] {
new StandardHandler( "luke", new LukeRequestHandler() ),
new StandardHandler( "system", new SystemInfoHandler() ),
new StandardHandler( "mbeans", new SolrInfoMBeanHandler() ),
new StandardHandler( "plugins", new PluginInfoHandler() ),
new StandardHandler( "threads", new ThreadDumpHandler() ),
new StandardHandler( "properties", new PropertiesRequestHandler() ),
new StandardHandler( "logging", new LoggingHandler() ),
new StandardHandler( "file", new ShowFileRequestHandler() )
};
for( StandardHandler handler : list ) {
if( core.getRequestHandler( path+handler.name ) == null ) {
handler.handler.init( initArgs );
core.registerRequestHandler( path+handler.name, handler.handler );
if( handler.handler instanceof SolrCoreAware ) {
((SolrCoreAware)handler.handler).inform(core);
}
}
}
}
示例5: inform
import org.apache.solr.util.plugin.SolrCoreAware; //导入依赖的package包/类
/**
* NOTE: ideally we'd just override the list of admin handlers, but
* since AdminHandlers in solr doesn't allow it, let's just copy the
* entire function. This is deprecated in Solr 5.0, so we should do something
* different with Solr 5.0 anyway.
*/
@Override
public void inform(SolrCore core)
{
String path = null;
for( Map.Entry<String, SolrRequestHandler> entry : core.getRequestHandlers().entrySet() ) {
if( entry.getValue() == this ) {
path = entry.getKey();
break;
}
}
if( path == null ) {
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,
"The AdminHandler is not registered with the current core." );
}
if( !path.startsWith( "/" ) ) {
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,
"The AdminHandler needs to be registered to a path. Typically this is '/admin'" );
}
// Remove the parent handler
core.registerRequestHandler(path, null);
if( !path.endsWith( "/" ) ) {
path += "/";
}
StandardHandler[] list = new StandardHandler[] {
new StandardHandler( "luke", new SecureLukeRequestHandler() ),
new StandardHandler( "system", new SecureSystemInfoHandler() ),
new StandardHandler( "mbeans", new SecureSolrInfoMBeanHandler() ),
new StandardHandler( "plugins", new SecurePluginInfoHandler() ),
new StandardHandler( "threads", new SecureThreadDumpHandler() ),
new StandardHandler( "properties", new SecurePropertiesRequestHandler() ),
new StandardHandler( "logging", new SecureLoggingHandler() ),
new StandardHandler( "file", new SecureShowFileRequestHandler() )
};
for( StandardHandler handler : list ) {
if( core.getRequestHandler( path+handler.name ) == null ) {
handler.handler.init( initArgs );
core.registerRequestHandler( path+handler.name, handler.handler );
if( handler.handler instanceof SolrCoreAware ) {
((SolrCoreAware)handler.handler).inform(core);
}
}
}
}