Examples#
Getting started#
Migrations are simple small classes, which consist of basically two methods and a static description variable. The two methods are named update()
and downgrade()
and are called respecively when running the migration or rolling it back.
The most basic migration does therefore look something like this:
<?php class Migration_2015_10_21_12_13 extends Migration { /** * Describe what the migration does */ public static $description = "Doesn't change anything, just shows messages."; /** * Is executed when the migration is run */ public function update() { $this->message("Ran the update() function!"); } /** * Is executed when the migration is rolled back */ public function downgrade() { $this->message("Ran the downgrade() function!"); } }
Simple Examples#
You might do lot's of different things in those migrations, but I'll just name some examples:
Change a field or template setting#
<?php class Migration_2015_10_21_12_15 extends Migration { public static $description = "Change the blog-post template to use it's new alternative template file"; public function update() { $t = $this->templates->get('blog-post'); $t->altFilename = 'blog-post-new.php'; $t->save(); } public function downgrade() { $t = $this->templates->get('blog-post'); $t->altFilename = 'blog-post.php'; $t->save(); } }
Add some new pages to the installation#
<?php class Migration_2015_10_21_12_16 extends Migration { public static $description = "Change the blog-post template to use it's new alternative template file"; public function update() { $this->pages->add('basic-page', $this->pages->get('/'), 'about', array( 'title' => 'About me', 'summary' => 'A short summary about my life?', 'body' => "…" )); } public function downgrade() { $about = $this->pages->get('template=basic-page, parent=1, name=about'); if(!$about instanceof Page) return; $about->delete(); } }
Add a field to a tempate, which wasn't needed before#
<?php class Migration_2015_10_21_12_16 extends Migration { public static $description = "Change the blog-post template to use it's new alternative template file"; public function update() { $this->insertIntoTemplate('home', 'google_analytics', 'title'); $this->editInTemplateContext('home', 'google_analytics', function($f){ $f->columnWidth = 50; }); $this->pages->get('/')->setAndSave('google_analytics', 'UA-XXXXX-XX'); } public function downgrade() { $t = $this->templates->get('home'); $t->fieldgroup->remove('google_analytics'); $t->fieldgroup->save(); } }
Specialized Migration Types#
Specialized migration types are much simpler to use, because their rollback functionality is much simpler and often tightly coupled to the data needed to run the migration in the first place. Therefore it's enough to supply the information about what to create/add and the deletion will just work as well.
Field Migration#
Does create a field and remove it on rollback.
<?php class Migration_2015_10_21_12_15 extends FieldMigration { public static $description = "Create a new integer field to store the max. number of participants."; /** * Supply the name of the field */ protected function getFieldName(){ return 'num_max_participants'; } /** * Supply the type of the field */ protected function getFieldType(){ return 'FieldtypeInteger'; } /** * Set the field up (it's saved automatically) */ protected function fieldSetup(Field $f){ // Base Settings $f->label = 'Max. Participants'; $f->description = 'The maximum number of participants for this event.'; $f->collapsed = Inputfield::collapsedNever; // Fieldtype Settings $f->zeroNotEmpty = 1; // Inputfield Settings $f->min = 0; $f->inputType = 'number'; // Add this field after the date field in the event template $this->insertIntoTemplate('event', $f->name, 'date'); } }
Template Migration#
Does create a template and remove it on rollback.
<?php class Migration_2015_10_21_12_17 extends TemplateMigration { public static $description = "Create a new blog-post template"; /** * Supply the name of the template */ protected function getTemplateName(){ return 'blog-post'; } /** * Set the field up (it's saved automatically) */ protected function templateSetup(Template $t){ $t->label = 'Blog-Post'; // Global fields are already added $this->insertIntoTemplate($t, 'title', 'body'); $this->insertIntoTemplate($t, 'body', 'date_published'); $this->insertIntoTemplate($t, 'date_published', 'author'); // Allow specific urlSegments $t->urlSegments(array( 'comments', 'media' )); } }
Module Migration#
This is the simplest migration type. Add the module into the vcs (>3.0 can also use composer) and install it like this. Will only deinstalled the module on rollback.
Do not remove the module from the vcs before running the migration
Trying to remove a module without it's files will fail. At best just let ProcessWire remove the files in a additional migration, which could also download it on rollback.
<?php class Migration_2015_10_21_12_16 extends ModuleMigration { public static $description = "Install LazyCron"; protected function getModuleName(){ return 'LazyCron'; } }


Button 1
(0,0)=>NW
Button 2
(80%,0)=>NE
Button 3
(0,80%)=>SW
Button 4
(80%,80%)=>SE
Button 5
(0,40%)=>W
Button 6
(80%,40%)=>E
Button 7
(40%,0)=>N
Button 8
(40%,80%)=>S
START
(50%,50%)=>ALL


full-stack web developer | software engineer
VIEW RESUMEI am a software engineer with a background teaching yoga and a passion for learning and for helping others be their best. I enjoy coaching, teaching, strategizing, and problem solving with diverse populations to create customized solutions that meet individual needs. Whether teaching yoga or developing apps, my aim is to develop solutions that are relevant, accessible, and sustainable – and to use my technical skills to create meaningful change in people’s lives.
Thanks for checking out my site! Please do not hesitate to contact me with comments or questions, or if you would like to discuss how I can best help you to meet your goals!


BaseSourceSwitcher¶
BaseSourceSwitcher is a button group to change the map’s background sources. The BaseSourceSwitcher allows you to switch over between the predefined source sets. For every sourceset a button will be displayed in the client. Notice that only one button can be active.
You have the possibility to define groups. All sourcesets of the same group will be listed in a dropdown list with the group name as title.
Configuration¶
The configuration occurs in 2 steps:
- Create a BaseSourceSwitcher Element with Title, Tooltip and Target
- Add Sourceset/s with one or more sources and definition of a group (optional)
- Title: Title of the element.
- Tooltip: The text entered as a tooltip will be indicated by hovering over the element with the mouse cursor a longer time.
- Target: Id of Map element, activated after the click.
- Instances: List of Sourcesets, defined by a title and group: (optional) group name to group of sourcesets by “group name”
In the configuration example you can see that either one, none or several entries per instanceset can be selected. You can created groups, which are then grouped together in the drop-down list.
- Title: Title of the BaseSource
- Group: Optionaly group name to group of sourcesets by “group name”
- Instances: Sources for the BaseSource
YAML-Definition:¶
title: 'BaseSourceSwitcher' # title
tooltip: 'BaseSourceSwitcher' # text to use as tooltip
target: map # Id of Map element
sourcesets: # List of sourcesets
- { title: sourcesetname, group: groupname,
sources: [sourceId]} # sourceset: title,
# group: (optional) group name to group of sourcesets by "group name"
# sources list of sources
Class, Widget & Style¶
- Class: Mapbender\CoreBundle\Element\BaseSourceSwitcher
- Widget: mapbender.element.basesourceswitcher.js
HTTP Callbacks¶
None.
JavaScript API¶
None.
JavaScript Signals¶
None.


Quality: {{ post.quality }}
Customer Service: {{ post.customerservice }}
Value for Money: {{ post.value }}
{% assign overall = post.quality | plus: post.customerservice | plus: post.value) | divided_by: 3 %}
{% capture overall %}{{ overall }}{% endcapture %}
Overall: {{ overall }}
{{ post.content }}


Want to combine your favorite comfort food with warm soup? Look no further than this delicious twist.
These cool and crisp bites are the perfect snack for a summer day!
Learn how to prepare this simple and yummi dish here.
Here's one for the vegetarians! Try these delectable bites today.
Not the holiday season? Who cares? These refreshing treats are good anytime. :)
Learn how to make this classic delight.


material demand climate change environmental media television paper energy BBC broadcast issues reduction {border-style consumption px;} #ffffff;} cultural population terms UK: decision-makers need audiences challenges global make particular policy politics programme set social stories Allwood difficult interviews life research Cambridge, body examples human political presented series audience channel content future programming public Earth nature offered programmes reduction. themes work ./rsta.. Change University Vision approaches arguments coverage critical directly discussion documentary factual good informed issue new popular present project px; resources theme time {font-family Phil. Press. Soc. Stories Trans. account alternative associated change, change. clearly everyday font-size including mainstream offer prominent recent significant simple specific story Cambridge Fraser However, Material Smith Tyszczuk actions argument available change: come community demand. double; economic example history home just materials noted population, power producers production questions relatively response section self-sufficiency sense special successful technology BBC's Boykoff New approach border-color border-width broadcasting, carbon challenge commissioners commissioning communities complex decision-making did dimensions emissions example, fact far food funded held help impacts life, life. little living novel question range reduce reference relation relevant resource reviews service shows solid; strand strong sustainability television, thinking told undertaken way ways {font-style {font-weight (including AHRC Archives Climate Interviews London, NY: Research Written York, action address addressed archive aspirational bold broadcaster broadcasting capita central centrality challenging clear consideration considered considers context courier; creative currently demands demonstrated distinctive drawn driven economies economy em; engagement environment exceptional explores features focus frame generated having high household ideas important influential issues. knowledge literature lives media, nicely non-news note notes notion obligations point possible potential process provided pt;} quality reasons reduction, regarding regular related relationship represented research, responses satisfy script settings shaping shared space specialist stories. storylines supply support systems telling think tone topics understanding use varied wide widely ‘the


|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
| Class Summary | |
|---|---|
| AtomicBoolean | A boolean value that may be updated atomically. |
| AtomicInteger | An int value that may be updated atomically. |
| AtomicIntegerArray | An int array in which elements may be updated atomically. |
| AtomicIntegerFieldUpdater<T> | A reflection-based utility that enables atomic updates to designated volatile int fields of designated classes. |
| AtomicLong | A long value that may be updated atomically. |
| AtomicLongArray | A long array in which elements may be updated atomically. |
| AtomicLongFieldUpdater<T> | A reflection-based utility that enables atomic updates to designated volatile long fields of designated classes. |
| AtomicMarkableReference<V> | An AtomicMarkableReference maintains an object reference along with a mark bit, that can be updated atomically. |
| AtomicReference<V> | An object reference that may be updated atomically. |
| AtomicReferenceArray<E> | An array of object references in which elements may be updated atomically. |
| AtomicReferenceFieldUpdater<T,V> | A reflection-based utility that enables atomic updates to designated volatile reference fields of designated classes. |
| AtomicStampedReference<V> | An AtomicStampedReference maintains an object reference along with an integer "stamp", that can be updated atomically. |
A small toolkit of classes that support lock-free thread-safe programming on single variables. In essence, the classes in this package extend the notion of volatile values, fields, and array elements to those that also provide an atomic conditional update operation of the form:
boolean compareAndSet(expectedValue, updateValue);
This method (which varies in argument types across different classes) atomically sets a variable to the updateValue if it currently holds the expectedValue, reporting true on success. The classes in this package also contain methods to get and unconditionally set values, as well as a weaker conditional atomic update operation weakCompareAndSet. The weak version may be more efficient in the normal case, but differs in that any given invocation of weakCompareAndSet method may fail, even spuriously (that is, for no apparent reason). A false return means only that the operation may be retried if desired, relying on the guarantee that repeated invocation when the variable holds expectedValue and no other thread is also attempting to set the variable will eventually succeed.
The specifications of these methods enable implementations to employ efficient machine-level atomic instructions that are available on contemporary processors. However on some platforms, support may entail some form of internal locking. Thus the methods are not strictly guaranteed to be non-blocking -- a thread may block transiently before performing the operation.
Instances of classes AtomicBoolean
, AtomicInteger
, AtomicLong
, and AtomicReference
each provide access and
updates to a single variable of the corresponding type. Each class
also provides appropriate utility methods for that type. For example,
classes AtomicLong and AtomicInteger provide atomic
increment methods. One application is to generate sequence numbers,
as in:
class Sequencer { private AtomicLong sequenceNumber = new AtomicLong(0); public long next() { return sequenceNumber.getAndIncrement(); } }
The memory effects for accesses and updates of atomics generally follow the rules for volatiles:
In addition to classes representing single values, this package
contains Updater classes that can be used to obtain
compareAndSet operations on any selected volatile
field of any selected class. AtomicReferenceFieldUpdater
, AtomicIntegerFieldUpdater
, and AtomicLongFieldUpdater
are
reflection-based utilities that provide access to the associated field
types. These are mainly of use in atomic data structures in which
several volatile fields of the same node (for example, the
links of a tree node) are independently subject to atomic
updates. These classes enable greater flexibility in how and when to
use atomic updates, at the expense of more awkward reflection-based
setup, less convenient usage, and weaker guarantees.
The AtomicIntegerArray
, AtomicLongArray
, and AtomicReferenceArray
classes further
extend atomic operation support to arrays of these types. These
classes are also notable in providing volatile access
semantics for their array elements, which is not supported for
ordinary arrays.
The AtomicMarkableReference
class associates a single boolean with a reference. For example, this
bit might be used inside a data structure to mean that the object
being referenced has logically been deleted. The AtomicStampedReference
class associates
an integer value with a reference. This may be used for example, to
represent version numbers corresponding to series of updates.
Atomic classes are designed primarily as building blocks for implementing non-blocking data structures and related infrastructure classes. The compareAndSet method is not a general replacement for locking. It applies only when critical updates for an object are confined to a single variable.
Atomic classes are not general purpose replacements for java.lang.Integer and related classes. They do not define methods such as hashCode and compareTo. (Because atomic variables are expected to be mutated, they are poor choices for hash table keys.) Additionally, classes are provided only for those types that are commonly useful in intended applications. For example, there is no atomic class for representing byte. In those infrequent cases where you would like to do so, you can use an AtomicInteger to hold byte values, and cast appropriately. You can also hold floats using Float.floatToIntBits and Float.intBitstoFloat conversions, and doubles using Double.doubleToLongBits and Double.longBitsToDouble conversions.
|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
Copyright © 2004, 2010 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.


While I was sitting here at home envying a large majority of my fellow collegues are
off having a blast at JavaOne (sigh), I was fiddling with some of the stuff
that I haven't had a chance to play with until now. One of those new and nifty
features is the
java.lang.instrument
package. This is another one of
those Java 5 features that I am really surprised hasn't made more of a splash as
of yet. This library finally makes it possible for tools such as a Java code profiler
and optimizer to be a.) written in 100% Java code and b.) be 100% spec compliant,
all
at the same time
, which up to this point hasn't been possible. Most
of the popular tools out there for profiling are either a.) proprietary (meaning I don't know
what they use) (see
JProfiler
,
YourKit
)
b.) open source and tied to the the JVMPI infrastructure from pre-Java 5 which
is native in nature (see
Extensible Java Profiler
),
or c.) open source and implemented using a non-standard approach (see
JRat
).
Each has problems:
A. - Proprietary software can be expensive.
B. - Native code is always a mess to deal with, even if the worst of the work is done ahead of time for you.
C. - Non-Standard implementations have a tendency to not have any core tool support, and as such, aren't always as flexible.
You can see a pretty thorough list of existing open source profilers
here
via Carlos Perez's Manageability.org.
The new instrumentation package provides a standard library to implement 100% Java
instrumentation code, and is also paired with a standard syntax for
connecting an instrumentation library with any running application. Today, I want
to walk through creating your first instrumentation class (the how), and
hopefully get into what you can do with it (the what/why) in the near future.
The instrumentation package is intended to be used by special Java libraries called
Java agents. A Java agent is a pluggable library that runs embedded in a JVM and
intercepts the classloading process. What this allows then, is to have the agent
a.) monitor the classloading process and b.) instrument (or engineer) the bytecode
of the classes to provide informational callbacks into the agent's libraries. Notice
I said that it *allows* the agent to instrument/engineer the bytecode - the core
Java packages don't have support for programmatic manipulation of bytecode, they leave
that up to the developer. Thankfully we have a mass of open-source support already
(
BCEL
,
Javassist
, and
ASM
to name a few).
Implementing an agent is quite easy. First, you need a special
premain
bootstrap
class. Like the
main
method you put in a bootstrap class for a regular
Java application, agents have a
premain
method that takes different
arguments specialized for writing an instrumentation agent. Here is the signature of a
premain
method:
A String representing the arguments to the agent (we'll get to how you pass them
momentarily). Note that it is *not* a string array. The agent hook expects you to do
any argument parsing/tokenizing yourself. Pipes, commas, spaces, semi-colons, it is
up to you.
The Instrumentation instance. This class is the hook into the active instrumentation
library that is running for your agent. This class is where you will pass in any class
transformers or redefined classes that you have manipulated.
The
java.lang.instrument.Instrumentation
object passed into the
premain
gives you access to do two primary ways to manipulate classes - class file transformations via a
java.lang.instrument.ClassFileTransformer
instance, and class file redefinitions
via the
java.lang.instrument.Instrumentation#redefineClasses(ClassDefinition[])
method. The main difference between the two is that the redefine method is used to redefine
already loaded classes, and as such can be used to alter classes in the active JVM
that even the agent may be dependent on (such as
java.lang.Object
)
where-as the transformer will only see classes loaded after it has been registered, and
only classes that the transformer itself is not dependent on. For today I will
simply show how to write a
ClassFileTransformer
.
Instances of
ClassFileTransformer
are meant to perform modifications
to the bytecode of existing classes for a variety of reasons. What I mention here
is the primary intention of the library (instrumentation), but creativity may prevail -
here is a link to someone who wrote an agent to engineer
out Log4J logging calls from an application
by using an agent (in otherwords, without changing the application distribution itself).
Writing a
ClassFileTransformer
is deceptively easy - the interface only
has one method. The trick is what you do with the parameters and return-value of the
method. Here is a simple example that simply prints to the console every time a class
is loaded in the JVM.
Obviously, printing to the console is not the same as doing bytecode transformations.
That process is complicated enough, however, that I feel I owe a separate article
to that alone.
For our simple agent, I created a very simple
premain
class that simply adds our
transformer. Here is the source:
The last component we need then, is to figure out how to package our agent
up so we can execute it with our applications. The
java.lang.instrument
package summary describes the manifest format in good detail - for our simple example,
here is what I have:
Please be very careful about the
Premain-Class
line - the agent library
is not very good at parsing the manifest file, and spaces that are actually allowed
by the manifest specification are not trimmed off of the class name, and it will say something
like this when you try to start:
Exception in thread "main" java.lang.ClassNotFoundException: com.javalobby.tnt.instrument.SimpleMain
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(Unknown Source)
FATAL ERROR in native method: processing of -javaagent failed
This sure looks like a classpath problem (and boy did I think it was for a *long* time
working on this article) before I found this bug:
Bug 6274276
about the problem i just described. You *must* have the mandatory one space before the
class name, and *no* spaces after the classname - only a carriage return. Also, remember that
the manifest should end in a blank line (hence why the manifest above has extra blank
space below it).
Ok, then we just compile and package our code (like this) in the JAR:
test.jar
|
+--- META-INF
| |
| +--- MANIFEST.MF (we just worked on this one)
|
+--- com
|
+--- javalobby
|
+--- tnt
|
+--- instrument
|
+--- SimpleMain.class
|
+--- SimpleTransformer.class
Finally, we just need to execute it. The
java.lang.instrument
package summary comes to the rescue again - this time showing us the execution
syntax:
java(w) -javaagent:jarpath[=options]
Executing this agent is about as easy as it gets -
we have no options, and we have no classpath dependencies. Presuming a program
called 'MyProgram', our startup command may look something like this:
Executing this on a simple main method that just loaded a class to do some fibonacci
calculations returned these results in the console:
~>java -javaagent:test.jar com.javalobby.tnt.instrument.example.ExampleMain
Transformer to Transform Class: sun/misc/URLClassPath$FileLoader$1
Transformer to Transform Class: com/javalobby/tnt/instrument/example/ExampleMain
Transformer to Transform Class: com/javalobby/tnt/instrument/example/ExampleClass
Transformer to Transform Class: java/lang/Shutdown
Transformer to Transform Class: java/lang/Shutdown$Lock
Try this new instrumentation out on Java applications you have; I have attached
the completed JAR file for giggles - it should be able to run with anything you
throw at it. Stay tuned as I'll cover how to actually engineer our classes,
and what can be done with the results.
Re: Instrumentation: Modify Applications with Java 5 Class File Transformat
Rory Winston's reply is the better one.
There certainly have been performance issues with Java.
We've been working really hard on them.
The primary way we've attacked the problem is with advanced virtual machines. The performance
has been getting very nice. --James Gosling, 1999.
Re: Instrumentation: Modify Applications with Java 5 Class File Transformat
Hi all,I tried to make a java agent with this code
public static void premain(String agentArgs, Instrumentation inst) {
PropertyConfigurator.configure("config/log4j.properties");
String agentName = ConfigInitiator.getConfiguration().getString("jvmstat_agent.name");
JvmThread jvmstatThread = new JvmThread(0, agentName);
logger.info("Starting JVM Stats Collector...");
Thread thread = new Thread(jvmstatThread);
thread.start();
}
And it gives me this exception
Exception in thread "main" java.lang.NoSuchMethodError: main
I launch it throw a ".bat" file using this line
Re: Instrumentation: Modify Applications with Java 5 Class File Transformations
I tried to instrument FileInputStream and FileOutputStream classes to monitor open files and check if the application closes all files after opening them. The problem is when I try to access a class defined by me from the close method of FileInputStream I get a ClassNotFound Exception, I am however able to access the class from the premain method. Any idea what the problem could be?
Instrumentation: Modify Applications with Java 5 Class File Transformations
At 11:02 PM on Jun 27, 2005, R.J. Lorimer wrote:
Fresh Jobs for Developers Post a job opportunity
While I was sitting here at home envying a large majority of my fellow collegues are off having a blast at JavaOne (sigh), I was fiddling with some of the stuff that I haven't had a chance to play with until now. One of those new and nifty features is the
java.lang.instrument
package. This is another one of those Java 5 features that I am really surprised hasn't made more of a splash as of yet. This library finally makes it possible for tools such as a Java code profiler and optimizer to be a.) written in 100% Java code and b.) be 100% spec compliant, all at the same time , which up to this point hasn't been possible. Most of the popular tools out there for profiling are either a.) proprietary (meaning I don't know what they use) (see JProfiler , YourKit ) b.) open source and tied to the the JVMPI infrastructure from pre-Java 5 which is native in nature (see Extensible Java Profiler ), or c.) open source and implemented using a non-standard approach (see JRat ). Each has problems:You can see a pretty thorough list of existing open source profilers here via Carlos Perez's Manageability.org.
The new instrumentation package provides a standard library to implement 100% Java instrumentation code, and is also paired with a standard syntax for connecting an instrumentation library with any running application. Today, I want to walk through creating your first instrumentation class (the how), and hopefully get into what you can do with it (the what/why) in the near future.
The instrumentation package is intended to be used by special Java libraries called Java agents. A Java agent is a pluggable library that runs embedded in a JVM and intercepts the classloading process. What this allows then, is to have the agent a.) monitor the classloading process and b.) instrument (or engineer) the bytecode of the classes to provide informational callbacks into the agent's libraries. Notice I said that it *allows* the agent to instrument/engineer the bytecode - the core Java packages don't have support for programmatic manipulation of bytecode, they leave that up to the developer. Thankfully we have a mass of open-source support already ( BCEL , Javassist , and ASM to name a few).
Implementing an agent is quite easy. First, you need a special
premain
bootstrap class. Like themain
method you put in a bootstrap class for a regular Java application, agents have apremain
method that takes different arguments specialized for writing an instrumentation agent. Here is the signature of apremain
method:The two arguments are:
The
java.lang.instrument.Instrumentation
object passed into thepremain
gives you access to do two primary ways to manipulate classes - class file transformations via ajava.lang.instrument.ClassFileTransformer
instance, and class file redefinitions via thejava.lang.instrument.Instrumentation#redefineClasses(ClassDefinition[])
method. The main difference between the two is that the redefine method is used to redefine already loaded classes, and as such can be used to alter classes in the active JVM that even the agent may be dependent on (such asjava.lang.Object
) where-as the transformer will only see classes loaded after it has been registered, and only classes that the transformer itself is not dependent on. For today I will simply show how to write aClassFileTransformer
.Instances of
ClassFileTransformer
are meant to perform modifications to the bytecode of existing classes for a variety of reasons. What I mention here is the primary intention of the library (instrumentation), but creativity may prevail - here is a link to someone who wrote an agent to engineer out Log4J logging calls from an application by using an agent (in otherwords, without changing the application distribution itself).Writing a
ClassFileTransformer
is deceptively easy - the interface only has one method. The trick is what you do with the parameters and return-value of the method. Here is a simple example that simply prints to the console every time a class is loaded in the JVM.Obviously, printing to the console is not the same as doing bytecode transformations. That process is complicated enough, however, that I feel I owe a separate article to that alone.
For our simple agent, I created a very simple
premain
class that simply adds our transformer. Here is the source:The last component we need then, is to figure out how to package our agent up so we can execute it with our applications. The java.lang.instrument package summary describes the manifest format in good detail - for our simple example, here is what I have:
Please be very careful about the
Premain-Class
line - the agent library is not very good at parsing the manifest file, and spaces that are actually allowed by the manifest specification are not trimmed off of the class name, and it will say something like this when you try to start:This sure looks like a classpath problem (and boy did I think it was for a *long* time working on this article) before I found this bug: Bug 6274276 about the problem i just described. You *must* have the mandatory one space before the class name, and *no* spaces after the classname - only a carriage return. Also, remember that the manifest should end in a blank line (hence why the manifest above has extra blank space below it).
Ok, then we just compile and package our code (like this) in the JAR:
Finally, we just need to execute it. The java.lang.instrument package summary comes to the rescue again - this time showing us the execution syntax:
Executing this agent is about as easy as it gets - we have no options, and we have no classpath dependencies. Presuming a program called 'MyProgram', our startup command may look something like this:
Executing this on a simple main method that just loaded a class to do some fibonacci calculations returned these results in the console:
Try this new instrumentation out on Java applications you have; I have attached the completed JAR file for giggles - it should be able to run with anything you throw at it. Stay tuned as I'll cover how to actually engineer our classes, and what can be done with the results.
Until next time,
R.J. Lorimer
rj -at- javalobby.org
http://www.coffee-bytes.com
6 replies so far ( Post your own)
Re: Instrumentation: Modify Applications with Java 5 Class File Transformat
Hido you know if an agent can have extra methods than can be called from inside premain method?
or if an agent class is allowed to extend another class?
I just created an agent and It worked correctly but when It extends another class and contains extra methods, it sends error messages
thanks for your help
Re: Instrumentation: Modify Applications with Java 5 Class File Transformat
Are there any tools out there that use these new capabilities?Thanks,
Guy
Re: Instrumentation: Modify Applications with Java 5 Class File Transformat
I think the AspectJ aspect weaving tools use this....I remember AspctWerkz used to use this mechanism, anyways.Rory Winston
http://www.researchkitchen.co.uk/blog
http://people.apache.org/~rwinston
Re: Instrumentation: Modify Applications with Java 5 Class File Transformat
Rory Winston's reply is the better one.Re: Instrumentation: Modify Applications with Java 5 Class File Transformat
Hi all,I tried to make a java agent with this codepublic static void premain(String agentArgs, Instrumentation inst) {
PropertyConfigurator.configure("config/log4j.properties");
String agentName = ConfigInitiator.getConfiguration().getString("jvmstat_agent.name");
JvmThread jvmstatThread = new JvmThread(0, agentName);
logger.info("Starting JVM Stats Collector...");
Thread thread = new Thread(jvmstatThread);
thread.start();
}
And it gives me this exception
Exception in thread "main" java.lang.NoSuchMethodError: main
I launch it throw a ".bat" file using this line
java -cp %APEF_JVMSTATCOLLECTOR_CP% -javaagent:%APEF_DIST%\JVMSTAT1.5.0.AgentExtension.jar com.adhocpes.apef.perf.pecollector.jvmstat.exec.JvmStatAgent
%APEF_JVMSTATCOLLECTOR_CP% is a variable which already difined in the .bat file ...
I don't know the error causes ...
Re: Instrumentation: Modify Applications with Java 5 Class File Transformations
I tried to instrument FileInputStream and FileOutputStream classes to monitor open files and check if the application closes all files after opening them. The problem is when I try to access a class defined by me from the close method of FileInputStream I get a ClassNotFound Exception, I am however able to access the class from the premain method. Any idea what the problem could be?


