public void onModuleLoad() { // Add a handler to send the name to the server // TextButton b = new TextButton("Button sencha"); // RootPanel.get("main_content").add(b); RootLayoutPanel.get().add(mainLayout); MainMenu mainMenu = new MainMenu(); mainLayout.getMenuPanel().add(mainMenu); EventBus eventBus = ClientFactory.getEventBus(); PlaceController placeController = ClientFactory.getPlaceController(); ActivityMapper activityMapper = new AppActivityMapper(); ActivityManager activityManager = new ActivityManager(activityMapper, eventBus); activityManager.setDisplay((AcceptsOneWidget) mainLayout.getContentPanel().asWidget()); Place defaultPlace = new LoginPlace("World!"); AppPlaceHistoryMapper historyMapper = GWT.create(AppPlaceHistoryMapper.class); PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(historyMapper); historyHandler.register(placeController, eventBus, defaultPlace); historyHandler.handleCurrentHistory(); // RootPanel.get().add(panel); }
@Override public void onModuleLoad() { defaultPlace = new ProfilePlace("Profile"); ClientFactory clientFactory = GWT.create(ClientFactory.class); EventBus eventBus = clientFactory.getEventBus(); PlaceController placeController = clientFactory.getPlaceController(); // Start ActivityManager for the main widget with our ActivityMapper ActivityMapper activityMapper = new AppActivityMapper(clientFactory); ActivityManager activityManager = new ActivityManager(activityMapper, eventBus); activityManager.setDisplay(appWidget); // Start PlaceHistoryHandler with our PlaceHistoryMapper AppPlaceHistoryMapper historyMapper = GWT.create(AppPlaceHistoryMapper.class); PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(historyMapper); historyHandler.register(placeController, eventBus, defaultPlace); // Header // DockLayoutPanel dlPanel = new DockLayoutPanel(Unit.EM); // dlPanel.addNorth(new HeaderViewImpl(), 5); // dlPanel.add(appWidget); RootPanel.get().add(appWidget); // RootPanel.get().add(appWidget); // Goes to the place represented on URL else default place historyHandler.handleCurrentHistory(); }
@Test public void testTwoEndPoints() throws Exception { new Thread( () -> { final ArrayList<ServiceDefinition> endpoints = new ArrayList<>(); endpoints.add(DEF); endpoints.add(DEF2); final Server server = new Server(logger, handlerFactory()); server.init(PORT, endpoints, Executors.newSingleThreadExecutor()); }) .start(); final ClientFactory clientFactory = new MultiplexedClientFactory(PORT); final TestService.AsyncIface client = clientFactory.create(DEF, HOSTNAME); final TestResponse response = callTestService(client); logger.info("Received: " + response); assertEquals(response.getResult(), Handler.RESULT); final TestService2.AsyncIface client2 = clientFactory.create(DEF2, HOSTNAME); final TestResponse2 response2 = callTestService2(client2); logger.info("Received: " + response2); assertEquals(response2.getResult(), Handler2.RESULT); clientFactory.close(); }
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(MultiActivityManagerTest.class); activityMapper = mock(ActivityMapper.class); placeHistoryMapper = mock(PlaceHistoryMapper.class); eventBus = mock(EventBus.class); tabbedPanel = mock(TabbedPanel.class); ClientFactory clientFactory = mock(ClientFactory.class); when(clientFactory.getActivityMapper()).thenReturn(activityMapper); when(clientFactory.getPlaceHistoryMapper()).thenReturn(placeHistoryMapper); when(clientFactory.getEventBus()).thenReturn(eventBus); multiActivityManager = new MultiActivityManager(clientFactory); }
/** * Invokes the given request * * @param <R> the return type * @param request the request to invoke * @return the response * @throws Exception the exception */ private <R> HttpResponse invoke(HttpRequest<R> request, boolean useNonStrictSSL) throws Exception { Client client = ClientFactory.create(useNonStrictSSL); WebTarget target = client.target(request.getEndpoint()).path(request.getPath()); if (Boolean.getBoolean(HttpLoggingFilter.class.getName())) target.register(new HttpLoggingFilter(Logger.getLogger("os"), 10000)); target = populateQueryParams(target, request); Invocation.Builder invocation = target.request(MediaType.APPLICATION_JSON); populateHeaders(invocation, request); Entity<?> entity = (request.getEntity() == null) ? null : Entity.entity(request.getEntity(), request.getContentType()); try { if (entity != null) { return HttpResponse.wrap(invocation.method(request.getMethod().name(), entity)); } if (HttpMethod.PUT == request.getMethod() || request.hasJson()) { return HttpResponse.wrap( invocation.method( request.getMethod().name(), Entity.entity(request.getJson(), ClientConstants.CONTENT_TYPE_JSON))); } return HttpResponse.wrap(invocation.method(request.getMethod().name())); } catch (ProcessingException pe) { throw new ConnectionException(pe.getMessage(), 0, pe); } catch (ClientErrorException e) { throw HttpResponse.mapException( e.getResponse().getStatusInfo().toString(), e.getResponse().getStatus(), e); } }
@Override protected void run() throws Exception { while (isRunning()) { // PACKET RECEIVED socket.receive(packet); int length = packet.getLength(); byte[] data = ByteBuffer.allocate(length).put(packet.getData(), 0, length).array(); SocketAddress address = packet.getSocketAddress(); // ALLOCATE CLIENT SWGClient client = (!connections.containsKey(address)) ? clientFactory.create(address) : connections.get(address); data = packagingService.disassemble(data, client.getCrc()); if (data.length == 1) { // TODO: Queue logout packet // TODO: Disconnect client } else if (data.length == 0) { } else { // TODO: Create SWG Message from data } } }
@RequestMapping("/get/{blogId}") public void get(HttpServletResponse resp, @PathVariable("blogId") String blogId) throws IOException { resp.setContentType("audio/mp3"); resp.setHeader("Content-Disposition", "attachment;filename=\"blah.mp3\""); String content = clientFactory.makeClient().getBlog(blogId).get("content"); Translit.textToMp3(content, resp.getOutputStream()); }
public boolean confirm(String message) { boolean x = Window.confirm(message); Log.debug("DONE WITH CONFIRM = " + x); if (!x) { // set tab to correct place on cancel cf.getHome().setTab(cf); } return x; }
Client client(Random random) { if (closed.get()) { throw new RuntimeException("already closed"); } if (client != null) { return client; } return client = clientFactory.client(node, clusterName, random); }
@BeforeClass public static void initializeTest() throws Exception { FSUtils.delTree(new java.io.File(SetupUtils.TEST_DIR)); Logging.start(SetupUtils.DEBUG_LEVEL, SetupUtils.DEBUG_CATEGORIES); dirConfig = SetupUtils.createDIRConfig(); dir = new DIRRequestDispatcher(dirConfig, SetupUtils.createDIRdbsConfig()); dir.startup(); dir.waitForStartup(); testEnv = new TestEnvironment( new TestEnvironment.Services[] { TestEnvironment.Services.DIR_CLIENT, TestEnvironment.Services.TIME_SYNC, TestEnvironment.Services.RPC_CLIENT, TestEnvironment.Services.MRC }); testEnv.start(); userCredentials = UserCredentials.newBuilder().setUsername("test").addGroups("test").build(); dirAddress = testEnv.getDIRAddress().getHostName() + ":" + testEnv.getDIRAddress().getPort(); mrcAddress = testEnv.getMRCAddress().getHostName() + ":" + testEnv.getMRCAddress().getPort(); defaultCoordinates = VivaldiCoordinates.newBuilder() .setXCoordinate(0) .setYCoordinate(0) .setLocalError(0) .build(); defaultStripingPolicy = StripingPolicy.newBuilder() .setType(StripingPolicyType.STRIPING_POLICY_RAID0) .setStripeSize(128) .setWidth(1) .build(); osds = new OSD[4]; configs = SetupUtils.createMultipleOSDConfigs(4); // start three OSDs osds[0] = new OSD(configs[0]); osds[1] = new OSD(configs[1]); osds[2] = new OSD(configs[2]); osds[3] = new OSD(configs[3]); mrcClient = new MRCServiceClient(testEnv.getRpcClient(), null); options = new Options(); client = ClientFactory.createClient(dirAddress, userCredentials, null, options); client.start(); }
public void onModuleLoad() { ClientFactory clientFactory = GWT.create(ClientFactory.class); EventBus eventBus = clientFactory.getEventBus(); PlaceController placeController = clientFactory.getPlaceController(); SimplePanel contentPanel = new SimplePanel(); // Start ActivityManager for the main widget with our ActivityMapper ActivityMapper activityMapper = new AppActivityMapper(clientFactory); ActivityManager activityManager = new ActivityManager(activityMapper, eventBus); activityManager.setDisplay(contentPanel); // Start PlaceHistoryHandler with our PlaceHistoryMapper AppPlaceHistoryMapper historyMapper = GWT.create(AppPlaceHistoryMapper.class); PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(historyMapper); historyHandler.register(placeController, eventBus, new TaskResultListPlace()); RootPanel.get().add(contentPanel); // Goes to the place represented on URL else default place historyHandler.handleCurrentHistory(); }
@RequestMapping("/podcast.rss") public void podcast(HttpServletRequest req, HttpServletResponse resp) throws IOException { PrintWriter pw = resp.getWriter(); List<Map<String, String>> summaries = clientFactory.makeClient().getBlogEntries(); List<BlogSummary> blogIds = new ArrayList<BlogSummary>(); for (Map<String, String> summary : summaries) { String id = summary.get("id"); String date = summary.get("publishDate"); String title = summary.get("title"); String url = summary.get("url"); blogIds.add(new BlogSummary(id, title, date, url)); } pw.write(rssMaker.makeRss(blogIds)); }
@UiHandler("prueba2") void onPrueba2Click(ClickEvent event) { clientFactory.getPlaceController().goTo(new SeleccionAlumnoPlace("2")); }
protected final HttpClient getHttpClient() { return clientFactory.getHttpClient(); }
protected final ClientConfig getClientConfig() { return clientFactory.getClientConfig(); }
protected final Client getClient() { return clientFactory.getClient(); }
private void bind() { ProjectChangeEvent.register( clientFactory.getEventBus(), new ProjectChangeEvent.Handler() { @Override public void onProjectChange(ProjectObject project) { handleProjectChange(project); } }); // observe add project event to add new item to menu NewProjectAvailableEvent.register( clientFactory.getEventBus(), new NewProjectAvailableEvent.Handler() { @Override public void onNewProject(int projectId) { handleAddProject(projectId); } }); ProjectDeleteEvent.register( clientFactory.getEventBus(), new ProjectDeleteEvent.Handler() { @Override public void onProjectDelete(int projectId) { handleRemoveProject(projectId); } }); clientFactory .getEventBus() .addHandler( PlaceChangeEvent.TYPE, new PlaceChangeEvent.Handler() { public void onPlaceChange(PlaceChangeEvent event) { Place newPlace = event.getNewPlace(); String gaName = null; if (newPlace instanceof AboutPlace) { gaName = "#AboutPlace:" + ((AboutPlace) newPlace).getToken(); } else if (newPlace instanceof RequestPlace) { RequestPlace _place = (RequestPlace) newPlace; if (_place.isProject() || _place.isProjectsEndpoint()) { // projects.setSelected(true); } else { // request.setSelected(true); } if (_place.isHistory()) { gaName = "#RequestPlace:history"; } else if (_place.isProjectsEndpoint()) { gaName = "#RequestPlace:projectEndpoint"; } else if (_place.isProject()) { gaName = "#RequestPlace:project"; } else if (_place.isSaved()) { gaName = "#RequestPlace:saved"; } else if (_place.isExternal()) { gaName = "#RequestPlace:external"; } else { gaName = "#RequestPlace:default"; } } else if (newPlace instanceof SettingsPlace) { gaName = "#SettingsPlace:" + ((SettingsPlace) newPlace).getToken(); } else if (newPlace instanceof ImportExportPlace) { gaName = "#ImportExportPlace:" + ((ImportExportPlace) newPlace).getToken(); } else if (newPlace instanceof HistoryPlace) { gaName = "#HistoryPlace:" + ((HistoryPlace) newPlace).getToken(); } else if (newPlace instanceof SavedPlace) { gaName = "#SavedPlace:" + ((SavedPlace) newPlace).getToken(); } else if (newPlace instanceof SocketPlace) { gaName = "#SocketPlace:" + ((SocketPlace) newPlace).getToken(); } GoogleAnalytics.sendPageView(gaName); GoogleAnalyticsApp.sendScreen(gaName); } }); }
public void onModuleLoad() { Logger logger = Logger.getLogger(""); // logger.log(Level.FINE, "Arrancando aplicaciĆ³n"); logger.log(Level.INFO, "Arrancando aplicaciĆ³n2"); // Create app layout // Create ClientFactory using deferred binding so we can replace with // different // impls in gwt.xml clientFactory = GWT.create(ClientFactory.class); clientFactory.getLogger().log(Level.INFO, "holaaaaa"); // clientFactory.setMainView(this); EventBus eventBus = clientFactory.getEventBus(); PlaceController placeController = clientFactory.getPlaceController(); clientFactory.getRequestFactory().initialize(eventBus); // Initialize RequestFactory // clientFactory.initializeRequestFactory(); System.out.println("contruyendo mappers"); // Start ActivityManager for each area with its ActivityMapper ActivityMapper alumnoMapper = new AlumnoMapper(clientFactory); ActivityMapper observacionesAlumnoMapper = new ObservacionesAlumnoMapper(clientFactory); ActivityMapper matriculaMapper = new MatriculaMapper(clientFactory); ActivityMapper materialMapper = new MaterialMapper(clientFactory); /* ActivityMapper mainPanelActivityMapper = new MainPanelActivityMapper( clientFactory); ActivityMapper formularioAlumnoPanelActivityMapper = new FormularioAlumnoPanelActivityMapper( clientFactory); ActivityMapper alumnoPanelActivityMapper = new AlumnoPanelActivityMapper( clientFactory); ActivityMapper observacionesPanelActivityMapper = new ObservacionesPanelActivityMapper( clientFactory); ActivityMapper matriculaPanelActivityMapper = new MatriculaPanelActivityMapper( clientFactory); ActivityManager mainPanelActivityManager = new ActivityManager( mainPanelActivityMapper, eventBus); mainPanelActivityManager.setDisplay(appWidget); ActivityManager alumnoPanelActivityManager = new ActivityManager( alumnoPanelActivityMapper, eventBus); alumnoPanelActivityManager.setDisplay(alumnoPanel); ActivityManager formularioAlumnoPanelActivityManager = new ActivityManager( formularioAlumnoPanelActivityMapper, eventBus); formularioAlumnoPanelActivityManager.setDisplay(alumnoPanel); ActivityManager panelObservacionesActivityManager = new ActivityManager( observacionesPanelActivityMapper, eventBus); panelObservacionesActivityManager.setDisplay(observacionesalumnoPanel); ActivityManager panelMatriculaActivityManager = new ActivityManager( matriculaPanelActivityMapper, eventBus); panelMatriculaActivityManager.setDisplay(matriculaPanel); */ tabAlumno.selectTab(1); ActivityManager alumnoManager = new ActivityManager(alumnoMapper, eventBus); alumnoManager.setDisplay(alumnoPanel); ActivityManager observacionesAlumnoManager = new ActivityManager(observacionesAlumnoMapper, eventBus); observacionesAlumnoManager.setDisplay(observacionesalumnoPanel); ActivityManager matriculaManager = new ActivityManager(matriculaMapper, eventBus); matriculaManager.setDisplay(matriculaPanel); ActivityManager materialManager = new ActivityManager(materialMapper, eventBus); materialManager.setDisplay(materialPanel); // Start PlaceHistoryHandler with our PlaceHistoryMapper AppPlaceHistoryMapper historyMapper = GWT.create(AppPlaceHistoryMapper.class); PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(historyMapper); historyHandler.register(placeController, eventBus, defaultPlace); // Add app layout to root layout RootLayoutPanel.get().add(outer); // historyHandler.handleCurrentHistory(); /*eventBus.addHandler(SeleccionAlumnoEvent.TYPE, new SeleccionAlumnoEventHandler() { @Override public void onSelecc( SeleccionAlumnoEvent authenticationEvent) { // authentication changed - do something System.out.println("tocado" + clientFactory.getSelectedAlumnoNif()); if (clientFactory.getSelectedAlumnoNif() == null) tabDatosAlumno.setVisible(false); else tabDatosAlumno.setVisible(true); } });*/ PopupPanel loggingPopup = new PopupPanel(false); loggingPopup.setPopupPosition(10, 240); loggingPopup.setWidth("500px"); clientFactory.getLogger().addHandler(new HasWidgetsLogHandler(loggingPopup)); }