private void componentMenu() throws Exception { String state = "stopped"; String toggle = "start"; String temp; IComponent comp = manager.findByName(input); if (comp.getState() == ComponentState.Running) { state = "running"; toggle = "stop"; } System.out.println("Component name: " + comp.getName()); System.out.println("Component description: " + comp.getDescription()); System.out.println("Component state: " + state); System.out.println("\nEnter 1 or '" + toggle + "'to " + toggle + "the component"); System.out.println("Enter 2 or 'remove' to remove the component from the RTE"); System.out.println("Enter 0 or 'back' to return to the main Menu."); temp = input; input = in.readLine(); if (input.equals("0") || input.equals("back")) { name = MenuName.MAIN; } else if (input.equals("1") || input.equals(toggle)) { if (comp.getState() == ComponentState.Running) comp.stop(); else comp.start(new ComponentContext(manager)); input = temp; } else if (input.equals("2") || input.equals("remove")) { manager.remove(comp); System.out.println("Component " + comp.getName() + " has been removed from the RTE."); name = MenuName.MAIN; } else { System.out.println("Invalid input!"); } }
public <T extends Component> T create(Class<T> componentKlazz) { ComponentManager componentManager = world.getComponentManager(); T component = componentManager.create(entity, componentKlazz); ComponentTypeFactory tf = world.getComponentManager().typeFactory; ComponentType componentType = tf.getTypeFor(componentKlazz); componentBits.set(componentType.getIndex()); return component; }
private ComponentManager copyComponentManager(String id) throws UndefinedComponentManagerException { ComponentManager componentManager = null; for (Iterator iterator = componentManagers.iterator(); iterator.hasNext(); ) { componentManager = (ComponentManager) iterator.next(); if (id.equals(componentManager.getId())) { return componentManager.copy(); } } throw new UndefinedComponentManagerException( "Specified component manager cannot be found: " + id); }
@Override public void onDisable() { if (componentManager != null) { int componentCount = componentManager.components.size(); for (Component component : componentManager.components) { component.dispose(); } componentManager.clear(); Log.info("Unloaded " + componentCount + " components."); } if (mapManager != null) { mapManager.stopRendering(); mapManager = null; } if (webServer != null) { webServer.shutdown(); webServer = null; } /* Clean up all registered handlers */ for (Event.Type t : event_handlers.keySet()) { List<Listener> ll = event_handlers.get(t); ll .clear(); /* Empty list - we use presence of list to remember that we've registered with Bukkit */ } playerfacemgr = null; /* Don't clean up markerAPI - other plugins may still be accessing it */ Debug.clearDebuggers(); }
/** * Inform subscribers of state changes. * * <p>Performs callbacks on registered instances of {@link * com.artemis.EntitySubscription.SubscriptionListener}. * * <p>Will run repeatedly until any state changes caused by subscribers have been handled. */ void updateEntityStates() { // changed can be populated by EntityTransmuters and Archetypes, // bypassing the editPool. while (!changed.isEmpty() || editPool.processEntities()) am.process(changed, deleted); cm.clean(); }
/** * create a component manager based on a list of component.xml * * @param configPaths a ';' seperated list of xml bean config files * @throws IOException */ public TestComponentManagerContainer(String configPaths) throws IOException { // we assume that all the jars are in the same classloader, so this will // not check for // incorrect bindings and will not fully replicate the tomcat // experience, but is an easier environment // to work within for kernel testing. // For a more complex structure we could use the kernel poms in the repo // to generate the dep list. if (ComponentManager.m_componentManager != null) { log.info("Closing existing Component Manager "); /* try { ComponentManager.m_componentManager.close(); } catch ( Throwable t ) { log.warn("Close Failed with message, safe to ignore "+t.getMessage()); } */ log.info("Closing Complete "); ComponentManager.m_componentManager = null; } log.info("Starting Component Manager with [" + configPaths + "]"); ComponentManager.setLateRefresh(true); componentManager = (SpringCompMgr) ComponentManager.getInstance(); ConfigurableApplicationContext ac = componentManager.getApplicationContext(); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); // we could take the kernel bootstrap from from the classpath in future // rather than from // the filesystem List<Resource> config = new ArrayList<Resource>(); String[] configPath = configPaths.split(";"); for (String p : configPath) { File xml = new File(p); config.add(new FileSystemResource(xml.getCanonicalPath())); } loadComponent(ac, config, classLoader); ac.refresh(); log.debug("Finished starting the component manager"); // TODO Auto-generated constructor stub }
public ComponentManager createComponentManager( ComponentDescriptor descriptor, MutablePlexusContainer container) throws UndefinedComponentManagerException, UndefinedLifecycleHandlerException { String componentManagerId = descriptor.getInstantiationStrategy(); ComponentManager componentManager; if (componentManagerId == null) { componentManagerId = defaultComponentManagerId; } componentManager = copyComponentManager(componentManagerId); componentManager.setup(container, findLifecycleHandler(descriptor), descriptor); componentManager.initialize(); activeComponentManagers.put(descriptor.getComponentKey(), componentManager); return componentManager; }
/** * Returns a sequence that creates an object of type compatible the given class. Wraps the object * in a list, and returns the list. * * <p>CURRENTLY, will return a sequence (i.e. a non-empty list) only if cls is an array. */ public static SimpleList<Sequence> createSequence(ComponentManager components, Class<?> cls) { // Class<?> cls = statement.getInputTypes().get(i); if (!cls.isArray()) { return new ArrayListSimpleList<Sequence>(); } Sequence s = null; if (cls.getComponentType().isPrimitive()) { s = randPrimitiveArray(cls.getComponentType()); } else { SimpleList<Sequence> candidates = components.getSequencesForType(cls.getComponentType(), false); if (candidates.isEmpty()) { if (GenInputsAbstract.forbid_null) { // No sequences that produce appropriate component values found, and null forbidden. // Return the empty array. ArrayDeclaration decl = new ArrayDeclaration(cls.getComponentType(), 0); s = new Sequence(); s = s.extend(decl); } else { // No sequences that produce appropriate component values found, and null allowed. // TODO: We should also randomly return the empty array--it's a perfectly good case // even if null is allowed. // Return the array [ null ]. ArrayDeclaration decl = new ArrayDeclaration(cls.getComponentType(), 1); s = new Sequence(); s = s.extend(PrimitiveOrStringOrNullDecl.nullOrZeroDecl(cls.getComponentType())); List<Variable> ins = new ArrayList<Variable>(); ins.add(s.getVariable(0)); s = s.extend(decl, ins); } } else { // Return the array [ x ] where x is the last value in the sequence. ArrayDeclaration decl = new ArrayDeclaration(cls.getComponentType(), 1); s = candidates.get(Randomness.nextRandomInt(candidates.size())); List<Variable> ins = new ArrayList<Variable>(); // XXX IS THIS OLD COMMENT TRUE? : this assumes that last statement will have such a var, // which I know is currently true because of SequenceCollection implementation. ins.add( s.randomVariableForTypeLastStatement(cls.getComponentType(), Match.COMPATIBLE_TYPE)); s = s.extend(decl, ins); } } assert s != null; ArrayListSimpleList<Sequence> l = new ArrayListSimpleList<Sequence>(); l.add(s); return l; }
private void componentsMenu() throws IOException { if (running) { components = manager.getRunningComponents(); System.out.println("Currently running components."); } else { components = manager.getAllComponents(); System.out.println("List of all components."); } for (int i = 0; i < components.size(); i++) { System.out.println("Component " + (i + 1) + ": " + components.get(i).getName()); } System.out.println( "\nFor more information on a component " + "please enter the name or number of it."); System.out.println("Enter 0 or 'back' to return to the main Menu."); input = in.readLine(); if (input.equals("0") || input.equals("back")) { name = MenuName.MAIN; } else if (manager.findByName(input) != null) { name = MenuName.COMPONENT; } else { System.out.println("Invalid input!"); } }
private void addMenu() throws IOException { System.out.println("Please enter the classname of the component you want to add"); System.out.println("Enter 0 or 'back' to return to the main menu."); input = in.readLine(); if (input.equals("0") || input.equals("back")) { name = MenuName.MAIN; } else { try { IComponent comp = repo.createComponent(input); manager.add(comp); System.out.println("Compnent has been added."); name = MenuName.MAIN; } catch (Exception e) { System.out.println("The specified component could not be found."); } } }
@PostConstruct public void init() { if (enabled) { LOG.info(String.format("Starting '%s' refresh task", componentName)); manager.apply(getUpdateTask()); this.refreshFuture = executor.scheduleAtFixedRate( new Runnable() { @Override public void run() { manager.apply(getUpdateTask()); } }, refreshRate, refreshRate, TimeUnit.SECONDS); } else { LOG.info(String.format("'%s' refresh task diabled", componentName)); } }
/** * This is the preferred method to use when retrieving a component from a entity. It will provide * good performance. But the recommended way to retrieve components from an entity is using the * ComponentMapper. * * @param type in order to retrieve the component fast you must provide a ComponentType instance * for the expected component. * @return */ public Component getComponent(ComponentType type) { return componentManager.getComponent(this, type); }
public ByteBuffer GetJarFromMaster(String sTopologyName) throws TException { return m_oComponentManager.GetJarFromMaster(sTopologyName); }
public void AddWorker(String sIP) throws TException { m_oComponentManager.AdmitNewWorker(sIP); }
public void ReceiveJobFromClient(String TopologyName, ByteBuffer Jarfile) throws TException { m_oComponentManager.ReceiveNewJob(Jarfile, TopologyName); }
/** * Create and return an {@link Entity} wrapping a new or reused entity instance. Entity is * automatically added to the world. * * <p>Use {@link Entity#edit()} to set up your newly created entity. * * <p>You can also create entities using: - {@link com.artemis.utils.EntityBuilder} Convenient * entity creation. Not useful when pooling. - {@link com.artemis.Archetype} Fastest, low level, * no parameterized components. - {@link com.artemis.EntityFactory} Fast, clean and convenient. * For fixed composition entities. Requires some setup. Best choice for parameterizing pooled * components. * * @see #create(int) recommended alternative. * @return entity */ public Entity createEntity(Archetype archetype) { Entity e = em.createEntityInstance(archetype); cm.addComponents(e.getId(), archetype); changed.set(e.getId()); return e; }
/** * Create and return an {@link Entity} wrapping a new or reused entity instance. Entity is * automatically added to the world. * * <p>Use {@link Entity#edit()} to set up your newly created entity. * * <p>You can also create entities using: - {@link com.artemis.utils.EntityBuilder} Convenient * entity creation. Not useful when pooling. - {@link com.artemis.Archetype} Fastest, low level, * no parameterized components. - {@link com.artemis.EntityFactory} Fast, clean and convenient. * For fixed composition entities. Requires some setup. Best choice for parameterizing pooled * components. * * @return assigned entity id */ public int create(Archetype archetype) { int entityId = em.create(archetype); cm.addComponents(entityId, archetype); changed.set(entityId); return entityId; }
@Override public void onEnable() { /* Start with clean events */ events = new Events(); permissions = NijikokunPermissions.create(getServer(), "dynmap"); if (permissions == null) permissions = BukkitPermissions.create("dynmap"); if (permissions == null) permissions = new OpPermissions( new String[] { "fullrender", "cancelrender", "radiusrender", "resetstats", "reload", "purgequeue" }); dataDirectory = this.getDataFolder(); if (dataDirectory.exists() == false) dataDirectory.mkdirs(); /* Initialize confguration.txt if needed */ File f = new File(this.getDataFolder(), "configuration.txt"); if (!createDefaultFileFromResource("/configuration.txt", f)) { this.setEnabled(false); return; } /* Load configuration.txt */ org.bukkit.util.config.Configuration bukkitConfiguration = new org.bukkit.util.config.Configuration(f); bukkitConfiguration.load(); configuration = new ConfigurationNode(bukkitConfiguration); /* Load block models */ HDBlockModels.loadModels(dataDirectory, configuration); /* Load texture mappings */ TexturePack.loadTextureMapping(dataDirectory, configuration); /* Now, process worlds.txt - merge it in as an override of existing values (since it is only user supplied values) */ f = new File(this.getDataFolder(), "worlds.txt"); if (!createDefaultFileFromResource("/worlds.txt", f)) { this.setEnabled(false); return; } org.bukkit.util.config.Configuration cfg = new org.bukkit.util.config.Configuration(f); cfg.load(); ConfigurationNode cn = new ConfigurationNode(cfg); mergeConfigurationBranch(cn, "worlds", true, true); /* Now, process templates */ loadTemplates(); Log.verbose = configuration.getBoolean("verbose", true); deftemplatesuffix = configuration.getString("deftemplatesuffix", ""); /* Default swamp shading off for 1.8, on after */ swampshading = configuration.getBoolean("swampshaded", !getServer().getVersion().contains("(MC: 1.8")); /* Default water biome shading off for 1.8, on after */ waterbiomeshading = configuration.getBoolean( "waterbiomeshaded", !getServer().getVersion().contains("(MC: 1.8")); /* Default fence-to-block-join off for 1.8, on after */ fencejoin = configuration.getBoolean( "fence-to-block-join", !getServer().getVersion().contains("(MC: 1.8")); /* Default compassmode to pre19, to newrose after */ String cmode = configuration.getString( "compass-mode", getServer().getVersion().contains("(MC: 1.8") ? "pre19" : "newrose"); if (cmode.equals("newnorth")) compassmode = CompassMode.NEWNORTH; else if (cmode.equals("newrose")) compassmode = CompassMode.NEWROSE; else compassmode = CompassMode.PRE19; loadDebuggers(); tilesDirectory = getFile(configuration.getString("tilespath", "web/tiles")); if (!tilesDirectory.isDirectory() && !tilesDirectory.mkdirs()) { Log.warning("Could not create directory for tiles ('" + tilesDirectory + "')."); } playerList = new PlayerList(getServer(), getFile("hiddenplayers.txt"), configuration); playerList.load(); PlayerListener pl = new PlayerListener() { public void onPlayerJoin(PlayerJoinEvent evt) { playerList.updateOnlinePlayers(null); } public void onPlayerQuit(PlayerQuitEvent evt) { playerList.updateOnlinePlayers(evt.getPlayer()); } }; registerEvent(Type.PLAYER_JOIN, pl); registerEvent(Type.PLAYER_QUIT, pl); mapManager = new MapManager(this, configuration); mapManager.startRendering(); playerfacemgr = new PlayerFaces(this); loadWebserver(); enabledTriggers.clear(); List<String> triggers = configuration.getStrings("render-triggers", new ArrayList<String>()); if (triggers != null) { for (Object trigger : triggers) { enabledTriggers.add((String) trigger); } } // Load components. for (Component component : configuration.<Component>createInstances( "components", new Class<?>[] {DynmapPlugin.class}, new Object[] {this})) { componentManager.add(component); } Log.verboseinfo("Loaded " + componentManager.components.size() + " components."); registerEvents(); if (!configuration.getBoolean("disable-webserver", false)) { startWebserver(); } /* Print version info */ PluginDescriptionFile pdfFile = this.getDescription(); Log.info("version " + pdfFile.getVersion() + " is enabled"); events.<Object>trigger("initialized", null); }
/** * Faster adding of components into the entity. Not neccessery to use this, but in some cases you * might need the extra performance. * * @param component the component to add * @param type of the component * @return this entity for chaining. */ public Entity addComponent(Component component, ComponentType type) { componentManager.addComponent(this, type, component); return this; }
public void removeAttributeFilter(AttributeFilter attributeFilter) { componentManager.removeAttributeFilter(attributeFilter); }
/** * Faster removal of components from a entity. * * @param component to remove from this entity. * @return this entity for chaining. */ public Entity removeComponent(ComponentType type) { componentManager.removeComponent(this, type); return this; }
/** * Retrieves a ComponentMapper instance for fast retrieval of components from entities. * * <p>Odb automatically injects component mappers into systems, calling this method is usually not * required., * * @param <T> class type of the component * @param type type of component to get mapper for * @return mapper for specified component type */ public <T extends Component> ComponentMapper<T> getMapper(Class<T> type) { return cm.getMapper(type); }
/** * Returns a bag of all components this entity has. You need to reset the bag yourself if you * intend to fill it more than once. * * @param fillBag the bag to put the components into. * @return the fillBag with the components in. */ public Bag<Component> getComponents(Bag<Component> fillBag) { return componentManager.getComponentsFor(this, fillBag); }
public void addAttributeFilter(AttributeFilter attributeFilter) { componentManager.addAttributeFilter(attributeFilter); }