Name:
First
Last
Include input in output
Remove diacritics from output login
Remove diacritics from output password
User string
Login string
Password string
Minimum characters
Must include:
lowercase letter
uppercase letter
number
special character
include randomly
pass output format:
Each character in field above contributes to generated password
n/N -- each next letter from name in lowercase/uppercase
s/S -- each next letter from surname in lowercase/uppercase
z/Z -- one part of name
m/M -- one part of surname
a/A -- random letter in lowercase/uppercase
q/Q -- random letter
1 -- random number
% -- random special character
* -- random character
C -- random noun
V -- random verb
B -- random adjective
\ -- treat next character literally
login output format:
Each character in field above contributes to generated login
n -- one character from name
N -- one part of name
s -- one character from surname
S -- one part of surname
\ -- treat next character literally


@ProviderType
public interface RequestPathInfo
Decomposition of a Request URL
content path
- The longest substring of the request
URI resolving to a Resource
object such
that the content path is either the complete request URI or the next
character in the request URI after the content path is either a dot (.
)
or a slash (/
).
selectors
- If the first character in the
request URI after the content path is a dot, the string after the dot upto
but not including the last dot before the next slash character or the end of
the request URI. If the content path spans the complete request URI or if a
slash follows the content path in the request, then no selectors exist. If
only one dot follows the content path before the end of the request URI or
the next slash, no selectors exist. The selectors are available as
a single string
and as an
array of strings
, which is the selector string
splitted on dots.
extension
- The string after the last dot after
the content path in the request uri but before the end of the request uri or
the next slash after the content path in the request uri. If the content path
spans the complete request URI or a slash follows the content path in the
request URI, the extension is empty.
suffix path
- If the request URI contains a slash
character after the content path and optional selectors and extension, the
path starting with the slash upto the end of the request URI is the suffix
path.
Examples:
| URI | Content Path | Selectors | Extension | Suffix |
|---|---|---|---|---|
| /a/b | /a/b | null | null | null |
| /a/b.html | /a/b | null | html | null |
| /a/b.s1.html | /a/b | s1 | html | null |
| /a/b.s1.s2.html | /a/b | s1.s2 | html | null |
| /a/b/c/d | /a/b | null | null | /c/d |
| /a/b.html/c/d | /a/b | null | html | /c/d |
| /a/b.s1.html/c/d | /a/b | s1 | html | /c/d |
| /a/b.s1.s2.html/c/d | /a/b | s1.s2 | html | /c/d |
| /a/b/c/d.s.txt | /a/b | null | null | /c/d.s.txt |
| /a/b.html/c/d.s.txt | /a/b | null | html | /c/d.s.txt |
| /a/b.s1.html/c/d.s.txt | /a/b | s1 | html | /c/d.s.txt |
| /a/b.s1.s2.html/c/d.s.txt | /a/b | s1.s2 | html | /c/d.s.txt |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getExtension()
Returns the extension from the URL or
null if the request
URL does not contain an extension. |
java.lang.String |
getResourcePath()
Return the "resource path" part of the URL, what comes before selectors,
extension and suffix.
|
java.lang.String[] |
getSelectors()
Returns the selectors decoded from the request URL as an array of
strings.
|
java.lang.String |
getSelectorString()
Returns the selectors decoded from the request URL as string.
|
java.lang.String |
getSuffix()
Returns the suffix part of the URL or
null if the request
URL does not contain a suffix. |
Resource |
getSuffixResource()
Returns the resource addressed by the suffix or null if the request does
not have a suffix or the suffix does not address an accessible resource.
|
@Nonnull java.lang.String getResourcePath()
Resource.getPath()
.
Rather it is equal to the
resolution path metadata property
of the resource.@CheckForNull java.lang.String getExtension()
null
if the request
URL does not contain an extension.
Decomposition of the request URL is defined in the Decomposition of a Request URL above.
@CheckForNull java.lang.String getSelectorString()
null
if the request has no selectors.
Decomposition of the request URL is defined in the Decomposition of a Request URL above.
null
getSelectors()
@Nonnull java.lang.String[] getSelectors()
selector string
by splitting the string on
dots. Returns an empty array if the request has no selectors.
Decomposition of the request URL is defined in the Decomposition of a Request URL above.
getSelectorString()
@CheckForNull java.lang.String getSuffix()
null
if the request
URL does not contain a suffix.
Decomposition of the request URL is defined in the Decomposition of a Request URL above.
@CheckForNull Resource getSuffixResource()
The suffix is expected to be the absolute path to the resource suitable
as an argument to the
ResourceResolver.getResource(String)
method.
null
.Copyright © 2018 The Apache Software Foundation. All rights reserved.


