code
stringlengths
73
34.1k
label
stringclasses
1 value
String upcaseFirst(String name) { StringBuilder sb = new StringBuilder(); sb.append(name.substring(0, 1).toUpperCase(Locale.ENGLISH)); sb.append(name.substring(1)); return sb.toString(); }
java
public int getInitialSize() { if (initialSize == null) return getMinSize(); if (initialSize.intValue() > maxSize) return maxSize; return initialSize.intValue(); }
java
private String dumpQueuedThread(Thread t) { StringBuilder sb = new StringBuilder(); // Header sb = sb.append("Queued thread: "); sb = sb.append(t.getName()); sb = sb.append(newLine); // Body StackTraceElement[] stes = SecurityActions.getStackTrace(t); if (stes != nul...
java
public synchronized void addEvent(WorkManagerEvent event) { if (trace) log.tracef("addEvent(%s)", event); List<WorkManagerEvent> e = events.get(event.getAddress().getWorkManagerName()); if (e == null) { e = new ArrayList<WorkManagerEvent>(); events.put(event.getAd...
java
private ScriptText createScriptText(int key, BMRule rule) { StringBuilder builder = new StringBuilder(); builder.append("# BMUnit autogenerated script: ").append(rule.name()); builder.append("\nRULE "); builder.append(rule.name()); if (rule.isInterface()) { builder.appen...
java
static Class<?>[] getDeclaredClasses(final Class<?> c) { if (System.getSecurityManager() == null) return c.getDeclaredClasses(); return AccessController.doPrivileged(new PrivilegedAction<Class<?>[]>() { public Class<?>[] run() { return c.getDeclaredClasses();...
java
static Field getDeclaredField(final Class<?> c, final String name) throws NoSuchFieldException { if (System.getSecurityManager() == null) return c.getDeclaredField(name); Field result = AccessController.doPrivileged(new PrivilegedAction<Field>() { public Field run() ...
java
public String getAsText() { if (throwable != null) return throwable.toString(); if (result != null) { try { if (editor != null) { editor.setValue(result); return editor.getAsText(); } else ...
java
private void checkTransport() throws WorkException { if (!transport.isInitialized()) { try { transport.initialize(); initialize(); } catch (Throwable t) { WorkException we = new WorkException("Exception during transport init...
java
private synchronized void removeDistributedStatistics() { if (distributedStatistics != null) { listeners.remove((NotificationListener)distributedStatistics); distributedStatistics.setTransport(null); distributedStatistics = null; } }
java
Address getLocalAddress() { if (localAddress == null) localAddress = new Address(getId(), getName(), transport != null ? transport.getId() : null); return localAddress; }
java
public void setShortRunningThreadPool(BlockingExecutor executor) { if (trace) log.trace("short running executor:" + (executor != null ? executor.getClass() : "null")); if (executor != null) { if (executor instanceof StatisticsExecutor) { this.shortRunningExec...
java
public void setLongRunningThreadPool(BlockingExecutor executor) { if (trace) log.trace("long running executor:" + (executor != null ? executor.getClass() : "null")); if (executor != null) { if (executor instanceof StatisticsExecutor) { this.longRunningExecut...
java
public void doFirstChecks(Work work, long startTimeout, ExecutionContext execContext) throws WorkException { if (isShutdown()) throw new WorkRejectedException(bundle.workmanagerShutdown()); if (work == null) throw new WorkRejectedException(bundle.workIsNull()); if (startTimeout ...
java
void addWorkWrapper(WorkWrapper ww) { synchronized (activeWorkWrappers) { activeWorkWrappers.add(ww); if (statisticsEnabled) statistics.setWorkActive(activeWorkWrappers.size()); } }
java
void removeWorkWrapper(WorkWrapper ww) { synchronized (activeWorkWrappers) { activeWorkWrappers.remove(ww); if (statisticsEnabled) statistics.setWorkActive(activeWorkWrappers.size()); } }
java
private BlockingExecutor getExecutor(Work work) { BlockingExecutor executor = shortRunningExecutor; if (longRunningExecutor != null && WorkManagerUtil.isLongRunning(work)) { executor = longRunningExecutor; } fireHintsComplete(work); return executor; }
java
private void fireHintsComplete(Work work) { if (work != null && work instanceof WorkContextProvider) { WorkContextProvider wcProvider = (WorkContextProvider) work; List<WorkContext> contexts = wcProvider.getWorkContexts(); if (contexts != null && !contexts.isEmpty()) ...
java
private void checkAndVerifyWork(Work work, ExecutionContext executionContext) throws WorkException { if (specCompliant) { verifyWork(work); } if (work instanceof WorkContextProvider && executionContext != null) { //Implements WorkContextProvider and not-null Execution...
java
private void verifyWork(Work work) throws WorkException { Class<? extends Work> workClass = work.getClass(); String className = workClass.getName(); if (!validatedWork.contains(className)) { if (isWorkMethodSynchronized(workClass, RUN_METHOD_NAME)) throw new WorkExcepti...
java
private boolean isWorkMethodSynchronized(Class<? extends Work> workClass, String methodName) { try { Method method = SecurityActions.getMethod(workClass, methodName, new Class[0]); if (Modifier.isSynchronized(method.getModifiers())) return true; } catch (NoSuchMe...
java
private void checkWorkCompletionException(WorkWrapper wrapper) throws WorkException { if (wrapper.getWorkException() != null) { if (trace) log.tracef("Exception %s for %s", wrapper.getWorkException(), this); deltaWorkFailed(); throw wrapper.getWorkException(); ...
java
private void fireWorkContextSetupFailed(Object workContext, String errorCode, WorkListener workListener, Work work, WorkException exception) { if (workListener != null) { WorkEvent event = new WorkEvent(this, WorkEvent.WORK_STARTED, work, null); ...
java
@SuppressWarnings("unchecked") private <T extends WorkContext> Class<T> getSupportedWorkContextClass(Class<T> adaptorWorkContext) { for (Class<? extends WorkContext> supportedWorkContext : SUPPORTED_WORK_CONTEXT_CLASSES) { // Assignable or not if (supportedWorkContext.isAssignableFro...
java
public <T> T getWorkContext(Class<T> workContextClass) { T instance = null; if (workContexts != null && workContexts.containsKey(workContextClass)) { instance = workContextClass.cast(workContexts.get(workContextClass)); } return instance; }
java
public void addWorkContext(Class<? extends WorkContext> workContextClass, WorkContext workContext) { if (workContextClass == null) { throw new IllegalArgumentException("Work context class is null"); } if (workContext == null) { throw new IllegalArgumentException("Work...
java
private void fireWorkContextSetupComplete(Object workContext) { if (workContext != null && workContext instanceof WorkContextLifecycleListener) { if (trace) log.tracef("WorkContextSetupComplete(%s) for %s", workContext, this); WorkContextLifecycleListener listener = (Work...
java
private void fireWorkContextSetupFailed(Object workContext) { if (workContext != null && workContext instanceof WorkContextLifecycleListener) { if (trace) log.tracef("WorkContextSetupFailed(%s) for %s", workContext, this); WorkContextLifecycleListener listener = (WorkCont...
java
@SuppressWarnings("unchecked") public void inject(Object object, String propertyName, Object propertyValue, String propertyType, boolean includeFields) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { if (object == null) ...
java
protected String getSubstitutionValue(String input) { if (input == null || input.trim().equals("")) return input; while (input.indexOf("${") != -1) { int from = input.indexOf("${"); int to = input.indexOf("}"); int dv = input.indexOf(":", from + 2); if...
java
public static Boolean getShouldDistribute(DistributableWork work) { if (work != null && work instanceof WorkContextProvider) { List<WorkContext> contexts = ((WorkContextProvider)work).getWorkContexts(); if (contexts != null) { for (WorkContext wc : contexts) ...
java
private Xid convertXid(Xid xid) { if (xid instanceof XidWrapper) return xid; else return new XidWrapperImpl(xid, pad, jndiName); }
java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); validatorFactory = BeanValidationImpl.createValidatorFactory(); }
java
public void setExecutorService(ExecutorService v) { if (v != null) { executorService = v; isExternal = true; } else { executorService = null; isExternal = false; } }
java
public void registerPool(ManagedConnectionPool mcp, long mcpInterval) { try { lock.lock(); synchronized (registeredPools) { registeredPools.put(new Key(System.identityHashCode(mcp), System.currentTimeMillis(), mcpInterval), mcp); } ...
java
public void unregisterPool(ManagedConnectionPool mcp) { synchronized (registeredPools) { registeredPools.values().remove(mcp); if (registeredPools.isEmpty()) interval = Long.MAX_VALUE; } }
java
public Metadata registerMetadata(String name, Connector c, File archive) { Metadata md = new MetadataImpl(name, c, archive); metadataRepository.registerMetadata(md); return md; }
java
protected void createResourceAdapter(DeploymentBuilder builder, String raClz, Collection<org.ironjacamar.common.api.metadata.spec.ConfigProperty> configProperties, Map<String, String> overrides, Transac...
java
protected void createAdminObject(DeploymentBuilder builder, Connector connector, AdminObject ao) throws DeployException { try { String aoClass = findAdminObject(ao.getClassName(), connector); Class<?> clz = Class.forName(aoClass, true, builder.getClassLoader()); Object a...
java
private String findManagedConnectionFactory(String className, Connector connector) { for (org.ironjacamar.common.api.metadata.spec.ConnectionDefinition cd : connector.getResourceadapter().getOutboundResourceadapter().getConnectionDefinitions()) { if (className.equals(cd.getManagedC...
java
private String findAdminObject(String className, Connector connector) { for (org.ironjacamar.common.api.metadata.spec.AdminObject ao : connector.getResourceadapter().getAdminObjects()) { if (className.equals(ao.getAdminobjectClass().getValue()) || className.equals(ao.g...
java
private Collection<org.ironjacamar.common.api.metadata.spec.ConfigProperty> findConfigProperties(String className, Connector connector) { for (org.ironjacamar.common.api.metadata.spec.ConnectionDefinition cd : connector.getResourceadapter().getOutboundResourceadapter().getConnectionDefiniti...
java
private Class<?> convertType(Class<?> old) { if (Boolean.class.equals(old)) { return boolean.class; } else if (boolean.class.equals(old)) { return Boolean.class; } else if (Byte.class.equals(old)) { return byte.class; } else if (b...
java
private boolean isSupported(Class<?> t) { if (Boolean.class.equals(t) || boolean.class.equals(t) || Byte.class.equals(t) || byte.class.equals(t) || Short.class.equals(t) || short.class.equals(t) || Integer.class.equals(t) || int.class.equals(t) || Long.class.equals(t) ||...
java
@SuppressWarnings("unchecked") protected void associateResourceAdapter(javax.resource.spi.ResourceAdapter resourceAdapter, Object object) throws DeployException { if (resourceAdapter != null && object != null && object instanceof ResourceAdapterAssociation) { try { ...
java
private TransactionSupportEnum getTransactionSupport(Connector connector, Activation activation) { if (activation.getTransactionSupport() != null) return activation.getTransactionSupport(); if (connector.getResourceadapter().getOutboundResourceadapter() != null) return connector.getRes...
java
private void applyConnectionManagerConfiguration(ConnectionManagerConfiguration cmc, org.ironjacamar.common.api.metadata.resourceadapter.ConnectionDefinition cd) { if (cd.getJndiName() != null) cmc.setJndiName(cd.getJndiName()); if (cd.isSharable() != null) cmc.setSharable(cd.isS...
java
private void applyConnectionManagerConfiguration(ConnectionManagerConfiguration cmc, org.ironjacamar.common.api.metadata.common.Security s) { if (s != null && s.getSecurityDomain() != null) { cmc.setSecurityDomain(s.getSecurityDomain()); } }
java
private void applyConnectionManagerConfiguration(ConnectionManagerConfiguration cmc, org.ironjacamar.common.api.metadata.common.XaPool xp) { if (xp != null) { if (xp.isIsSameRmOverride() != null) cmc.setIsSameRMOverride(xp.isIsSameRmOverride()); if (xp.isPadXid() != n...
java
private void applyConnectionManagerConfiguration(ConnectionManagerConfiguration cmc, org.ironjacamar.common.api.metadata.common.Timeout t) { if (t != null) { if (t.getAllocationRetry() != null) cmc.setAllocationRetry(t.getAllocationRetry()); if (t.getAllocationRetryWa...
java
private void applyPoolConfiguration(PoolConfiguration pc, org.ironjacamar.common.api.metadata.common.Pool p) { if (p != null) { if (p.getMinPoolSize() != null) pc.setMinSize(p.getMinPoolSize().intValue()); if (p.getInitialPoolSize() !=...
java
private void applyPoolConfiguration(PoolConfiguration pc, org.ironjacamar.common.api.metadata.common.Timeout t) { if (t != null) { if (t.getBlockingTimeoutMillis() != null) pc.setBlockingTimeout(t.getBlockingTimeoutMillis().longValue()); ...
java
private void applyPoolConfiguration(PoolConfiguration pc, org.ironjacamar.common.api.metadata.common.Validation v) { if (v != null) { if (v.isValidateOnMatch() != null) pc.setValidateOnMatch(v.isValidateOnMatch().booleanValue()); if (v...
java
private Map<String, ActivationSpecImpl> createInboundMapping(InboundResourceAdapter ira, ClassLoader cl) throws Exception { if (ira != null) { Map<String, ActivationSpecImpl> result = new HashMap<>(); for (org.ironjacamar.common.api.metadata.spec.MessageListener ml : ...
java
private Map<String, Class<?>> createPropertyMap(Class<?> clz) throws Exception { Map<String, Class<?>> result = new HashMap<>(); for (Method m : clz.getMethods()) { if (m.getName().startsWith("set")) { if (m.getReturnType().equals(Void.TYPE) && m.getPa...
java
private String getProductName(Connector raXml) { if (raXml != null && !XsdString.isNull(raXml.getEisType())) return raXml.getEisType().getValue(); return ""; }
java
private String getProductVersion(Connector raXml) { if (raXml != null && !XsdString.isNull(raXml.getResourceadapterVersion())) return raXml.getResourceadapterVersion().getValue(); return ""; }
java
private boolean is16(Connector connector) { if (connector == null || connector.getVersion() == Connector.Version.V_16 || connector.getVersion() == Connector.Version.V_17) return true; return false; }
java
@SuppressWarnings("unchecked") private void verifyBeanValidation(Deployment deployment) throws DeployException { if (beanValidation != null) { ValidatorFactory vf = null; try { vf = beanValidation.getValidatorFactory(); javax.validation.Validator v =...
java
private void loadNativeLibraries(File root) { if (root != null && root.exists()) { List<String> libs = new ArrayList<String>(); if (root.isDirectory()) { if (root.listFiles() != null) { for (File f : root.listFiles()) { ...
java
protected boolean hasFailuresLevel(Collection<Failure> failures, int severity) { if (failures != null) { for (Failure failure : failures) { if (failure.getSeverity() == severity) { return true; } } } return false; ...
java
public String printFailuresLog(Validator validator, Collection<Failure> failures, FailureHelper... fhInput) { String errorText = ""; FailureHelper fh = null; if (fhInput.length == 0) fh = new FailureHelper(failures); else fh = fhInput[0]; if (failures != null && failu...
java
private void resetXAResourceTimeout() { // Do a reset of the underlying XAResource timeout if (!(xaResource instanceof LocalXAResource) && xaResourceTimeout > 0) { try { xaResource.setTransactionTimeout(xaResourceTimeout); } catch (XAException e) ...
java
@Override public void process(Map<String, String> varMap, Writer out) { try { if (templateText == null) { templateText = Utils.readFileIntoString(input); } String replacedString = replace(varMap); out.write(replacedString); out.flush();...
java
public String replace(Map<String, String> varMap) { StringBuilder newString = new StringBuilder(); int p = 0; int p0 = 0; while (true) { p = templateText.indexOf("${", p); if (p == -1) { newString.append(templateText.substring(p0, templateText.len...
java
public Collection<ConnectionFactory> getConnectionFactories() { if (connectionFactories == null) return Collections.emptyList(); return Collections.unmodifiableCollection(connectionFactories); }
java
public DeploymentBuilder connectionFactory(ConnectionFactory v) { if (connectionFactories == null) connectionFactories = new ArrayList<ConnectionFactory>(); connectionFactories.add(v); return this; }
java
public Collection<AdminObject> getAdminObjects() { if (adminObjects == null) return Collections.emptyList(); return Collections.unmodifiableCollection(adminObjects); }
java
public DeploymentBuilder adminObject(AdminObject v) { if (adminObjects == null) adminObjects = new ArrayList<AdminObject>(); adminObjects.add(v); return this; }
java
protected Boolean attributeAsBoolean(XMLStreamReader reader, String attributeName, Boolean defaultValue, Map<String, String> expressions) throws XMLStreamException, ParserException { String attributeString = rawAttributeText(reader, attributeName); if (attri...
java
private String rawAttributeText(XMLStreamReader reader, String attributeName) { String attributeString = reader.getAttributeValue("", attributeName); if (attributeString == null) return null; return attributeString.trim(); }
java
protected Integer elementAsInteger(XMLStreamReader reader, String key, Map<String, String> expressions) throws XMLStreamException, ParserException { Integer integerValue = null; String elementtext = rawElementText(reader); if (key != null && expressions != null && elementtext != null && elem...
java
protected Long elementAsLong(XMLStreamReader reader, String key, Map<String, String> expressions) throws XMLStreamException, ParserException { Long longValue = null; String elementtext = rawElementText(reader); if (key != null && expressions != null && elementtext != null && elementtext.inde...
java
protected FlushStrategy elementAsFlushStrategy(XMLStreamReader reader, Map<String, String> expressions) throws XMLStreamException, ParserException { String elementtext = rawElementText(reader); if (expressions != null && elementtext != null && elementtext.indexOf("${") != -1) expressions....
java
protected Capacity parseCapacity(XMLStreamReader reader) throws XMLStreamException, ParserException, ValidateException { Extension incrementer = null; Extension decrementer = null; while (reader.hasNext()) { switch (reader.nextTag()) { case END_ELEMENT : {...
java
public static List<TraceEvent> filterPoolEvents(List<TraceEvent> data) throws Exception { List<TraceEvent> result = new ArrayList<TraceEvent>(); for (TraceEvent te : data) { if (te.getType() == TraceEvent.CREATE_CONNECTION_LISTENER_GET || te.getType() == TraceEvent.CREATE_CON...
java
public static Map<String, List<TraceEvent>> filterLifecycleEvents(List<TraceEvent> data) throws Exception { Map<String, List<TraceEvent>> result = new TreeMap<String, List<TraceEvent>>(); for (TraceEvent te : data) { if (te.getType() == TraceEvent.CREATE_CONNECTION_LISTENER_GET || ...
java
public static List<TraceEvent> filterCCMEvents(List<TraceEvent> data) throws Exception { List<TraceEvent> result = new ArrayList<TraceEvent>(); for (TraceEvent te : data) { if (te.getType() == TraceEvent.PUSH_CCM_CONTEXT || te.getType() == TraceEvent.POP_CCM_CONTEXT) ...
java
public static Map<String, List<TraceEvent>> filterCCMPoolEvents(List<TraceEvent> data) throws Exception { Map<String, List<TraceEvent>> result = new TreeMap<String, List<TraceEvent>>(); for (TraceEvent te : data) { if (te.getType() == TraceEvent.REGISTER_CCM_CONNECTION || te....
java
public static Map<String, Set<String>> poolManagedConnectionPools(List<TraceEvent> data) throws Exception { Map<String, Set<String>> result = new TreeMap<String, Set<String>>(); for (TraceEvent te : data) { if (te.getType() == TraceEvent.GET_CONNECTION_LISTENER || te.getType(...
java
public static List<TraceEvent> getEvents(FileReader fr, File directory) throws Exception { return getEvents(getData(fr, directory)); }
java
public static boolean isStartState(TraceEvent te) { if (te.getType() == TraceEvent.GET_CONNECTION_LISTENER || te.getType() == TraceEvent.GET_CONNECTION_LISTENER_NEW || te.getType() == TraceEvent.GET_INTERLEAVING_CONNECTION_LISTENER || te.getType() == TraceEvent.GET_INTERLEAVING_CO...
java
public static boolean isEndState(TraceEvent te) { if (te.getType() == TraceEvent.RETURN_CONNECTION_LISTENER || te.getType() == TraceEvent.RETURN_CONNECTION_LISTENER_WITH_KILL || te.getType() == TraceEvent.RETURN_INTERLEAVING_CONNECTION_LISTENER || te.getType() == TraceEvent.RETURN...
java
public static Map<String, List<Interaction>> getConnectionListenerData(List<Interaction> data) { Map<String, List<Interaction>> result = new TreeMap<String, List<Interaction>>(); for (int i = 0; i < data.size(); i++) { Interaction interaction = data.get(i); List<Interaction> l =...
java
public static boolean hasException(List<TraceEvent> events) { for (TraceEvent te : events) { if (te.getType() == TraceEvent.EXCEPTION) return true; } return false; }
java
public static String exceptionDescription(String encoded) { char[] data = encoded.toCharArray(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < data.length; i++) { char c = data[i]; if (c == '|') { sb = sb.append('\n'); } ...
java
public static String prettyPrint(TraceEvent te) { if (te.getType() != TraceEvent.GET_CONNECTION_LISTENER && te.getType() != TraceEvent.GET_CONNECTION_LISTENER_NEW && te.getType() != TraceEvent.GET_INTERLEAVING_CONNECTION_LISTENER && te.getType() != TraceEvent.GET_INTERLEAVING_CONN...
java
public static TraceEvent getVersion(List<TraceEvent> events) { for (TraceEvent te : events) { if (te.getType() == TraceEvent.VERSION) return te; } return null; }
java
static boolean hasMoreApplicationEvents(List<TraceEvent> events, int index) { if (index < 0 || index >= events.size()) return false; for (int j = index; j < events.size(); j++) { TraceEvent te = events.get(j); if (te.getType() == TraceEvent.GET_CONNECTION || ...
java
private Collection<FrameworkMethod> filterAndSort(List<FrameworkMethod> fms, boolean isStatic) throws Exception { SortedMap<Integer, FrameworkMethod> m = new TreeMap<>(); for (FrameworkMethod fm : fms) { SecurityActions.setAccessible(fm.getMethod()); if (Modifier.isStatic(fm.get...
java
private Object[] getParameters(FrameworkMethod fm) { Method m = fm.getMethod(); SecurityActions.setAccessible(m); Class<?>[] parameters = m.getParameterTypes(); Annotation[][] parameterAnnotations = m.getParameterAnnotations(); Object[] result = new Object[parameters.length]; ...
java
private Object resolveBean(String name, Class<?> type) { try { return embedded.lookup(name, type); } catch (Throwable t) { return null; } }
java
static void setAccessible(final Method m, final boolean value) { AccessController.doPrivileged(new PrivilegedAction<Object>() { public Object run() { m.setAccessible(value); return null; } }); }
java
private void writeVars(Definition def, Writer out, int indent) throws IOException { writeWithIndent(out, indent, "/** JNDI name */\n"); writeWithIndent(out, indent, "private static final String JNDI_NAME = \"java:/eis/" + def.getDefaultValue() + "\";\n\n"); writeWithIndent(out, indent,...
java
private void writeMethods(Definition def, Writer out, int indent) throws IOException { if (def.getMcfDefs().get(0).isDefineMethodInConnection()) { if (def.getMcfDefs().get(0).getMethods().size() > 0) { for (MethodForConnection method : def.getMcfDefs().get(0).getMethods()) ...
java
private void writeGetConnection(Definition def, Writer out, int indent) throws IOException { String connInterface = def.getMcfDefs().get(0).getConnInterfaceClass(); String cfInterface = def.getMcfDefs().get(0).getCfInterfaceClass(); writeWithIndent(out, indent, "/**\n"); writeWithIndent(out,...
java
public Timer createTimer() { Timer t = new Timer(true); if (timers == null) timers = new ArrayList<Timer>(); timers.add(t); return t; }
java
public boolean isContextSupported(Class<? extends WorkContext> workContextClass) { if (workContextClass == null) return false; return supportedContexts.contains(workContextClass); }
java
void writeConfigPropsXml(List<ConfigPropType> props, Writer out, int indent) throws IOException { if (props == null || props.size() == 0) return; for (ConfigPropType prop : props) { writeIndent(out, indent); out.write("<config-property>"); writeEol(out); ...
java
void writeRequireConfigPropsXml(List<ConfigPropType> props, Writer out, int indent) throws IOException { if (props == null || props.size() == 0) return; for (ConfigPropType prop : props) { if (prop.isRequired()) { writeIndent(out, indent); out.writ...
java