code
stringlengths
73
34.1k
label
stringclasses
1 value
private void writeInbound(Definition def, Writer out, int indent) throws IOException { writeIndent(out, indent); out.write("<inbound-resourceadapter>"); writeEol(out); writeIndent(out, indent + 1); out.write("<messageadapter>"); writeEol(out); writeIndent(out, indent + 2); ...
java
public static void main(String[] args) { String outputDir = "out"; //default output directory String defxml = null; int arg = 0; if (args.length > 0) { while (args.length > arg + 1) { if (args[arg].startsWith("-")) { if (args[arg...
java
private static Definition inputFromXml(String defxml) throws IOException, JAXBException { JAXBContext context = JAXBContext.newInstance("org.ironjacamar.codegenerator"); Unmarshaller unmarshaller = context.createUnmarshaller(); return (Definition) unmarshaller.unmarshal(new File(defxml)); }
java
private static void setDefaultValue(Definition def, String className, String stringValue) { if (className.endsWith(stringValue)) def.setDefaultValue(className.substring(0, className.length() - stringValue.length())); }
java
private static void copyAllJars(String outputDir) throws IOException { File out = new File(outputDir); String targetPath = out.getAbsolutePath() + File.separatorChar + "lib"; File current = new File("."); String path = current.getCanonicalPath(); String libPath = path + File.separator...
java
private static Properties loadProperties() { Properties properties = new Properties(); boolean loaded = false; String sysProperty = SecurityActions.getSystemProperty("ironjacamar.options"); if (sysProperty != null && !sysProperty.equals("")) { File file = new File(sysProperty)...
java
private static String configurationString(Properties properties, String key, String defaultValue) { if (properties != null) { return properties.getProperty(key, defaultValue); } return defaultValue; }
java
private static boolean configurationBoolean(Properties properties, String key, boolean defaultValue) { if (properties != null) { if (properties.containsKey(key)) return Boolean.valueOf(properties.getProperty(key)); } return defaultValue; }
java
private static int configurationInteger(Properties properties, String key, int defaultValue) { if (properties != null) { if (properties.containsKey(key)) return Integer.valueOf(properties.getProperty(key)); } return defaultValue; }
java
private static void applySystemProperties(Properties properties) { if (properties != null) { for (Map.Entry<Object, Object> entry : properties.entrySet()) { String key = (String)entry.getKey(); if (key.startsWith("system.property.")) { ...
java
public void setResourceAdapterClassLoader(ResourceAdapterClassLoader v) { if (trace) log.tracef("%s: setResourceAdapterClassLoader(%s)", Integer.toHexString(System.identityHashCode(this)), v); resourceAdapterClassLoader = v; }
java
private static void bind(Context ctx, Name name, Object value) throws NamingException { int size = name.size(); String atom = name.get(size - 1); Context parentCtx = createSubcontext(ctx, name.getPrefix(size - 1)); parentCtx.bind(atom, value); }
java
public void startTransaction() { Long key = Long.valueOf(Thread.currentThread().getId()); TransactionImpl tx = txs.get(key); if (tx == null) { TransactionImpl newTx = new TransactionImpl(key); tx = txs.putIfAbsent(key, newTx); if (tx == null) tx = newTx...
java
public void commitTransaction() throws SystemException { Long key = Long.valueOf(Thread.currentThread().getId()); TransactionImpl tx = txs.get(key); if (tx != null) { try { tx.commit(); } catch (Throwable t) { SystemExceptio...
java
public void assignTransaction(TransactionImpl v) { txs.put(Long.valueOf(Thread.currentThread().getId()), v); }
java
public static ClassLoader getClassLoader(final Class<?> c) { if (System.getSecurityManager() == null) return c.getClassLoader(); return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { public ClassLoader run() { return c.getClassLoader(); ...
java
public static String restoreExpression(Map<String, String> m, String key, String subkey, String v) { String k = key; if (subkey != null) { if (!isIncorrectExpression(subkey) && subkey.startsWith("${")) { subkey = subkey.substring(2, subkey.length() - 1); ...
java
public static String substituteValueInExpression(String expression, String newValue) { ExpressionTemplate t = new ExpressionTemplate(expression); if (newValue != null && (getExpressionKey(t.getTemplate()) == null || (t.isComplex() && !newValue.equals(t.getValue())))) return newValue...
java
public static String getExpressionKey(String result) { if (result == null) return null; try { int from = result.indexOf(startTag); int to = result.indexOf(endTag, from); Integer.parseInt(result.substring(from + 5, to)); return result.substring(from, to +...
java
private void writeXAResource(Definition def, Writer out, int indent) throws IOException { writeWithIndent(out, indent, "/**\n"); writeWithIndent(out, indent, " * This method is called by the application server during crash recovery.\n"); writeWithIndent(out, indent, " *\n"); writeWithIndent(o...
java
private void writeEndpointLifecycle(Definition def, Writer out, int indent) throws IOException { writeWithIndent(out, indent, "/**\n"); writeWithIndent(out, indent, " * This is called during the activation of a message endpoint.\n"); writeWithIndent(out, indent, " *\n"); writeWithIndent(out, ...
java
private void writeGetAs(Definition def, Writer out, int indent) throws IOException { writeWithIndent(out, indent, "/**\n"); writeWithIndent(out, indent, " * Get activation spec class\n"); writeWithIndent(out, indent, " * @return Activation spec\n"); writeWithIndent(out, indent, " */\n"); ...
java
private void writeMef(Definition def, Writer out, int indent) throws IOException { writeWithIndent(out, indent, "/**\n"); writeWithIndent(out, indent, " * Get message endpoint factory\n"); writeWithIndent(out, indent, " * @return Message endpoint factory\n"); writeWithIndent(out, indent, " */...
java
public void unregisterWorkManager(WorkManager wm) { if (wm != null) { if (wm.getName() == null || wm.getName().trim().equals("")) throw new IllegalArgumentException("The name of WorkManager is invalid: " + wm); if (trace) log.tracef("Unregistering WorkManager: %...
java
public void setDefaultWorkManager(WorkManager wm) { if (trace) log.tracef("Default WorkManager: %s", wm); String currentName = null; if (defaultWorkManager != null) currentName = defaultWorkManager.getName(); defaultWorkManager = wm; if (wm != null) { ...
java
public DistributedWorkManager resolveDistributedWorkManager(Address address) { if (trace) { log.tracef("resolveDistributedWorkManager(%s)", address); log.tracef(" ActiveWorkManagers: %s", activeWorkmanagers); } WorkManager wm = activeWorkmanagers.get(address.getWorkManager...
java
public synchronized WorkManager createWorkManager(String id, String name) { if (id == null || id.trim().equals("")) throw new IllegalArgumentException("The id of WorkManager is invalid: " + id); // Check for an active work manager if (activeWorkmanagers.keySet().contains(id)) { ...
java
public synchronized void removeWorkManager(String id) { if (id == null || id.trim().equals("")) throw new IllegalArgumentException("The id of WorkManager is invalid: " + id); Integer i = refCountWorkmanagers.get(id); if (i != null) { int newValue = i.intValue() - 1; ...
java
public synchronized void forceAdminObjects(List<AdminObject> newContent) { if (newContent != null) { this.adminobjects = new ArrayList<AdminObject>(newContent); } else { this.adminobjects = new ArrayList<AdminObject>(0); } }
java
public void deltaTotalBlockingTime(long delta) { if (enabled.get() && delta > 0) { totalBlockingTime.addAndGet(delta); totalBlockingTimeInvocations.incrementAndGet(); if (delta > maxWaitTime.get()) maxWaitTime.set(delta); } }
java
public void deltaTotalCreationTime(long delta) { if (enabled.get() && delta > 0) { totalCreationTime.addAndGet(delta); if (delta > maxCreationTime.get()) maxCreationTime.set(delta); } }
java
public void deltaTotalGetTime(long delta) { if (enabled.get() && delta > 0) { totalGetTime.addAndGet(delta); totalGetTimeInvocations.incrementAndGet(); if (delta > maxGetTime.get()) maxGetTime.set(delta); } }
java
public void deltaTotalPoolTime(long delta) { if (enabled.get() && delta > 0) { totalPoolTime.addAndGet(delta); totalPoolTimeInvocations.incrementAndGet(); if (delta > maxPoolTime.get()) maxPoolTime.set(delta); } }
java
public void deltaTotalUsageTime(long delta) { if (enabled.get() && delta > 0) { totalUsageTime.addAndGet(delta); totalUsageTimeInvocations.incrementAndGet(); if (delta > maxUsageTime.get()) maxUsageTime.set(delta); } }
java
@SuppressWarnings("unchecked") private void verifyBeanValidation(Object as) throws Exception { if (beanValidation != null) { ValidatorFactory vf = null; try { vf = beanValidation.getValidatorFactory(); Validator v = vf.getValidator(); Co...
java
private static void generateToCManagedConnection(Map<String, TraceEvent> events, FileWriter fw) throws Exception { writeString(fw, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\""); writeEOL(fw); writeString(fw, " \"http://www.w3.org/TR/html4/loose.dtd\"...
java
private static void generateToCConnectionListener(Map<String, List<TraceEvent>> events, FileWriter fw) throws Exception { writeString(fw, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\""); writeEOL(fw); writeString(fw, " \"http://www.w3.org/TR/html4/loos...
java
public void store(Activation metadata, XMLStreamWriter writer) throws Exception { if (metadata != null && writer != null) { writer.writeStartElement(XML.ELEMENT_IRONJACAMAR); storeCommon(metadata, writer); writer.writeEndElement(); } }
java
private static File extract(File file, File directory) throws IOException { if (file == null) throw new IllegalArgumentException("File is null"); if (directory == null) throw new IllegalArgumentException("Directory is null"); File target = new File(directory, file.getName()); ...
java
private void parse() { template = text; if (StringUtils.isEmptyTrimmed(template)) return; int index = 0; while (template.indexOf("${") != -1) { int from = template.lastIndexOf("${"); int to = template.indexOf("}", from + 2); if (to == -1) { ...
java
private void updateComplex(String string) { if (string != null && StringUtils.getExpressionKey(string) != null && !string.equals(StringUtils.getExpressionKey(string))) { complex = true; } }
java
private String resolveTemplate(boolean toValue) { String result = template; if (StringUtils.isEmptyTrimmed(result)) return result; String key; while ((key = StringUtils.getExpressionKey(result)) != null) { String subs; Expression ex = entities.get(key); ...
java
public Connector merge(Connector connector, AnnotationRepository annotationRepository, ClassLoader classLoader) throws Exception { // Process annotations if (connector == null || (connector.getVersion() == Version.V_16 || connector.getVersion() == Version.V_17)) { boolean isMetadataC...
java
private boolean hasAnnotation(Class c, Class targetClass, AnnotationRepository annotationRepository) { Collection<Annotation> values = annotationRepository.getAnnotation(targetClass); if (values == null) return false; for (Annotation annotation : values) { if (annotation.get...
java
private String getConfigPropertyName(Annotation annotation) throws ClassNotFoundException, NoSuchFieldException, NoSuchMethodException { if (annotation.isOnField()) { return annotation.getMemberName(); } else if (annotation.isOnMethod()) { String name = annotatio...
java
@SuppressWarnings("unchecked") private String getConfigPropertyType(Annotation annotation, Class<?> type, ClassLoader classLoader) throws ClassNotFoundException, ValidateException { if (annotation.isOnField()) { ...
java
private Set<String> getClasses(String name, ClassLoader cl) { Set<String> result = new HashSet<String>(); try { Class<?> clz = Class.forName(name, true, cl); while (!Object.class.equals(clz)) { result.add(clz.getName()); clz = clz.getSupercl...
java
private boolean hasNotNull(AnnotationRepository annotationRepository, Annotation annotation) { Collection<Annotation> values = annotationRepository.getAnnotation(javax.validation.constraints.NotNull.class); if (values == null || values.isEmpty()) return false; for (Annotation notNullAnno...
java
protected ConnectionListener validateConnectionListener(Collection<ConnectionListener> listeners, ConnectionListener cl, int newState) { ManagedConnectionFactory mcf = pool.getConnectionManager...
java
protected void destroyAndRemoveConnectionListener(ConnectionListener cl, Collection<ConnectionListener> listeners) { try { pool.destroyConnectionListener(cl); } catch (ResourceException e) { // TODO: cl.setState(ZOMBIE); } finally { ...
java
protected ConnectionListener findConnectionListener(ManagedConnection mc, Object c, Collection<ConnectionListener> listeners) { for (ConnectionListener cl : listeners) { if (cl.getManagedConnection().equals(mc) && (c == null || cl.getConnect...
java
protected ConnectionListener removeConnectionListener(boolean free, Collection<ConnectionListener> listeners) { if (free) { for (ConnectionListener cl : listeners) { if (cl.changeState(FREE, IN_USE)) return cl; } } else { fo...
java
public Connector getStandardMetaData(File root) throws Exception { Connector result = null; File metadataFile = new File(root, "/META-INF/ra.xml"); if (metadataFile.exists()) { InputStream input = null; String url = metadataFile.getAbsolutePath(); try { ...
java
public Activation getIronJacamarMetaData(File root) throws Exception { Activation result = null; File metadataFile = new File(root, "/META-INF/ironjacamar.xml"); if (metadataFile.exists()) { InputStream input = null; String url = metadataFile.getAbsolutePath(); tr...
java
public synchronized void forceConnectionDefinitions(List<ConnectionDefinition> newContent) { if (newContent != null) { this.connectionDefinition = new ArrayList<ConnectionDefinition>(newContent); } else { this.connectionDefinition = new ArrayList<ConnectionDefinition>(...
java
static InputStream getResourceAsStream(final String name) { if (System.getSecurityManager() == null) return Thread.currentThread().getContextClassLoader().getResourceAsStream(name); return AccessController.doPrivileged(new PrivilegedAction<InputStream>() { public InputStream run...
java
static WorkClassLoader createWorkClassLoader(final ClassBundle cb) { return AccessController.doPrivileged(new PrivilegedAction<WorkClassLoader>() { public WorkClassLoader run() { return new WorkClassLoader(cb); } }); }
java
public static TraceEvent parse(String data) { String[] raw = data.split("-"); String header = raw[0]; String p = raw[1]; String m = raw[2]; long tid = Long.parseLong(raw[3]); int t = Integer.parseInt(raw[4]); long ts = Long.parseLong(raw[5]); String c = raw[6]; ...
java
private void writeEIS(Definition def, Writer out, int indent) throws IOException { writeWithIndent(out, indent, "/**\n"); writeWithIndent(out, indent, " * Returns product name of the underlying EIS instance connected\n"); writeWithIndent(out, indent, " *\n"); writeWithIndent(out, indent, " * ...
java
static ValidatorFactory createValidatorFactory() { Configuration configuration = Validation.byDefaultProvider().configure(); Configuration<?> conf = configuration.traversableResolver(new IronJacamarTraversableResolver()); return conf.buildValidatorFactory(); }
java
Builder prepareNextPage() { int offset = this.offset + pageSize; validateOffset( offset ); this.offset = offset; return builder; }
java
Builder preparePreviousPage() { int offset = this.offset - pageSize; validateOffset( offset ); this.offset = offset; return builder; }
java
@Override public void handleFault( BackendlessFault fault ) { progressDialog.cancel(); Toast.makeText( context, fault.getMessage(), Toast.LENGTH_SHORT ).show(); }
java
public static Map<String, Object> serializeToMap( Object entity ) { IObjectSerializer serializer = getSerializer( entity.getClass() ); return (Map<String, Object>) serializer.serializeToMap( entity, new HashMap<Object, Map<String, Object>>() ); }
java
public static String getSimpleName( Class clazz ) { IObjectSerializer serializer = getSerializer( clazz ); return serializer.getClassName( clazz ); }
java
private Object getOrMakeSerializedObject( Object entityEntryValue, Map<Object, Map<String, Object>> serializedCache ) { if( serializedCache.containsKey( entityEntryValue ) ) //cyclic relation { //take from cache and substitute return serializedCac...
java
public static void serializeUserProperties( BackendlessUser user ) { Map<String, Object> serializedProperties = user.getProperties(); Set<Map.Entry<String, Object>> properties = serializedProperties.entrySet(); for( Map.Entry<String, Object> property : properties ) { Object propertyValue = prop...
java
private static IObjectSerializer getSerializer( Class clazz ) { Iterator<Map.Entry<Class, IObjectSerializer>> iterator = serializers.entrySet().iterator(); IObjectSerializer serializer = DEFAULT_SERIALIZER; while( iterator.hasNext() ) { Map.Entry<Class, IObjectSerializer> entry = iterator.next(...
java
public void setCurrentUser( BackendlessUser user ) { if( currentUser == null ) currentUser = user; else currentUser.setProperties( user.getProperties() ); }
java
public MessageStatus publish( String channelName, Object message ) { return publish( channelName, message, new PublishOptions() ); }
java
public static Object getFieldValue( Object object, String lowerKey, String upperKey ) //throws NoSuchFieldException { if( object == null ) return null; Method getMethod = getMethod( object, "get" + lowerKey ); if( getMethod == null ) getMethod = getMethod( object, "get" + upperKey ); if...
java
public static boolean hasField( Class clazz, String fieldName ) { try { clazz.getDeclaredField( fieldName ); return true; } catch( NoSuchFieldException nfe ) { if( clazz.getSuperclass() != null ) { return hasField( clazz.getSuperclass(), fieldName ); } e...
java
@Deprecated public void afterMoveToRepository( RunnerContext context, String fileUrlLocation, ExecutionResult<String> result ) throws Exception { }
java
@Nonnull public ImmutableList<T> toList() { return this.foldAbelian((v, acc) -> acc.cons(v), ImmutableList.empty()); }
java
protected void setArrayValue(final PreparedStatement statement, final int i, Connection connection, Object[] array) throws SQLException { if (array == null || (isEmptyStoredAsNull() && array.length == 0)) { statement.setNull(i, Types.ARRAY); } else { statement.setArra...
java
@Nonnull public final ArrayList<A> toArrayList() { ArrayList<A> list = new ArrayList<>(this.length); ImmutableList<A> l = this; for (int i = 0; i < length; i++) { list.add(((NonEmptyImmutableList<A>) l).head); l = ((NonEmptyImmutableList<A>) l).tail; } ...
java
@Nonnull public final LinkedList<A> toLinkedList() { LinkedList<A> list = new LinkedList<>(); ImmutableList<A> l = this; for (int i = 0; i < length; i++) { list.add(((NonEmptyImmutableList<A>) l).head); l = ((NonEmptyImmutableList<A>) l).tail; } return...
java
public<T> Get<T> read(Class<T> cls) throws APIException { return new Get<T>(this,getDF(cls)); }
java
public<T> Get<T> get(Class<T> cls) throws APIException { return new Get<T>(this,getDF(cls)); }
java
public<T> Post<T> post(Class<T> cls) throws APIException { return new Post<T>(this,getDF(cls)); }
java
public<T> Post<T> create(Class<T> cls) throws APIException { return new Post<T>(this,getDF(cls)); }
java
public<T> Put<T> put(Class<T> cls) throws APIException { return new Put<T>(this,getDF(cls)); }
java
public<T> Put<T> update(Class<T> cls) throws APIException { return new Put<T>(this,getDF(cls)); }
java
public<T> Delete<T> delete(Class<T> cls) throws APIException { return new Delete<T>(this,getDF(cls)); }
java
public void set(TafResp tafResp, Lur lur) { principal = tafResp.getPrincipal(); access = tafResp.getAccess(); this.lur = lur; }
java
public void invalidate(String id) { if(lur instanceof EpiLur) { ((EpiLur)lur).remove(id); } else if(lur instanceof CachingLur) { ((CachingLur<?>)lur).remove(id); } }
java
public<RET> RET same(SecuritySetter<HttpURLConnection> ss, Retryable<RET> retryable) throws APIException, CadiException, LocatorException { RET ret = null; boolean retry = true; int retries = 0; Rcli<HttpURLConnection> client = retryable.lastClient(); try { do { // if no previous state, get the best ...
java
protected int seg(Cached<?,?> cache, Object ... fields) { return cache==null?0:cache.invalidate(CachedDAO.keyFromObjs(fields)); }
java
public Result<DATA> create(TRANS trans, DATA data) { if(createPS==null) { Result.err(Result.ERR_NotImplemented,"Create is disabled for %s",getClass().getSimpleName()); } if(async) /*ResultSetFuture */ { Result<ResultSetFuture> rs = createPS.execAsync(trans, C_TEXT, data); if(rs.notOK()) { return Res...
java
public Result<List<DATA>> read(TRANS trans, DATA data) { if(readPS==null) { Result.err(Result.ERR_NotImplemented,"Read is disabled for %s",getClass().getSimpleName()); } return readPS.read(trans, R_TEXT, data); }
java
public Result<Void> delete(TRANS trans, DATA data, boolean reread) { if(deletePS==null) { Result.err(Result.ERR_NotImplemented,"Delete is disabled for %s",getClass().getSimpleName()); } // Since Deleting will be stored off, for possible re-constitution, need the whole thing if(reread) { Result<List<DATA>>...
java
private String update() { // If this has been done before, there is no change in checkSum and the last time notified is within GracePeriod if(checksum!=0 && checksum()==checksum && now < last.getTime()+graceEnds && now > last.getTime()+lastdays) { return null; } else { return "UPDATE authz.notify SET last =...
java
protected void addUser(String key, User<PERM> user) { userMap.put(key, user); }
java
protected boolean addMiss(String key, byte[] bs) { Miss miss = missMap.get(key); if(miss==null) { synchronized(missMap) { missMap.put(key, new Miss(bs,clean==null?MIN_INTERVAL:clean.timeInterval)); } return true; } return miss.add(bs); }
java
public void remove(String user) { Object o = userMap.remove(user); if(o!=null) { access.log(Level.INFO, user,"removed from Client Cache by Request"); } }
java
public Result<List<DATA>> read(final String key, final TRANS trans, final Object ... objs) { DAOGetter getter = new DAOGetter(trans,dao,objs); return get(trans, key, getter); // if(ld!=null) { // return Result.ok(ld);//.emptyList(ld.isEmpty()); // } // // Result Result if exists // if(getter.result==null) { ...
java
public String get(String key) { if(key==null)return null; int idx=0,equal=0,amp=0; while(idx>=0 && (equal = tresp.indexOf('=',idx))>=0) { amp = tresp.indexOf('&',equal); if(key.regionMatches(0, tresp, idx, equal-idx)) { return amp>=0?tresp.substring(equal+1, amp):tresp.substring(equal+1); } idx=a...
java
public static void timeSensitiveInit(Env env, AuthAPI authzAPI, AuthzFacade facade, final DirectAAFUserPass directAAFUserPass) throws Exception { /** * Basic Auth, quick Validation * * Responds OK or NotAuthorized */ authzAPI.route(env, HttpMethods.GET, "/authn/basicAuth", new Code(facade,"Is given Bas...
java
public Result<Void> addDescription(AuthzTrans trans, String ns, String name, String description) { try { getSession(trans).execute(UPDATE_SP + TABLE + " SET description = '" + description + "' WHERE ns = '" + ns + "' AND name = '" + name + "';"); } catch (DriverException | APIException | IOException e) { ...
java
public void setPathInfo(String pathinfo) { int qp = pathinfo.indexOf('?'); if(qp<0) { client.setContext(isProxy?("/proxy"+pathinfo):pathinfo); } else { client.setContext(isProxy?("/proxy"+pathinfo.substring(0,qp)):pathinfo.substring(0,qp)); client.setQueryParams(pathinfo.substring(qp+1)); } }
java