TokenIssueResponse extends ApiResponse
Response from Authlete's /api/auth/token/issue API.
Authlete's /api/auth/token/issue
API returns JSON which can be mapped
to this class. The token endpoint implementation should retrieve the
value of the action
response parameter (which can be obtained by
getAction()
method of this class) from the response and take the
following steps according to the value.
When the value returned from getAction()
method is
TokenIssueAction::$INTERNAL_SERVER_ERROR
, it means that the request
from your system was wrong or that an error occurred in Authlete. In
either case, from a viewpoint of the client application, it is an error
on the server side. Therefore, the token endpoint implementation should
generate a response to the client application with the HTTP status of
500 Internal Server Error
.
In this case, getResponseContent()
method returns a JSON string which
describes the error, so it can be used as the entity body of the response.
The following illustrates the response which the token endpoint
implementation should generate and return to the client application.
HTTP/1.1 500 Internal Server Error
Content-Type: application/json
Cache-Control: no-store
Pragma: no-cache
(The value returned from getResponseContent())
When the value returned from getAction()
method is
TokenIssueAction::$OK
, it means that Authlete's /api/auth/token/issue
API successfully generated an access token. The HTTP status of the
response returned to the client application must be 200 OK
and the
content type must be application/json
.
In this case, getResponseContent()
method returns a JSON string which
contains the issued access token, so it can be used as the entity body
of the response. The following illustrates the response which the token
endpoint implementation should generate and return to the client
application.
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: no-store
Pragma: no-cache
(The value returned from getResponseContent())
Table of Contents
- copyFromArray() : mixed
- Copy the content of the given array into this object.
- copyToArray() : mixed
- Copy the content of this object into the given array.
- fromArray() : static
- Convert an array into an instance of this class.
- fromJson() : static
- Convert a JSON string into an instance of this class.
- getAccessToken() : string
- Get the newly issued access token.
- getAccessTokenDuration() : int|string
- Get the duration of the access token in seconds.
- getAccessTokenExpiresAt() : int|string
- Get the date at which the access token will expire.
- getAccessTokenResources() : array<string|int, string>
- Get the target resources of the access token.
- getAction() : TokenIssueAction
- Get the next action that the token endpoint implementation should take.
- getClientId() : int|string
- Get the ID of the client application associated with the access token.
- getClientIdAlias() : string
- Get the client ID alias.
- getJwtAccessToken() : string
- Get the newly issued access token in JWT format.
- getProperties() : array<string|int, Property>
- Get the properties associated with the access token.
- getRefreshToken() : string
- Get the newly issued refresh token.
- getRefreshTokenDuration() : int|string
- Get the duration of the refresh token in seconds.
- getRefreshTokenExpiresAt() : int|string
- Get the date at which the refresh token will expire.
- getResponseContent() : string
- Get the response content which can be used as the entity body of the response to the client application.
- getResultCode() : string
- Get the code of the result of an Authlete API call.
- getResultMessage() : string
- Get the message of the result of an Authlete API call.
- getScopes() : array<string|int, string>
- Get the scopes covered by the access token.
- getSubject() : string
- Get the subject (= unique identifier) of the end-user (= resource owner) of the access token.
- isClientIdAliasUsed() : bool
- Get the flag which indicates whether the client ID alias was used when the token request was made.
- setAccessToken() : TokenIssueResponse
- Set the newly issued access token.
- setAccessTokenDuration() : TokenIssueResponse
- Set the duration of the access token in seconds.
- setAccessTokenExpiresAt() : TokenIssueResponse
- Set the date at which the access token will expire.
- setAccessTokenResources() : TokenIssueResponse
- Set the target resources of the access token.
- setAction() : TokenIssueAction
- Set the next action that the token endpoint implementation should take.
- setClientId() : TokenIssueResponse
- Set the ID of the client application associated with the access token.
- setClientIdAlias() : TokenIssueResponse
- Set the client ID alias.
- setClientIdAliasUsed() : TokenIssueResponse
- Set the flag which indicates whether the client ID alias was used when the token request was made.
- setJwtAccessToken() : TokenIssueResponse
- Set the newly issued access token in JWT format.
- setProperties() : TokenIssueResponse
- Set the properties associated with the access token.
- setRefreshToken() : TokenIssueResponse
- Set the newly issued refresh token.
- setRefreshTokenDuration() : TokenIssueResponse
- Set the duration of the refresh token in seconds.
- setRefreshTokenExpiresAt() : TokenIssueResponse
- Set the date at which the refresh token will expire.
- setResponseContent() : TokenIssueResponse
- Set the response content which can be used as the entity body of the response to the client application.
- setResultCode() : ApiResponse
- Set the code of the result of an Authlete API call.
- setResultMessage() : ApiResponse
- Set the message of the result of an Authlete API call.
- setScopes() : TokenIssueResponse
- Set the scopes covered by the access token.
- setSubject() : TokenIssueResponse
- Set the subject (= unique identifier) of the end-user (= resource owner) of the access token.
- toArray() : array<string|int, mixed>
- Convert this object into an array.
- toJson() : string
- Convert this object into a JSON string.
Methods
copyFromArray()
Copy the content of the given array into this object.
public
copyFromArray(array<string|int, mixed> &$array) : mixed
Parameters
- $array : array<string|int, mixed>
Return values
mixed —copyToArray()
Copy the content of this object into the given array.
public
copyToArray(array<string|int, mixed> &$array) : mixed
Parameters
- $array : array<string|int, mixed>
Return values
mixed —fromArray()
Convert an array into an instance of this class.
public
static fromArray([array<string|int, mixed> $array = null ]) : static
This static function returns a new instance of this class.
If $array
is null
, null
is returned.
Parameters
- $array : array<string|int, mixed> = null
-
An array
Return values
static —An instance of this class.
fromJson()
Convert a JSON string into an instance of this class.
public
static fromJson(string $json) : static
This static function returns a new instance of this class.
If $json
is null
or the type of $json
is not string
,
null
is returned.
Parameters
- $json : string
-
A JSON string.
Return values
static —An instance of this class.
getAccessToken()
Get the newly issued access token.
public
getAccessToken() : string
This method returns a non-null value only when getAction()
method
returns TokenIssueAction::$OK
.
Return values
string —The access token.
getAccessTokenDuration()
Get the duration of the access token in seconds.
public
getAccessTokenDuration() : int|string
Return values
int|string —The duration of the access token in seconds.
getAccessTokenExpiresAt()
Get the date at which the access token will expire.
public
getAccessTokenExpiresAt() : int|string
Return values
int|string —The date at which the access token will expire. The value is expressed in milliseconds since the Unix epoch (1970-Jan-1).
getAccessTokenResources()
Get the target resources of the access token.
public
getAccessTokenResources() : array<string|int, string>
Tags
Return values
array<string|int, string> —The target resources of the access token.
getAction()
Get the next action that the token endpoint implementation should take.
public
getAction() : TokenIssueAction
Return values
TokenIssueAction —The next action that the token endpoint implementation should take.
getClientId()
Get the ID of the client application associated with the access token.
public
getClientId() : int|string
Return values
int|string —The client ID.
getClientIdAlias()
Get the client ID alias.
public
getClientIdAlias() : string
If no alias is assigned to the client application, this method returns
null
.
Return values
string —The client ID alias.
getJwtAccessToken()
Get the newly issued access token in JWT format.
public
getJwtAccessToken() : string
If the authorization server is configured to issue JWT-based access
tokens (if getAccessTokenSignAlg()
of Service
returns a non-null
value), a JWT-based access token is issued along with the original
random-string one.
Tags
Return values
string —The newly issued access token in JWT format.
getProperties()
Get the properties associated with the access token.
public
getProperties() : array<string|int, Property>
Return values
array<string|int, Property> —The properties associated with the access token.
getRefreshToken()
Get the newly issued refresh token.
public
getRefreshToken() : string
This method returns a non-null value only when getAction()
method
returns TokenIssueAction::$OK
and the service is configured to
support the refresh token flow.
If "Refresh Token Continuous Use" conifiguration parameter of the
service is NO
(= refreshTokenKept=false
), a new refresh token is
issued and the old refresh token used in the refresh token flow is
invalidated. On the contrary, if the configuration parameter is YES
,
the refresh token itself is not refreshed.
Return values
string —The refresh token.
getRefreshTokenDuration()
Get the duration of the refresh token in seconds.
public
getRefreshTokenDuration() : int|string
Return values
int|string —The duration of the refresh token in seconds.
getRefreshTokenExpiresAt()
Get the date at which the refresh token will expire.
public
getRefreshTokenExpiresAt() : int|string
Return values
int|string —The date at which the refresh token will expire. The value is expressed in milliseconds since the Unix epoch (1970-Jan-1).
getResponseContent()
Get the response content which can be used as the entity body of the response to the client application.
public
getResponseContent() : string
Return values
string —The response content.
getResultCode()
Get the code of the result of an Authlete API call.
public
getResultCode() : string
Return values
string —The result code.
getResultMessage()
Get the message of the result of an Authlete API call.
public
getResultMessage() : string
Return values
string —The result message.
getScopes()
Get the scopes covered by the access token.
public
getScopes() : array<string|int, string>
Return values
array<string|int, string> —The scopes covered by the access token.
getSubject()
Get the subject (= unique identifier) of the end-user (= resource owner) of the access token.
public
getSubject() : string
Return values
string —The subject of the end-user.
isClientIdAliasUsed()
Get the flag which indicates whether the client ID alias was used when the token request was made.
public
isClientIdAliasUsed() : bool
Return values
bool —true
if the client ID alias was used in the token request.
setAccessToken()
Set the newly issued access token.
public
setAccessToken(string $accessToken) : TokenIssueResponse
Parameters
- $accessToken : string
-
The access token.
Return values
TokenIssueResponse —$this
object.
setAccessTokenDuration()
Set the duration of the access token in seconds.
public
setAccessTokenDuration(int|string $duration) : TokenIssueResponse
Parameters
- $duration : int|string
-
The duration of the access token in seconds.
Return values
TokenIssueResponse —$this
object.
setAccessTokenExpiresAt()
Set the date at which the access token will expire.
public
setAccessTokenExpiresAt(int|string $expiresAt) : TokenIssueResponse
Parameters
- $expiresAt : int|string
-
The date at which the access token will expire. The value should be expressed in milliseconds since the Unix epoch (1970-Jan-1).
Return values
TokenIssueResponse —$this
object.
setAccessTokenResources()
Set the target resources of the access token.
public
setAccessTokenResources([array<string|int, string> $resources = null ]) : TokenIssueResponse
Parameters
- $resources : array<string|int, string> = null
-
The target resources of the access token.
Tags
Return values
TokenIssueResponse —$this
object.
setAction()
Set the next action that the token endpoint implementation should take.
public
setAction([TokenIssueAction $action = null ]) : TokenIssueAction
Parameters
- $action : TokenIssueAction = null
-
The next action that the token endpoint implementation should take.
Return values
TokenIssueAction —$this
object.
setClientId()
Set the ID of the client application associated with the access token.
public
setClientId(int|string $clientId) : TokenIssueResponse
Parameters
- $clientId : int|string
-
The client ID.
Return values
TokenIssueResponse —$this
object.
setClientIdAlias()
Set the client ID alias.
public
setClientIdAlias(string $alias) : TokenIssueResponse
Parameters
- $alias : string
-
The client ID alias.
Return values
TokenIssueResponse —$this
object.
setClientIdAliasUsed()
Set the flag which indicates whether the client ID alias was used when the token request was made.
public
setClientIdAliasUsed(bool $used) : TokenIssueResponse
Parameters
- $used : bool
-
true
to indicate that the client ID alias was used in the token request.
Return values
TokenIssueResponse —$this
object.
setJwtAccessToken()
Set the newly issued access token in JWT format.
public
setJwtAccessToken(string $jwtAccessToken) : TokenIssueResponse
If the authorization server is configured to issue JWT-based access
tokens (if getAccessTokenSignAlg()
of Service
returns a non-null
value), a JWT-based access token is issued along with the original
random-string one.
Parameters
- $jwtAccessToken : string
-
The newly issued access token in JWT format.
Tags
Return values
TokenIssueResponse —$this
object.
setProperties()
Set the properties associated with the access token.
public
setProperties([array<string|int, Property> $properties = null ]) : TokenIssueResponse
Parameters
- $properties : array<string|int, Property> = null
-
The properties associated with the access token.
Return values
TokenIssueResponse —$this
object.
setRefreshToken()
Set the newly issued refresh token.
public
setRefreshToken(string $refreshToken) : TokenIssueResponse
Parameters
- $refreshToken : string
-
The refresh token.
Return values
TokenIssueResponse —$this
object.
setRefreshTokenDuration()
Set the duration of the refresh token in seconds.
public
setRefreshTokenDuration(int|string $duration) : TokenIssueResponse
Parameters
- $duration : int|string
-
The duration of the refresh token in seconds.
Return values
TokenIssueResponse —$this
object.
setRefreshTokenExpiresAt()
Set the date at which the refresh token will expire.
public
setRefreshTokenExpiresAt(int|string $expiresAt) : TokenIssueResponse
Parameters
- $expiresAt : int|string
-
The date at which the refresh token will expire. The value should be expressed in milliseconds since the Unix epoch (1970-Jan-1).
Return values
TokenIssueResponse —$this
object.
setResponseContent()
Set the response content which can be used as the entity body of the response to the client application.
public
setResponseContent(string $responseContent) : TokenIssueResponse
Parameters
- $responseContent : string
-
The response content.
Return values
TokenIssueResponse —$this
object.
setResultCode()
Set the code of the result of an Authlete API call.
public
setResultCode(string $resultCode) : ApiResponse
Parameters
- $resultCode : string
-
The result code.
Return values
ApiResponse —$this
object.
setResultMessage()
Set the message of the result of an Authlete API call.
public
setResultMessage(string $resultMessage) : ApiResponse
Parameters
- $resultMessage : string
-
The result message.
Return values
ApiResponse —$this
object.
setScopes()
Set the scopes covered by the access token.
public
setScopes([array<string|int, string> $scopes = null ]) : TokenIssueResponse
Parameters
- $scopes : array<string|int, string> = null
-
The scopes covered by the access token.
Return values
TokenIssueResponse —$this
object.
setSubject()
Set the subject (= unique identifier) of the end-user (= resource owner) of the access token.
public
setSubject(string $subject) : TokenIssueResponse
Parameters
- $subject : string
-
The subject of the end-user.
Return values
TokenIssueResponse —$this
object.
toArray()
Convert this object into an array.
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array.
toJson()
Convert this object into a JSON string.
public
toJson(int $options) : string
Parameters
- $options : int
-
Options passed to
json_encode()
. This parameter is optional and its default value is 0.
Return values
string —A JSON string.


