public static Driver createDriver(ClassLoader classLoader, String driverClassName) throws SQLException { if (classLoader != null) { try { return (Driver) classLoader.loadClass(driverClassName).newInstance(); } catch (IllegalAccessException e) { throw new SQLException(e.getMessage(), e); } catch (InstantiationException e) { throw new SQLException(e.getMessage(), e); } catch (ClassNotFoundException e) { throw new SQLException(e.getMessage(), e); } } try { return (Driver) Class.forName(driverClassName).newInstance(); } catch (IllegalAccessException e) { throw new SQLException(e.getMessage(), e); } catch (InstantiationException e) { throw new SQLException(e.getMessage(), e); } catch (ClassNotFoundException e) { // skip } try { return (Driver) Thread.currentThread().getContextClassLoader().loadClass(driverClassName).newInstance(); } catch (IllegalAccessException e) { throw new SQLException(e.getMessage(), e); } catch (InstantiationException e) { throw new SQLException(e.getMessage(), e); } catch (ClassNotFoundException e) { throw new SQLException(e.getMessage(), e); } }
/** * Creates a new class instance. Logs errors along the way. Classes are loaded using the ehcache * standard classloader. * * @param className a fully qualified class name * @return null if the instance cannot be loaded */ public static Object createNewInstance(String className) throws CacheException { Class clazz; Object newInstance; try { clazz = Class.forName(className, true, getStandardClassLoader()); } catch (ClassNotFoundException e) { // try fallback try { clazz = Class.forName(className, true, getFallbackClassLoader()); } catch (ClassNotFoundException ex) { throw new CacheException( "Unable to load class " + className + ". Initial cause was " + e.getMessage(), e); } } try { newInstance = clazz.newInstance(); } catch (IllegalAccessException e) { throw new CacheException( "Unable to load class " + className + ". Initial cause was " + e.getMessage(), e); } catch (InstantiationException e) { throw new CacheException( "Unable to load class " + className + ". Initial cause was " + e.getMessage(), e); } return newInstance; }
protected ClientConnectionManager createClientConnectionManager() { final SchemeRegistry registry = SchemeRegistryFactory.createDefault(); ClientConnectionManager connManager = null; final HttpParams params = getParams(); ClientConnectionManagerFactory factory = null; final String className = (String) params.getParameter(ClientPNames.CONNECTION_MANAGER_FACTORY_CLASS_NAME); if (className != null) { try { final Class<?> clazz = Class.forName(className); factory = (ClientConnectionManagerFactory) clazz.newInstance(); } catch (final ClassNotFoundException ex) { throw new IllegalStateException("Invalid class name: " + className); } catch (final IllegalAccessException ex) { throw new IllegalAccessError(ex.getMessage()); } catch (final InstantiationException ex) { throw new InstantiationError(ex.getMessage()); } } if (factory != null) { connManager = factory.newInstance(params, registry); } else { connManager = new BasicClientConnectionManager(registry); } return connManager; }
@Before public void setUp() { try { Class.forName("com.intersys.jdbc.CacheDriver").newInstance(); } catch (InstantiationException ex) { System.out.print(ex.getMessage()); } catch (Exception ex) { System.out.print(ex.getMessage()); } CacheDataSource ds = new CacheDataSource(); try { ds.setURL("jdbc:Cache://192.168.1.172:56773/USER"); } catch (SQLException ex) { System.out.println(ex.getMessage()); } java.sql.Connection dbconn = null; try { dbconn = ds.getConnection("_SYSTEM", "SYS"); } catch (SQLException ex) { Logger.getLogger(DatabaseDAOTests.class.getName()).log(Level.SEVERE, null, ex); } try { db = CacheDatabase.getDatabase(dbconn); } catch (CacheException ex) { System.out.print(ex.getMessage()); } dbDao = new DatabaseDAO(dbconn, db); }
@Override public boolean connect() { try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance(); String url = "jdbc:sqlserver://" + Config.DATABASE_IP + ":" + Config.DATABASE_PORT + ";databaseName=Narda"; conn = DriverManager.getConnection(url, Config.DATABASE_USERNAME, Config.DATABASE_PASSWORD); OrbitStamps.log(OrbitStamps.LOG_NOTICE, "HuddingeDataMapper: connection success!"); return true; } catch (ClassNotFoundException ex) { System.err.println(ex.getMessage()); } catch (IllegalAccessException ex) { System.err.println(ex.getMessage()); } catch (InstantiationException ex) { System.err.println(ex.getMessage()); } catch (SQLException ex) { System.err.println(ex.getMessage()); } OrbitStamps.log(OrbitStamps.LOG_NOTICE, "HuddingeDataMapper: connection failed!"); return false; }
public static synchronized void addAgentSelectorClass(Class newClass) throws IllegalArgumentException { try { AgentSelector newAlgorithm = (AgentSelector) newClass.newInstance(); // Make sure the interceptor isn't already in the list. List<AgentSelector> availableAgentSelectors = getAvailableAgentSelectors(); for (AgentSelector algorithm : availableAgentSelectors) { if (newAlgorithm.getClass().equals(algorithm.getClass())) { return; } } // Add in the new algorithm availableAgentSelectors.add(newAlgorithm); // Write out new class names. JiveGlobals.deleteProperty("agentSelector.classes"); for (int i = 0; i < availableAgentSelectors.size(); i++) { String cName = availableAgentSelectors.get(i).getClass().getName(); JiveGlobals.setProperty("agentSelector.classes." + i, cName); } } catch (IllegalAccessException e) { throw new IllegalArgumentException(e.getMessage()); } catch (InstantiationException e2) { throw new IllegalArgumentException(e2.getMessage()); } catch (ClassCastException e5) { throw new IllegalArgumentException("Class is not a AgentSelector"); } }
@Override public void open(int taskNumber, int numTasks) throws IOException { super.open(taskNumber, numTasks); DatumWriter<E> datumWriter; Schema schema; if (org.apache.avro.specific.SpecificRecordBase.class.isAssignableFrom(avroValueType)) { datumWriter = new SpecificDatumWriter<E>(avroValueType); try { schema = ((org.apache.avro.specific.SpecificRecordBase) avroValueType.newInstance()).getSchema(); } catch (InstantiationException e) { throw new RuntimeException(e.getMessage()); } catch (IllegalAccessException e) { throw new RuntimeException(e.getMessage()); } } else { datumWriter = new ReflectDatumWriter<E>(avroValueType); schema = ReflectData.get().getSchema(avroValueType); } dataFileWriter = new DataFileWriter<E>(datumWriter); if (userDefinedSchema == null) { dataFileWriter.create(schema, stream); } else { dataFileWriter.create(userDefinedSchema, stream); } }
private static String getFilePathByFileDialog(Shell shell, boolean isExport, String fileName) { try { final Class<EMFStoreFileDialogHelper> clazz = loadClass(EMFSTORE_CLIENT_UI_PLUGIN_ID, FILE_DIALOG_HELPER_CLASS); final EMFStoreFileDialogHelper fileDialogHelper = clazz.getConstructor().newInstance(); if (isExport) { return fileDialogHelper.getPathForExport(shell, fileName); } return fileDialogHelper.getPathForImport(shell); } catch (final ClassNotFoundException ex) { WorkspaceUtil.logException(ex.getMessage(), ex); } catch (final InstantiationException ex) { WorkspaceUtil.logException(ex.getMessage(), ex); } catch (final IllegalAccessException ex) { WorkspaceUtil.logException(ex.getMessage(), ex); } catch (final IllegalArgumentException ex) { WorkspaceUtil.logException(ex.getMessage(), ex); } catch (final InvocationTargetException ex) { WorkspaceUtil.logException(ex.getMessage(), ex); } catch (final NoSuchMethodException ex) { WorkspaceUtil.logException(ex.getMessage(), ex); } catch (final SecurityException ex) { WorkspaceUtil.logException(ex.getMessage(), ex); } return null; }
public synchronized Object getJavaClassInstance(Class<?> clazz) { Object instance = instanceCache.get(clazz); if (instance != null) { return instance; } try { Constructor<?> constructor = clazz.getConstructor(IValueFactory.class); instance = constructor.newInstance(vf); instanceCache.put(clazz, instance); return instance; } catch (IllegalArgumentException e) { throw new ImplementationError(e.getMessage(), e); } catch (InstantiationException e) { throw new ImplementationError(e.getMessage(), e); } catch (IllegalAccessException e) { throw new ImplementationError(e.getMessage(), e); } catch (InvocationTargetException e) { throw new ImplementationError(e.getMessage(), e); } catch (SecurityException e) { throw new ImplementationError(e.getMessage(), e); } catch (NoSuchMethodException e) { throw new ImplementationError(e.getMessage(), e); } }
/** * This method does the work of creating an instance of the class given the URL of the wsdl * provided in the constructor. This is actually type-safe, so the fact that "abort" if anything * goes wrong should never happen. */ protected void init() { try { URL url = WSDLService.getURLForWSDL(wsdl); Constructor<S> constructor = clazzS.getConstructor(URL.class); service = constructor.newInstance(url); } catch (SecurityException e) { throw new RuntimeException( "You supplied a bad *service*/port pair (Security):" + e.getMessage()); } catch (NoSuchMethodException e) { throw new RuntimeException( "You supplied a bad *service*/port pair (NoSuchMethod):" + e.getMessage()); } catch (IllegalArgumentException e) { throw new RuntimeException( "You supplied a bad *service*/port pair (IllegalArgument):" + e.getMessage()); } catch (IllegalAccessException e) { throw new RuntimeException( "You supplied a bad *service*/port pair (IllegalAccess):" + e.getMessage()); } catch (InvocationTargetException e) { throw new RuntimeException( "You supplied a bad *service*/port pair (InvocationTarget):" + e.getMessage()); } catch (InstantiationException e) { throw new RuntimeException( "You supplied a bad *service*/port pair (Instantiation):" + e.getMessage()); } }
/** * Gets an instance of a checksum decoder for the specified encoding. * * @param encoding The encoding name. * @param config The configuration object. * @param in The input stream. * @throws NullPointerException If any parameter is null. * @throws IllegalArgumentException If the specified encoding cannot be found, or if any of the * arguments are inappropriate. */ public static ChecksumEncoder getInstance(String encoding, Configuration config, InputStream in) { if (encoding == null || config == null || in == null) { throw new NullPointerException(); } if (encoding.length() == 0) { throw new IllegalArgumentException(); } try { Class clazz = Class.forName(System.getProperty(PROPERTY + encoding)); if (!ChecksumEncoder.class.isAssignableFrom(clazz)) { throw new IllegalArgumentException( clazz.getName() + ": not a subclass of " + ChecksumEncoder.class.getName()); } Constructor c = clazz.getConstructor(new Class[] {Configuration.class, InputStream.class}); return (ChecksumEncoder) c.newInstance(new Object[] {config, in}); } catch (ClassNotFoundException cnfe) { throw new IllegalArgumentException("class not found: " + cnfe.getMessage()); } catch (NoSuchMethodException nsme) { throw new IllegalArgumentException("subclass has no constructor"); } catch (InvocationTargetException ite) { throw new IllegalArgumentException(ite.getMessage()); } catch (InstantiationException ie) { throw new IllegalArgumentException(ie.getMessage()); } catch (IllegalAccessException iae) { throw new IllegalArgumentException(iae.getMessage()); } }
/** * Creates an instance of an event class using a config which may be new or recycled from an * existing event, possibly of another type * * @param theClass * @param theTest * @param theInitialConfig * @return */ public AbstractEvent createEvent( Class<? extends AbstractEvent> theClass, TestImpl theTest, Event theInitialConfig) throws ConfigurationException { Class<? extends Event> configType = myEventClasses2ConfigTypes.get(theClass); try { Constructor<? extends AbstractEvent> constructor = theClass.getConstructor(TestImpl.class, configType); final Event convertConfig = convertConfig(theInitialConfig, configType); AbstractEvent event = constructor.newInstance(theTest, convertConfig); return event; } catch (InstantiationException ex) { throw new ConfigurationException(ex.getMessage(), ex); } catch (IllegalAccessException ex) { throw new ConfigurationException(ex.getMessage(), ex); } catch (IllegalArgumentException ex) { throw new ConfigurationException(ex.getMessage(), ex); } catch (InvocationTargetException ex) { throw new ConfigurationException(ex.getMessage(), ex); } catch (NoSuchMethodException ex) { throw new ConfigurationException(ex.getMessage(), ex); } catch (SecurityException ex) { throw new ConfigurationException(ex.getMessage(), ex); } }
/** * Creates the appropriate editor form for the given event type * * @throws InstantiationException If the form can't be created for any reason */ public <T extends AbstractEvent, V extends AbstractEventEditorForm> V createEditorForm( EventEditorContextController theController, T event) throws ConfigurationException { Class<V> formClass = (Class<V>) myEventClasses2EditorForm.get(event.getClass()); if (formClass == null) { throw new ConfigurationException("No editor for " + event.getClass()); } try { Constructor<V> constructor = formClass.getConstructor(); V instance = constructor.newInstance(); instance.setController(theController); return instance; } catch (InstantiationException ex) { throw new ConfigurationException(ex.getMessage(), ex); } catch (IllegalAccessException ex) { throw new ConfigurationException(ex.getMessage(), ex); } catch (IllegalArgumentException ex) { throw new ConfigurationException(ex.getMessage(), ex); } catch (InvocationTargetException ex) { throw new ConfigurationException(ex.getMessage(), ex); } catch (NoSuchMethodException ex) { throw new ConfigurationException(ex.getMessage(), ex); } catch (SecurityException ex) { throw new ConfigurationException(ex.getMessage(), ex); } }
protected ConnectionFigure createConnection() { try { Class cLayer = Class.forName(objType); LayerConnection lc = (LayerConnection) cLayer.newInstance(); lc.setParams(params); // Each component is provided with a pointer to the parent NeuralNet object NeuralNetDrawing nnd = (NeuralNetDrawing) view.drawing(); lc.setParam("NeuralNet", nnd.getNeuralNet()); return lc; } catch (ClassNotFoundException cnfe) { log.warn( "ClassNotFoundException exception thrown while ConnectionFigure. Message is : " + cnfe.getMessage(), cnfe); } catch (InstantiationException ie) { log.warn( "InstantiationException exception thrown while ConnectionFigure. Message is : " + ie.getMessage(), ie); } catch (IllegalAccessException iae) { log.warn( "IllegalAccessException exception thrown while ConnectionFigure. Message is : " + iae.getMessage(), iae); } return null; }
public static Connection connectWithC3p0() { try { Class.forName("com.mysql.jdbc.Driver").newInstance(); } catch (ClassNotFoundException cnfe) { System.err.println("Error: " + cnfe.getMessage()); } catch (InstantiationException ie) { System.err.println("Error: " + ie.getMessage()); } catch (IllegalAccessException iae) { System.err.println("Error: " + iae.getMessage()); } ComboPooledDataSource cpds = getC3p0(); try { if (con != null && !con.isClosed()) { con.close(); con = null; } con = cpds.getConnection(); } catch (SQLException ex) { ex.printStackTrace(); } System.out.println("Returning c3p0 Connection " + con); return con; }
@SuppressWarnings("unchecked") private void checkFields() throws ControllerException { try { super.checkFields( new String[] {"systemOid", "title", "content"}, new String[] { this.getText("MESSAGE.CORE_PROG001D0010A_systemOid") + "<BR/>", this.getText("MESSAGE.CORE_PROG001D0010A_title") + "<BR/>", this.getText("MESSAGE.CORE_PROG001D0010A_content") + "<BR/>" }, new Class[] { SelectItemFieldCheckUtils.class, NotBlankFieldCheckUtils.class, NotBlankFieldCheckUtils.class }, this.getFieldsId()); } catch (InstantiationException e) { e.printStackTrace(); throw new ControllerException(e.getMessage().toString()); } catch (IllegalAccessException e) { e.printStackTrace(); throw new ControllerException(e.getMessage().toString()); } if (this.getFields().get("content").length() > 2000 || this.getFields().get("content").indexOf("twitter") == -1 || this.getFields().get("content").indexOf("data-widget-id") == -1) { this.getFieldsId().add("content"); throw new ControllerException( this.getText("MESSAGE.CORE_PROG001D0010A_contentTwitterWidget") + "<BR/>"); } }
protected TableMeta(String dsmName, Class<? extends Model> modelClass) { Table tableAnnotation = modelClass.getAnnotation(Table.class); checkNotNull(tableAnnotation, "Could not found @Table Annotation."); this.dsmName = dsmName; this.tableName = tableAnnotation.name(); this.generatedKey = tableAnnotation.generatedKey(); this.primaryKey = tableAnnotation.primaryKey(); this.generated = tableAnnotation.generated(); Generator generator = null; try { generator = tableAnnotation.generator().newInstance(); } catch (InstantiationException e) { throw new DBException(e.getMessage(), e); } catch (IllegalAccessException e) { throw new DBException(e.getMessage(), e); } this.generator = generator; this.cached = tableAnnotation.cached(); this.expired = tableAnnotation.expired(); this.sequence = tableAnnotation.sequence(); this.modelClass = modelClass; this.tableSetting = new TableSetting( tableName, generatedKey, primaryKey, generated, generator, cached, expired, sequence); }
@SuppressWarnings("unchecked") private static void createServletContextsHolder() { try { Class<?> clazz = Holders.class.getClassLoader().loadClass("grails.web.context.WebRequestServletHolder"); servletContexts = (Holder) clazz.newInstance(); } catch (ClassNotFoundException e) { // shouldn't happen LOG.debug( "Error initializing servlet context holder, not running in Servlet environment: " + e.getMessage(), e); } catch (InstantiationException e) { // shouldn't happen LOG.debug( "Error initializing servlet context holder, not running in Servlet environment: " + e.getMessage(), e); } catch (IllegalAccessException e) { // shouldn't happen LOG.debug( "Error initializing servlet context holder, not running in Servlet environment: " + e.getMessage(), e); } }
@Override protected ClientConnectionManager createClientConnectionManager() { SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); registry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory())); ClientConnectionManager connManager = null; HttpParams params = getParams(); ClientConnectionManagerFactory factory = null; String className = (String) params.getParameter(ClientPNames.CONNECTION_MANAGER_FACTORY_CLASS_NAME); if (className != null) { try { Class<?> clazz = Class.forName(className); factory = (ClientConnectionManagerFactory) clazz.newInstance(); } catch (ClassNotFoundException ex) { throw new IllegalStateException("Invalid class name: " + className); } catch (IllegalAccessException ex) { throw new IllegalAccessError(ex.getMessage()); } catch (InstantiationException ex) { throw new InstantiationError(ex.getMessage()); } } if (factory != null) { connManager = factory.newInstance(params, registry); } else { connManager = new SingleClientConnManager(registry); } return connManager; }
@Test public void testCommands() { Reflections reflections = new Reflections("com.greatmancode.craftconomy3.commands"); for (Class<? extends CommandExecutor> clazz : reflections.getSubTypesOf(CommandExecutor.class)) { try { CommandExecutor instance = clazz.newInstance(); if (instance.help() == null) { fail("Help is null for: " + clazz.getName()); } if (instance.maxArgs() < 0) { fail("Fail maxArgs for class: " + clazz.getName()); } if (instance.minArgs() < 0) { fail("Fail minArgs for class: " + clazz.getName()); } if (instance.maxArgs() < instance.minArgs()) { fail("Fail maxArgs less than minArgs for class:" + clazz.getName()); } if (instance.getPermissionNode() != null) { if (!instance.getPermissionNode().contains("craftconomy")) { fail("Fail permissionNode for class: " + clazz.getName()); } } if (!instance.playerOnly() && instance.playerOnly()) { fail("Fail playerOnly. Should never get this.."); } } catch (InstantiationException e) { fail(e.getMessage()); } catch (IllegalAccessException e) { fail(e.getMessage()); } } }
/** Get new PHYSICAL connection, to be managed by a connection manager. */ public XAConnection getXAConnection() throws SQLException { // Comment out before public release: System.err.print("Executing " + getClass().getName() + ".getXAConnection()..."); try { Class.forName(driver).newInstance(); } catch (ClassNotFoundException e) { throw new SQLException("Error opening connection: " + e.getMessage()); } catch (IllegalAccessException e) { throw new SQLException("Error opening connection: " + e.getMessage()); } catch (InstantiationException e) { throw new SQLException("Error opening connection: " + e.getMessage()); } JDBCConnection connection = (JDBCConnection) DriverManager.getConnection(url, connProperties); // Comment out before public release: System.err.print("New phys: " + connection); JDBCXAResource xaResource = new JDBCXAResource(connection, this); JDBCXAConnectionWrapper xaWrapper = new JDBCXAConnectionWrapper(connection, xaResource, connectionDefaults); JDBCXAConnection xaConnection = new JDBCXAConnection(xaWrapper, xaResource); xaWrapper.setPooledConnection(xaConnection); return xaConnection; }
@Override public Connection connect() { String url; String userName = this.user; String passName = this.pass; url = "jdbc:mysql://" + this.host + ":" + this.port + ";databaseName=" + this.database; try { Class.forName("com.mysql.jdbc.Driver").newInstance(); this.c = DriverManager.getConnection(url, userName, passName); connected = true; } catch (SQLException e) { e.printStackTrace(); System.out.println(e.getMessage()); connected = false; } catch (ClassNotFoundException e) { e.printStackTrace(); System.out.println(e.getMessage()); connected = false; } catch (InstantiationException e) { e.printStackTrace(); System.out.println(e.getMessage()); connected = false; } catch (IllegalAccessException e) { e.printStackTrace(); System.out.println(e.getMessage()); connected = false; } return c; }
@SuppressWarnings({"unchecked", "rawtypes"}) private Spell getSpellClass(int id, String name) { try { Object[] instanceArguments = new Object[] {id}; Class[] constructorArguments = new Class[] {int.class}; Class spellClass = Class.forName("com.ignoreourgirth.gary.oakmagic.spells." + name); Constructor spellConstructor = spellClass.getConstructor(constructorArguments); Object instancedClass = spellConstructor.newInstance(instanceArguments); Spell returnValue = (Spell) instancedClass; // OakMagic.log.info("Loaded: " + spellClass.getSimpleName()); return returnValue; } catch (ClassNotFoundException ex) { OakMagic.log.log(Level.SEVERE, ex.getMessage()); } catch (InstantiationException ex) { OakMagic.log.log(Level.SEVERE, ex.getMessage()); } catch (IllegalAccessException ex) { OakMagic.log.log(Level.SEVERE, ex.getMessage()); } catch (SecurityException ex) { OakMagic.log.log(Level.SEVERE, ex.getMessage()); } catch (NoSuchMethodException ex) { OakMagic.log.log(Level.SEVERE, ex.getMessage()); } catch (IllegalArgumentException ex) { OakMagic.log.log(Level.SEVERE, ex.getMessage()); } catch (InvocationTargetException ex) { OakMagic.log.log(Level.SEVERE, ex.getMessage()); } return null; }
@Override public void disconnect() { String url; String userName = this.user; String passName = this.pass; url = "jdbc:sqlserver://" + this.host + ":" + this.port + ";databaseName=" + this.database; try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance(); this.c = DriverManager.getConnection(url, userName, passName); this.c.close(); connected = false; } catch (SQLException e) { System.out.println(e.getMessage()); connected = true; } catch (ClassNotFoundException e) { System.out.println(e.getMessage()); connected = true; } catch (InstantiationException e) { System.out.println(e.getMessage()); connected = true; } catch (IllegalAccessException e) { System.out.println(e.getMessage()); connected = true; } }
static { // API Level 11 is Build.VERSION_CODES.HONEYCOMB. // When right/left adjustment mode, outInsets uses touchableRegion to cut out IME rectangle. // Because only after API.11(HONEYCOMB) supports touchableRegion, filter it. InsetsCalculator tmpCalculator = null; if (Build.VERSION.SDK_INT >= 11) { // Try to create RegsionInsetsCalculator if the API level is high enough. try { Class<?> clazz = Class.forName( new StringBuilder(MozcView.class.getCanonicalName()) .append('$') .append("RegionInsetsCalculator") .toString()); tmpCalculator = InsetsCalculator.class.cast(clazz.newInstance()); } catch (ClassNotFoundException e) { MozcLog.e(e.getMessage(), e); } catch (IllegalArgumentException e) { MozcLog.e(e.getMessage(), e); } catch (IllegalAccessException e) { MozcLog.e(e.getMessage(), e); } catch (InstantiationException e) { MozcLog.e(e.getMessage(), e); } } if (tmpCalculator == null) { tmpCalculator = new DefaultInsetsCalculator(); } insetsCalculator = tmpCalculator; }
/* */ private static SignatureAlgorithmSpi buildSigner( String paramString, SignatureAlgorithmSpi paramSignatureAlgorithmSpi) throws XMLSignatureException { /* */ try { /* 130 */ Class localClass = getImplementingClass(paramString); /* */ /* 132 */ if (log.isLoggable(Level.FINE)) { /* 133 */ log.log( Level.FINE, "Create URI \"" + paramString + "\" class \"" + localClass + "\""); /* */ } /* 135 */ return (SignatureAlgorithmSpi) localClass.newInstance(); /* */ } /* */ catch (IllegalAccessException localIllegalAccessException) { /* 138 */ arrayOfObject = new Object[] {paramString, localIllegalAccessException.getMessage()}; /* */ /* 140 */ throw new XMLSignatureException( "algorithms.NoSuchAlgorithm", arrayOfObject, localIllegalAccessException); /* */ } /* */ catch (InstantiationException localInstantiationException) { /* 143 */ arrayOfObject = new Object[] {paramString, localInstantiationException.getMessage()}; /* */ /* 145 */ throw new XMLSignatureException( "algorithms.NoSuchAlgorithm", arrayOfObject, localInstantiationException); /* */ } /* */ catch (NullPointerException localNullPointerException) { /* 148 */ Object[] arrayOfObject = {paramString, localNullPointerException.getMessage()}; /* */ /* 150 */ throw new XMLSignatureException( "algorithms.NoSuchAlgorithm", arrayOfObject, localNullPointerException); /* */ } /* */ }
private Map<String, List<Object>> loadContextDatabase() { // context DB 생 Map<String, List<Object>> contextMap = new HashMap<String, List<Object>>(); log.d("pakage is " + pakagename); List<Class<?>> classlist = getFilterClasses(pakagename, ContextSchemable.class); try { ContextSchemable schemable; for (Class<?> clazz : classlist) { if (clazz.isEnum()) { // enum 타입 schemable = (ContextSchemable) clazz.getEnumConstants()[0]; // log.d("Type of enum: "+clazz.getSimpleName()); } else { // 그외 interface 타입 schemable = (ContextSchemable) clazz.newInstance(); // log.d("Type of class: "+clazz.getSimpleName()); } List<Object> list = schemable.getContextSchemaData(); if (list != null) { contextMap.put(schemable.getClass().getSimpleName(), list); } } } catch (InstantiationException e) { log.e(e.getMessage()); } catch (IllegalAccessException e) { log.e(e.getMessage()); } return contextMap; }
private void connect() { try { Class.forName("com.mysql.jdbc.Driver").newInstance(); } catch (InstantiationException e) { L.Error(e.getMessage(), e); } catch (IllegalAccessException e) { L.Error(e.getMessage(), e); } catch (ClassNotFoundException e) { L.Error(e.getMessage(), e); } try { // load conf MySQLDBConfLoader loader = MySQLDBConfLoader.getInstance(); dbuser = loader.getDbuser(); pass = loader.getPass(); dbHost = loader.getDbHost(); dbPort = loader.getDbPort(); dbName = loader.getDbName(); conn = DriverManager.getConnection( "jdbc:mysql://" + this.dbHost + ":" + this.dbPort + "/" + this.dbName, dbuser, pass); } catch (SQLException e) { L.Error(e.getMessage(), e); } try { stat = conn.createStatement(); } catch (SQLException e) { L.Error(e.getMessage(), e); } }
public void doArtefactConfiguration() { if (!pluginBean.isReadableProperty(ARTEFACTS)) { return; } List l = (List) plugin.getProperty(ARTEFACTS); for (Object artefact : l) { if (artefact instanceof Class) { Class artefactClass = (Class) artefact; if (ArtefactHandler.class.isAssignableFrom(artefactClass)) { try { application.registerArtefactHandler((ArtefactHandler) artefactClass.newInstance()); } catch (InstantiationException e) { LOG.error("Cannot instantiate an Artefact Handler:" + e.getMessage(), e); } catch (IllegalAccessException e) { LOG.error( "The constructor of the Artefact Handler is not accessible:" + e.getMessage(), e); } } else { LOG.error("This class is not an ArtefactHandler:" + artefactClass.getName()); } } else { if (artefact instanceof ArtefactHandler) { application.registerArtefactHandler((ArtefactHandler) artefact); } else { LOG.error( "This object is not an ArtefactHandler:" + artefact + "[" + artefact.getClass().getName() + "]"); } } } }
protected void getPages() throws FTPServerTimeoutException, FTPServerException, NoFTPServiceException { // Setup the ftp server FtpServer ftp; try { ftp = (FtpServer) Class.forName(Registry.getFTPService()).newInstance(); ftp.setServer(Registry.getUrl()); ftp.setPassword(Registry.getFtpPassword()); ftp.setUserName(Registry.getFtpUserName()); ftp.setPassive(Registry.usePassive()); ftp.setTimeout(Registry.getFtpTimeout()); // get the pages and store them in the _workingDir _pages = ftp.getFiles(getWssrdDocumentName(), _workingDir); if ((_pages.length == 1) && _pages[0].endsWith(".PDF")) { _fileType = PDF_FILETYPE; } } catch (InstantiationException e) { log.warn(e.getMessage()); throw new NoFTPServiceException(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } }