public void run() { // System.out.println("update: "+desc); pause.setEnabled(!IComponentDescription.STATE_SUSPENDED.equals(desc.getState())); step.setEnabled(IComponentDescription.STATE_SUSPENDED.equals(desc.getState())); // && IComponentDescription.PROCESSINGSTATE_READY.equals(desc.getProcessingState())); run.setEnabled(IComponentDescription.STATE_SUSPENDED.equals(desc.getState())); } });
public void run() { // System.out.println("update: "+desc); pause.setEnabled(!IComponentDescription.STATE_SUSPENDED.equals(desc.getState())); step.setEnabled(IComponentDescription.STATE_SUSPENDED.equals(desc.getState())); // && IComponentDescription.PROCESSINGSTATE_READY.equals(desc.getProcessingState())); run.setEnabled(IComponentDescription.STATE_SUSPENDED.equals(desc.getState())); } });
/** * Get a space of the application. * @param name The name of the space. * @return The space. */ public IExtensionInstance[] getExtensions() { // Hack!!! When init fails , terminateExtensions() can not be called on component thread // as component already terminated. assert !getComponentAdapter().isExternalThread() || IComponentDescription.STATE_TERMINATED.equals(getComponentDescription().getState()); return extensions==null? new IExtensionInstance[0]: (IExtensionInstance[])extensions.values().toArray(new IExtensionInstance[extensions.size()]); }
/** * Check if threa is allowed. * * There is the problem that a component is already terminated and calls come back later. * In that case we allow the listeners to be called on the wrong thread. */ public void checkAllowedThread() { assert !getComponentAdapter().isExternalThread() || IComponentDescription.STATE_TERMINATED.equals(getComponentDescription().getState()); }
/** * Called when a stream was sent to the component. * (Called from message transport). * (Is it ok to call on external thread?). */ public void receiveStream(IConnection con) { if(IComponentDescription.STATE_TERMINATED.equals(desc.getState()) || exception!=null) throw new ComponentTerminatedException(desc.getName()); component.streamArrived(con); }
/** * Called when a stream was sent to the component. * (Called from message transport). * (Is it ok to call on external thread?). */ public void receiveStream(IConnection con) { if(IComponentDescription.STATE_TERMINATED.equals(desc.getState()) || exception!=null) throw new ComponentTerminatedException(desc.getName()); component.streamArrived(con); }
/** * Check if the external thread is accessing. * @return True, if access is ok. */ public boolean isExternalThread() { return initthread!=Thread.currentThread() && !isPlanThread() && !(IComponentDescription.STATE_TERMINATED.equals(getComponentDescription().getState()) && Starter.isRescueThread(getComponentIdentifier())); }
public Icon getSwingOverlay(ISwingTreeNode node) { Icon ret = null; IComponentDescription desc = null; if(node instanceof IActiveComponentTreeNode) { desc = ((IActiveComponentTreeNode)node).getDescription(); // if(IComponentDescription.PROCESSINGSTATE_READY.equals(desc.getProcessingState())) // { // ret = icons.getIcon("overlay_ready"); // } // else if(IComponentDescription.PROCESSINGSTATE_RUNNING.equals(desc.getProcessingState())) // { // ret = icons.getIcon("overlay_running"); // } // else if(IComponentDescription.PROCESSINGSTATE_IDLE.equals(desc.getProcessingState())) // { // // -> susp // } if(IComponentDescription.STATE_SUSPENDED.equals(desc.getState())) { ret = icons.getIcon("component_suspended"); } } return ret; }
/** * Test if current thread is the component thread. * @return True if the current thread is the component thread. */ public boolean isComponentThread() { return Thread.currentThread()==componentthread || IComponentDescription.STATE_TERMINATED.equals(getComponent().getComponentDescription().getState()) && Starter.isRescueThread(getComponent().getComponentIdentifier()); }
/** * Check if the external thread is accessing. * @return True, if called from an external (i.e. non-synchronized) thread. */ public boolean isExternalThread() { boolean ret = Thread.currentThread()!=componentthread && !(IComponentDescription.STATE_TERMINATED.equals(getDescription().getState()) && Starter.isRescueThread(getComponentIdentifier())); if(ret) ret = getComponentInstance().isExternalThread(); return ret; }
/** * Called when a message was sent to the component. * (Called from message transport). * (Is it ok to call on external thread?). */ public void receiveMessage(Map<String, Object> message, MessageType type) { if(IComponentDescription.STATE_TERMINATED.equals(desc.getState()) || exception!=null) throw new ComponentTerminatedException(desc.getName()); // Add optional receival time. // String rd = type.getReceiveDateIdentifier(); // Object recdate = message.get(rd); // if(recdate==null) // message.put(rd, new Long(getClock().getTime())); IMessageAdapter msg = new DefaultMessageAdapter(message, type); component.messageArrived(msg); }
/** * Called when a message was sent to the component. * (Called from message transport). * (Is it ok to call on external thread?). */ public void receiveMessage(Map message, MessageType type) { if(IComponentDescription.STATE_TERMINATED.equals(desc.getState()) || exception!=null) throw new ComponentTerminatedException(desc.getName()); // Add optional receival time. // String rd = type.getReceiveDateIdentifier(); // Object recdate = message.get(rd); // if(recdate==null) // message.put(rd, new Long(getClock().getTime())); IMessageAdapter msg = new DefaultMessageAdapter(message, type); component.messageArrived(msg); }
/** * Set the step mode. */ public IFuture doStep() { Future ret = new Future(); if(IComponentDescription.STATE_TERMINATED.equals(desc.getState()) || exception!=null) ret.setException(new ComponentTerminatedException(desc.getName())); else if(dostep) ret.setException(new RuntimeException("Only one step allowed at a time.")); this.dostep = true; this.stepfuture = ret; wakeup(); return ret; }
/** * Set the step mode. */ public IFuture<Void> doStep() { Future<Void> ret = new Future<Void>(); if(IComponentDescription.STATE_TERMINATED.equals(desc.getState()) || exception!=null) ret.setException(new ComponentTerminatedException(desc.getName())); else if(dostep) ret.setException(new RuntimeException("Only one step allowed at a time.")); this.dostep = true; this.stepfuture = ret; wakeup(); return ret; }
/** * Do a step of a suspended component. */ public IFuture<Void> doStep(String stepinfo) { Future<Void> ret = new Future<Void>(); synchronized(this) { if(!IComponentDescription.STATE_SUSPENDED.equals(getComponent().getComponentDescription().getState())) { ret.setException(new IllegalStateException("Component not suspended: "+getComponent().getComponentIdentifier())); } else if(this.stepinfo!=null || stepfuture!=null) { ret.setException(new RuntimeException("Only one step allowed at a time.")); } else { // this.dostep = true; this.stepfuture = ret; this.stepinfo = stepinfo; } } wakeup(); return ret; }
/** * Set the description. */ public void setDescription(IComponentDescription desc) { getTextField("Name").setText(desc.getName().getName()); getTextField("Type").setText(desc.getType()); getTextField("Model name").setText(desc.getModelName()); getTextField("Creator").setText(desc.getCreator()!=null? desc.getCreator().getName(): "n/a"); getTextField("Ownership").setText(desc.getOwnership()); getTextField("State").setText(desc.getState()); String gid = desc.getResourceIdentifier().getGlobalIdentifier()!=null? desc.getResourceIdentifier().getGlobalIdentifier().getResourceId(): "n/a"; ILocalResourceIdentifier lid = desc.getResourceIdentifier().getLocalIdentifier(); getTextField("Resource Identifier").setText(gid==null? "n/a": gid); getTextField("(global / local)").setText(lid==null? "n/a": lid.toString()); // getTextField("Processing state").setText(desc.getProcessingState()); getCheckBox("Master").setSelected(desc.getMaster()==null? false: desc.getMaster().booleanValue()); getCheckBox("Daemon").setSelected(desc.getDaemon()==null? false: desc.getDaemon().booleanValue()); getCheckBox("Auto shutdown").setSelected(desc.getAutoShutdown()==null? false: desc.getAutoShutdown().booleanValue()); JTable list = (JTable)getComponent("Addresses"); String[] addresses = desc.getName().getAddresses(); DefaultTableModel dtm = new DefaultTableModel(); dtm.addColumn("Addresses", addresses!=null?addresses:SUtil.EMPTY_STRING_ARRAY); list.setModel(dtm); } }
/** * Terminate all extensions. */ public IFuture<Void> terminateExtensions() { // Hack!!! When init fails , terminateExtensions() can not be called on component thread // as component already terminated. assert !getComponentAdapter().isExternalThread() || IComponentDescription.STATE_TERMINATED.equals(getComponentDescription().getState()); Future<Void> ret = new Future<Void>(); IExtensionInstance[] exts = getExtensions(); CounterResultListener<Void> lis = new CounterResultListener<Void>(exts.length, false, new DelegationResultListener<Void>(ret)); for(int i=0; i<exts.length; i++) { exts[i].terminate().addResultListener(lis); } return ret; }
if(IComponentDescription.STATE_TERMINATED.equals(getComponent().getComponentDescription().getState()))