Platform
- Documents such as PDF, word processing documents, ePub, and slideware.
- Web-based languages such as HTML, and ARIA.
- Platforms such as iOS, and Android.
Technology
HTML
Summary
Assistive Technologies like screen readers rely on semantics in the code to properly help their users understand and navigate the material. For example, screen reader users can bring up a list of headings on the page to browse and navigate to the material they want without having to listen to everything.
How it solves user need
Properly coded headings allow assistive technology users to understand the hierarchy of content and navigate to the section most likely to have the material of interest.


Expert advice on resources for your subject area
Research support and tips on accessing the libraries' collections
Guides to getting started in the Bodleian Libraries
Workshops to develop your skills in information discovery


This is the API documentation for the multi-thread context(MTC), a simple java lib for transmitting context between threads even using thread pool.


The failures in https://circleci.com/gh/pulibrary/figgy/23051#tests/containers/0 appear to be related to the version of Chromedriver in the tests
head_ref_force_pushed
by James R. Griffin III at 2020-01-04 03:23:17.head_ref_force_pushed
by None at 2020-01-04 02:33:24.head_ref_force_pushed
by None at 2020-01-04 02:46:25.head_ref_force_pushed
by None at 2020-01-04 02:58:22.review_requested
by None at 2020-01-04 03:15:39.referenced
by Francis Kayiwa at 2020-01-04 18:00:45.merged
by Francis Kayiwa at 2020-01-04 18:00:45.closed
by Francis Kayiwa at 2020-01-04 18:00:46.head_ref_deleted
by Francis Kayiwa at 2020-01-04 18:03:54.head_ref_force_pushed
by None at 2020-01-04 01:30:02.head_ref_force_pushed
by None at 2020-01-04 01:46:44.head_ref_force_pushed
by Francis Kayiwa at 2020-01-04 18:08:25.referenced
by Francis Kayiwa at 2020-01-04 18:37:27.merged
by Francis Kayiwa at 2020-01-04 18:37:27.closed
by Francis Kayiwa at 2020-01-04 18:37:27.head_ref_deleted
by Francis Kayiwa at 2020-01-04 18:37:31.Coverage increased (+0.04%) to 87.4% when pulling e67693982a9170161dbcfa8c599b4f0af7aa2d4d on lewis-paging into cefd41be34db7a2bcd92108544d677af40b5fea7 on master.
referenced
by Kevin Reiss at 2020-01-03 22:23:18.merged
by Kevin Reiss at 2020-01-03 22:23:18.closed
by Kevin Reiss at 2020-01-03 22:23:19.closed
by Kevin Reiss at 2020-01-03 22:23:19.closed
by Kevin Reiss at 2020-01-03 22:23:19.


