/** * Create an <code>ObjectName</code> for this <code>Manager</code> object. * * @param domain Domain in which this name is to be created * @param manager The Manager to be named * @exception MalformedObjectNameException if a name cannot be created */ static ObjectName createObjectName(String domain, Manager manager) throws MalformedObjectNameException { ObjectName name = null; Container container = manager.getContainer(); if (container instanceof Engine) { name = new ObjectName(domain + ":type=Manager"); } else if (container instanceof Host) { name = new ObjectName(domain + ":type=Manager,host=" + container.getName()); } else if (container instanceof Context) { String path = ((Context) container).getPath(); if (path.length() < 1) { path = "/"; } Host host = (Host) container.getParent(); name = new ObjectName(domain + ":type=Manager,path=" + path + ",host=" + host.getName()); } else if (container == null) { DefaultContext defaultContext = manager.getDefaultContext(); if (defaultContext != null) { Container parent = defaultContext.getParent(); if (parent instanceof Engine) { name = new ObjectName(domain + ":type=DefaultManager"); } else if (parent instanceof Host) { name = new ObjectName(domain + ":type=DefaultManager,host=" + parent.getName()); } } } return (name); }
/* ------------------------------------------------------------ */ public void startConnection(HttpDestination destination) throws IOException { SocketChannel channel = null; try { channel = SocketChannel.open(); Address address = destination.isProxied() ? destination.getProxy() : destination.getAddress(); channel.socket().setTcpNoDelay(true); if (_httpClient.isConnectBlocking()) { channel.socket().connect(address.toSocketAddress(), _httpClient.getConnectTimeout()); channel.configureBlocking(false); _selectorManager.register(channel, destination); } else { channel.configureBlocking(false); channel.connect(address.toSocketAddress()); _selectorManager.register(channel, destination); ConnectTimeout connectTimeout = new ConnectTimeout(channel, destination); _httpClient.schedule(connectTimeout, _httpClient.getConnectTimeout()); _connectingChannels.put(channel, connectTimeout); } } catch (UnresolvedAddressException ex) { if (channel != null) channel.close(); destination.onConnectionFailed(ex); } catch (IOException ex) { if (channel != null) channel.close(); destination.onConnectionFailed(ex); } }
/** Error cases test. */ @Test public void errorCasesTest() { try { ServiceFactory<SampleService> factory = null; Manager.register(SampleService.class, factory, null, new Scope[] {}); Assert.fail("Exception shold be thrown before this step."); } catch (IllegalArgumentException e) { Assert.assertTrue( "Right exception should be there.", e.getMessage().startsWith("serviceFactory")); } try { Manager.register(null, new SampleServiceFactory(), null, new Scope[] {}); Assert.fail("Exception shold be thrown before this step."); } catch (IllegalArgumentException e) { Assert.assertTrue("Right exception should be there.", e.getMessage().startsWith("service")); } try { Manager.get(null); Assert.fail("Exception shold be thrown before this step."); } catch (IllegalArgumentException e) { Assert.assertTrue("Right exception should be there.", e.getMessage().startsWith("service")); } catch (ManagerException e) { Assert.fail("No exception should be on this step."); } }
/** * Test {@link Manager} warm up if there service with circular dependency in post-construct. * * @throws ManagerException */ @Test public void circularDependencyInWarmUpTest() throws ManagerException { Manager.register( ServiceWithCircularDependencyInWarmUp.class, ServiceWithCircularDependencyInWarmUpFactory.class); Manager.get(ServiceWithCircularDependencyInWarmUp.class); }
// 73 public SmTbProductBean decodeRow(ResultSet rs, int[] fieldList) throws SQLException { SmTbProductBean pObject = createSmTbProductBean(); int pos = 0; for (int i = 0; i < fieldList.length; i++) { switch (fieldList[i]) { case ID_PRD_ID: ++pos; pObject.setPrdId(Manager.getLong(rs, pos)); break; case ID_PRD_TYPE_ID: ++pos; pObject.setPrdTypeId(Manager.getLong(rs, pos)); break; case ID_NAME: ++pos; pObject.setName(rs.getString(pos)); break; case ID_PRICE: ++pos; pObject.setPrice(Manager.getLong(rs, pos)); break; case ID_PRICE_VIP: ++pos; pObject.setPriceVip(Manager.getLong(rs, pos)); break; case ID_SUPLY_STATUS: ++pos; pObject.setSuplyStatus(rs.getString(pos)); break; case ID_FORMAT_DESC: ++pos; pObject.setFormatDesc(rs.getString(pos)); break; case ID_DETAIL_DESC: ++pos; pObject.setDetailDesc(rs.getString(pos)); break; case ID_SEND_AREA: ++pos; pObject.setSendArea(rs.getString(pos)); break; case ID_SEND_DESC: ++pos; pObject.setSendDesc(rs.getString(pos)); break; case ID_PRD_PIC_FILE: ++pos; pObject.setPrdPicFile(rs.getString(pos)); break; case ID_OWNER: ++pos; pObject.setOwner(Manager.getLong(rs, pos)); break; } } pObject.isNew(false); pObject.resetIsModified(); return pObject; }
public void onDisable() { Manager.save(); Manager.cancelAllTasks(); getLogger().info(getDescription().getFullName() + " disabled!"); }
/** * 方法开始时调用,采集开始时间 * * @param methodId */ public static void Start(int methodId) { if (!Manager.instance().canProfile()) { return; } long threadId = Thread.currentThread().getId(); if (threadId >= size) { return; } long startTime; if (Manager.isNeedNanoTime()) { startTime = System.nanoTime(); } else { startTime = System.currentTimeMillis(); } try { ThreadData thrData = threadProfile[(int) threadId]; if (thrData == null) { thrData = new ThreadData(); threadProfile[(int) threadId] = thrData; } long[] frameData = new long[3]; frameData[0] = methodId; frameData[1] = thrData.stackNum; frameData[2] = startTime; thrData.stackFrame.push(frameData); thrData.stackNum++; } catch (Exception e) { e.printStackTrace(); } }
public static void main1(String[] args) throws IOException, ClassNotFoundException { Employee harry = new Employee("Harry Hacker", 50000, 1989, 10, 1); Manager carl = new Manager("Carl Cracker", 80000, 1987, 12, 15); carl.setSecretary(harry); Manager tony = new Manager("Tony Tester", 40000, 1990, 3, 15); tony.setSecretary(harry); Employee[] staff = new Employee[3]; staff[0] = carl; staff[1] = harry; staff[2] = tony; // save all employee records to the file employee.dat try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("employee.dat"))) { out.writeObject(staff); } try (ObjectInputStream in = new ObjectInputStream(new FileInputStream("employee.dat"))) { // retrieve all records into a new array Employee[] newStaff = (Employee[]) in.readObject(); // raise secretary's salary newStaff[1].raiseSalary(10); // print the newly read employee records for (Employee e : newStaff) System.out.println(e); } }
@Test public void XY() { Zwierze z1 = new Zwierze(); z1.setImie(imie1); z1.setGatunek(gatunek1); Zwierze z2 = new Zwierze(); z2.setImie(imie2); z2.setGatunek(gatunek2); Zwierze z3 = new Zwierze(); z3.setImie(imie3); z3.setGatunek(gatunek3); Weterynarz w = new Weterynarz(); w.setImie(wi1); w.setNazwisko(wn1); manager.addZwierze(z2); manager.addZwierze(z3); w.getZwierzes().add(manager.findZwierzeByImie(imie2)); w.getZwierzes().add(manager.findZwierzeByImie(imie2)); manager.addWeterynarz(w); manager.findWeterynarzByImie(wi1); assertEquals(manager.findWeterynarzByImie(wi1).getZwierzes().size(), 2); }
public VideoPlay(URL mediaURL) { setLayout(new BorderLayout()); // use a BorderLayout // Use lightweight components for Swing compatibility Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, true); try { // create a player to play the media specified in the URL Player mediaPlayer = Manager.createRealizedPlayer(mediaURL); // get the components for the video and the playback controls Component video = mediaPlayer.getVisualComponent(); Component controls = mediaPlayer.getControlPanelComponent(); if (video != null) add(video, BorderLayout.CENTER); // add video component if (controls != null) add(controls, BorderLayout.SOUTH); // add controls mediaPlayer.start(); // start playing the media clip } // end try catch (NoPlayerException noPlayerException) { System.err.println("No media player found"); } // end catch catch (CannotRealizeException cannotRealizeException) { System.err.println("Could not realize media player"); } // end catch catch (IOException iOException) { System.err.println("Error reading from the source"); } // end catch } // end MediaPanel constructor
/** draw part of the surface */ public void draw() { manager.startGeometry(Manager.Type.TRIANGLES); du = (uMax - uMin) / uNb; dv = (vMax - vMin) / vNb; /* * uMinFadeNb = uNb*uMinFade/(uMax-uMin); uMaxFadeNb = * uNb*uMaxFade/(uMax-uMin); vMinFadeNb = vNb*vMinFade/(vMax-vMin); * vMaxFadeNb = vNb*vMaxFade/(vMax-vMin); */ uMinFadeNb = uMinFade / du; uMaxFadeNb = uMaxFade / du; vMinFadeNb = vMinFade / dv; vMaxFadeNb = vMaxFade / dv; // Application.debug("vMin, vMax, dv="+vMin+", "+vMax+", "+dv); for (int ui = 0; ui < uNb; ui++) { for (int vi = 0; vi < vNb; vi++) { drawQuad(ui, vi); } } manager.endGeometry(); }
@Override public void initPersonalInfo(Manager manager) throws DataBaseException, QueryResultIsNullException { Statement stmt = DB.CreateStatement(); String sql = "select *from DormManage where DMId=" + manager.getId(); // System.out.println(sql); try { ResultSet rs = null; rs = stmt.executeQuery(sql); if (!rs.next()) { throw new QueryResultIsNullException(); } // rs.next(); manager.setName(rs.getString("DMName")); manager.setSex(rs.getString("DMsex")); manager.setDormId(rs.getString("DormId")); manager.setPhone(rs.getString("DMPhone")); } catch (SQLException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); throw new DataBaseException(); } }
public static BigDecimal[] salaryCalculationProportionally( Employee[] section, BigDecimal fondSalary) { BigDecimal fondVariable = fondSalary; BigDecimal[] salaries = new BigDecimal[section.length]; BigDecimal sumOfSalary = new BigDecimal("0.00"); // переменная для поверки достаточности фонда для начисления зп boolean[] birthDayBonus = birthDayBonus(section); for (int i = 0; i < salaries.length; i++) { BigDecimal employeeSalary = section[i].getSalary(); salaries[i] = employeeSalary; sumOfSalary = sumOfSalary.add(employeeSalary); fondVariable = fondVariable.subtract(employeeSalary); if (section[i] instanceof Manager) { Manager manager = (Manager) section[i]; BigDecimal managerBonus = (BigDecimal.valueOf(manager.getSubordinateEmployees().size())) .multiply(new BigDecimal("20.00")); salaries[i].add(managerBonus); sumOfSalary = sumOfSalary.add(managerBonus); fondVariable = fondVariable.subtract(managerBonus); } // начисление бонусов за день рожденья if (birthDayBonus[i] == true) { salaries[i] = salaries[i].add(new BigDecimal(200.00)); fondVariable = fondVariable.subtract(new BigDecimal(200.00)); sumOfSalary = sumOfSalary.add(new BigDecimal(200.00)); fondVariable = fondVariable.subtract(new BigDecimal(200.00)); } } // проверка достаточности фонда для начисления зп if (sumOfSalary.doubleValue() > fondSalary.doubleValue()) { System.out.println("Salary fund is insufficient! Please, change the amount of salary fund!"); System.out.println("The amount should be at least " + sumOfSalary); } else { // вычиление коэффициента для начисления премии пропорционально BigDecimal[] factor = new BigDecimal[section.length]; for (int i = 0; i < section.length; i++) { factor[i] = section[i].getSalary().divide(sumOfSalary, 2, BigDecimal.ROUND_HALF_EVEN); } for (int i = 0; i < section.length; i++) { salaries[i] = salaries[i] .add(factor[i].multiply(fondVariable)) .setScale(2, BigDecimal.ROUND_HALF_EVEN); // System.out.println(section[i].getName() + " " + salaries[i].toString()); } } return salaries; }
public void startTrianglesWireFrameSurfaceBoundary() { manager.startGeometry(Manager.Type.TRIANGLES); manager.setDummyTexture(); manager.color(0f, 0f, 1f, 0.25f); }
public static void main(String[] args) { Manager manager = new Manager(); manager.setParallel(4); for (int i = 0; i < 100; i++) { manager.addJob("JOB" + i); } manager.go(); }
public void startTrianglesWireFrame() { // lines manager.startGeometry(Manager.Type.LINE_LOOP); manager.setDummyTexture(); manager.color(0f, 0f, 0f, 1f); }
@Test public void testToString() { System.out.println(manager.toString()); String expectNullValues = "Person [personID=0, CPR=null, fname=null," + " lname=null, country=null, ZIP=null, city=null, address=null," + " email=null, password=null]Staff [salary=0.0]Manager []"; assertEquals(expectNullValues, manager.toString()); }
@Test public void addWeterynarzCheck() { Weterynarz w = new Weterynarz(); w.setImie(wi1); w.setNazwisko(wn1); manager.addWeterynarz(w); Weterynarz pobrany = manager.findWeterynarzByImie(wi1); assertEquals(pobrany.getImie(), wi1); }
/** * Indicates whether this ThrowableSet includes some exception that might be caught by a handler * argument of the type <code>catcher</code>. * * @param catcher type of the handler parameter to be tested. * @return <code>true</code> if this set contains an exception type that might be caught by <code> * catcher</code>, false if it does not. */ public boolean catchableAs(RefType catcher) { if (INSTRUMENTING) { Manager.v().catchableAsQueries++; } FastHierarchy h = Scene.v().getOrMakeFastHierarchy(); if (exceptionsExcluded.size() > 0) { if (INSTRUMENTING) { Manager.v().catchableAsFromSearch++; } for (Iterator i = exceptionsExcluded.iterator(); i.hasNext(); ) { AnySubType exclusion = (AnySubType) i.next(); if (h.canStoreType(catcher, exclusion.getBase())) { return false; } } } if (exceptionsIncluded.contains(catcher)) { if (INSTRUMENTING) { if (exceptionsExcluded.size() == 0) { Manager.v().catchableAsFromMap++; } else { Manager.v().catchableAsFromSearch++; } } return true; } else { if (INSTRUMENTING) { if (exceptionsExcluded.size() == 0) { Manager.v().catchableAsFromSearch++; } } for (Iterator i = exceptionsIncluded.iterator(); i.hasNext(); ) { RefLikeType thrownType = (RefLikeType) i.next(); if (thrownType instanceof RefType) { if (thrownType == catcher) { // assertion failure. throw new IllegalStateException( "ThrowableSet.catchableAs(RefType): exceptions.contains() failed to match contained RefType " + catcher); } else if (h.canStoreType(thrownType, catcher)) { return true; } } else { RefType thrownBase = ((AnySubType) thrownType).getBase(); // At runtime, thrownType might be instantiated by any // of thrownBase's subtypes, so: if (h.canStoreType(thrownBase, catcher) || h.canStoreType(catcher, thrownBase)) { return true; } } } return false; } }
/** * {@link PostConstruct} test. * * @throws ManagerException */ @Test public void postConstructTest() throws ManagerException { // saving initial state final int currentValue = SampleServiceImpl.getPostConstructedAcount(); Manager.register(SampleService.class, SampleServiceFactory.class); Manager.warmUp(); Assert.assertEquals(currentValue + 2, SampleServiceImpl.getPostConstructedAcount()); }
/** * {@link PreDestroy} test. * * @throws ManagerException */ @Test public void preDestroyTest() throws ManagerException { // saving initial state final int currentValue = SampleServiceImpl.getPreDestroyedAcount(); Manager.register(SampleService.class, SampleServiceFactory.class); Manager.get(SampleService.class); // force initialization Manager.tearDown(); Assert.assertEquals(currentValue + 2, SampleServiceImpl.getPreDestroyedAcount()); }
public void start() { try { Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT)); Display.create(); Display.setFullscreen(true); } catch (LWJGLException e) { e.printStackTrace(); System.exit(0); } GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_ALPHA); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glClearAccum(0f, 0f, 0f, 1f); GL11.glClear(GL11.GL_ACCUM_BUFFER_BIT); while (!Display.isCloseRequested() && !finished) { if (System.currentTimeMillis() - time > 1000) { System.out.println(framecount + " FPS"); time = System.currentTimeMillis(); framecount = 0; } GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); GL11.glColor3f(1, 1, 1); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glOrtho(0, WIDTH, HEIGHT, 0, -10, 10); Manager.DrawBackground(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glOrtho(0, WIDTH, HEIGHT, 0, -10, 10); GL11.glTranslatef(-Camera.x, -Camera.y, 0); Display.sync(60); Manager.Draw(); Manager.Update(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glOrtho(0, WIDTH, HEIGHT, 0, -10, 10); Manager.DrawForeground(); Display.update(); framecount++; } }
public static void main(String[] args) { Identification auth = new Identification(); auth.setVisible(true); // On attend d'etre loggué pour continuer l'initialisation du programme while (!auth.isLogged()) ; Simulateur simu = new Simulateur(); Manager mana = new Manager(simu); simu.setManager(mana); mana.session(); }
public static void main(String[] args) { Employee e = new Manager("Jimmy", 1000, 2010, 3, 31); System.out.println(e.getName() + "," + e.getSalary() + "," + e.getHireDate()); e.raiseSalary(0.1); System.out.println(e.getName() + "," + e.getSalary() + "," + e.getHireDate()); Manager m = (Manager) e; m.setBonus(5000); System.out.println(e.getName() + "," + e.getSalary() + "," + e.getHireDate()); }
private void cooking() throws InterruptedException { Manager manager = Manager.getInstance(); Order order = manager.getOrderQueue().poll(); // повар берет заказ из очереди System.out.println( String.format( "Заказ будет готовиться %d мс для стола №%d", order.getTime(), order.getTableNumber())); Thread.sleep(order.getTime()); // готовим блюдо Dishes dishes = new Dishes(order.getTableNumber()); // это готовое блюдо manager.getDishesQueue().add(dishes); System.out.println(String.format("Заказ для стола №%d готов", dishes.getTableNumber())); }
public void drawTriangle(Coords p1, Coords p2, Coords p3) { manager.startGeometry(Manager.Type.TRIANGLE_STRIP); float uT = getTextureCoord(1, uNb, uMinFadeNb, uMaxFadeNb); float vT = getTextureCoord(1, vNb, vMinFadeNb, vMaxFadeNb); manager.texture(uT, vT); manager.vertex(p1); manager.vertex(p3); manager.vertex(p2); manager.endGeometry(); }
@Test public void addZwierzeCheck() { Zwierze zwierze = new Zwierze(); zwierze.setImie(imie1); zwierze.setGatunek(gatunek1); // test dodawanie i pobranie po imieniu manager.addZwierze(zwierze); Zwierze pobzwierze = manager.findZwierzeByImie(imie1); assertEquals(imie1, pobzwierze.getImie()); assertEquals(gatunek1, pobzwierze.getGatunek()); }
public void drawQuadNoTexture(Coords p1, Coords p2, Coords p3, Coords p4) { manager.startGeometry(Manager.Type.TRIANGLE_STRIP); manager.setDummyTexture(); manager.vertex(p1); manager.vertex(p2); manager.vertex(p4); manager.vertex(p3); manager.endGeometry(); }
public void reload() { myConfig.config = YamlConfiguration.loadConfiguration(new File(FilePath.config)); Msg.file = YamlConfiguration.loadConfiguration(new File(FilePath.messages)); ClazzLoader.classes = YamlConfiguration.loadConfiguration(new File(FilePath.classes)); Manager.cancelTask(backupTask); if (myConfig.getBackupTime() > 0) backupTask = Manager.scheduleRepeatingTask( DataFolder.backupTask(), 20L * 60L * myConfig.getBackupTime(), 20L * 60L * myConfig.getBackupTime()); }
public static void main(String[] args) { Mitarbeiter emp1 = new Entwickler("Uwe", 10000); Mitarbeiter emp2 = new Entwickler("Dirk", 15000); Mitarbeiter manager1 = new Manager("Peter", 25000); manager1.add(emp1); manager1.add(emp2); Mitarbeiter emp3 = new Entwickler("Michael", 20000); Manager generalManager = new Manager("Tim", 50000); generalManager.add(emp3); generalManager.add(manager1); generalManager.print(); }