/** * Baseclass for senders. * * <p><b>Configuration:</b> * * <table border="1"> * <tr><th>attributes</th><th>description</th><th>default</th></tr> * <tr><td>{@link #setName(String) name}</td><td>name of the Sender</td><td> </td></tr> * </table> * * @author Gerrit van Brakel * @since 4.9 */ public abstract class SenderBase implements ISender { protected Logger log = LogUtil.getLogger(this); private String name; public void configure() throws ConfigurationException {} public void open() throws SenderException {} public void close() throws SenderException {} public abstract String sendMessage(String correlationID, String message) throws SenderException, TimeOutException; public boolean isSynchronous() { return true; } protected String getLogPrefix() { return "[" + this.getClass().getName() + "] [" + getName() + "] "; } public void setName(String name) { this.name = name; } public String getName() { return name; } }
/** * Straightforward XML-validation based on javax.validation. This is work in programs. * * @author Michiel Meeuwissen * @author Jaco de Groot */ public class JavaxXmlValidator extends AbstractXmlValidator { protected static final Logger LOG = LogUtil.getLogger(JavaxXmlValidator.class); // TODO I think many (if not all) schemas can simply be registered globally, because xmlns should // be uniquely defined. // missing a generic generic mechanism for now private static final Map<String, URL> globalRegistry = new HashMap<String, URL>(); static { globalRegistry.put( "http://schemas.xmlsoap.org/soap/envelope/", ClassUtils.getResourceURL("/Tibco/xsd/soap/envelope.xsd")); // globalRegistry.put("http://ing.nn.afd/AFDTypes", // ClassUtils.getResourceURL("/Tibco/wsdl/BankingCustomer_01_GetPartyBasicDataBanking_01_concrete1/AFDTypes.xsd")); } private Map<String, Schema> javaxSchemas = new HashMap<String, Schema>(); @Override protected void init() throws ConfigurationException { if (needsInit) { super.init(); String schemasId = null; schemasId = schemasProvider.getSchemasId(); if (schemasId != null) { getSchemaObject(schemasId, schemasProvider.getSchemas()); } } } @Override public String validate( Object input /*impossible to understand*/, IPipeLineSession session, String logPrefix) throws XmlValidatorException, ConfigurationException, PipeRunException { InputSource source = getInputSource(input); SAXSource sax = new SAXSource(source); return validate(sax, session); } protected String validate(Source source, IPipeLineSession session) throws XmlValidatorException, ConfigurationException, PipeRunException { init(); String schemasId = schemasProvider.getSchemasId(); if (schemasId == null) { schemasId = schemasProvider.getSchemasId(session); getSchemaObject(schemasId, schemasProvider.getSchemas(session)); } Schema xsd = javaxSchemas.get(schemasId); try { Validator validator = xsd.newValidator(); validator.setResourceResolver( new LSResourceResolver() { public LSInput resolveResource(String s, String s1, String s2, String s3, String s4) { System.out.println("--"); return null; // To change body of implemented methods Settings | File Templates. } }); validator.setErrorHandler( new ErrorHandler() { public void warning(SAXParseException e) throws SAXException { LOG.warn(e.getMessage()); } public void error(SAXParseException e) throws SAXException { LOG.error(e.getMessage()); } public void fatalError(SAXParseException e) throws SAXException { LOG.error(e.getMessage()); } }); // validator.setFeature("http://xml.org/sax/features/namespace-prefixes", true); /// DOESNT" // WORK any more? validator.validate(source); } catch (SAXException e) { throw new XmlValidatorException(e.getClass() + " " + e.getMessage()); } catch (IOException e) { throw new XmlValidatorException(e.getMessage(), e); } return XML_VALIDATOR_VALID_MONITOR_EVENT; } /** * Returns the {@link Schema} associated with this validator. This ia an XSD schema containing * knowledge about the schema source as returned by {@link #getSchemaSources()} * * @throws ConfigurationException */ protected synchronized Schema getSchemaObject( String schemasId, List<nl.nn.adapterframework.validation.Schema> schemas) throws ConfigurationException { Schema schema = javaxSchemas.get(schemasId); if (schema == null) { SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); factory.setResourceResolver( new LSResourceResolver() { public LSInput resolveResource(String s, String s1, String s2, String s3, String s4) { return null; } }); try { Collection<Source> sources = getSchemaSources(schemas); schema = factory.newSchema(sources.toArray(new Source[sources.size()])); javaxSchemas.put(schemasId, schema); } catch (Exception e) { throw new ConfigurationException("cannot read schema's [" + schemasId + "]", e); } } return schema; } protected List<Source> getSchemaSources(List<nl.nn.adapterframework.validation.Schema> schemas) throws IOException, XMLStreamException, ConfigurationException { List<Source> result = new ArrayList<Source>(); for (nl.nn.adapterframework.validation.Schema schema : schemas) { result.add(new StreamSource(schema.getInputStream(), schema.getSystemId())); } return result; } }
/** * A JmsRealm is a definition of a JMS provider, and is kind of a utility class to prevent the * tedeous work of repeatedly defining all parameters to connect to a queue or topic. <br> * This class is not an extension of JNDIBase, which would be logical, because in the JMSBase class * the function PropertyUtils.copyProperties is used, which cannot handle this. * * @see JMSFacade#setJmsRealm * @author Johan Verrips IOS */ public class JmsRealm { // TODO: change to J2eeRealm private Logger log = LogUtil.getLogger(this); private String realmName; private String providerURL = null; private String initialContextFactoryName = null; private String authentication = null; private String credentials = null; private String principal = null; private String authAlias = null; private String jndiAuthAlias = null; private String urlPkgPrefixes = null; private String securityProtocol = null; private String jndiContextPrefix = ""; private String jndiProperties = null; private String queueConnectionFactoryName; private String topicConnectionFactoryName; private String queueConnectionFactoryNameXA; private String topicConnectionFactoryNameXA; private String datasourceName; private String datasourceNameXA; private String userTransactionUrl; public JmsRealm() { super(); } /** Includes another realm into this one */ public void setAliasForRealm(String jmsRealmName) { String myName = getRealmName(); // save name, as it will be overwritten by the copy try { copyRealm(this, jmsRealmName); } catch (ConfigurationException e) { log.warn("cannot set aliasForRealm", e); } setRealmName(myName); // restore the original name } /** copies matching properties to any other class */ public void copyRealm(Object destination) { String logPrefixDest = destination.getClass().getName() + " "; if (destination instanceof INamedObject) { INamedObject namedDestination = (INamedObject) destination; logPrefixDest += "[" + namedDestination.getName() + "] "; } try { PropertyUtils.copyProperties(destination, this); } catch (Exception e) { log.error(logPrefixDest + "unable to copy properties of JmsRealm", e); } log.info(logPrefixDest + "loaded properties from jmsRealm [" + toString() + "]"); } /** * copies matching properties from a JmsRealm to any other class * * @see JmsRealm * <p>TODO: Some amount of cleanup possible by putting JmsRealmFactory in Spring context */ public static void copyRealm(Object destination, String jmsRealmName) throws ConfigurationException { JmsRealm jmsRealm = JmsRealmFactory.getInstance().getJmsRealm(jmsRealmName); if (jmsRealm == null) { throw new ConfigurationException("Could not find jmsRealm [" + jmsRealmName + "]"); } jmsRealm.copyRealm(destination); } public String getAuthentication() { return authentication; } public String getCredentials() { return credentials; } public String getInitialContextFactoryName() { return initialContextFactoryName; } public String getProviderURL() { return providerURL; } public String getConnectionFactoryName() { if (queueConnectionFactoryName != null) { return queueConnectionFactoryName; } else if (queueConnectionFactoryNameXA != null) { return queueConnectionFactoryNameXA; } else if (topicConnectionFactoryName != null) { return topicConnectionFactoryName; } else if (topicConnectionFactoryNameXA != null) { return topicConnectionFactoryNameXA; } return null; } /** The name of the QueueConnectionFactory <br> */ public java.lang.String getQueueConnectionFactoryName() { return queueConnectionFactoryName; } /** The name of this realm<br> */ public java.lang.String getRealmName() { return realmName; } public String getSecurityProtocol() { return securityProtocol; } /** The name of the TopicConnectionFactory <br> */ public java.lang.String getTopicConnectionFactoryName() { return topicConnectionFactoryName; } public String getUrlPkgPrefixes() { return urlPkgPrefixes; } public void setAuthentication(String authentication) { this.authentication = authentication; } public void setCredentials(String credentials) { this.credentials = credentials; } public void setInitialContextFactoryName(String initialContextFactoryName) { this.initialContextFactoryName = initialContextFactoryName; } public void setProviderURL(String providerURL) { this.providerURL = providerURL; } /** * Set the name of the QueueConnectionFactory<br> * * @param newQueueConnectionFactoryName java.lang.String */ public void setQueueConnectionFactoryName(java.lang.String newQueueConnectionFactoryName) { queueConnectionFactoryName = newQueueConnectionFactoryName; } /** * Set the name of this realm<br> * . * * @param newName java.lang.String */ public void setRealmName(java.lang.String newName) { realmName = newName; } public void setSecurityProtocol(String securityProtocol) { this.securityProtocol = securityProtocol; } /** * Set the name of the TopicConnectionFactory<br> * * @param newTopicConnectionFactoryName java.lang.String */ public void setTopicConnectionFactoryName(java.lang.String newTopicConnectionFactoryName) { topicConnectionFactoryName = newTopicConnectionFactoryName; } public void setUrlPkgPrefixes(String urlPkgPrefixes) { this.urlPkgPrefixes = urlPkgPrefixes; } /** * The <code>toString()</code> method retrieves its value by reflection. * * @see org.apache.commons.lang.builder.ToStringBuilder#reflectionToString */ public String toString() { return ToStringBuilder.reflectionToString(this); } /** Returns the queueConnectionFactoryNameXA. */ public String getQueueConnectionFactoryNameXA() { return queueConnectionFactoryNameXA; } /** Returns the topicConnectionFactoryNameXA. */ public String getTopicConnectionFactoryNameXA() { return topicConnectionFactoryNameXA; } /** * Sets the queueConnectionFactoryNameXA. * * @param queueConnectionFactoryNameXA The queueConnectionFactoryNameXA to set */ public void setQueueConnectionFactoryNameXA(String queueConnectionFactoryNameXA) { this.queueConnectionFactoryNameXA = queueConnectionFactoryNameXA; } /** * Sets the topicConnectionFactoryNameXA. * * @param topicConnectionFactoryNameXA The topicConnectionFactoryNameXA to set */ public void setTopicConnectionFactoryNameXA(String topicConnectionFactoryNameXA) { this.topicConnectionFactoryNameXA = topicConnectionFactoryNameXA; } public String getDatasourceName() { return datasourceName; } public String getDatasourceNameXA() { return datasourceNameXA; } public void setDatasourceName(String string) { datasourceName = string; } public void setDatasourceNameXA(String string) { datasourceNameXA = string; } public String getUserTransactionUrl() { return userTransactionUrl; } public void setUserTransactionUrl(String string) { userTransactionUrl = string; } public void setPrincipal(String string) { principal = string; } public String getPrincipal() { return principal; } public void setJndiAuthAlias(String string) { jndiAuthAlias = string; } public String getJndiAuthAlias() { return jndiAuthAlias; } public void setAuthAlias(String string) { authAlias = string; } public String getAuthAlias() { return authAlias; } public void setJndiContextPrefix(String string) { jndiContextPrefix = string; } public String getJndiContextPrefix() { return jndiContextPrefix; } public String getJndiProperties() { return jndiProperties; } public void setJndiProperties(String jndiProperties) { this.jndiProperties = jndiProperties; } }
/** * EJB layer around the IbisManager implementation which is defined in the Spring context. * * <p>The base-class {@link AbstractEJBBase} takes care of initializing the Spring context in it's * static class initialization. * * @author Tim van der Leeuw * @since 4.8 */ public class IbisManagerEjbBean extends AbstractEJBBase implements SessionBean, IbisManager { private static final Logger log = LogUtil.getLogger(IbisManagerEjbBean.class); SessionContext sessionContext; public IbisManagerEjbBean() { super(); log.info("Created IbisManagerEjbBean instance"); } public void setSessionContext(SessionContext sessionContext) throws EJBException, RemoteException { log.info("Set session context for IbisManagerEjb"); this.sessionContext = sessionContext; } public void ejbCreate() throws CreateException { log.info("Creating IbisManagerEjb"); } public void ejbRemove() throws EJBException, RemoteException { log.info("Removing IbisManagerEjb"); } public void ejbActivate() throws EJBException, RemoteException { throw new UnsupportedOperationException("Not supported yet."); } public void ejbPassivate() throws EJBException, RemoteException { throw new UnsupportedOperationException("Not supported yet."); } public Configuration getConfiguration() { return ibisManager.getConfiguration(); } public void handleAdapter( String action, String adapterName, String receiverName, String commandIssuedBy) { ibisManager.handleAdapter(action, adapterName, receiverName, commandIssuedBy); } public void startIbis() { ibisManager.startIbis(); } public void shutdownIbis() { ibisManager.shutdownIbis(); ibisContext.destroyConfig(); } public void startAdapters() { ibisManager.startAdapters(); } public void stopAdapters() { ibisManager.stopAdapters(); } public void startAdapter(IAdapter adapter) { ibisManager.startAdapter(adapter); } public void stopAdapter(IAdapter adapter) { ibisManager.stopAdapter(adapter); } public void loadConfigurationFile(String configurationFile) { ibisManager.loadConfigurationFile(configurationFile); } public String getDeploymentModeString() { return ibisManager.getDeploymentModeString(); } public int getDeploymentMode() { return ibisManager.getDeploymentMode(); } public PlatformTransactionManager getTransactionManager() { return ibisManager.getTransactionManager(); } /* (non-Javadoc) * @see nl.nn.adapterframework.ejb.AbstractEJBBase#getEJBContext() */ protected EJBContext getEJBContext() { return this.sessionContext; } }