/** *implementsaconfigurableinterceptorfordispatchevents.
*/ publicclass Interceptor implements XDispatch,
XDispatchProviderInterceptor,
XInterceptorInfo
{ /** contains the list of interception URL schema's (wildcards are allowed there!) supportedbythisinterceptor.Itcanbesetfromoutside. IfnoexternalURLsareset,thedefault"*"isusedinstead. Thatwouldhavethesameeffectasifthisimplementationwouldnotsupportthe interfaceXInterceptorInfo!
*/ private String[] m_lURLs4InterceptionInfo = null;
/** These URL's will be blocked by this interceptor. Canbesetfromoutside.EveryqueryDispatch()forthese setofURL'swillbeansweredwithanemptydispatchobject! IfnoexternalURLsaresetthedefault"*"isusedinstead. SoeveryincomingURLwillbeblocked.-)
*/ private String[] m_lURLs4Blocking = null;
/** indicates if this interceptor object is currently part of the interceptor chainofOOo.Onlytrueifavalidslaveormasterdispatchissetonthis instance.
*/ privateboolean m_bIsRegistered = false;
/** points to the global uno service manager. */ private XMultiServiceFactory m_xMSF = null;
public Interceptor(XMultiServiceFactory xMSF)
{
m_xMSF = xMSF;
}
/** A beautiful method whose only purpose is to take and release a *solarmutex.Ifthishangs-youcanseeabeautifuldeadlock *whenyouattachyourdebuggertothemainprocess.
*/ privatevoid checkNoSolarMutexHeld()
{ try
{ if (m_xToolkit == null)
m_xToolkit = UnoRuntime.queryInterface(
XDataTransferProviderAccess.class,
m_xMSF.createInstance("com.sun.star.awt.Toolkit"));
// A Method notable only for taking the solar mutex.
System.out.println("Check solarmutex not held - if so deadlock");
m_xToolkit.getDragSource( null );
System.out.println("Solarmutex not held.");
} catch (java.lang.Throwable ex) {
System.out.println("Failed to create and invoke toolkit method " + ex.toString());
}
}
/** set a new list of URL's, which should be blocked by this interceptor. (that'swhyit'snecessarytocallthisimpl-methodbeforetheinterceptor isusedattheOOoAPI!)
*/ publicsynchronizedvoid setURLs4URLs4Blocking(String[] lURLs)
{
m_lURLs4Blocking = lURLs;
}
/** must be used internal to access the member m_lURLs4InterceptionInfo -threadsafe -andtomakesureit'sinitializedondemand
*/ privatesynchronized String[] impl_getURLs4InterceptionInfo()
{ if (m_lURLs4InterceptionInfo == null)
{
m_lURLs4InterceptionInfo = new String[] { "*" };
}
return m_lURLs4InterceptionInfo;
}
/** must be used internal to access the member m_lURLs4Blocking -threadsafe -andtomakesureit'sinitializedondemand
*/ privatesynchronized String[] impl_getURLs4Blocking()
{ if (m_lURLs4Blocking == null)
{
m_lURLs4Blocking = new String[] { "*" };
}
return m_lURLs4Blocking;
}
privateboolean impl_isBlockedURL(String sURL)
{
String[] lBlockedURLs = impl_getURLs4Blocking(); int i = 0; int c = lBlockedURLs.length;
for (i=0; i<c; ++i)
{ if (impl_match(sURL, lBlockedURLs[i]))
{ returntrue;
}
}
returnfalse;
}
privateboolean impl_match(String sVal1, String sVal2)
{ // TODO implement wildcard match return sVal1.equals(sVal2);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.