private Future<Recommendation> getDestinationWithReccomendation(Destination destination) { ActorRef pricingActor = SpringAppContext.actorSystem().actorOf(Props.create(PriceCalculationActor.class)); ActorRef foreCastActor = SpringAppContext.actorSystem().actorOf(Props.create(WeatherForecastActor.class)); final Future<Calculation> calculationFuture = toPrice( Patterns.ask( pricingActor, new PriceRequest("moon", destination.getDestination()), new Timeout(Duration.create(5, TimeUnit.SECONDS)))); final Future<Forecast> forecastFuture = toForecast( Patterns.ask( foreCastActor, new WeatherRequest(destination.getDestination()), new Timeout(Duration.create(5, TimeUnit.SECONDS)))); return calculationFuture .zip(forecastFuture) .map( new Mapper<Tuple2<Calculation, Forecast>, Recommendation>() { @Override public Recommendation apply(Tuple2<Calculation, Forecast> tuple) { return new Recommendation( destination.getDestination(), tuple._2().getForecast(), tuple._1().getPrice()); } }, SpringAppContext.actorSystem().dispatcher()); }
@RequestMapping(value = "/api/cacheFlightSearch", method = RequestMethod.GET) public String cacheFlightSearch( @RequestParam("departureDate") String departureDate, @RequestParam("departureAirport") String departureAirport) { DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ISO_DATE; LocalDate depDate = LocalDate.parse(departureDate, DATE_FORMAT); LocalDate returnDate = depDate.plusDays(7); String retDate = returnDate.format(DATE_FORMAT); List<Destination> destinations = new Destinations().getDestinations(); for (Destination destination : destinations) { String arrivalAirportCode = destination.getAirportCodes().get(0); System.out.println( "Getting best flight price for destination: " + arrivalAirportCode + "," + destination.getCity()); flightSearchService.getFlights(departureDate, departureAirport, arrivalAirportCode, retDate); System.out.println( "Finished processing best flight price for destination: " + arrivalAirportCode + "," + destination.getCity()); } return "success"; }
private static Destination createDestination(Map<String, String> beanAttr) { if (beanAttr == null) return null; Destination destination = new Destination(); destination.setId(Integer.valueOf(beanAttr.get("id")).intValue()); destination.setDestination(BeansUtils.eraseEscaping(beanAttr.get("destination"))); destination.setType(BeansUtils.eraseEscaping(beanAttr.get("type"))); return destination; }
/** @param canvas */ private void drawCornerTextsAndTrack(Canvas canvas) { /* * Misc text in the information text location on the view like GPS status, * Maps status, and point destination/destination bearing, altitude, ... * Add shadows for better viewing */ mPaint.setShadowLayer(SHADOW, SHADOW, SHADOW, Color.BLACK); mPaint.setColor(Color.WHITE); mPaint.setTextAlign(Align.LEFT); /* * Speed */ canvas.drawText( "" + Math.round(mGpsParams.getSpeed()) + "kt", 0, getHeight() / mTextDiv, mPaint); /* * Altitude */ canvas.drawText( "" + Math.round(mGpsParams.getAltitude()) + "ft", 0, getHeight() - mFontHeight, mPaint); mPaint.setTextAlign(Align.RIGHT); /* * Heading */ canvas.drawText( "" + Math.round(mGpsParams.getBearing()) + '\u00B0', getWidth(), getHeight() - mFontHeight, mPaint); /* * Status/destination top right */ if (mErrorStatus != null) { mPaint.setColor(Color.RED); canvas.drawText(mErrorStatus, getWidth(), getHeight() / mTextDiv * 2, mPaint); } /* * Point above error status */ mPaint.setColor(Color.WHITE); if (mPoint != null) { canvas.drawText(mPoint, getWidth(), getHeight() / mTextDiv, mPaint); } else if (mDestination != null) { canvas.drawText(mDestination.toString(), getWidth(), getHeight() / mTextDiv, mPaint); if (mDestination.isFound() && mPref.isTrackEnabled() && (!mPref.isSimulationMode())) { if (null != mTrackShape) { mPaint.setColor(Color.MAGENTA); mPaint.setStrokeWidth(4); mTrackShape.drawShape(canvas, mOrigin, mScale, mMovement, mPaint, mFace); } } } }
public boolean hasMessageListener(String destinationName) { Destination destination = _destinations.get(destinationName); if ((destination != null) && destination.isRegistered()) { return true; } else { return false; } }
public void addDestinationEventListener( String destinationName, DestinationEventListener destinationEventListener) { Destination destination = _destinations.get(destinationName); if (destination != null) { destination.addDestinationEventListener(destinationEventListener); } }
public void replace(Destination destination) { Destination oldDestination = _destinations.get(destination.getName()); oldDestination.copyDestinationEventListeners(destination); oldDestination.copyMessageListeners(destination); removeDestination(oldDestination.getName()); addDestination(destination); }
/** * This method first calls stop on its superclass <code>Destination</code> and then removes any * assemblers from the ServletContext or Session that are ready for removal. If an assembler is * only used by a single destination (attribute-id==destination-id) then it is removed. If an * assembler is shared across destinations, (attribute-id<>destination-id) then it is only * removed if its reference count (maintained in <code>MessageBroker</code>) is down to zero */ public void stop() { if (isStarted()) { super.stop(); // destroy factory instance to free up resources if (factory != null && (factory instanceof DestructibleFlexFactory)) ((DestructibleFlexFactory) factory).destroyFactoryInstance(factoryInstance); } else { super.stop(); } }
public static void main(String args[]) { Connection connection = null; try { // JNDI lookup of JMS Connection Factory and JMS Destination Context context = new InitialContext(); ConnectionFactory factory = (ConnectionFactory) context.lookup(CONNECTION_FACTORY_NAME); Destination destination = (Destination) context.lookup(DESTINATION_NAME); connection = factory.createConnection(); connection.start(); Session session = connection.createSession(NON_TRANSACTED, Session.AUTO_ACKNOWLEDGE); MessageConsumer consumer = session.createConsumer(destination); LOG.info( "Start consuming messages from " + destination.toString() + " with " + MESSAGE_TIMEOUT_MILLISECONDS + "ms timeout"); // Synchronous message consumer int i = 1; while (true) { Message message = consumer.receive(MESSAGE_TIMEOUT_MILLISECONDS); if (message != null) { if (message instanceof TextMessage) { String text = ((TextMessage) message).getText(); LOG.info("Got " + (i++) + ". message: " + text); } } else { break; } } consumer.close(); session.close(); } catch (Throwable t) { LOG.error("Error receiving message", t); } finally { // Cleanup code // In general, you should always close producers, consumers, // sessions, and connections in reverse order of creation. // For this simple example, a JMS connection.close will // clean up all other resources. if (connection != null) { try { connection.close(); } catch (JMSException e) { LOG.error("Error closing connection", e); } } } }
public synchronized Destination removeDestination(String destinationName) { Destination destinationModel = _destinations.remove(destinationName); if (destinationModel != null) { destinationModel.removeDestinationEventListeners(); destinationModel.unregisterMessageListeners(); fireDestinationRemovedEvent(destinationModel); } return destinationModel; }
public void doCheckRemoveActionAfterRestart() throws Exception { boolean res = true; final ActiveMQDestination[] list = broker.getRegionBroker().getDestinations(); for (final ActiveMQDestination element : list) { final Destination destination = broker.getDestination(element); if (destination.getActiveMQDestination().getPhysicalName().equals(destinationName)) { res = false; break; } } assertTrue("The removed destination is reloaded after restart !", res); }
public void _jspService(final Destination destination) throws IOException, JspEngineException { ObjectJspFactory _jspxFactory = null; ObjectPageContext pageContext = null; Session session = null; ObjectContainerContext application = null; ObjectConfig config = null; ObjectJspWriter out = null; Object page = this; String _value = null; try { if (_jspx_inited == false) { _jspx_init(); _jspx_inited = true; } _jspxFactory = destination.getServer().getObjectJspFactory(); pageContext = _jspxFactory.getPageContext(this, destination, "", true, 8192, true); application = pageContext.getObjectContainerContext(); config = pageContext.getObjectConfig(); session = destination.getSession(); out = pageContext.getOut(); // HTML // begin // [file="/home/teknopaul/workspace/AntInstaller/web/home/teknopaul/workspace/AntInstaller/web/contents.jsp";from=(0,0);to=(13,0)] out.write( "<html>\r\n<head>\r\n <title>Ant Installer</title>\r\n <link href=\"css/nav.css\" rel=\"stylesheet\" type=\"text/css\">\r\n <link href=\"style.css\" type=\"text/css\" rel=\"stylesheet\">\r\n <meta name=\"keywords\"\r\n content=\"Ant, installer, AntInstall, gui, console, input, parameters, properties, swing, user interface, valiation, configuration\">\r\n <script type=\"text/javascript\" src=\"js/menu.js\"></script>\r\n <script type=\"text/javascript\" src=\"js/sstree.js\"></script>\r\n</head>\r\n<body onload='collapseAll([\"ol\"]); openBookMark();'>\r\n<a href=\"index.html\" alt=\"home\" target=\"_content\">\r\n<img src=\"images/ant-install-small.png\" target=\"_content\" align=\"baseline\"/></a><br/>\r\n"); // end // begin // [file="/home/teknopaul/workspace/AntInstaller/web/home/teknopaul/workspace/AntInstaller/web/contents.jsp";from=(13,0);to=(13,56)] { String _jspx_qStr = ""; pageContext.include("contents-include.html" + _jspx_qStr); } // end // HTML // begin // [file="/home/teknopaul/workspace/AntInstaller/web/home/teknopaul/workspace/AntInstaller/web/contents.jsp";from=(13,56);to=(15,0)] out.write("\r\n</body>\r\n"); // end } catch (Exception ex) { if (out.getBufferSize() != 0) out.clearBuffer(); pageContext.handlePageException(ex); } finally { out.flush(); _jspxFactory.releasePageContext(pageContext); } }
public void sendMessage(String destinationName, Message message) { Destination destination = _destinations.get(destinationName); if (destination == null) { if (_log.isWarnEnabled()) { _log.warn("Destination " + destinationName + " is not configured"); } return; } message.setDestinationName(destinationName); destination.send(message); }
/** @param params */ public void initParams(GpsParams params, StorageService service) { /* * Comes from storage service. This will do nothing for fresh start, * but it will load previous combo on re-activation */ mService = service; mMovement = mService.getMovement(); mImageDataSource = mService.getDBResource(); if (null == mMovement) { mMovement = new Movement(); } mPan = mService.getPan(); if (null == mPan) { mPan = new Pan(); } if (null != params) { mGpsParams = params; } else if (null != mDestination) { mGpsParams = new GpsParams(mDestination.getLocation()); } else { mGpsParams = new GpsParams(null); } mScale.setScaleAt(mGpsParams.getLatitude()); dbquery(true); postInvalidate(); }
public void doRemoveDestination() throws Exception { boolean res = true; broker.removeDestination( ActiveMQDestination.createDestination(destinationName, destinationType)); final ActiveMQDestination[] list = broker.getRegionBroker().getDestinations(); for (final ActiveMQDestination element : list) { final Destination destination = broker.getDestination(element); if (destination.getActiveMQDestination().getPhysicalName().equals(destinationName)) { res = false; break; } } assertTrue("Removing destination Failed", res); }
public synchronized boolean registerMessageListener( String destinationName, MessageListener messageListener) { Destination destination = _destinations.get(destinationName); if (destination == null) { throw new IllegalStateException("Destination " + destinationName + " is not configured"); } boolean registered = destination.register(messageListener); if (registered) { fireMessageListenerRegisteredEvent(destination, messageListener); } return registered; }
public synchronized boolean unregisterMessageListener( String destinationName, MessageListener messageListener) { Destination destination = _destinations.get(destinationName); if (destination == null) { return false; } boolean unregistered = destination.unregister(messageListener); if (unregistered) { fireMessageListenerUnregisteredEvent(destination, messageListener); } return unregistered; }
public LinearPath(ArrayList<Destination> destinations) { this.destinations = destinations; // Make sure all times are set correctly Vector2 temp = new Vector2(); int index = 0; int lastIndex = destinations.size() - 1; for (Destination dest : destinations) { if (index < lastIndex) { Destination next = destinations.get(index + 1); dest.moveTime = temp.set(next).sub(dest).len() / dest.speed; } dest.startTime = totalTime; totalTime += dest.moveTime; index++; } }
protected void fireMessageListenerUnregisteredEvent( Destination destination, MessageListener messageListener) { for (DestinationEventListener destinationEventListener : _destinationEventListeners) { destinationEventListener.messageListenerUnregistered(destination.getName(), messageListener); } }
private Counter finder(Counter[] val, byte[] bitfield) { boolean[] bools = checker(bitfield); for (int i = 0; i < counter; i++) { if (bitF[val[i].getCount()] == 0 && bools[val[i].getCount()]) { outP.progtake(i); return val[i]; } } return new Counter(-1); }
public void doAddDestination() throws Exception { boolean res = false; ActiveMQDestination amqDestination = ActiveMQDestination.createDestination(destinationName, destinationType); broker .getRegionBroker() .addDestination(broker.getAdminConnectionContext(), amqDestination, true); final ActiveMQDestination[] list = broker.getRegionBroker().getDestinations(); for (final ActiveMQDestination element : list) { final Destination destination = broker.getDestination(element); if (destination.getActiveMQDestination().getPhysicalName().equals(destinationName)) { res = true; break; } } assertTrue("Adding destination Failed", res); }
/** * Construct a Reusable Object to get SSO Uri's <br> * note: the password is never transited as we use NTLM Auth * * @param destination Where in FOL the link should endup * @param user The username to authenticate * @param pass The password to authenticate */ public GetSSO(Destination destination, String user, String pass) { switch (destination) { case FOL: requestURL = "https://portal.myfanshawe.ca/_layouts/Fanshawe/fol_pass_thru.aspx"; break; case EMAIL: requestURL = "https://portal.myfanshawe.ca/_layouts/Fanshawe/fol_pass_thru.aspx?dest=inbox"; break; default: throw new IllegalArgumentException(destination.toString() + " is not a valid destination"); } this.user = user; this.pass = pass; }
/** * Initializes the <code>FactoryDestination</code> with the properties. * * @param id the factory id * @param properties Properties for the <code>FactoryDestination</code>. */ public void initialize(String id, ConfigMap properties) { super.initialize(id, properties); if (properties == null || properties.size() == 0) return; // Need to cache this for later. TODO: We shouldn't need to do this. factoryProperties = properties; factoryId = properties.getPropertyAsString(FACTORY, factoryId); scope = properties.getPropertyAsString(FlexFactory.SCOPE, scope); source = properties.getPropertyAsString(FlexFactory.SOURCE, source); if (source == null) source = getId(); if (factory != null) factory.initialize(getId(), factoryProperties); }
/** @param destination */ public void updateDestination(Destination destination) { /* * Comes from database */ mDestination = destination; if (null != destination) { if (destination.isFound()) { /* * Set pan to zero since we entered new destination * and we want to show it without pan. */ mPan = new Pan(); tfrReset(); mTrackShape = new TrackShape(mDestination); } } }
@BeforeClass @SuppressWarnings("unchecked") public void setUp() throws Exception { // Making the staging and/or output dirs if necessary File stagingDir = new File(TestConstants.TEST_STAGING_DIR); File outputDir = new File(TestConstants.TEST_OUTPUT_DIR); if (!stagingDir.exists()) { stagingDir.mkdirs(); } if (!outputDir.exists()) { outputDir.mkdirs(); } this.schema = new Schema.Parser().parse(TestConstants.AVRO_SCHEMA); this.filePath = TestConstants.TEST_EXTRACT_NAMESPACE.replaceAll("\\.", "/") + "/" + TestConstants.TEST_EXTRACT_TABLE + "/" + TestConstants.TEST_EXTRACT_ID + "_" + TestConstants.TEST_EXTRACT_PULL_TYPE; State properties = new State(); properties.setProp(ConfigurationKeys.WRITER_BUFFER_SIZE, ConfigurationKeys.DEFAULT_BUFFER_SIZE); properties.setProp(ConfigurationKeys.WRITER_FILE_SYSTEM_URI, TestConstants.TEST_FS_URI); properties.setProp(ConfigurationKeys.WRITER_STAGING_DIR, TestConstants.TEST_STAGING_DIR); properties.setProp(ConfigurationKeys.WRITER_OUTPUT_DIR, TestConstants.TEST_OUTPUT_DIR); properties.setProp(ConfigurationKeys.WRITER_FILE_PATH, this.filePath); properties.setProp(ConfigurationKeys.WRITER_FILE_NAME, TestConstants.TEST_FILE_NAME); // Build a writer to write test records this.writer = new AvroDataWriterBuilder() .writeTo(Destination.of(Destination.DestinationType.HDFS, properties)) .writeInFormat(WriterOutputFormat.AVRO) .withWriterId(TestConstants.TEST_WRITER_ID) .withSchema(this.schema) .forBranch(-1) .build(); }
/** Verifies that the <code>FactoryDestination</code> is in valid state before it is started. */ protected void validate() { if (isValid()) return; super.validate(); if (factory == null) { if (factoryId == null) { factoryId = DEFAULT_FACTORY; } MessageBroker broker = getService().getMessageBroker(); FlexFactory f = broker.getFactory(factoryId); if (f == null) { ConfigurationException ex = new ConfigurationException(); ex.setMessage(INVALID_FACTORY, new Object[] {getId(), factoryId}); throw ex; } factory = f; } if (scope == null) scope = FlexFactory.SCOPE_REQUEST; if (source == null) source = getId(); }
public static void main(String[] args) { Parcel10 p = new Parcel10(); Destination d = p.destination("Tasmania", 101.395F); System.out.println("d (destination) read label: " + d.readLabel()); }
public void ship(String dest) { Contents c = cont(); Destination d = to(dest); System.out.println(d.readLabel()); }
private void reconverDestinationSequence( Endpoint endpoint, Conduit conduit, Destination d, DestinationSequence ds) { d.addSequence(ds, false); // TODO add the redelivery code }
public SourceSequence getSequence(Identifier inSeqId, Message message, AddressingProperties maps) throws RMException { Source source = getSource(message); SourceSequence seq = source.getCurrent(inSeqId); RMConfiguration config = getEffectiveConfiguration(message); if (null == seq || seq.isExpired()) { // TODO: better error handling EndpointReferenceType to = null; boolean isServer = RMContextUtils.isServerSide(message); EndpointReferenceType acksTo = null; RelatesToType relatesTo = null; if (isServer) { AddressingProperties inMaps = RMContextUtils.retrieveMAPs(message, false, false); inMaps.exposeAs(config.getAddressingNamespace()); acksTo = RMUtils.createReference(inMaps.getTo().getValue()); to = inMaps.getReplyTo(); source.getReliableEndpoint().getServant().setUnattachedIdentifier(inSeqId); relatesTo = (new org.apache.cxf.ws.addressing.ObjectFactory()).createRelatesToType(); Destination destination = getDestination(message); DestinationSequence inSeq = inSeqId == null ? null : destination.getSequence(inSeqId); relatesTo.setValue(inSeq != null ? inSeq.getCorrelationID() : null); } else { to = RMUtils.createReference(maps.getTo().getValue()); acksTo = maps.getReplyTo(); if (RMUtils.getAddressingConstants().getNoneURI().equals(acksTo.getAddress().getValue())) { Endpoint ei = message.getExchange().getEndpoint(); org.apache.cxf.transport.Destination dest = ei == null ? null : ei.getEndpointInfo() .getProperty( MAPAggregator.DECOUPLED_DESTINATION, org.apache.cxf.transport.Destination.class); if (null == dest) { acksTo = RMUtils.createAnonymousReference(); } else { acksTo = dest.getAddress(); } } } if (ContextUtils.isGenericAddress(to)) { org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message( "CREATE_SEQ_ANON_TARGET", LOG, to != null && to.getAddress() != null ? to.getAddress().getValue() : null); LOG.log(Level.INFO, msg.toString()); throw new RMException(msg); } Proxy proxy = source.getReliableEndpoint().getProxy(); ProtocolVariation protocol = config.getProtocolVariation(); Exchange exchange = new ExchangeImpl(); Map<String, Object> context = new HashMap<String, Object>(16); for (String key : message.getContextualPropertyKeys()) { // copy other properties? if (key.startsWith("ws-security")) { context.put(key, message.getContextualProperty(key)); } } CreateSequenceResponseType createResponse = proxy.createSequence(acksTo, relatesTo, isServer, protocol, exchange, context); if (!isServer) { Servant servant = source.getReliableEndpoint().getServant(); servant.createSequenceResponse(createResponse, protocol); // propagate security properties to application endpoint, in case we're using // WS-SecureConversation Exchange appex = message.getExchange(); if (appex.get(SecurityConstants.TOKEN) == null) { appex.put(SecurityConstants.TOKEN, exchange.get(SecurityConstants.TOKEN)); appex.put(SecurityConstants.TOKEN_ID, exchange.get(SecurityConstants.TOKEN_ID)); } } seq = source.awaitCurrent(inSeqId); seq.setTarget(to); } return seq; }