public String transform(Object source, ClassLoader loader) throws Fabric3Exception { try { return mapper.writeValueAsString(source); } catch (IOException e) { throw new Fabric3Exception(e); } }
public Date transform(final Node node, ClassLoader loader) throws Fabric3Exception { try { return dateFormatter.parse(node.getTextContent()); } catch (ParseException pe) { throw new Fabric3Exception("Unsupported Date Format ", pe); } }
public synchronized void register(URI id, ClassLoader classLoader) { if (registry.containsKey(id)) { throw new Fabric3Exception("Duplicate classloader: " + id); } registry.put(id, classLoader); }
public Byte transform(Node node, ClassLoader loader) throws Fabric3Exception { try { return Byte.valueOf(node.getTextContent()); } catch (NumberFormatException ex) { throw new Fabric3Exception("Unsupportable byte " + node.getTextContent(), ex); } } }
public Double transform(Node node, ClassLoader loader) throws Fabric3Exception { try { return Double.valueOf(node.getTextContent()); } catch (NumberFormatException ex) { throw new Fabric3Exception("Unsupportable double " + node.getTextContent(), ex); } } }
public Document transform(Object source, ClassLoader loader) throws Fabric3Exception { try { DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.newDocument(); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.marshal(source, document); return document; } catch (JAXBException | ParserConfigurationException e) { throw new Fabric3Exception(e); } }
public String transform(Object source, ClassLoader loader) throws Fabric3Exception { try { Marshaller marshaller = jaxbContext.createMarshaller(); StringWriter writer = new StringWriter(); marshaller.marshal(source, writer); return writer.toString(); } catch (JAXBException e) { throw new Fabric3Exception(e); } }
public Object transform(String source, ClassLoader loader) throws Fabric3Exception { ClassLoader cl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(loader); StringReader reader = new StringReader(source); return jaxbContext.createUnmarshaller().unmarshal(reader); } catch (JAXBException e) { throw new Fabric3Exception(e); } finally { Thread.currentThread().setContextClassLoader(cl); } }
public void begin() throws Fabric3Exception { try { tm.begin(); tm.setTransactionTimeout(transactionTimeout); } catch (NotSupportedException | SystemException e) { throw new Fabric3Exception(e); } }
public void rollback(Session session) throws Fabric3Exception { try { if (tm.getStatus() != Status.STATUS_NO_TRANSACTION) { tm.rollback(); statistics.incrementTransactionsRolledBack(); } } catch (SystemException e) { throw new Fabric3Exception("Error reverting transaction for " + uri, e); } }
public void rollback(Session session) throws Fabric3Exception { try { session.recover(); } catch (JMSException e) { throw new Fabric3Exception("Error handling message for " + uri, e); } }
private List<Port> checkAllocated(String name, String type) throws Fabric3Exception { List<Port> ports = allocated.get(type); if (ports != null) { for (Port port : ports) { if (port.getName().equals(name)) { throw new Fabric3Exception("Port already allocated: " + type); } } } return ports; }
private Channel getChannel(URI uri, ChannelSide channelSide) throws Fabric3Exception { Channel channel = channelManager.getChannel(uri, channelSide); if (channel == null) { throw new Fabric3Exception("Channel not found"); } return channel; } }
private void validateDestination(javax.jms.Destination requestDestination, Destination requestDestinationDefinition) throws Fabric3Exception { DestinationType requestDestinationType = requestDestinationDefinition.geType(); if (DestinationType.QUEUE == requestDestinationType && !(requestDestination instanceof Queue)) { throw new Fabric3Exception("Destination is not a queue: " + requestDestinationDefinition.getName()); } else if (DestinationType.TOPIC == requestDestinationType && !(requestDestination instanceof Topic)) { throw new Fabric3Exception("Destination is not a topic: " + requestDestinationDefinition.getName()); } }
public javax.jms.Destination getDestination(Destination definition, ConnectionFactory factory) throws Fabric3Exception { for (DestinationResolver resolver : resolvers) { Optional<javax.jms.Destination> destination = resolver.resolve(definition); if (destination.isPresent()) { return destination.get(); } } throw new Fabric3Exception("Destination not found: " + definition.getName()); }
@SuppressWarnings("unchecked") private Object createKey(DataType targetType, String value, ClassLoader classLoader) throws Fabric3Exception { Class<?> type = targetType.getType(); List<Class<?>> types = new ArrayList<>(); types.add(type); Transformer<String, ?> transformer = (Transformer<String, ?>) transformerRegistry.getTransformer(TypeConstants.STRING_TYPE, targetType, types, types); if (transformer == null) { throw new Fabric3Exception("No transformer for : " + targetType); } return transformer.transform(value, classLoader); }
@SuppressWarnings("unchecked") private Object createKey(DataType targetType, String value, ClassLoader classLoader) throws Fabric3Exception { Class<?> type = targetType.getType(); List<Class<?>> types = new ArrayList<>(); types.add(type); Transformer<String, ?> transformer = (Transformer<String, ?>) transformerRegistry.getTransformer(TypeConstants.STRING_TYPE, targetType, types, types); if (transformer == null) { throw new Fabric3Exception("No transformer for : " + targetType); } return transformer.transform(value, classLoader); }
public void end(Session session, Message message) throws Fabric3Exception { try { session.commit(); } catch (JMSException e) { throw new Fabric3Exception("Error handling message for " + uri, e); } statistics.incrementTransactions(); }
public void release(ConnectionFactoryDefinition definition) throws Fabric3Exception { String name = definition.getName(); if (created.remove(name)) { ConnectionFactory factory = manager.unregister(name); if (factory == null) { throw new Fabric3Exception("Connection factory not found: " + name); } creatorRegistry.release(factory); } }
public Optional<ConnectionFactory> resolve(ConnectionFactoryDefinition definition) throws Fabric3Exception { try { String name = definition.getName(); ConnectionFactory factory = contextManager.lookup(ConnectionFactory.class, name); if (factory == null) { return Optional.empty(); } return Optional.ofNullable(factoryManager.register(name, factory, definition.getProperties())); } catch (NamingException e) { throw new Fabric3Exception(e); } }