Package org.bedework.synch.shared.cnctrs
Class AbstractConnector<T,TI extends AbstractConnectorInstance<?,?,?>,TN extends Notification<?>,Tconf extends ConnectorConfigI,InfoT extends BaseSubscriptionInfo>
- java.lang.Object
-
- org.bedework.synch.shared.cnctrs.AbstractConnector<T,TI,TN,Tconf,InfoT>
-
- Type Parameters:
T- Connector subclassTI- Connector instance subclassTN- Notification subclassTconf- Configuration class
- All Implemented Interfaces:
Connector<TI,TN,Tconf>,org.bedework.util.logging.Logged
public abstract class AbstractConnector<T,TI extends AbstractConnectorInstance<?,?,?>,TN extends Notification<?>,Tconf extends ConnectorConfigI,InfoT extends BaseSubscriptionInfo> extends Object implements org.bedework.util.logging.Logged, Connector<TI,TN,Tconf>
A special connector to handle calls to the synch engine via the web context.This is the way to call the system to add subscriptions, to unsubscribe etc.
- Author:
- Mike Douglass
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.bedework.synch.shared.cnctrs.Connector
Connector.NotificationBatch<N extends Notification>
-
-
Field Summary
Fields Modifier and Type Field Description protected StringcallbackUriprotected Tconfconfigprotected booleanfailedprotected javax.xml.bind.JAXBContextjcprotected org.bedework.synch.wsmessages.ObjectFactoryofprotected PropertiesInfopropInfoprotected booleanrunningprotected javax.xml.soap.MessageFactorysoapMsgFactoryprotected booleanstoppedprotected SynchEnginesyncher
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractConnector(PropertiesInfo propInfo)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description StringgetCallbackUri()StringgetConnectorId()TIgetConnectorInstance(Subscription sub, org.bedework.synch.wsmessages.SynchEndType end)Called to obtain a connector instance for a subscription.ietf.params.xml.ns.icalendar_2.ObjectFactorygetIcalObjectFactory()StringgetId()org.bedework.util.logging.BwLoggergetLogger()protected org.bedework.synch.wsmessages.SynchRemoteServicePortTypegetPort(String uri)PropertiesInfogetPropertyInfo()Information about properties required for subscriptions via this connector.List<Object>getSkipList()protected javax.xml.soap.MessageFactorygetSoapMsgFactory()StringgetStatus()SynchEnginegetSyncher()booleangetTrustLastmod()Can we trust the lastmod from this connector?Connector.NotificationBatch<TN>handleCallback(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, List<String> resourceUri)Will create a notification batch object which will be passed to a synchling for processing.booleanisFailed()booleanisManager()booleanisReadOnly()Is this a read-only connector?booleanisStarted()booleanisStopped()abstract TImakeInstance(Subscription sub, org.bedework.synch.wsmessages.SynchEndType end)protected voidmarshal(Object o, OutputStream out)voidrespondCallback(javax.servlet.http.HttpServletResponse resp, Connector.NotificationBatch<TN> notifications)Will respond to a notification.voidstart(String connectorId, Tconf conf, String callbackUri, SynchEngine syncher)Start the connector.voidstop()Shut down the connectorprotected ObjectunmarshalBody(javax.servlet.http.HttpServletRequest req)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.bedework.util.logging.Logged
audit, debug, debug, enableAuditLogger, enableErrorLogger, enableMetricsLogger, error, error, error, getLogLevel, info, isAuditLoggerEnabled, isErrorLoggerEnabled, isMetricsDebugEnabled, isMetricsLoggerEnabled, metrics, setLoggerClass, setLoggerClass, trace, trace, warn
-
-
-
-
Field Detail
-
config
protected Tconf extends ConnectorConfigI config
-
callbackUri
protected String callbackUri
-
syncher
protected SynchEngine syncher
-
running
protected boolean running
-
stopped
protected boolean stopped
-
failed
protected boolean failed
-
of
protected org.bedework.synch.wsmessages.ObjectFactory of
-
soapMsgFactory
protected javax.xml.soap.MessageFactory soapMsgFactory
-
jc
protected javax.xml.bind.JAXBContext jc
-
propInfo
protected PropertiesInfo propInfo
-
-
Constructor Detail
-
AbstractConnector
protected AbstractConnector(PropertiesInfo propInfo)
-
-
Method Detail
-
getConnectorId
public String getConnectorId()
- Returns:
- the connector id
-
start
public void start(String connectorId, Tconf conf, String callbackUri, SynchEngine syncher)
Description copied from interface:ConnectorStart the connector. A response of null means no synch available.The callback url is unique to the connector. It will be used as a path prefix to allow the callback service to locate the handler for incoming callback requests.
For example, if the callback context is /synchcb/ and the connector id is "bedework" then the callback uri might be /synchcb/bedework/. The connector might append a uid to that path to allow it to locate the active subscription for which the callback is intended.
- Specified by:
startin interfaceConnector<T,TI extends AbstractConnectorInstance<?,?,?>,TN extends Notification<?>>- Parameters:
connectorId- - registered id for the connector
-
getStatus
public String getStatus()
- Specified by:
getStatusin interfaceConnector<T,TI extends AbstractConnectorInstance<?,?,?>,TN extends Notification<?>>- Returns:
- a useful status message
-
isStarted
public boolean isStarted()
- Specified by:
isStartedin interfaceConnector<T,TI extends AbstractConnectorInstance<?,?,?>,TN extends Notification<?>>- Returns:
- true if we started
-
isFailed
public boolean isFailed()
- Specified by:
isFailedin interfaceConnector<T,TI extends AbstractConnectorInstance<?,?,?>,TN extends Notification<?>>- Returns:
- true if we failed in some way
-
isStopped
public boolean isStopped()
- Specified by:
isStoppedin interfaceConnector<T,TI extends AbstractConnectorInstance<?,?,?>,TN extends Notification<?>>- Returns:
- true if we're stopped
-
isManager
public boolean isManager()
- Specified by:
isManagerin interfaceConnector<T,TI extends AbstractConnectorInstance<?,?,?>,TN extends Notification<?>>- Returns:
- true if we are the manager
-
isReadOnly
public boolean isReadOnly()
Description copied from interface:ConnectorIs this a read-only connector?- Specified by:
isReadOnlyin interfaceConnector<T,TI extends AbstractConnectorInstance<?,?,?>,TN extends Notification<?>>- Returns:
- boolean
-
getTrustLastmod
public boolean getTrustLastmod()
Description copied from interface:ConnectorCan we trust the lastmod from this connector?- Specified by:
getTrustLastmodin interfaceConnector<T,TI extends AbstractConnectorInstance<?,?,?>,TN extends Notification<?>>- Returns:
- boolean
-
getId
public String getId()
- Specified by:
getIdin interfaceConnector<T,TI extends AbstractConnectorInstance<?,?,?>,TN extends Notification<?>>- Returns:
- id provided at start
-
getCallbackUri
public String getCallbackUri()
- Specified by:
getCallbackUriin interfaceConnector<T,TI extends AbstractConnectorInstance<?,?,?>,TN extends Notification<?>>- Returns:
- callbackUri provided at start
-
getSyncher
public SynchEngine getSyncher()
- Specified by:
getSyncherin interfaceConnector<T,TI extends AbstractConnectorInstance<?,?,?>,TN extends Notification<?>>- Returns:
- syncher provided at start
-
getIcalObjectFactory
public ietf.params.xml.ns.icalendar_2.ObjectFactory getIcalObjectFactory()
- Specified by:
getIcalObjectFactoryin interfaceConnector<T,TI extends AbstractConnectorInstance<?,?,?>,TN extends Notification<?>>- Returns:
- an object factory for icalendar
-
getPropertyInfo
public PropertiesInfo getPropertyInfo()
Description copied from interface:ConnectorInformation about properties required for subscriptions via this connector.- Specified by:
getPropertyInfoin interfaceConnector<T,TI extends AbstractConnectorInstance<?,?,?>,TN extends Notification<?>>- Returns:
- list of info
-
getSkipList
public List<Object> getSkipList()
- Specified by:
getSkipListin interfaceConnector<T,TI extends AbstractConnectorInstance<?,?,?>,TN extends Notification<?>>- Returns:
- list of icalendar properties to skip.
-
stop
public void stop() throws SynchExceptionDescription copied from interface:ConnectorShut down the connector- Specified by:
stopin interfaceConnector<T,TI extends AbstractConnectorInstance<?,?,?>,TN extends Notification<?>>- Throws:
SynchException
-
makeInstance
public abstract TI makeInstance(Subscription sub, org.bedework.synch.wsmessages.SynchEndType end) throws SynchException
- Throws:
SynchException
-
getConnectorInstance
public TI getConnectorInstance(Subscription sub, org.bedework.synch.wsmessages.SynchEndType end) throws SynchException
Description copied from interface:ConnectorCalled to obtain a connector instance for a subscription. A response of null means no synch available.- Specified by:
getConnectorInstancein interfaceConnector<T,TI extends AbstractConnectorInstance<?,?,?>,TN extends Notification<?>>- Parameters:
sub- - the subscriptionend- - which end- Returns:
- null for no synch else a connector instance.
- Throws:
SynchException
-
handleCallback
public Connector.NotificationBatch<TN> handleCallback(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, List<String> resourceUri) throws SynchException
Description copied from interface:ConnectorWill create a notification batch object which will be passed to a synchling for processing. When processing is complete respond will be called.The resource URI has been stripped of the context element and the element which identifies the connector. What remains is used by the connector to determine a subscription id allowing retrieval of the subscription from the synch engine.
- Specified by:
handleCallbackin interfaceConnector<T,TI extends AbstractConnectorInstance<?,?,?>,TN extends Notification<?>>resourceUri- - elements of the path with context and connector id removed- Returns:
- Notification with 1 or more Notification items or null for no action.
- Throws:
SynchException
-
respondCallback
public void respondCallback(javax.servlet.http.HttpServletResponse resp, Connector.NotificationBatch<TN> notifications) throws SynchExceptionDescription copied from interface:ConnectorWill respond to a notification.- Specified by:
respondCallbackin interfaceConnector<T,TI extends AbstractConnectorInstance<?,?,?>,TN extends Notification<?>>notifications- from handleCallback.- Throws:
SynchException
-
getPort
protected org.bedework.synch.wsmessages.SynchRemoteServicePortType getPort(String uri) throws SynchException
- Throws:
SynchException
-
unmarshalBody
protected Object unmarshalBody(javax.servlet.http.HttpServletRequest req) throws SynchException
- Throws:
SynchException
-
marshal
protected void marshal(Object o, OutputStream out) throws SynchException
- Throws:
SynchException
-
getSoapMsgFactory
protected javax.xml.soap.MessageFactory getSoapMsgFactory() throws SynchException- Throws:
SynchException
-
getLogger
public org.bedework.util.logging.BwLogger getLogger()
- Specified by:
getLoggerin interfaceorg.bedework.util.logging.Logged
-
-