⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basemonitor.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
			return null;		return ts.serviceLocale;	}	public Locale getLocaleFromString(String localeDescription)											throws StandardException {		return staticGetLocaleFromString(localeDescription);	}	/**		Return the name of the service that the passed in module lives in.	*/	public String getServiceName(Object serviceModule) {		TopService ts = findTopService(serviceModule);		if (ts == null)			return null;		return ts.getServiceType().getUserServiceName(ts.getKey().getIdentifier());	}	/**		Set the locale for the service *outside* of boot time.		@exception StandardException Standard Cloudscape error.	*/	public Locale setLocale(Object serviceModule, String userDefinedLocale)		throws StandardException {		TopService ts = findTopService(serviceModule);		if (ts == null)			return null;		PersistentService provider = ts.getServiceType();		if (provider == null)			return null;		String serviceName = ts.getKey().getIdentifier();		Properties properties = provider.getServiceProperties(serviceName, (Properties) null);		properties = new UpdateServiceProperties(provider, serviceName, properties, true);		return setLocale(properties, userDefinedLocale);	}	/**		Set the locale for the service at boot time. The passed in		properties must be the one passed to the boot method.		@exception StandardException Standard Cloudscape error.	*/	public Locale setLocale(Properties serviceProperties, String userDefinedLocale)		throws StandardException {		Locale locale = staticGetLocaleFromString(userDefinedLocale);		// this will write the property through to the service.properties file.		serviceProperties.put(Property.SERVICE_LOCALE, locale.toString());		return locale;	}	/**		Return the PersistentService object for a service.		Will return null if the service does not exist.	*/	public PersistentService getServiceType(Object serviceModule) {		TopService ts = findTopService(serviceModule);		if (ts == null)			return null;		return ts.getServiceType();	}	/**		Start a module.		@exception StandardException se An attempt to start the module failed.		@see ModuleFactory#startModule	*/	public Object startModule(boolean create, Object serviceModule, String factoryInterface,		String identifier, Properties properties) throws StandardException {		ProtocolKey key = ProtocolKey.create(factoryInterface, identifier);		TopService ts = findTopService(serviceModule);		Object instance = ts.bootModule(create, serviceModule, key, properties);		if (instance == null)			throw Monitor.missingImplementation(factoryInterface);		return instance;	}	private synchronized TopService findTopService(Object serviceModule) {		if (serviceModule == null)			return (TopService) services.elementAt(0);		for (int i = 1; i < services.size(); i++) {			TopService ts = (TopService) services.elementAt(i);			if (ts.inService(serviceModule))				return ts;		}		return null;	}	public Object findModule(Object serviceModule, String factoryInterface, String identifier)	{		ProtocolKey key;		try {			key = ProtocolKey.create(factoryInterface, identifier);		} catch (StandardException se) {			return null;		}		TopService ts = findTopService(serviceModule);		if (ts == null)			return null;		return ts.findModule(key, true, null);	}	/**		Obtain a class that supports the given identifier.		@param identifier	identifer to associate with class		@param length		number of bytes to use from identifier		@return a reference InstanceGetter		@exception StandardException See Monitor.classFromIdentifier		@see ModuleFactory#classFromIdentifier	*/	public InstanceGetter classFromIdentifier(int fmtId)		throws StandardException {		String className;		int off;		InstanceGetter[] iga;		InstanceGetter ig;		try {			off = fmtId - StoredFormatIds.MIN_TWO_BYTE_FORMAT_ID;			iga = rc2;			if (iga == null) {				iga = rc2 = new InstanceGetter[RegisteredFormatIds.TwoByte.length];			}			ig = iga[off];			if (ig != null) {				return ig;			}			className = RegisteredFormatIds.TwoByte[off];		} catch (ArrayIndexOutOfBoundsException aioobe) {			className = null;			iga = null;			off = 0;		}		if (className != null) {			Throwable t;			try {				Class clazz = Class.forName(className);				// See if it is a FormatableInstanceGetter				if (FormatableInstanceGetter.class.isAssignableFrom(clazz)) {					FormatableInstanceGetter tfig = (FormatableInstanceGetter) clazz.newInstance();					tfig.setFormatId(fmtId);					return iga[off] = tfig;				}				return iga[off] = new ClassInfo(clazz);			} catch (ClassNotFoundException cnfe) {				t = cnfe;			} catch (IllegalAccessException iae) {				t = iae;			} catch (InstantiationException ie) {				t = ie;			} catch (LinkageError le) {				t = le;			}			throw StandardException.newException(SQLState.REGISTERED_CLASS_LINAKGE_ERROR,				t, FormatIdUtil.formatIdToString(fmtId), className);		}		throw StandardException.newException(SQLState.REGISTERED_CLASS_NONE, FormatIdUtil.formatIdToString(fmtId));	}	/**		Obtain an new instance of a class that supports the given identifier.		@return a reference to a newly created object or null if a matching class			    cannot be found.	*/	public Object newInstanceFromIdentifier(int identifier)		throws StandardException {		InstanceGetter ci = classFromIdentifier(identifier);		Throwable t;		try {			Object result = ci.getNewInstance();/*				if (SanityManager.DEBUG) {					if(SanityManager.DEBUG_ON(Monitor.NEW_INSTANCE_FROM_ID_TRACE_DEBUG_FLAG))					{						String traceResult = "null";						if (result != null) traceResult = "not null";						SanityManager.DEBUG(Monitor.NEW_INSTANCE_FROM_ID_TRACE_DEBUG_FLAG,											"newInstanceFromIdentifier("+identifier+") "+											" ClassName: "+											result.getClass().getName() +											" returned "+											traceResult);					}				}*/			return result;		}		catch (InstantiationException ie) {			t = ie;		} 		catch (IllegalAccessException iae) {			t = iae;		}		catch (InvocationTargetException ite) {			t = ite;		}		catch (LinkageError le) {			t = le;		}		throw StandardException.newException(SQLState.REGISTERED_CLASS_INSTANCE_ERROR,			t, new Integer(identifier), "XX" /*ci.getClassName()*/);	}	private Boolean exceptionTrace;	/**		load a module instance.		Look through the implementations for a module that implements the		required factory interface and can handle the properties given.		The module's start or create method is not called.	*/	protected Object loadInstance(Class factoryInterface, Properties properties) {		Object instance = null;		Vector localImplementations = getImplementations(properties, false);		if (localImplementations != null) {			instance = loadInstance(localImplementations, factoryInterface, properties);		}		for (int i = 0; i < implementationSets.length; i++) {			instance = loadInstance(implementationSets[i], factoryInterface, properties);			if (instance != null)				break;		}		return instance;	}	private Object loadInstance(Vector implementations, Class factoryInterface, Properties properties) {		for (int index = 0; true; index++) {			// find an implementation			index = findImplementation(implementations, index, factoryInterface);			if (index < 0)				return null;			// try to create an instance			Object instance = newInstance((Class) implementations.elementAt(index));			if (BaseMonitor.canSupport(instance, properties))				return instance;		}	}	/**		Find a class that implements the required index, return the index		into the implementations vecotr of that class. Returns -1 if no class		could be found.	*/	private static int findImplementation(Vector implementations, int startIndex, Class factoryInterface) {		for (int i = startIndex; i < implementations.size(); i++) {			//try {				Class factoryClass = (Class) implementations.elementAt(i);				if (!factoryInterface.isAssignableFrom(factoryClass)) {					continue;				}				return i;			//}			//catch (ClassNotFoundException e) {			//	report("Class not found " + (String) implementations.elementAt(i));			//	continue;			//}		}		return -1;	}	/**	*/	private Object newInstance(String className) {		try {			Class factoryClass = Class.forName(className);			return factoryClass.newInstance();		}		catch (ClassNotFoundException e) {			report(className + " " + e.toString());		}		catch (InstantiationException e) {			report(className + " " + e.toString());		} 		catch (IllegalAccessException e) {			report(className + " " + e.toString());		}		catch (LinkageError le) {			report(className + " " + le.toString());			reportException(le);		}		return null;	}	/**	*/	private Object newInstance(Class classObject) {		try {			return classObject.newInstance();		}		catch (InstantiationException e) {			report(classObject.getName() + " " + e.toString());		} 		catch (IllegalAccessException e) {			report(classObject.getName() + " " + e.toString());		}		catch (LinkageError le) {			report(classObject.getName() + " " + le.toString());			reportException(le);		}		return null;	}	public Properties getApplicationProperties() {		return applicationProperties;	}	/**		Return an array of the service identifiers that are running and		implement the passed in protocol (java interface class name).		@return The list of service names, if no services exist that		implement the protocol an array with zero elements is returned.		@see ModuleFactory#getServiceList	*/	public String[] getServiceList(String protocol) {		TopService ts;		synchronized (this) {			int count = 0;			// count the number of services that implement the required protocol			for (int i = 1; i < services.size(); i++) {				ts = (TopService) services.elementAt(i);				if (ts.isActiveService()) {					if (ts.getKey().getFactoryInterface().getName().equals(protocol))						count++;				}			}			// and then fill in the newly allocated string array			String[] list = new String[count];			if (count != 0) {				int j = 0;				for (int i = 1; i < services.size(); i++) {					ts = (TopService) services.elementAt(i);					if (ts.isActiveService()) {						if (ts.getKey().getFactoryInterface().getName().equals(protocol)) {							list[j++] = ts.getServiceType().getUserServiceName(ts.getKey().getIdentifier());							if (j == count)								break;						}					}				}			}			return list;		}	}	/*	** non-public methods.	*/	void dumpProperties(String title, Properties props) {		if (SanityManager.DEBUG) {			// this method is only called if reportOn is true, so no need to check it here			report(title);			if (props != null) {				for (Enumeration e = props.propertyNames(); e.hasMoreElements(); ) {					String key = (String) e.nextElement();					// Get property as object in case of non-string properties					report(key + "=" + props.getProperty(key));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -