/** * Rethrow a throwable as a deployment exception if it isn't already. * * @param message the message * @param t the throwable * @throws DeploymentException always */ public static DeploymentException rethrowAsDeploymentException(String message, Throwable t) throws DeploymentException { if (t instanceof DeploymentException) throw (DeploymentException) t; else throw new DeploymentException(message, t); }
/** * Resolve the resource adapter * * @throws DeploymentException for any error */ protected void resolveResourceAdapter() throws DeploymentException { resourceAdapterName = resolveResourceAdapterName(); try { resourceAdapterObjectName = new ObjectName("jboss.jca:service=RARDeployment,name='" + resourceAdapterName + "'"); int state = ((Integer) server.getAttribute(resourceAdapterObjectName, "State")).intValue(); if (state != STARTED) throw new DeploymentException("The resource adapter is not started " + resourceAdapterName); } catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Cannot locate resource adapter deployment " + resourceAdapterName, e); } }
/** * Resolve message listener class * * @throws DeploymentException for any error */ protected void resolveMessageListener() throws DeploymentException { String messagingType = metaData.getMessagingType(); try { messagingTypeClass = GetTCLAction.getContextClassLoader().loadClass(messagingType); } catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Could not load messaging-type class " + messagingType, e); } }
throw new IllegalStateException(e.getMessage());
/** * Activate * * @throws DeploymentException for any error */ protected void activate() throws DeploymentException { if (deliveryActive.get() == false) { log.info("Delivery is disabled: " + getServiceName()); return; } Object[] params = new Object[] { this, activationSpec }; try { server.invoke(resourceAdapterObjectName, "endpointActivation", params, activationSig); } catch (Throwable t) { t = JMXExceptionDecoder.decode(t); DeploymentException.rethrowAsDeploymentException("Endpoint activation failed ra=" + resourceAdapterObjectName + " activationSpec=" + activationSpec, t); } }
/** * Gets the jdbc type mapping for this entity * * @return the jdbc type mapping for this entity */ public JDBCTypeMappingMetaData getTypeMapping() throws DeploymentException { if(datasourceMapping == null) { throw new DeploymentException("type-mapping is not initialized: " + dataSourceName + " was not deployed or type-mapping was not configured."); } return datasourceMapping; }
Element endpointInterceptors = MetaData.getOptionalChild(proxyConfig, "endpoint-interceptors", null); if (endpointInterceptors == null) throw new DeploymentException("No endpoint interceptors found"); else DeploymentException.rethrowAsDeploymentException("Error loading interceptor class " + className, t);
/** * Create the activation spec * * @throws DeploymentException for any error */ protected void createActivationSpec() throws DeploymentException { properties = new HashMap(metaData.getActivationConfigProperties()); augmentActivationConfigProperties(); Object[] params = new Object[] { messagingTypeClass, properties.values() }; try { activationSpec = (ActivationSpec) server.invoke(resourceAdapterObjectName, "createActivationSpec", params, createActivationSpecSig); } catch (Throwable t) { t = JMXExceptionDecoder.decode(t); DeploymentException.rethrowAsDeploymentException("Unable to create activation spec ra=" + resourceAdapterObjectName + " messaging-type=" + messagingTypeClass.getName() + " properties=" + metaData.getActivationConfigProperties(), t); } }
/** * Gets the jdbc type mapping for this entity * * @return the jdbc type mapping for this entity */ public JDBCTypeMappingMetaData getTypeMapping() throws DeploymentException { if(datasourceMapping == null) { throw new DeploymentException("type-mapping is not initialized: " + dataSourceName + " was not deployed or type-mapping was not configured."); } return datasourceMapping; }
@Override protected <U> void deploy(DeploymentUnit unit, DeploymentVisitor<U> visitor) throws DeploymentException { U deployment = unit.getAttachment(attachmentName, visitor.getVisitorType()); try { visitor.deploy(unit, deployment); } catch (Throwable t) { throw DeploymentException.rethrowAsDeploymentException("Error deploying: " + unit.getName(), t); } }
protected void startService() throws Exception { if (MBeanProxyExt.remote != null) throw new IllegalStateException("Remote MBeanServerConnection is already set " + MBeanProxyExt.remote); Object o = server.getAttribute(mbeanServerConnection, "Proxy"); if (o instanceof MBeanServerConnection == false) throw new DeploymentException(mbeanServerConnection + " does not define an MBeanServerConnection"); MBeanProxyExt.remote = (MBeanServerConnection) o; }
/** * Gets the load group with the specified name. * * @return the load group with the specified name * @throws DeploymentException if group with the specified name is not found */ public List getLoadGroup(String name) throws DeploymentException { List group = (List) loadGroups.get(name); if(group == null) { throw new DeploymentException("Unknown load group: name=" + name); } return group; }
public static final QLCompiler getInstance(Class impl, Catalog catalog) throws DeploymentException { if(impl == null) { throw new DeploymentException("ql-compiler is not specified."); } final Constructor constructor; try { constructor = impl.getConstructor(new Class[]{Catalog.class}); } catch(NoSuchMethodException e) { throw new DeploymentException("Compiler class does not have a constructor which takes " + Catalog.class.getName()); } try { return (QLCompiler)constructor.newInstance(new Object[]{catalog}); } catch(Exception e) { throw new DeploymentException("Failed to create an instance of " + impl.getName() + ": " + e.getMessage(), e); } }
private KeyGenerator initKeyGenerator(String keygenFactoryName) throws DeploymentException { try { InitialContext ctx = new InitialContext(); KeyGeneratorFactory keygenFactory = (KeyGeneratorFactory)ctx.lookup(keygenFactoryName); return keygenFactory.getKeyGenerator(); } catch(NamingException e) { throw new DeploymentException("Could not lookup key generator factory: " + keygenFactoryName, e); } catch(Exception e) { throw new DeploymentException("Could not create KeyGenerator instance.", e); } }
private Object newInstance(String className) throws DeploymentException { Class clazz = loadClass(className); try { return clazz.newInstance(); } catch(Exception e) { throw new DeploymentException("Failed to instantiate " + className, e); } } private Class loadClass(String className) throws DeploymentException
public void init(JDBCStoreManager manager) throws DeploymentException { if (CONNECTION_PREPARE == null) { throw new DeploymentException("Create command requires JDBC 3.0 (JDK1.4+)"); } super.init(manager); }
protected JDBCCMPFieldBridge getGeneratedPKField() throws DeploymentException { // extract the pk field to be generated JDBCCMPFieldBridge pkField = null; JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; ++i) { if(pkField != null) throw new DeploymentException("Generation only supported with single PK field"); pkField = (JDBCCMPFieldBridge)pkFields[i]; } return pkField; }
private Class loadClass(String className) throws DeploymentException { try { final ClassLoader contextClassLoader = TCLAction.UTIL.getContextClassLoader(); return contextClassLoader.loadClass(className); } catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load class: " + className, e); } } }
/** * Gets the JDBC type constant int for the name. The mapping from name to jdbc * type is contained in java.sql.Types. * * @param name the name for the jdbc type * @return the int type constant from java.sql.Types * @see java.sql.Types */ public static int getJdbcTypeFromName(String name) throws DeploymentException { if(name == null) { throw new DeploymentException("jdbc-type cannot be null"); } try { Integer constant = (Integer)Types.class.getField(name).get(null); return constant.intValue(); } catch(Exception e) { log.warn("Unrecognized jdbc-type: " + name + ", using Types.OTHER", e); return Types.OTHER; } }
/** * Constructs a JDBCDynamicQLQueryMetaData with DynamicQL declared in the * jboss-ql elemnt and is invoked by the specified method. */ public JDBCDynamicQLQueryMetaData(boolean resultTypeMappingLocal, Method method, JDBCReadAheadMetaData readAhead, Class compiler, boolean lazyResultSetLoading) throws DeploymentException { this.method = method; this.readAhead = readAhead; this.resultTypeMappingLocal = resultTypeMappingLocal; Class[] parameterTypes = method.getParameterTypes(); if(parameterTypes.length != 2 || !parameterTypes[0].equals(String.class) || !parameterTypes[1].equals(Object[].class)) { throw new DeploymentException( "Dynamic-ql method must have two " + "parameters of type String and Object[]." ); } this.compiler = compiler; this.lazyResultSetLoading = lazyResultSetLoading; }