int isLocked(EclipseAppDescriptor eclipseApp) { synchronized (lock) { if (activeGlobalSingleton != null) return LOCKED_SINGLETON_GLOBAL_RUNNING; switch (eclipseApp.getCardinalityType()) { case EclipseAppDescriptor.FLAG_CARD_SINGLETON_GLOGAL : if (activeHandles.size() > 0) return LOCKED_SINGLETON_GLOBAL_APPS_RUNNING; break; case EclipseAppDescriptor.FLAG_CARD_SINGLETON_SCOPED : if (activeScopedSingleton != null) return LOCKED_SINGLETON_SCOPED_RUNNING; break; case EclipseAppDescriptor.FLAG_CARD_LIMITED : if (activeLimited != null) { ArrayList limited = (ArrayList) activeLimited.get(eclipseApp.getApplicationId()); if (limited != null && limited.size() >= eclipseApp.getCardinality()) return LOCKED_SINGLETON_LIMITED_RUNNING; } break; case EclipseAppDescriptor.FLAG_CARD_UNLIMITED : break; default : break; } if (eclipseApp.getThreadType() == EclipseAppDescriptor.FLAG_TYPE_MAIN_THREAD && activeMain != null) return LOCKED_MAIN_THREAD_RUNNING; return NOT_LOCKED; } }
Hashtable getServiceProperties() { Hashtable props = new Hashtable(10); props.put(ApplicationDescriptor.APPLICATION_PID, getApplicationId()); if (name != null) props.put(ApplicationDescriptor.APPLICATION_NAME, name); props.put(ApplicationDescriptor.APPLICATION_CONTAINER, Activator.PI_APP); props.put(ApplicationDescriptor.APPLICATION_LOCATION, getLocation()); Boolean launchable = appContainer.isLocked(this) == 0 ? Boolean.TRUE : Boolean.FALSE; props.put(ApplicationDescriptor.APPLICATION_LAUNCHABLE, launchable); props.put(ApplicationDescriptor.APPLICATION_LOCKED, getLocked()); Boolean visible = (flags & FLAG_VISIBLE) != 0 ? Boolean.TRUE : Boolean.FALSE; props.put(ApplicationDescriptor.APPLICATION_VISIBLE, visible); props.put(APP_TYPE, getThreadTypeString()); if ((flags & FLAG_DEFAULT_APP) != 0) props.put(APP_DEFAULT, Boolean.TRUE); if (iconURL != null) props.put(ApplicationDescriptor.APPLICATION_ICON, iconURL); return props; }
void refreshProperties() { ServiceRegistration reg = getServiceRegistration(); if (reg != null) try { reg.setProperties(getServiceProperties()); } catch (IllegalStateException e) { // this must mean the service was unregistered // just ignore } }
iconPath = configs[0].getAttribute(PT_APP_ICON); appDescriptor = new EclipseAppDescriptor(Activator.getBundle(appExtension.getContributor()), appExtension.getUniqueIdentifier(), appExtension.getLabel(), iconPath, flags, cardinality, this); ServiceRegistration sr = (ServiceRegistration) AccessController.doPrivileged(new RegisterService(new String[] {ApplicationDescriptor.class.getName()}, appDescriptor, appDescriptor.getServiceProperties())); appDescriptor.setServiceRegistration(sr);
@Override public String getBrandingId() { IBranding branding = ((EclipseAppDescriptor) getApplicationDescriptor()).getContainerManager().getBranding(); return branding == null ? null : branding.getId(); }
void unlock(EclipseAppHandle appHandle) { synchronized (lock) { if (activeGlobalSingleton == appHandle) activeGlobalSingleton = null; else if (activeScopedSingleton == appHandle) activeScopedSingleton = null; else if (((EclipseAppDescriptor) appHandle.getApplicationDescriptor()).getCardinalityType() == EclipseAppDescriptor.FLAG_CARD_LIMITED) { if (activeLimited != null) { ArrayList limited = (ArrayList) activeLimited.get(((EclipseAppDescriptor) appHandle.getApplicationDescriptor()).getApplicationId()); if (limited != null) limited.remove(appHandle); } } if (activeMain == appHandle) activeMain = null; if (activeHandles.remove(appHandle)) refreshAppDescriptors(); // only refresh descriptors if we really unlocked something } }
protected ApplicationHandle launchSpecific(Map arguments) throws Exception { // if this application is locked throw an exception. if (getLocked().booleanValue()) throw new IllegalStateException("Cannot launch a locked application."); //$NON-NLS-1$ // initialize the appHandle EclipseAppHandle appHandle = createAppHandle(arguments); try { // use the appContainer to launch the application on the main thread. appContainer.launch(appHandle); } catch (Throwable t) { // be sure to destroy the appHandle if an error occurs try { appHandle.destroy(); } catch (Throwable destroyError) { // ignore and clean up } if (t instanceof Exception) throw (Exception) t; throw (Error) t; } return appHandle; }
private EclipseAppHandle createAppHandle(Map arguments) throws ApplicationException { EclipseAppHandle newAppHandle = new EclipseAppHandle(getInstanceID(), arguments, this); appContainer.lock(newAppHandle); ServiceRegistration appHandleReg = (ServiceRegistration) AccessController.doPrivileged(appContainer.getRegServiceAction(new String[] {ApplicationHandle.class.getName(), IApplicationContext.class.getName()}, newAppHandle, newAppHandle.getServiceProperties())); newAppHandle.setServiceRegistration(appHandleReg); return newAppHandle; }
private synchronized String getInstanceID() { // make sure the instanceID has not reached the max if (instanceID == Long.MAX_VALUE) instanceID = 0; // create a unique instance id return getApplicationId() + "." + instanceID++; //$NON-NLS-1$ } }
@Override protected Map getPropertiesSpecific(String locale) { // just use the service properties; for now we do not localize any properties return getServiceProperties(); }
iconPath = configs[0].getAttribute(PT_APP_ICON); appDescriptor = new EclipseAppDescriptor(Activator.getBundle(appExtension.getContributor()), appExtension.getUniqueIdentifier(), appExtension.getLabel(), iconPath, flags, cardinality, this); ServiceRegistration sr = (ServiceRegistration) AccessController.doPrivileged(new RegisterService(new String[] {ApplicationDescriptor.class.getName()}, appDescriptor, appDescriptor.getServiceProperties())); appDescriptor.setServiceRegistration(sr);
@Override public String getBrandingProperty(String key) { IBranding branding = ((EclipseAppDescriptor) getApplicationDescriptor()).getContainerManager().getBranding(); return branding == null ? null : branding.getProperty(key); }
void unlock(EclipseAppHandle appHandle) { synchronized (lock) { if (activeGlobalSingleton == appHandle) activeGlobalSingleton = null; else if (activeScopedSingleton == appHandle) activeScopedSingleton = null; else if (((EclipseAppDescriptor) appHandle.getApplicationDescriptor()).getCardinalityType() == EclipseAppDescriptor.FLAG_CARD_LIMITED) { if (activeLimited != null) { ArrayList limited = (ArrayList) activeLimited.get(((EclipseAppDescriptor) appHandle.getApplicationDescriptor()).getApplicationId()); if (limited != null) limited.remove(appHandle); } } if (activeMain == appHandle) activeMain = null; if (activeHandles.remove(appHandle)) refreshAppDescriptors(); // only refresh descriptors if we really unlocked something } }
@Override protected ApplicationHandle launchSpecific(Map arguments) throws Exception { // if this application is locked throw an exception. if (getLocked().booleanValue()) throw new IllegalStateException("Cannot launch a locked application."); //$NON-NLS-1$ // initialize the appHandle EclipseAppHandle appHandle = createAppHandle(arguments); try { // use the appContainer to launch the application on the main thread. appContainer.launch(appHandle); } catch (Throwable t) { // be sure to destroy the appHandle if an error occurs try { appHandle.destroy(); } catch (Throwable destroyError) { // ignore and clean up } if (t instanceof Exception) throw (Exception) t; throw (Error) t; } return appHandle; }
private EclipseAppHandle createAppHandle(Map arguments) throws ApplicationException { EclipseAppHandle newAppHandle = new EclipseAppHandle(getInstanceID(), arguments, this); appContainer.lock(newAppHandle); ServiceRegistration appHandleReg = (ServiceRegistration) AccessController.doPrivileged(appContainer.getRegServiceAction(new String[] {ApplicationHandle.class.getName(), IApplicationContext.class.getName()}, newAppHandle, newAppHandle.getServiceProperties())); newAppHandle.setServiceRegistration(appHandleReg); return newAppHandle; }
private synchronized String getInstanceID() { // make sure the instanceID has not reached the max if (instanceID == Long.MAX_VALUE) instanceID = 0; // create a unique instance id return getApplicationId() + "." + instanceID++; //$NON-NLS-1$ } }
protected Map getPropertiesSpecific(String locale) { // just use the service properties; for now we do not localize any properties return getServiceProperties(); }
int isLocked(EclipseAppDescriptor eclipseApp) { synchronized (lock) { if (activeGlobalSingleton != null) return LOCKED_SINGLETON_GLOBAL_RUNNING; switch (eclipseApp.getCardinalityType()) { case EclipseAppDescriptor.FLAG_CARD_SINGLETON_GLOGAL : if (activeHandles.size() > 0) return LOCKED_SINGLETON_GLOBAL_APPS_RUNNING; break; case EclipseAppDescriptor.FLAG_CARD_SINGLETON_SCOPED : if (activeScopedSingleton != null) return LOCKED_SINGLETON_SCOPED_RUNNING; break; case EclipseAppDescriptor.FLAG_CARD_LIMITED : if (activeLimited != null) { ArrayList limited = (ArrayList) activeLimited.get(eclipseApp.getApplicationId()); if (limited != null && limited.size() >= eclipseApp.getCardinality()) return LOCKED_SINGLETON_LIMITED_RUNNING; } break; case EclipseAppDescriptor.FLAG_CARD_UNLIMITED : break; default : break; } if (eclipseApp.getThreadType() == EclipseAppDescriptor.FLAG_TYPE_MAIN_THREAD && activeMain != null) return LOCKED_MAIN_THREAD_RUNNING; return NOT_LOCKED; } }
Hashtable getServiceProperties() { Hashtable props = new Hashtable(10); props.put(ApplicationDescriptor.APPLICATION_PID, getApplicationId()); if (name != null) props.put(ApplicationDescriptor.APPLICATION_NAME, name); props.put(ApplicationDescriptor.APPLICATION_CONTAINER, Activator.PI_APP); props.put(ApplicationDescriptor.APPLICATION_LOCATION, getLocation()); Boolean launchable = appContainer.isLocked(this) == 0 ? Boolean.TRUE : Boolean.FALSE; props.put(ApplicationDescriptor.APPLICATION_LAUNCHABLE, launchable); props.put(ApplicationDescriptor.APPLICATION_LOCKED, getLocked()); Boolean visible = (flags & FLAG_VISIBLE) != 0 ? Boolean.TRUE : Boolean.FALSE; props.put(ApplicationDescriptor.APPLICATION_VISIBLE, visible); props.put(APP_TYPE, getThreadTypeString()); if ((flags & FLAG_DEFAULT_APP) != 0) props.put(APP_DEFAULT, Boolean.TRUE); if (iconURL != null) props.put(ApplicationDescriptor.APPLICATION_ICON, iconURL); return props; }
iconPath = configs[0].getAttribute(PT_APP_ICON); appDescriptor = new EclipseAppDescriptor(Activator.getBundle(appExtension.getContributor()), appExtension.getUniqueIdentifier(), appExtension.getLabel(), iconPath, flags, cardinality, this); ServiceRegistration sr = (ServiceRegistration) AccessController.doPrivileged(new RegisterService(new String[] {ApplicationDescriptor.class.getName()}, appDescriptor, appDescriptor.getServiceProperties())); appDescriptor.setServiceRegistration(sr);