--- layout: page title: About header-img: "img/about-bg.png" ---
I am just starting out my blog/Flatirons School experience. I enjoy designing, and thats what brought me to FI school. I hope to learn tremendously, and enjoy my blogging!


|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object PImage codeanticode.gltexture.GLTexture
public class GLTexture
This class adds an opengl texture to a PImage object. The texture is handled in a similar way to the pixels property: image data can be copied to and from the texture using loadTexture and updateTexture methods. However, bringing the texture down to image or pixels data can slow down the application considerably (since involves copying texture data from GPU to CPU), especially when handling large textures. So it is recommended to do all the texture handling without calling updateTexture, and doing so only at the end if the texture is needed as a regular image.
| Field Summary | |
|---|---|
protected GL |
gl
|
protected GLState |
glstate
|
protected PGraphicsOpenGL |
pgl
|
protected int[] |
tex
|
| Constructor Summary | |
|---|---|
GLTexture(PApplet parent)
Creates an instance of GLTexture with size 1x1. |
|
GLTexture(PApplet parent,
int width,
int height)
Creates an instance of GLTexture with size width x height. |
|
GLTexture(PApplet parent,
java.lang.String filename)
Creates an instance of GLTexture using image file filename as source. |
| Method Summary | |
|---|---|
boolean |
available()
Returns true if the texture has been initialized. |
void |
filter(GLTextureFilter texFilter,
GLTexture destTex)
Applies filter texFilter using this texture as source and destTex as destination. |
void |
filter(GLTextureFilter texFilter,
GLTexture[] destTexArray)
Applies filter texFilter using this texture as source and destTex as multiple destinations. |
void |
filter(GLTextureFilter texFilter,
GLTexture[] destTexArray,
GLTextureFilterParams params)
Applies filter texFilter using this texture as source, destTex as multiple destinations and params as the parameters for the filter. |
void |
filter(GLTextureFilter texFilter,
GLTexture destTex,
GLTextureFilterParams params)
Applies filter texFilter using this texture as source, destTex as destination and params as the parameters for the filter. |
void |
getImage(PImage img)
Copies texture to img. |
int |
getTextureID()
Provides the ID of the opegl texture object. |
int |
getTextureTarget()
Returns the texture target. |
void |
init(int width,
int height)
Sets the size of the image and texture to width x height. |
protected void |
initTexture(int w,
int h)
|
void |
loadTexture()
Copy pixels to texture (loadPixels should have been called beforehand). |
void |
loadTexture(java.lang.String filename)
Load texture, pixels and image from file. |
void |
putImage(PImage img)
Puts img into texture, pixels and image. |
void |
putPixels(int[] pix)
|
void |
putPixelsIntoTexture(PImage img)
Puts pixels of img into texture only. |
protected void |
releaseTexture()
|
void |
renderTexture()
Draws the texture using the opengl commands, inside a rectangle located at the origin with the original size of the texture. |
void |
renderTexture(float x,
float y)
Draws the texture using the opengl commands, inside a rectangle located at (x,y) with the original size of the texture. |
void |
renderTexture(float x,
float y,
float w,
float h)
Draws the texture using the opengl commands, inside a rectangle of width w and height h located at (x,y). |
void |
updateTexture()
Copy texture to pixels (doesn't call updatePixels). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected GL gl
protected PGraphicsOpenGL pgl
protected int[] tex
protected GLState glstate
| Constructor Detail |
|---|
public GLTexture(PApplet parent)
parent
- PAppletpublic GLTexture(PApplet parent, int width, int height)
parent
- PAppletwidth
- intheight
- intpublic GLTexture(PApplet parent, java.lang.String filename)
filename
- String| Method Detail |
|---|
public void init(int width, int height)
width
- intheight
- intpublic boolean available()
public int getTextureID()
public int getTextureTarget()
public void putImage(PImage img)
img
- PImagepublic void putPixelsIntoTexture(PImage img)
img
- PImagepublic void getImage(PImage img)
img
- PImagepublic void loadTexture(java.lang.String filename)
filename
- Stringpublic void loadTexture()
public void updateTexture()
public void filter(GLTextureFilter texFilter, GLTexture destTex)
public void filter(GLTextureFilter texFilter, GLTexture[] destTexArray)
public void filter(GLTextureFilter texFilter, GLTexture destTex, GLTextureFilterParams params)
public void filter(GLTextureFilter texFilter, GLTexture[] destTexArray, GLTextureFilterParams params)
public void renderTexture()
public void renderTexture(float x, float y)
x
- floaty
- floatpublic void renderTexture(float x, float y, float w, float h)
x
- floaty
- floatw
- floath
- floatprotected void initTexture(int w, int h)
w
- inth
- intprotected void releaseTexture()
public void putPixels(int[] pix)
pix
- int[]
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |


Current job: since December 2022, Paris (75)
3.5 years: July 2019 to December 2022, Gennevilliers (92)
3 years: September 2016 to Auguste 2019, Gennevilliers (92)
6 months: February to Auguste 2016, Gennevilliers (92)
5 months: April to Auguste 2015, Rambouillet (78)
2 months fixed-term employee: June to July 2014, Noisy-Le-Grand (93)
Fixed-term employee during school vacation: 2011, 2012, 2013 & 2014


Drexel UI programming projects
Places that got lots of snow
Boston
Alaska
Connecticut
not Philadelphia (yet)


--- layout: default ---
I am Pratham Oza, a Ph.D. candidate in the Electrical and Computer Engineering Department at Virginia Tech. I work with Dr. Thidapat (Tam) Chantem at the RTX Lab. My research focus is in the areas of Intelligent Transportation, specifically in Traditional/ Automated Vehicular Traffic Scheduling using real-time systems theories.
I completed my Bachelors degree in Electrical and Electronics Engineering from Manipal Institute of Technology, Manipal and my Masters degree at Virginia Tech in 2019. Prior to joining Virginia Tech, I worked for about two years with Tata Consultancy Services and a Japanese OEM on vehicular ECU diagnostics and ECU test validation. I have also briefly worked on HILS testing of the Meter ECU in a Japanese OEM vehicle using dSPACE, Vector CANoe and LabView.
Feel free to contact me at prathamo[at]vt[dot]edu for questions or comments.


Use One PDF.
See Convert image to pdf.
See Convert image to pdf.
Use the Audio Editor.
Use the Audio Editor.
Use Bitmap to vector, made to convert Scratch bitmap costumes to vector costumes. This embeds the image directly in the SVG, so there is no increase in quality, but this can prevent Scratch from shrinking the costume if it is too large.
Alternatively, use Bitmap to SVG. This converts each pixel into a square, so zooming in will reveal individual pixels. However, the result may be very large.
Use the Scratch Text Engine Maker to convert select glyphs from a font into individual SVG files. Note that the resulting SVG files only import properly in Scratch 2.0.
See Convert image to svg.
See Convert image to svg.
See Convert image to svg.
See Convert image to svg.
See Convert font to svg.
See Convert font to svg.
See Convert font to svg.
Use SVG to PNG.
Use Minecraft GIF to animated texture. This will make a PNG with each of the GIF's frames stacked on top of each other.
Use JPG quality.
See Convert image to jpg. Note that transparent pixels will become black.
See Convert image to jpg. Note that transparent pixels will become black, and the image will not be animated.
See Convert image to jpg. Note that transparent regions will become black.
See Convert image to jpg. Note that transparent pixels will become black.
Use JPG quality. Yes, contrary to what the name suggests, this tool also can produce webp files.
See Convert image to webp. Note that the image will not be animated.
Use OpenShit.
Use OpenShit.
See Convert image to webm. Note that even though this produces a video, the gif will not animate and will only show its first frame.
Use the HTMLifier.
Use Image to Scheme. This will convert each pixel to an ASCII character that visually represents its brightness.
See Convert image to txt. Note that transparent pixels will become at signs (@).
See Convert image to txt.
See Convert image to txt. Note that transparent pixels will become at signs (@), and the result will not be animated.
See Convert image to txt. Note that transparent pixels will become at signs (@).
See Convert image to txt. Note that transparent pixels will become at signs (@).


Please select all the ways you would like to hear from European Climate and Energy Modelling Forum.
You can unsubscribe at any time by clicking the link in the footer of our emails. For information about our privacy practices, please visit our website.
We use Mailchimp as our marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices here.